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


TypeScript DOMUtils.DOMUtils类代码示例

本文整理汇总了TypeScript中tinymce/core/api/dom/DOMUtils.DOMUtils的典型用法代码示例。如果您正苦于以下问题:TypeScript DOMUtils类的具体用法?TypeScript DOMUtils怎么用?TypeScript DOMUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: function

const getPoint = function (dom: DOMUtils, trim: TrimFn, normalized: boolean, rng: Range, start: boolean) {
  let container = rng[start ? 'startContainer' : 'endContainer'];
  let offset = rng[start ? 'startOffset' : 'endOffset'];
  const point = [];
  let  childNodes, after = 0;
  const root = dom.getRoot();

  if (NodeType.isText(container)) {
    point.push(normalized ? getNormalizedTextOffset(trim, container, offset) : offset);
  } else {
    childNodes = container.childNodes;

    if (offset >= childNodes.length && childNodes.length) {
      after = 1;
      offset = Math.max(0, childNodes.length - 1);
    }

    point.push(dom.nodeIndex(childNodes[offset], normalized) + after);
  }

  for (; container && container !== root; container = container.parentNode) {
    point.push(dom.nodeIndex(container, normalized));
  }

  return point;
};
开发者ID:danielpunkass,项目名称:tinymce,代码行数:26,代码来源:GetBookmark.ts

示例2: function

const moveStart = function (dom: DOMUtils, selection: Selection, rng: Range) {
  const offset = rng.startOffset;
  let container = rng.startContainer, walker, node, nodes;

  if (rng.startContainer === rng.endContainer) {
    if (isInlineBlock(rng.startContainer.childNodes[rng.startOffset])) {
      return;
    }
  }

  // Move startContainer/startOffset in to a suitable node
  if (container.nodeType === 1) {
    nodes = container.childNodes;
    if (offset < nodes.length) {
      container = nodes[offset];
      walker = new TreeWalker(container, dom.getParent(container, dom.isBlock));
    } else {
      container = nodes[nodes.length - 1];
      walker = new TreeWalker(container, dom.getParent(container, dom.isBlock));
      walker.next(true);
    }

    for (node = walker.current(); node; node = walker.next()) {
      if (node.nodeType === 3 && !isWhiteSpaceNode(node)) {
        rng.setStart(node, 0);
        selection.setRng(rng);

        return;
      }
    }
  }
};
开发者ID:danielpunkass,项目名称:tinymce,代码行数:32,代码来源:FormatUtils.ts

示例3: getStart

const getSelectedBlocks = (dom: DOMUtils, rng: Range, startElm?: Element, endElm?: Element): Element[] => {
  let node, root;
  const selectedBlocks = [];

  root = dom.getRoot();
  startElm = dom.getParent(startElm || getStart(root, rng, rng.collapsed), dom.isBlock) as Element;
  endElm = dom.getParent(endElm || getEnd(root, rng, rng.collapsed), dom.isBlock) as Element;

  if (startElm && startElm !== root) {
    selectedBlocks.push(startElm);
  }

  if (startElm && endElm && startElm !== endElm) {
    node = startElm;

    const walker = new TreeWalker(startElm, root);
    while ((node = walker.next()) && node !== endElm) {
      if (dom.isBlock(node)) {
        selectedBlocks.push(node);
      }
    }
  }

  if (endElm && startElm !== endElm && endElm !== root) {
    selectedBlocks.push(endElm);
  }

  return selectedBlocks;
};
开发者ID:danielpunkass,项目名称:tinymce,代码行数:29,代码来源:ElementSelection.ts

示例4:

const resolveCaretPositionBookmark = (dom: DOMUtils, bookmark) => {
  let rng, pos;

  rng = dom.createRng();
  pos = CaretBookmark.resolve(dom.getRoot(), bookmark.start);
  rng.setStart(pos.container(), pos.offset());

  pos = CaretBookmark.resolve(dom.getRoot(), bookmark.end);
  rng.setEnd(pos.container(), pos.offset());

  return rng;
};
开发者ID:danielpunkass,项目名称:tinymce,代码行数:12,代码来源:ResolveBookmark.ts

示例5: TreeWalker

const hasBrBeforeAfter = (dom: DOMUtils, node: Node, left: boolean) => {
  const walker = new TreeWalker(node, dom.getParent(node.parentNode, dom.isBlock) || dom.getRoot());

  while ((node = walker[left ? 'prev' : 'next']())) {
    if (NodeType.isBr(node)) {
      return true;
    }
  }
};
开发者ID:danielpunkass,项目名称:tinymce,代码行数:9,代码来源:NormalizeRange.ts

示例6: function

const extractAdvancedStyles = function (dom: DOMUtils, elm): Node {
  const css = dom.parseStyle(dom.getAttrib(elm, 'style'));
  const data: any = {};

  if (css['border-style']) {
    data.borderStyle = css['border-style'];
  }

  if (css['border-color']) {
    data.borderColor = css['border-color'];
  }

  if (css['background-color']) {
    data.backgroundColor = css['background-color'];
  }

  data.style = dom.serializeStyle(css);
  return data;
};
开发者ID:danielpunkass,项目名称:tinymce,代码行数:19,代码来源:Helpers.ts

示例7: each

      each(dom.getAttribs(node), function (attr) {
        const name = attr.nodeName.toLowerCase();

        // Don't compare internal attributes or style
        if (name.indexOf('_') !== 0 && name !== 'style' && name.indexOf('data-') !== 0) {
          attribs[name] = dom.getAttrib(node, name);
        }
      });
开发者ID:danielpunkass,项目名称:tinymce,代码行数:8,代码来源:ElementUtils.ts


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