Example #1
0
  const captureInput = DomEvent.bind(page, 'keydown', function (evt) {
    // Think about killing the event.
    if (! Arr.contains([ 'input', 'textarea' ], Node.name(evt.target()))) {

      // FIX: Close the menus
      // closeMenus()

      toEditing();
    }
  });
Example #2
0
 const onChange = (getData: () => LinkDialogData, change: { name: string }): Option<Partial<LinkDialogData>> => {
   if (change.name === 'url') {
     return onUrlChange(getData());
   } else if (Arr.contains([ 'anchor', 'link' ], change.name)) {
     return onCatalogChange(getData(), change);
   } else if (change.name === 'text') {
     // Update the persistent text state, as a user has input custom text
     persistentText.set(getData().text);
     return Option.none();
   } else {
     return Option.none();
   }
 };
Example #3
0
 const register = (mode: string, api: ModeApi) => {
   if (Arr.contains(defaultModes, mode)) {
     throw new Error(`Cannot override default mode ${mode}`);
   }
   availableModes[mode] = {
     ...api,
     deactivate: () => {
       // wrap custom deactivate APIs so they can't break the editor
       try {
         api.deactivate();
       } catch (e) {
         console.error(`problem while deactivating editor mode ${mode}:`);
         console.error(e);
       }
     },
   };
 };
Example #4
0
    return Arr.map(items, (item) => {
      const keys = Obj.keys(item);
      // If it is a submenu, enrich all the subitems.
      if (Objects.hasKey(item, 'items')) {
        const newItems = doEnrich(item.items);
        return Merger.deepMerge(
          enrichMenu(item),
          {
            getStyleItems: () => newItems
          }
        ) as FormatItem;
      } else if (Objects.hasKey(item, 'format')) {
        return enrichSupported(item);

        // NOTE: This branch is added from the original StyleFormats in mobile
      } else if (keys.length === 1 && Arr.contains(keys, 'title')) {
        return Merger.deepMerge(item, { type: 'separator' }) as FormatItem;

      } else {
        return enrichCustom(item);
      }
    });
Example #5
0
 const isRoot = function (element) {
   const name = Node.name(element);
   return Compare.eq(element, body) || Arr.contains(rootElements, name);
 };
  const open = function (settings: NotificationSpec, closeCallback: () => void) {
    const close = () => {
      closeCallback();
      InlineView.hide(notificationWrapper);
    };

    const notification = GuiFactory.build(
      Notification.sketch({
        text: settings.text,
        level: Arr.contains(['success', 'error', 'warning', 'info'], settings.type) ? settings.type : undefined,
        progress: settings.progressBar === true,
        icon: Option.from(settings.icon),
        onAction: close,
        iconProvider: backstage.shared.providers.icons,
        translationProvider: backstage.shared.providers.translate
      })
    );

    const notificationWrapper = GuiFactory.build(
      InlineView.sketch({
        dom: {
          tag: 'div',
          classes: [ 'tox-notifications-container' ]
        },
        lazySink: extras.backstage.shared.getSink,
        fireDismissalEventInstead: { }
      })
    );

    uiMothership.add(notificationWrapper);

    if (settings.timeout) {
      Delay.setTimeout(() => {
        close();
      }, settings.timeout);
    }

    return {
      close,
      moveTo: (x: number, y: number) => {
        InlineView.showAt(notificationWrapper, {
          anchor: 'makeshift',
          x,
          y
        }, GuiFactory.premade(notification));
      },
      moveRel: (element: Element, rel) => {
        // TODO: this should stack, TC-TC, BC-TC
        InlineView.showAt(notificationWrapper, extras.backstage.shared.anchors.banner(), GuiFactory.premade(notification));
      },
      text: (nuText: string) => {
        // check if component is still mounted
        Notification.updateText(notification, nuText);
      },
      settings,
      getEl: () => {
        // TODO: this is required to make stacking banners, should refactor getEl when AP-174 is implemented

      },
      progressBar: {
        value: (percent: number) => {
          Notification.updateProgress(notification, percent);
        }
      }
    };
  };
Example #7
0
 const needRtlClass = I18n.isRtl() && info.iconContent.exists((name) => Arr.contains(rtlTransform, name));
Example #8
0
 return iconName.map((name) => I18n.isRtl() && Arr.contains(rtlIcon, name) ? name + '-rtl' : name);
 const inInput = Focus.active().exists(function (elem) {
   return Arr.contains([ 'input', 'textarea' ], Node.name(elem));
 });
Example #10
0
 const result = Obj.bifilter(settings, function (value, key) {
   return Arr.contains(keys, key);
 });
Example #11
0
const isPreValue = (value: string) => Arr.contains([ 'pre', 'pre-line', 'pre-wrap' ], value);
Example #12
0
 const needsRtlClass = I18n.isRtl() && icon.exists((name) => Arr.contains(rtlTransform, name));
Example #13
0
 const getIconName = (iconName: string): string => {
   return I18n.isRtl() && Arr.contains(rtlIcon, iconName) ? iconName + '-rtl' : iconName;
 };
const isTarget = (node: Element) => Arr.contains(['figcaption'], Node.name(node));
Example #15
0
 const nonConvertable = Arr.filter(units, (unit) => !Arr.contains(convertableUnits, unit));
Example #16
0
 const heading = PredicateFind.closest(elem, (e) => {
   const nodeName = Node.name(e);
   return Arr.contains(headings, nodeName);
 }, function (e) {