当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Traverse.prevSibling方法代码示例

本文整理汇总了TypeScript中@ephox/sugar.Traverse.prevSibling方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Traverse.prevSibling方法的具体用法?TypeScript Traverse.prevSibling怎么用?TypeScript Traverse.prevSibling使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在@ephox/sugar.Traverse的用法示例。


在下文中一共展示了Traverse.prevSibling方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1:

 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:aha-app,项目名称:tinymce-word-paste-filter,代码行数:7,代码来源:PaddingBr.ts

示例2: function

const deleteNormalized = function (elm, afterDeletePosOpt) {
  return Options.liftN([Traverse.prevSibling(elm), Traverse.nextSibling(elm), afterDeletePosOpt], function (prev, next, afterDeletePos) {
    let offset;
    const prevNode = prev.dom();
    const nextNode = next.dom();

    if (NodeType.isText(prevNode) && NodeType.isText(nextNode)) {
      offset = prevNode.data.length;
      prevNode.appendData(nextNode.data);
      Remove.remove(next);
      Remove.remove(elm);
      if (afterDeletePos.container() === nextNode) {
        return new CaretPosition(prevNode, offset);
      } else {
        return afterDeletePos;
      }
    } else {
      Remove.remove(elm);
      return afterDeletePos;
    }
  }).orThunk(function () {
    Remove.remove(elm);
    return afterDeletePosOpt;
  });
};
开发者ID:aha-app,项目名称:tinymce-word-paste-filter,代码行数:25,代码来源:DeleteElement.ts

示例3: 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:danielpunkass,项目名称:tinymce,代码行数:9,代码来源:SelectionUtils.ts

示例4: CaretPosition

const deleteNormalized = (elm: Element, afterDeletePosOpt: Option<CaretPosition>, normalizeWhitespace?: boolean): Option<CaretPosition> => {
  const prevTextOpt = Traverse.prevSibling(elm).filter((e) => NodeType.isText(e.dom()));
  const nextTextOpt = Traverse.nextSibling(elm).filter((e) => NodeType.isText(e.dom()));

  // Delete the element
  Remove.remove(elm);

  // Merge and normalize any prev/next text nodes, so that they are merged and don't lose meaningful whitespace
  // eg. <p>a <span></span> b</p> -> <p>a &nsbp;b</p> or <p><span></span> a</p> -> <p>&nbsp;a</a>
  return Options.liftN([ prevTextOpt, nextTextOpt, afterDeletePosOpt ], (prev, next, pos) => {
    const prevNode = prev.dom(), nextNode = next.dom();
    const offset = prevNode.data.length;
    MergeText.mergeTextNodes(prevNode, nextNode, normalizeWhitespace);
    // Update the cursor position if required
    return pos.container() === nextNode ? CaretPosition(prevNode, offset) : pos;
  }).orThunk(() => {
    if (normalizeWhitespace) {
      prevTextOpt.each((elm) => MergeText.normalizeWhitespaceBefore(elm.dom(), elm.dom().length));
      nextTextOpt.each((elm) => MergeText.normalizeWhitespaceAfter(elm.dom(), 0));
    }
    return afterDeletePosOpt;
  });
};
开发者ID:tinymce,项目名称:tinymce,代码行数:23,代码来源:DeleteElement.ts

示例5: function

 const getPrevLast = function (last) {
   return Traverse.prevSibling(last).bind(function (prevLast) {
     return checkLast(prevLast) ? Option.some(prevLast) : getPrevLast(prevLast);
   });
 };
开发者ID:abstask,项目名称:tinymce,代码行数:5,代码来源:CellSelection.ts


注:本文中的@ephox/sugar.Traverse.prevSibling方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。