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