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


TypeScript Traverse.children方法代碼示例

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


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

示例1:

const getChildrenUntilBlockBoundary = (block: Element) => {
  const children = Traverse.children(block);
  return Arr.findIndex(children, ElementType.isBlock).fold(
    () => children,
    (index) => children.slice(0, index)
  );
};
開發者ID:danielpunkass,項目名稱:tinymce,代碼行數:7,代碼來源:MergeBlocks.ts

示例2: parser

const parseList: Parser = (depth: number, itemSelection: Option<ItemSelection>, selectionState: Cell<boolean>, list: Element): Entry[] => {
  return Arr.bind(Traverse.children(list), (element) => {
    const parser = isList(element) ? parseList : parseItem;
    const newDepth = depth + 1;
    return parser(newDepth, itemSelection, selectionState, element);
  });
};
開發者ID:danielpunkass,項目名稱:tinymce,代碼行數:7,代碼來源:ParseLists.ts

示例3: context

  const processElement = (elem) => {
    const ctx = context(editor, elem, 'span', Node.name(elem));

    switch (ctx) {
      case ChildContext.InvalidChild: {
        finishWrapper();
        const children = Traverse.children(elem);
        processElements(children);
        finishWrapper();
        break;
      }

      case ChildContext.Valid: {
        const w = getOrOpenWrapper();
        Insert.wrap(elem, w);
        break;
      }

      // INVESTIGATE: Are these sensible things to do?
      case ChildContext.Skipping:
      case ChildContext.Existing:
      case ChildContext.Caret: {
        // Do nothing.
      }
    }
  };
開發者ID:danielpunkass,項目名稱:tinymce,代碼行數:26,代碼來源:Wrapping.ts

示例4: function

const clamp = function (offset, element) {
  const max = Node.isText(element) ? Text.get(element).length : Traverse.children(element).length + 1;

  if (offset > max) {
    return max;
  } else if (offset < 0) {
    return 0;
  }

  return offset;
};
開發者ID:mdgbayly,項目名稱:tinymce,代碼行數:11,代碼來源:SelectionBookmark.ts

示例5: function

const getChildrenUntilBlockBoundary = function (block) {
  const children = Traverse.children(block);
  return Arr.findIndex(children, ElementType.isBlock).fold(
    function () {
      return children;
    },
    function (index) {
      return children.slice(0, index);
    }
  );
};
開發者ID:abstask,項目名稱:tinymce,代碼行數:11,代碼來源:MergeBlocks.ts

示例6: function

const getTableCaptionDeltaY = function (elm) {
  if (browser.isFirefox() && Node.name(elm) === 'table') {
    return firstElement(Traverse.children(elm)).filter(function (elm) {
      return Node.name(elm) === 'caption';
    }).bind(function (caption) {
      return firstElement(Traverse.nextSiblings(caption)).map(function (body) {
        const bodyTop = body.dom().offsetTop;
        const captionTop = caption.dom().offsetTop;
        const captionHeight = caption.dom().offsetHeight;
        return bodyTop <= captionTop ? -captionHeight : 0;
      });
    }).getOr(0);
  } else {
    return 0;
  }
};
開發者ID:aha-app,項目名稱:tinymce-word-paste-filter,代碼行數:16,代碼來源:Position.ts

示例7: function

 const isActive = function () {
   return Traverse.children(container).length > 0;
 };
開發者ID:abstask,項目名稱:tinymce,代碼行數:3,代碼來源:FakeSelection.ts

示例8: function

const hasOnlyOneChild = function (elm) {
  return Traverse.children(elm).length === 1;
};
開發者ID:abstask,項目名稱:tinymce,代碼行數:3,代碼來源:InlineFormatDelete.ts

示例9: function

const isPaddedElement = function (elm) {
  return Arr.filter(Traverse.children(elm), isPaddingContents).length === 1;
};
開發者ID:aha-app,項目名稱:tinymce-word-paste-filter,代碼行數:3,代碼來源:PaddingBr.ts

示例10: isList

const parseList: Parser = (depth: number, itemSelection: Option<ItemTuple>, selectionState: Cell<boolean>, list: Element): Entry[] => {
  const newDepth = depth + 1;
  return Arr.bind(Traverse.children(list), (child) =>
    isList(child) ? parseList(newDepth, itemSelection, selectionState, child) : parseItem(newDepth, itemSelection, selectionState, child)
  );
};
開發者ID:mdgbayly,項目名稱:tinymce,代碼行數:6,代碼來源:ParseLists.ts


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