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


TypeScript Traverse.parent方法代碼示例

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


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

示例1: function

      Step.sync(function () {
        const active = Focus.active().getOrDie();
        // The buttons are next and previous siblings
        const prev = Traverse.parent(active).bind(Traverse.prevSibling).getOrDie('Could not find button to left');
        const next = Traverse.parent(active).bind(Traverse.nextSibling).getOrDie('Could not find button to right');

        const assertNavButton = function (buttonLabel, expected, button) {
          Assertions.assertStructure(
            'Checking ' + buttonLabel + ' button should be enabled = ' + expected,
            ApproxStructure.build(function (s, str, arr) {
              return s.element('span', {
                attr: {
                  role: str.is('button')
                },
                classes: [
                  (expected ? arr.not : arr.has)('tinymce-mobile-toolbar-navigation-disabled')
                ]
              });
            }),
            button
          );
        };

        assertNavButton('previous', prevEnabled, prev);
        assertNavButton('next', nextEnabled, next);
      })
開發者ID:aha-app,項目名稱:tinymce-word-paste-filter,代碼行數:26,代碼來源:SerialisedLinkTest.ts

示例2: function

const hasSameParent = function (blockBoundary) {
  return Traverse.parent(blockBoundary.from().block()).bind(function (parent1) {
    return Traverse.parent(blockBoundary.to().block()).filter(function (parent2) {
      return Compare.eq(parent1, parent2);
    });
  }).isSome();
};
開發者ID:abstask,項目名稱:tinymce,代碼行數:7,代碼來源:BlockBoundary.ts

示例3: if

const outdentDlItem = (editor: Editor, item: Element): void => {
  if (Compare.is(item, 'DD')) {
    Replication.mutate(item, 'DT');
  } else if (Compare.is(item, 'DT')) {
    Traverse.parent(item).each((dl) => SplitList.splitList(editor, dl.dom(), item.dom()));
  }
};
開發者ID:mdgbayly,項目名稱:tinymce,代碼行數:7,代碼來源:Indendation.ts

示例4:

const isChild = (first: boolean, elm: Element): boolean => {
  const start = Element.fromDom(elm);
  const pointOp = first ? Arr.head : Arr.last;
  return Traverse.parent(start)
    .map((parent) => PredicateFilter.children(parent, (elm) => NodeType.isBogus(elm.dom()) === false))
    .bind(pointOp)
    .map((node) => Compare.eq(node, start))
    .getOr(false);
};
開發者ID:enigmatic-user,項目名稱:tinymce-1,代碼行數:9,代碼來源:TableNavigation.ts

示例5: function

const getInsertionPoint = function (fromBlock, toBlock) {
  if (Compare.contains(toBlock, fromBlock)) {
    return Traverse.parent(fromBlock).bind(function (parent) {
      return Compare.eq(parent, toBlock) ? Option.some(fromBlock) : findParentInsertPoint(toBlock, fromBlock);
    });
  } else {
    return Option.none();
  }
};
開發者ID:abstask,項目名稱:tinymce,代碼行數:9,代碼來源:MergeBlocks.ts

示例6: getItemContent

const createEntry = (li: Element, depth: number, isSelected: boolean): Entry => {
  const list = Traverse.parent(li);
  return {
    depth,
    isSelected,
    content: getItemContent(li),
    listType: list.bind(getListType).getOr(ListType.OL),
    listAttributes: list.map(Attr.clone).getOr({}),
    itemAttributes: Attr.clone(li)
  };
};
開發者ID:mdgbayly,項目名稱:tinymce,代碼行數:11,代碼來源:ParseLists.ts

示例7: function

const getRawOrComputed = function (isRoot, rawStart) {
  const optStart = Node.isElement(rawStart) ? Option.some(rawStart) : Traverse.parent(rawStart);
  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,代碼行數:11,代碼來源:FontSizes.ts

示例8: function

const getRectsFromRange = function (range) {
  if (! range.collapsed) {
    return Arr.map(range.getClientRects(), toRect);
  } else {
    const start = Element.fromDom(range.startContainer);
    return Traverse.parent(start).bind(function (parent) {
      const selection = Selection.exact(start, range.startOffset, parent, Awareness.getEnd(parent));
      const optRect = WindowSelection.getFirstRect(range.startContainer.ownerDocument.defaultView, selection);
      return optRect.map(collapsedRect).map(Arr.pure);
    }).getOr([ ]);
  }
};
開發者ID:abstask,項目名稱:tinymce,代碼行數:12,代碼來源:Rectangles.ts

示例9: function

const directListWrappers = function (commonAnchorContainer) {
  if (ElementType.isListItem(commonAnchorContainer)) {
    return Traverse.parent(commonAnchorContainer).filter(ElementType.isList).fold(
      Fun.constant([]),
      function (listElm) {
        return [ commonAnchorContainer, listElm ];
      }
    );
  } else {
    return ElementType.isList(commonAnchorContainer) ? [ commonAnchorContainer ] : [ ];
  }
};
開發者ID:howardjing,項目名稱:tinymce,代碼行數:12,代碼來源:FragmentReader.ts

示例10: function

const getRawOrComputed = function (isRoot, rawStart) {
  const optStart = Node.isElement(rawStart) ? Option.some(rawStart) : Traverse.parent(rawStart);
  return optStart.map(function (start) {
    const inline = TransformFind.closest(start, function (elem) {
      return Css.getRaw(elem, 'font-size');
    }, isRoot);

    return inline.getOrThunk(function () {
      return Css.get(start, 'font-size');
    });
  }).getOr('');
};
開發者ID:abstask,項目名稱:tinymce,代碼行數:12,代碼來源:FontSizes.ts


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