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


TypeScript sugar.Traverse類代碼示例

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


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

示例1: function

const parentsUntil = function (startNode, rootElm, predicate) {
  if (Compare.contains(rootElm, startNode)) {
    return dropLast(Traverse.parents(startNode, function (elm) {
      return predicate(elm) || Compare.eq(elm, rootElm);
    }));
  } else {
    return [];
  }
};
開發者ID:abstask,項目名稱:tinymce,代碼行數:9,代碼來源:Parents.ts

示例2: function

const trimBlockTrailingBr = function (elm) {
  Traverse.lastChild(elm).each(function (lastChild) {
    Traverse.prevSibling(lastChild).each(function (lastChildPrevSibling) {
      if (ElementType.isBlock(elm) && ElementType.isBr(lastChild) && ElementType.isBlock(lastChildPrevSibling)) {
        Remove.remove(lastChild);
      }
    });
  });
};
開發者ID:abstask,項目名稱:tinymce,代碼行數:9,代碼來源:PaddingBr.ts

示例3:

      Logger.t('Editor element properties', Step.sync(function () {
        const body = Element.fromDom(document.body);
        const targetElement = SelectorFind.descendant(body, '#' + editor.id).getOrDie('No elm');
        const editorElement = Traverse.nextSibling(targetElement).getOrDie('No elm');

        Assertions.assertDomEq('Should be expected element', editorElement, Element.fromDom(editor.editorContainer));
        Assertions.assertDomEq('Should be expected element', editorElement, Element.fromDom(editor.contentAreaContainer));
        Assertions.assertDomEq('Should be expected element', targetElement, Element.fromDom(editor.getElement()));
      }))
開發者ID:danielpunkass,項目名稱:tinymce,代碼行數:9,代碼來源:InitEditorNoThemeIframeTest.ts

示例4:

    return Chain.op(function () {
      const sc = Hierarchy.follow(Element.fromDom(viewBlock.get()), startPath).getOrDie('invalid startPath');
      const fc = Hierarchy.follow(Element.fromDom(viewBlock.get()), finishPath).getOrDie('invalid finishPath');
      const win = Traverse.defaultView(sc);

      WindowSelection.setExact(
        win.dom(), sc, soffset, fc, foffset
      );
    });
開發者ID:aha-app,項目名稱:tinymce-word-paste-filter,代碼行數:9,代碼來源:SelectionBookmarkTest.ts

示例5: function

const moveWindowScroll = function (toolbar, viewport, destY) {
  const outerWindow = Traverse.owner(toolbar).dom().defaultView;
  return Future.nu(function (callback) {
    updateTop(toolbar, destY);
    updateTop(viewport, destY);
    outerWindow.scrollTo(0, destY);
    callback(destY);
  });
};
開發者ID:danielpunkass,項目名稱:tinymce,代碼行數:9,代碼來源:IosScrolling.ts

示例6:

    bookmark.each(function (b) {
      const root = Element.fromDom(viewBlock.get());
      const win = Traverse.defaultView(root);

      SelectionBookmark.validate(root, b)
        .each(function (rng) {
          WindowSelection.setExact(win.dom(), rng.start(), rng.soffset(), rng.finish(), rng.foffset());
        });
    });
開發者ID:abstask,項目名稱:tinymce,代碼行數:9,代碼來源:SelectionBookmarkTest.ts

示例7:

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

示例8: function

 function (child) {
   if (Node.name(child) === 'br') {
     return Traverse.prevSibling(child).map(function (sibling) {
       return [node].concat(getLastChildren(sibling));
     }).getOr([]);
   } else {
     return [node].concat(getLastChildren(child));
   }
 }
開發者ID:tinymce,項目名稱:tinymce,代碼行數:9,代碼來源:SelectionUtils.ts

示例9: 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

示例10: function

const takeover = function (viewport, contentBody, toolbar, dropup) {
  const outerWindow = Traverse.owner(viewport).dom().defaultView;
  const toolbarSetup = takeoverToolbar(toolbar);
  const toolbarHeight = Height.get(toolbar);
  const dropupHeight = Height.get(dropup);
  const viewportHeight = deriveViewportHeight(viewport, toolbarHeight, dropupHeight);

  const viewportSetup = takeoverViewport(toolbarHeight, viewportHeight, viewport);

  const dropupSetup = takeoverDropup(dropup, toolbarHeight, viewportHeight);

  let isActive = true;

  const restore = function () {
    isActive = false;
    toolbarSetup.restore();
    viewportSetup.restore();
    dropupSetup.restore();
  };

  const isExpanding = function () {
    const currentWinHeight = outerWindow.innerHeight;
    const lastWinHeight = getLastWindowSize(viewport);
    return currentWinHeight > lastWinHeight;
  };

  const refresh = function () {
    if (isActive) {
      const newToolbarHeight = Height.get(toolbar);
      const dropupHeight = Height.get(dropup);
      const newHeight = deriveViewportHeight(viewport, newToolbarHeight, dropupHeight);
      Attr.set(viewport, yFixedData, newToolbarHeight + 'px');
      Css.set(viewport, 'height', newHeight + 'px');

      Css.set(dropup, 'bottom', -(newToolbarHeight + newHeight + dropupHeight) + 'px');
      DeviceZones.updatePadding(contentBody, viewport, dropup);
    }
  };

  const setViewportOffset = function (newYOffset) {
    const offsetPx = newYOffset + 'px';
    Attr.set(viewport, yFixedData, offsetPx);
    // The toolbar height has probably changed, so recalculate the viewport height.
    refresh();
  };

  DeviceZones.updatePadding(contentBody, viewport, dropup);

  return {
    setViewportOffset,
    isExpanding,
    isShrinking: Fun.not(isExpanding),
    refresh,
    restore
  };
};
開發者ID:abstask,項目名稱:tinymce,代碼行數:56,代碼來源:IosViewport.ts


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