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


TypeScript Element.default方法代码示例

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


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

示例1: getStart

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

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

  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:abstask,项目名称:tinymce,代码行数:29,代码来源:ElementSelection.ts

示例2: isBeforeSpace

const hasSpaceAfter = (root: Element, pos: CaretPosition): boolean => {
  if (isInMiddleOfText(pos)) {
    return isBeforeSpace(pos);
  } else {
    return isBeforeSpace(pos) || CaretFinder.nextPosition(getClosestBlock(root, pos).dom(), pos).exists(isBeforeSpace);
  }
};
开发者ID:danielpunkass,项目名称:tinymce,代码行数:7,代码来源:Nbsps.ts

示例3: getRootElement

 onAction: () => {
   // Ensure the figure/image is selected before opening the image edit dialog
   // as some browsers don't do this when right clicking
   const rootElm = getRootElement(Element.fromDom(node));
   editor.selection.select(rootElm.dom());
   // Open the dialog now that the image is selected
   Dialog(editor).open();
 }
开发者ID:tinymce,项目名称:tinymce,代码行数:8,代码来源:Buttons.ts

示例4: applyWordGrab

  editor.undoManager.transact(() => {
    const initialRng = editor.selection.getRng();
    if (initialRng.collapsed) {
      applyWordGrab(editor, initialRng);
    }

    // Even after applying word grab, we could not find a selection. Therefore,
    // just make a wrapper and insert it at the current cursor
    if (editor.selection.getRng().collapsed)  {
      const wrapper = makeAnnotation(editor.getDoc(), data, name, settings.decorate);
      // Put something visible in the marker
      Html.set(wrapper, '\u00A0');
      editor.selection.getRng().insertNode(wrapper.dom());
      editor.selection.select(wrapper.dom());
    } else {
      // The bookmark is responsible for splitting the nodes beforehand at the selection points
      // The "false" here means a zero width cursor is NOT put in the bookmark. It seems to be required
      // to stop an empty paragraph splitting into two paragraphs. Probably a better way exists.
      const bookmark = GetBookmark.getPersistentBookmark(editor.selection, false);
      const rng = editor.selection.getRng();
      annotate(editor, rng, name, settings.decorate, data);
      editor.selection.moveToBookmark(bookmark);
    }
  });
开发者ID:danielpunkass,项目名称:tinymce,代码行数:24,代码来源:Wrapping.ts

示例5: makeAnnotation

const annotate = (editor: Editor, rng: Range, annotationName: string, decorate: Decorator, data): any[] => {
  // Setup all the wrappers that are going to be used.
  const newWrappers = [ ];

  // Setup the spans for the comments
  const master = makeAnnotation(editor.getDoc(), data, annotationName, decorate);

  // Set the current wrapping element
  const wrapper = Cell(Option.none());

  // Clear the current wrapping element, so that subsequent calls to
  // getOrOpenWrapper spawns a new one.
  const finishWrapper = () => {
    wrapper.set(Option.none());
  };

  // Get the existing wrapper, or spawn a new one.
  const getOrOpenWrapper = () => {
    return wrapper.get().getOrThunk(() => {
      const nu = Replication.shallow(master);
      newWrappers.push(nu);
      wrapper.set(Option.some(nu));
      return nu;
    });
  };

  const processElements = (elems) => {
    Arr.each(elems, processElement);
  };

  const processElement = (elem) => {
    const ctx = context(editor, elem, 'span', Node.name(elem));

    switch (ctx) {
      case ChildContext.InvalidChild: {
        finishWrapper();
        const children = Traverse.children(elem);
        processElements(children);
        finishWrapper();
        break;
      }

      case ChildContext.Valid: {
        const w = getOrOpenWrapper();
        Insert.wrap(elem, w);
        break;
      }

      // INVESTIGATE: Are these sensible things to do?
      case ChildContext.Skipping:
      case ChildContext.Existing:
      case ChildContext.Caret: {
        // Do nothing.
      }
    }
  };

  const processNodes = (nodes) => {
    const elems = Arr.map(nodes, Element.fromDom);
    processElements(elems);
  };

  RangeWalk.walk(editor.dom, rng, (nodes) => {
    finishWrapper();
    processNodes(nodes);
  });

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

示例6: createItem

 Arr.last(newCast).each((segment) => {
   const item = createItem(scope, entry.itemAttributes, entry.content);
   appendItem(segment, item);
   normalizeSegment(segment, entry);
 });
开发者ID:danielpunkass,项目名称:tinymce,代码行数:5,代码来源:ComposeList.ts

示例7: setItem

 Arr.last(newOutline).each((section) => {
   setItem(section, createItem(scope, entry.itemAttributes, entry.content));
   normalizeSection(section, entry);
 });
开发者ID:mdgbayly,项目名称:tinymce,代码行数:4,代码来源:ComposeList.ts


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