• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript wed.EditorAPI类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: getBiblSelectionModal

function getBiblSelectionModal(editor: EditorAPI): Modal {
  let modal = editor.getModeData(BIBL_SELECTION_MODAL_KEY);
  if (modal) {
    return modal;
  }

  modal = editor.makeModal();
  modal.setTitle("Invalid Selection");
  modal.setBody("<p>The selection should contain only text. The current " +
                "selection contains elements.</p>");
  modal.addButton("Ok", true);
  editor.setModeData(BIBL_SELECTION_MODAL_KEY, modal);

  return modal;
}
开发者ID:mangalam-research,项目名称:btw,代码行数:15,代码来源:btw-actions.ts


示例2: getNestingModal

function getNestingModal(editor: EditorAPI): Modal {
  let nestingModal = editor.getModeData(NESTING_MODAL_KEY);
  if (nestingModal) {
    return nestingModal;
  }

  nestingModal = editor.makeModal();
  nestingModal.setTitle("Invalid nesting");
  nestingModal.setBody("<p>In this part of the article, you cannot embed one " +
                       "language into another.</p>");
  nestingModal.addButton("Ok", true);
  editor.setModeData(NESTING_MODAL_KEY, nestingModal);

  return nestingModal;
}
开发者ID:mangalam-research,项目名称:btw,代码行数:15,代码来源:btw-tr.ts


示例3: getEditSemanticFieldModal

function getEditSemanticFieldModal(editor: EditorAPI): Modal {
  let modal = editor.getModeData(EDIT_SF_MODAL_KEY);
  if (modal) {
    return modal;
  }

  modal = editor.makeModal({
    resizable: true,
    draggable: true,
  });
  modal.setTitle("Edit Semantic Fields");
  modal.addButton("Commit", true);
  modal.addButton("Cancel");
  const body = modal.getTopLevel()[0].getElementsByClassName("modal-body")[0];
  body.classList.add("sf-editor-modal-body");
  body.style.overflowY = "hidden";
  editor.setModeData(EDIT_SF_MODAL_KEY, modal);

  return modal;
}
开发者ID:mangalam-research,项目名称:btw,代码行数:20,代码来源:btw-actions.ts


示例4: executeDeleteAttribute

function executeDeleteAttribute(editor: EditorAPI,
                                data: TransformationData): void {
  const node = data.node;

  if (node == null || !isAttr(node)) {
    throw new Error("node must be an attribute");
  }

  const element = node.ownerElement!;
  const caretManager = editor.caretManager;
  const guiOwnerLoc = caretManager.mustFromDataLocation(element, 0);
  // If the node we start with is an Element, then the node in guiOwnerLoc
  // is necessarily an Element too.
  const guiOwner = guiOwnerLoc.node as Element;
  if (!guiOwner.classList.contains("_readonly")) {
    const encoded = node.name;
    const startLabel = childByClass(guiOwner, "__start_label")!;

    // An earlier version of this code relied on the order of attributes in the
    // data tree. However, this order is not consistent from platform to
    // platform. Using the order of attributes in the GUI is
    // consistent. Therefore we go to the GUI to find the next attribute.

    const values = startLabel.getElementsByClassName("_attribute_value");

    // We have to get the parent node because fromDataLocation brings us to the
    // text node that contains the value.
    const guiNode = caretManager.mustFromDataLocation(node, 0).node.parentNode;
    const index = indexOf(values, guiNode!);
    const nextGUIValue = values[index + 1];
    const nextAttr = nextGUIValue != null ?
      editor.toDataNode(nextGUIValue) : null;

    editor.dataUpdater.setAttribute(element, encoded, null);

    // We set the caret inside the next attribute, or if it does not exist,
    // inside the label.
    if (nextAttr !== null) {
      editor.caretManager.setCaret(nextAttr, 0);
    }
    else {
      editor.caretManager.setCaret(
        guiOwner.getElementsByClassName("_element_name")[0], 0);
    }
  }
}
开发者ID:lddubeau,项目名称:wed,代码行数:46,代码来源:generic-tr.ts


示例5: replaceSemanticFields

export function replaceSemanticFields(editor: EditorAPI,
                                      data: SemanticFieldTransformationData):
void {
  const dataCaret = editor.caretManager.getDataCaret(true)!;
  const guiCaret = editor.caretManager.fromDataLocation(dataCaret)!;
  const guiSfsContainer = domutil.closestByClass(guiCaret.node,
                                                 "btw:semantic-fields",
                                                 editor.guiRoot);
  if (guiSfsContainer === null) {
    throw new Error("unable to acquire btw:semantic-fields");
  }

  const sfsContainer = editor.toDataNode(guiSfsContainer)!;
  const sfsParent = sfsContainer.parentNode!;
  const sfsIndex = _indexOf.call(sfsParent.childNodes, sfsContainer);
  // Remove the container from the tree.
  editor.dataUpdater.removeNode(sfsContainer);

  // and manipulate it off-line.
  while (sfsContainer.firstChild !== null) {
    sfsContainer.removeChild(sfsContainer.firstChild);
  }

  const doc = sfsContainer.ownerDocument;
  const newPaths = data.newPaths;
  const mode = editor.modeTree.getMode(sfsContainer);
  const ename = mode.getAbsoluteResolver().resolveName("btw:sf")!;

  for (const path of newPaths) {
    const sf = makeElement(doc, ename.ns, "btw:sf");
    sf.textContent = path;
    sfsContainer.appendChild(sf);
  }

  // Finally, reintroduce it to the data tree.
  editor.dataUpdater.insertNodeAt(sfsParent, sfsIndex, sfsContainer);
  editor.caretManager.setCaret(sfsContainer, 0);
}
开发者ID:mangalam-research,项目名称:btw,代码行数:38,代码来源:btw-tr.ts


示例6:

 (editor: EditorAPI, data: NamedTransformationData) => {
   editor.insertText(data.name);
 });
开发者ID:lddubeau,项目名称:wed,代码行数:3,代码来源:generic-tr.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript wed.domutil类代码示例发布时间:2022-05-25
下一篇:
TypeScript webtorrent.add函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap