當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript sugar.PredicateFind類代碼示例

本文整理匯總了TypeScript中@ephox/sugar.PredicateFind的典型用法代碼示例。如果您正苦於以下問題:TypeScript PredicateFind類的具體用法?TypeScript PredicateFind怎麽用?TypeScript PredicateFind使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了PredicateFind類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: function

const sketch = function (realm, editor): SketchSpec {
  const spec = {
    onChange (value) {
      editor.execCommand('FormatBlock', null, headings[value].toLowerCase());
    },
    getInitialValue () {
      const node = editor.selection.getStart();
      const elem = Element.fromDom(node);
      const heading = PredicateFind.closest(elem, (e) => {
        const nodeName = Node.name(e);
        return Arr.contains(headings, nodeName);
      }, function (e) {
        return Compare.eq(e, Element.fromDom(editor.getBody()));
      });

      return heading.bind((elm) => Arr.indexOf(headings, Node.name(elm))).getOr(0);
    }
  };

  return ToolbarWidgets.button(realm, 'heading', function () {
    return [
      UiDomFactory.spec('<span class="${prefix}-toolbar-button ${prefix}-icon-small-heading ${prefix}-icon"></span>'),
      makeSlider(spec),
      UiDomFactory.spec('<span class="${prefix}-toolbar-button ${prefix}-icon-large-heading ${prefix}-icon"></span>')
    ];
  });
};
開發者ID:danielpunkass,項目名稱:tinymce,代碼行數:27,代碼來源:HeadingSlider.ts

示例2:

  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('');
開發者ID:danielpunkass,項目名稱:tinymce,代碼行數:8,代碼來源:FontSizes.ts

示例3: function

const deleteElement = function (editor, forward, elm) {
  const afterDeletePos = findCaretPosOutsideElmAfterDelete(forward, editor.getBody(), elm.dom());
  const parentBlock = PredicateFind.ancestor(elm, Fun.curry(isBlock, editor), eqRawNode(editor.getBody()));
  const normalizedAfterDeletePos = deleteNormalized(elm, afterDeletePos);

  if (editor.dom.isEmpty(editor.getBody())) {
    editor.setContent('');
    editor.selection.setCursorLocation();
  } else {
    parentBlock.bind(paddEmptyBlock).fold(
      function () {
        setSelection(editor, forward, normalizedAfterDeletePos);
      },
      function (paddPos) {
        setSelection(editor, forward, Option.some(paddPos));
      }
    );
  }
};
開發者ID:aha-app,項目名稱:tinymce-word-paste-filter,代碼行數:19,代碼來源:DeleteElement.ts

示例4: getProperty

const getSpecifiedFontProp = (propName: string, rootElm: Element, elm: HTMLElement): Option<string> => {
  const getProperty = (elm) => Css.getRaw(elm, propName);
  const isRoot = (elm) => Compare.eq(SugarElement.fromDom(rootElm), elm);

  return PredicateFind.closest(SugarElement.fromDom(elm), (elm) => getProperty(elm).isSome(), isRoot).bind(getProperty);
};
開發者ID:tinymce,項目名稱:tinymce,代碼行數:6,代碼來源:FontInfo.ts

示例5: function

const isRawNodeInTable = function (root, rawNode) {
  const node = Element.fromDom(rawNode);
  const isRoot = Fun.curry(Compare.eq, root);
  return PredicateFind.ancestor(node, ElementType.isTableCell, isRoot).isSome();
};
開發者ID:abstask,項目名稱:tinymce,代碼行數:5,代碼來源:BlockRangeDelete.ts

示例6:

const isEditable = (target: Element) => {
  return PredicateFind.closest(target, (elm) => {
    return NodeType.isContentEditableTrue(elm.dom()) || NodeType.isContentEditableFalse(elm.dom());
  }).exists((elm) => NodeType.isContentEditableTrue(elm.dom()));
};
開發者ID:tinymce,項目名稱:tinymce,代碼行數:5,代碼來源:IndentOutdent.ts

示例7: function

const getParentBlock = function (rootNode, elm) {
  return Compare.contains(rootNode, elm) ? PredicateFind.closest(elm, function (element) {
    return ElementType.isTextBlock(element) || ElementType.isListItem(element);
  }, isBeforeRoot(rootNode)) : Option.none();
};
開發者ID:aha-app,項目名稱:tinymce-word-paste-filter,代碼行數:5,代碼來源:DeleteUtils.ts

示例8:

 .bind((elm) => PredicateFind.closest(elm, Node.isElement))
開發者ID:danielpunkass,項目名稱:tinymce,代碼行數:1,代碼來源:Nbsps.ts

示例9:

const getClosestTargetBlock = (pos: CaretPosition, root: Element) => {
  const isRoot = Fun.curry(Compare.eq, root);
  return PredicateFind.closest(Element.fromDom(pos.container()), ElementType.isBlock, isRoot).filter(isTarget);
};
開發者ID:danielpunkass,項目名稱:tinymce,代碼行數:4,代碼來源:ContentEndpointNavigation.ts

示例10:

 () => PredicateFind.closest(sugarNode, (elem) => {
   return Node.name(elem) in textBlockElementsMap && editor.dom.isEmpty(elem.dom());
 }, isRoot).isSome(),
開發者ID:tinymce,項目名稱:tinymce,代碼行數:3,代碼來源:Toolbars.ts


注:本文中的@ephox/sugar.PredicateFind類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。