当前位置: 首页>>代码示例>>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;未经允许,请勿转载。