How to use the @ephox/katamari.Option.from function in @ephox/katamari

To help you get started, we’ve selected a few @ephox/katamari examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tinymce / tinymce / modules / tinymce / src / plugins / textpattern / main / ts / utils / Utils.ts View on Github external
const getParentBlock = (editor: Editor, rng: Range) => {
  const parentBlockOpt = Option.from(editor.dom.getParent(rng.startContainer, editor.dom.isBlock));
  if (Settings.getForcedRootBlock(editor) === '') {
    return parentBlockOpt.orThunk(() => Option.some(editor.getBody()));
  } else {
    return parentBlockOpt;
  }
};
github tinymce / tinymce / modules / tinymce / src / themes / silver / main / ts / ui / core / complex / BespokeSelect.ts View on Github external
spec.setInitialValue.each((f) => f(api.getComponent()));
    return spec.nodeChangeHandler.map((f) => {
      const handler = f(api.getComponent());
      editor.on('NodeChange', handler);

      return () => {
        editor.off('NodeChange', handler);
      };
    }).getOr(Fun.noop);
  };

  return renderCommonDropdown(
    {
      text: spec.icon.isSome() ? Option.none() : Option.some(''),
      icon: spec.icon,
      tooltip: Option.from(spec.tooltip),
      role: Option.none(),
      fetch: items.getFetch(backstage, getStyleItems),
      onSetup,
      getApi,
      columns: 1,
      presets: 'normal',
      classes: spec.icon.isSome() ? [] : [ 'bespoke' ],
      dropdownBehaviours: []
    },
    ToolbarButtonClasses.Button,
    backstage.shared
  );
};
github tinymce / tinymce / modules / tinymce / src / themes / silver / main / ts / api / Settings.ts View on Github external
const getMinHeightSetting = (editor): Option => Option.from(editor.settings.min_height).filter(Type.isNumber);
const getMaxWidthSetting = (editor): Option => Option.from(editor.getParam('max_width')).filter(Type.isNumber);
github tinymce / tinymce / modules / tinymce / src / plugins / link / main / ts / ui / Controls.ts View on Github external
onAction: (formApi) => {
          const anchor = Utils.getAnchorElement(editor);
          const value = formApi.getValue();
          if (!anchor) {
            const attachState = { href: value, attach: () => { } };
            const onlyText = Utils.isOnlyTextSelected(editor.selection.getContent());
            const text: Option = onlyText ? Option.some(Utils.getAnchorText(editor.selection, anchor)).filter((t) => t.length > 0).or(Option.from(value)) : Option.none();
            Utils.link(editor, attachState, {
              href: value,
              text,
              title: Option.none(),
              rel: Option.none(),
              target: Option.none(),
              class: Option.none()
            });
            formApi.hide();
          } else {
            editor.dom.setAttrib(anchor, 'href', value);
            collapseSelectionToEnd(editor);
            formApi.hide();
          }
        }
      },
github tinymce / tinymce / modules / tinymce / src / core / main / ts / EditorRemove.ts View on Github external
const safeDestroy = (x: any) => Option.from(x).each((x) => x.destroy());
github tinymce / tinymce / modules / tinymce / src / core / main / ts / caret / CaretPositionPredicates.ts View on Github external
  return (pos: CaretPosition) => Option.from(getChildNodeAtRelativeOffset(before ? 0 : -1, pos)).filter(predicate).isSome();
};
github tinymce / tinymce / modules / tinymce / src / themes / silver / main / ts / ui / core / color / ColorSwatch.ts View on Github external
return (api) => {
      const data = api.getData();
      callback(Option.from(data.colorpicker));
      api.close();
    };
  };
github tinymce / tinymce / modules / tinymce / src / themes / silver / main / ts / api / Settings.ts View on Github external
const getMinWidthSetting = (editor): Option => Option.from(editor.settings.min_width).filter(Type.isNumber);
const getMinHeightSetting = (editor): Option => Option.from(editor.settings.min_height).filter(Type.isNumber);
github tinymce / tinymce / modules / tinymce / src / themes / silver / main / ts / backstage / Anchors.ts View on Github external
const fixedToolbarAnchor = (): AnchorSpec => ({
    anchor: 'node',
    root: bodyElement(),
    node: Option.from(bodyElement()),
    layouts: {
      onRtl: () => [ LayoutInside.north ],
      onLtr: () => [ LayoutInside.north ]
    }
  });
github tinymce / tinymce / modules / tinymce / src / themes / silver / main / ts / ui / core / complex / FontSelect.ts View on Github external
}).orThunk(() => {
      if (isSystemFontStack(font)) {
        return Option.from({
          title: 'System Font',
          format: font
        });
      } else {
        return Option.none();
      }
    });