How to use the @ephox/katamari.Option.some 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 / themes / silver / main / ts / Autocompleter.ts View on Github external
const commenceIfNecessary = (context: AutocompleteContext) => {
    if (!isActive()) {
      // Create the wrapper
      const wrapper = AutocompleteTag.create(editor, context.range);

      // store the element/context
      activeAutocompleter.set(Option.some({
        triggerChar: context.triggerChar,
        element: wrapper,
        matchLength: context.text.length
      }));
      processingAction.set(false);
    }
  };
github tinymce / tinymce / modules / tinymce / src / themes / silver / main / ts / ContextToolbar.ts View on Github external
Objects.readOptFrom(scopes.lookupTable, e.toolbarKey).each((ctx) => {
      launchContext(ctx, e.target === editor ? Option.none() : Option.some(e as DomElement));
      // Forms launched via this way get immediate focus
      InlineView.getContent(contextbar).each(Keying.focusIn);
    });
  });
github tinymce / tinymce / modules / tinymce / src / themes / silver / main / ts / api / TouchEvents.ts View on Github external
const getTouch = (event): Option => {
  if (event.touches === undefined || event.touches.length !== 1) {
    return Option.none();
  }
  return Option.some(event.touches[0]);
};
github tinymce / tinymce / modules / tinymce / src / themes / silver / main / ts / ui / dialog / imagetools / SideBar.ts View on Github external
const createButton = (innerHtml: string, icon: string, disabled: boolean, action: (button: AlloyComponent) => void, providersBackstage: UiFactoryBackstageProviders): SketchSpec => {
  return renderIconButton({
    name: innerHtml,
    icon: Option.some(icon),
    disabled,
    tooltip: Option.some(innerHtml),
    primary: false
  }, action, providersBackstage);
};
github tinymce / tinymce / modules / tinymce / src / themes / silver / main / ts / ui / core / complex / FormatSelect.ts View on Github external
});
  };

  const updateSelectMenuText = (parents: Element[], comp: AlloyComponent) => {
    const detectedFormat = getMatchingValue(parents);
    const text = detectedFormat.fold(() => 'Paragraph', (fmt) => fmt.title);
    AlloyTriggers.emitWith(comp, updateMenuText, {
      text
    });
  };

  const nodeChangeHandler = Option.some((comp: AlloyComponent) => {
    return (e) => updateSelectMenuText(e.parents, comp);
  });

  const setInitialValue = Option.some((comp: AlloyComponent) => {
    const parents = getCurrentSelectionParents(editor);
    updateSelectMenuText(parents, comp);
  });

  const dataset = buildBasicSettingsDataset(editor, 'block_formats', defaultBlocks, Delimiter.SemiColon);

  return {
    tooltip: 'Blocks',
    icon: Option.none(),
    isSelectedFor,
    getCurrentValue: Fun.constant(Option.none()),
    getPreviewFor,
    onAction: onActionToggleFormat(editor),
    setInitialValue,
    nodeChangeHandler,
    dataset,
github tinymce / tinymce / modules / tinymce / src / themes / mobile / main / ts / util / FontSizes.ts View on Github external
const getRawOrComputed = function (isRoot, rawStart) {
  const optStart = Node.isElement(rawStart) ? Option.some(rawStart) : Traverse.parent(rawStart).filter(Node.isElement);
  return optStart.map(function (start) {
    const inline = PredicateFind.closest(start, (elem) => Css.getRaw(elem, 'font-size').isSome(), isRoot)
      .bind((elem) => Css.getRaw(elem, 'font-size'));

    return inline.getOrThunk(function () {
      return Css.get(start, 'font-size');
    });
  }).getOr('');
};
github tinymce / tinymce / modules / tinymce / src / themes / silver / main / ts / ui / dialog / AlertDialog.ts View on Github external
const memFooterClose = Memento.record(
      renderFooterButton({
        name: 'close-alert',
        text: 'OK',
        primary: true,
        align: 'end',
        disabled: false,
        icon: Option.none()
      }, 'cancel', extras.backstage)
    );

    const alertDialog = GuiFactory.build(
      Dialogs.renderDialog({
        lazySink: () => sharedBackstage.getSink(),
        headerOverride: Option.some(Dialogs.hiddenHeader),
        partSpecs: {
          title: Dialogs.pUntitled(),
          close: Dialogs.pClose(() => {
            closeDialog();
          }, sharedBackstage.providers),
          body: Dialogs.pBodyMessage(message, sharedBackstage.providers),
          footer: Dialogs.pFooter(Dialogs.pFooterGroup([], [
            memFooterClose.asSpec()
          ]))
        },
        onCancel: () => closeDialog(),
        onSubmit: Fun.noop,
        extraClasses: [ 'tox-alert-dialog' ]
      })
    );
github tinymce / tinymce / modules / tinymce / src / plugins / link / main / ts / ui / DialogInfo.ts View on Github external
const extractFromAnchor = (editor: Editor, anchor: HTMLAnchorElement) => {
  const dom = editor.dom;
  const onlyText = Utils.isOnlyTextSelected(editor.selection.getContent());
  const text: Option = onlyText ? Option.some(Utils.getAnchorText(editor.selection, anchor)) : Option.none();
  const url: Option = anchor ? Option.some(dom.getAttrib(anchor, 'href')) : Option.none();
  const target: Option = anchor ? Option.from(dom.getAttrib(anchor, 'target')) : Option.none();
  const rel = nonEmptyAttr(dom, anchor, 'rel');
  const linkClass = nonEmptyAttr(dom, anchor, 'class');
  const title = nonEmptyAttr(dom, anchor, 'title');

  return {
    url,
    text,
    title,
    target,
    rel,
    linkClass
  };
};
github tinymce / tinymce / modules / tinymce / src / core / main / ts / selection / SelectionUtils.ts View on Github external
const getEndNode = function (rng) {
  const ec = rng.endContainer, eo = rng.endOffset;
  if (NodeType.isText(ec)) {
    return eo === ec.data.length ? Option.some(Element.fromDom(ec)) : Option.none();
  } else {
    return Option.from(ec.childNodes[eo - 1]).map(Element.fromDom);
  }
};
github tinymce / tinymce / modules / tinymce / src / core / main / ts / keyboard / Nbsps.ts View on Github external
return Option.some(pos).filter(hasNbsp).bind((pos) => {
    const container = pos.container() as Text;
    const normalized = normalizeNbspAtStart(root, container) || normalizeNbspInMiddleOfTextNode(container) || normalizeNbspAtEnd(root, container);
    return normalized ? Option.some(pos) : Option.none();
  });
};