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


TypeScript Traverse.firstChild方法代碼示例

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


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

示例1: createEntry

const parseItem: Parser = (depth: number, itemSelection: Option<ItemSelection>, selectionState: Cell<boolean>, item: Element): Entry[] => {
  return Traverse.firstChild(item).filter(isList).fold(() => {

    // Update selectionState (start)
    itemSelection.each((selection) => {
      if (Compare.eq(selection.start, item)) {
        selectionState.set(true);
      }
    });

    const currentItemEntry = createEntry(item, depth, selectionState.get());

    // Update selectionState (end)
    itemSelection.each((selection) => {
      if (Compare.eq(selection.end, item)) {
        selectionState.set(false);
      }
    });

    const childListEntries: Entry[] = Traverse.lastChild(item)
      .filter(isList)
      .map((list) => parseList(depth, itemSelection, selectionState, list))
      .getOr([]);

    return currentItemEntry.toArray().concat(childListEntries);
  }, (list) => parseList(depth, itemSelection, selectionState, list));
};
開發者ID:danielpunkass,項目名稱:tinymce,代碼行數:27,代碼來源:ParseLists.ts

示例2: function

const getFirstChildren = function (node) {
  return Traverse.firstChild(node).fold(
    Fun.constant([node]),
    function (child) {
      return [node].concat(getFirstChildren(child));
    }
  );
};
開發者ID:danielpunkass,項目名稱:tinymce,代碼行數:8,代碼來源:SelectionUtils.ts

示例3: updateSelectionState

const parseItem: Parser = (depth: number, itemSelection: Option<ItemTuple>, selectionState: Cell<boolean>, item: Element): Entry[] => {
  const curriedParseList = Fun.curry(parseList, depth, itemSelection, selectionState);

  const updateSelectionState = (itemRange: ItemRange) => itemSelection.each((selection) => {
    if (Compare.eq(itemRange === ItemRange.Start ? selection.start : selection.end, item)) {
      selectionState.set(itemRange === ItemRange.Start);
    }
  });

  return Traverse.firstChild(item).filter(isList).fold(() => {
    updateSelectionState(ItemRange.Start);
    const fromCurrentItem: Entry = createEntry(item, depth, selectionState.get());
    updateSelectionState(ItemRange.End);
    const fromChildList: Entry[] = Traverse.lastChild(item).filter(isList).map(curriedParseList).getOr([]);

    return [ fromCurrentItem, ...fromChildList ];
  }, curriedParseList);
};
開發者ID:mdgbayly,項目名稱:tinymce,代碼行數:18,代碼來源:ParseLists.ts

示例4:

const hasFirstChildList = (li: Element) => {
  return Traverse.firstChild(li).map(isList).getOr(false);
};
開發者ID:mdgbayly,項目名稱:tinymce,代碼行數:3,代碼來源:Util.ts


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