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


TypeScript Traverse.nextSibling方法代碼示例

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


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

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

示例2:

      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:aha-app,項目名稱:tinymce-word-paste-filter,代碼行數:9,代碼來源:InitEditorNoThemeIframeTest.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 nextElement = Traverse.nextSibling(targetElement);

        Assertions.assertEq('Should be null since inline has no editorContainer', null, editor.editorContainer);
        Assertions.assertDomEq('Should be expected editor body element', targetElement, Element.fromDom(editor.getBody()));
        Assertions.assertDomEq('Should be expected editor target element', targetElement, Element.fromDom(editor.getElement()));
        Assertions.assertEq('Should be undefined for inline mode', undefined, editor.contentAreaContainer);
        Assertions.assertEq('Should be no element after target', true, nextElement.isNone());
      }))
開發者ID:abstask,項目名稱:tinymce,代碼行數:11,代碼來源:InitEditorNoThemeInlineTest.ts

示例4:

      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 nextElement = Traverse.nextSibling(targetElement);

        // TODO FIXME this seems like an odd exception
        Assertions.assertEq('Should be null since inline without a theme does not set editorContainer', null, editor.editorContainer);
        Assertions.assertDomEq('Should be expected editor body element', targetElement, Element.fromDom(editor.getBody()));
        Assertions.assertDomEq('Should be expected editor target element', targetElement, Element.fromDom(editor.getElement()));
        Assertions.assertDomEq('Editor.contentAreaContainer should equal target element', targetElement, Element.fromDom(editor.contentAreaContainer));
        Assertions.assertEq('Should be no element after target', true, nextElement.isNone());
      }))
開發者ID:tinymce,項目名稱:tinymce,代碼行數:12,代碼來源:InitEditorNoThemeInlineTest.ts

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

示例6:

 Chain.binder((elem) => Traverse.nextSibling(elem).fold(() => Result.error('Replaced element has no next sibling'), Result.value)),
開發者ID:tinymce,項目名稱:tinymce,代碼行數:1,代碼來源:ToxWrappingTest.ts


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