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


TypeScript Range.default方法代码示例

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


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

示例1: createRange

 .map(function (newEndPos) {
   if (!CaretUtils.isInSameBlock(startPos, endPos, rootNode) && CaretUtils.isInSameBlock(startPos, newEndPos, rootNode)) {
     return createRange(startPos.container(), startPos.offset(), newEndPos.container(), newEndPos.offset());
   } else {
     return rng;
   }
 }).getOr(rng);
开发者ID:danielpunkass,项目名称:tinymce,代码行数:7,代码来源:RangeNormalizer.ts

示例2: getNodeRange

const selectNode = (editor, node: Element): Range => {
  const e = editor.fire('BeforeObjectSelected', { target: node });
  if (e.isDefaultPrevented()) {
    return null;
  }

  return getNodeRange(node);
};
开发者ID:danielpunkass,项目名称:tinymce,代码行数:8,代码来源:CefUtils.ts

示例3: createRange

  const toRange = (): Range => {
    let range;

    range = createRange(container.ownerDocument);
    range.setStart(container, offset);
    range.setEnd(container, offset);

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

示例4: normalizeRange

const getNormalizedRangeEndPoint = (direction: number, root: Node, range: Range): CaretPosition => {
  const normalizedRange = normalizeRange(direction, root, range);

  if (direction === -1) {
    return CaretPosition.fromRangeStart(normalizedRange);
  }

  return CaretPosition.fromRangeEnd(normalizedRange);
};
开发者ID:danielpunkass,项目名称:tinymce,代码行数:9,代码来源:CaretUtils.ts

示例5: return

  return () => {
    const newRng = getVerticalRange(editor, down);

    if (newRng) {
      editor.selection.setRng(newRng);
      return true;
    } else {
      return false;
    }
  };
开发者ID:mdgbayly,项目名称:tinymce,代码行数:10,代码来源:CefNavigation.ts

示例6: renderCaretAtRange

const renderRangeCaret = (editor: Editor, range: Range, scrollIntoView: boolean): Range => {
  if (!range || !range.collapsed) {
    return range;
  }

  const caretRange = renderCaretAtRange(editor, range, scrollIntoView);
  if (caretRange) {
    return caretRange;
  }

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

示例7: showCaret

const renderCaretAtRange = (editor: Editor, range: Range, scrollIntoView: boolean): Range => {
  const normalizedRange = CaretUtils.normalizeRange(1, editor.getBody(), range);
  const caretPosition = CaretPosition.fromRangeStart(normalizedRange);

  const caretPositionNode = caretPosition.getNode();

  if (isContentEditableFalse(caretPositionNode)) {
    return showCaret(1, editor, caretPositionNode, !caretPosition.isAtEnd(), false);
  }

  const caretPositionBeforeNode = caretPosition.getNode(true);

  if (isContentEditableFalse(caretPositionBeforeNode)) {
    return showCaret(1, editor, caretPositionBeforeNode, false, false);
  }

  // TODO: Should render caret before/after depending on where you click on the page forces after now
  const ceRoot = editor.dom.getParent(caretPosition.getNode(), (node) => isContentEditableFalse(node) || isContentEditableTrue(node));
  if (isContentEditableFalse(ceRoot)) {
    return showCaret(1, editor, ceRoot, false, scrollIntoView);
  }

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

示例8: getContentEditableRoot

    editor.on('mousedown', (e: MouseEvent) => {
      let contentEditableRoot;
      const targetElm = e.target as Element;

      if (targetElm !== rootNode && targetElm.nodeName !== 'HTML' && !editor.dom.isChildOf(targetElm, rootNode)) {
        return;
      }

      if (EditorView.isXYInContentArea(editor, e.clientX, e.clientY) === false) {
        return;
      }

      contentEditableRoot = getContentEditableRoot(editor, targetElm);
      if (contentEditableRoot) {
        if (isContentEditableFalse(contentEditableRoot)) {
          e.preventDefault();
          setContentEditableSelection(CefUtils.selectNode(editor, contentEditableRoot));
        } else {
          removeContentEditableSelection();

          // Check that we're not attempting a shift + click select within a contenteditable='true' element
          if (!(isContentEditableTrue(contentEditableRoot) && e.shiftKey) && !RangePoint.isXYWithinRange(e.clientX, e.clientY, editor.selection.getRng())) {
            hideFakeCaret();
            editor.selection.placeCaretAt(e.clientX, e.clientY);
          }
        }
      } else if (isFakeCaretTarget(targetElm) === false) {
        // Remove needs to be called here since the mousedown might alter the selection without calling selection.setRng
        // and therefore not fire the AfterSetSelectionRange event.
        removeContentEditableSelection();
        hideFakeCaret();

        const caretInfo = LineUtils.closestCaret(rootNode, e.clientX, e.clientY);
        if (caretInfo) {
          if (!hasBetterMouseTarget(e.target, caretInfo.node)) {
            e.preventDefault();
            const range = showCaret(1, caretInfo.node as HTMLElement, caretInfo.before, false);
            editor.getBody().focus();
            setRange(range);
          }
        }
      }
    });
开发者ID:danielpunkass,项目名称:tinymce,代码行数:43,代码来源:SelectionOverrides.ts


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