當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。