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


TypeScript dom-globals.Node類代碼示例

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


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

示例1: TreeWalker

const findNode = (node: Node, direction: number, predicateFn: (node: Node) => boolean, rootNode: Node, shallow?: boolean) => {
  const walker = new TreeWalker(node, rootNode);

  if (isBackwards(direction)) {
    if (isContentEditableFalse(node) || isCaretContainerBlock(node)) {
      node = skipCaretContainers(walker.prev, true);
      if (predicateFn(node)) {
        return node;
      }
    }

    while ((node = skipCaretContainers(walker.prev, shallow))) {
      if (predicateFn(node)) {
        return node;
      }
    }
  }

  if (isForwards(direction)) {
    if (isContentEditableFalse(node) || isCaretContainerBlock(node)) {
      node = skipCaretContainers(walker.next, true);
      if (predicateFn(node)) {
        return node;
      }
    }

    while ((node = skipCaretContainers(walker.next, shallow))) {
      if (predicateFn(node)) {
        return node;
      }
    }
  }

  return null;
};
開發者ID:danielpunkass,項目名稱:tinymce,代碼行數:35,代碼來源:CaretUtils.ts

示例2: if

const insertAfter = (node: Node) => {
  if (isText(node.nextSibling)) {
    if (startsWithCaretContainer(node.nextSibling)) {
      return node.nextSibling;
    } else {
      node.nextSibling.insertData(0, Zwsp.ZWSP);
      return node.nextSibling;
    }
  } else if (isText(node)) {
    if (endsWithCaretContainer(node)) {
      return node;
    } else {
      node.appendData(Zwsp.ZWSP);
      return node;
    }
  } else {
    const newNode = createZwsp(node);
    if (node.nextSibling) {
      node.parentNode.insertBefore(newNode, node.nextSibling);
    } else {
      node.parentNode.appendChild(newNode);
    }
    return newNode;
  }
};
開發者ID:danielpunkass,項目名稱:tinymce,代碼行數:25,代碼來源:CaretContainerInline.ts

示例3: isElement

const isCaretContainerBlock = (node: Node): boolean => {
  if (isText(node)) {
    node = node.parentNode;
  }

  return isElement(node) && node.hasAttribute('data-mce-caret');
};
開發者ID:mdgbayly,項目名稱:tinymce,代碼行數:7,代碼來源:CaretContainer.ts

示例4:

const nodeAtIndex = (container: Node, offset: number): Node => {
  if (container.hasChildNodes() && offset < container.childNodes.length) {
    return container.childNodes[offset];
  }

  return null;
};
開發者ID:mdgbayly,項目名稱:tinymce,代碼行數:7,代碼來源:CaretWalker.ts

示例5: function

const isAtomicContentEditableFalse = (node: Node): boolean => {
  if (!isNonUiContentEditableFalse(node)) {
    return false;
  }

  return Arr.foldl(Arr.from(node.getElementsByTagName('*')), function (result, elm) {
    return result || isContentEditableTrue(elm);
  }, false) !== true;
};
開發者ID:danielpunkass,項目名稱:tinymce,代碼行數:9,代碼來源:CaretCandidate.ts

示例6: normalizedParent

const normalizedParent = (node: Node): Node => {
  const parentNode = node.parentNode;

  if (isBogus(parentNode)) {
    return normalizedParent(parentNode);
  }

  return parentNode;
};
開發者ID:tinymce,項目名稱:tinymce,代碼行數:9,代碼來源:CaretBookmark.ts

示例7: function

      editor.on('touchend', function (e) {
        const contentEditableRoot = getContentEditableRoot(editor, e.target);

        if (isContentEditableFalse(contentEditableRoot)) {
          if (!moved) {
            e.preventDefault();
            setContentEditableSelection(CefUtils.selectNode(editor, contentEditableRoot));
          }
        }
      });
開發者ID:danielpunkass,項目名稱:tinymce,代碼行數:10,代碼來源:SelectionOverrides.ts

示例8: function

const getNode = function (container: Node, offset: number): Node {
  if (container.nodeType === 1 && container.hasChildNodes()) {
    if (offset >= container.childNodes.length) {
      offset = container.childNodes.length - 1;
    }

    container = container.childNodes[offset];
  }

  return container;
};
開發者ID:danielpunkass,項目名稱:tinymce,代碼行數:11,代碼來源:RangeNodes.ts

示例9: function

const bindEventDelegate = function (editor: Editor, eventName: string) {
  let eventRootElm, delegate;

  if (!editor.delegates) {
    editor.delegates = {};
  }

  if (editor.delegates[eventName] || editor.removed) {
    return;
  }

  eventRootElm = getEventTarget(editor, eventName);

  if (editor.settings.event_root) {
    if (!customEventRootDelegates) {
      customEventRootDelegates = {};
      editor.editorManager.on('removeEditor', function () {
        let name;

        if (!editor.editorManager.activeEditor) {
          if (customEventRootDelegates) {
            for (name in customEventRootDelegates) {
              editor.dom.unbind(getEventTarget(editor, name));
            }

            customEventRootDelegates = null;
          }
        }
      });
    }

    if (customEventRootDelegates[eventName]) {
      return;
    }

    delegate = function (e) {
      const target = e.target;
      const editors = editor.editorManager.get();
      let i = editors.length;

      while (i--) {
        const body = editors[i].getBody();

        if (body === target || DOM.isChildOf(target, body)) {
          fireEvent(editors[i], eventName, e);
        }
      }
    };

    customEventRootDelegates[eventName] = delegate;
    DOM.bind(eventRootElm, eventName, delegate);
  } else {
    delegate = function (e) {
      fireEvent(editor, eventName, e);
    };

    DOM.bind(eventRootElm, eventName, delegate);
    editor.delegates[eventName] = delegate;
  }
};
開發者ID:danielpunkass,項目名稱:tinymce,代碼行數:60,代碼來源:EditorObservable.ts


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