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


TypeScript domutil.toGUISelector方法代码示例

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


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

示例1: toGUISelector

 toGUISelector(selector: string): string {
   return domutil.toGUISelector(selector, this.mapping);
 }
开发者ID:mangalam-research,项目名称:btw,代码行数:3,代码来源:mapped-util.ts

示例2: execute

  execute(data: TransformationData): void {
    const editor = this.editor;

    const dataCaret = editor.caretManager.getDataCaret(true)!;
    const mode = editor.modeTree.getMode(dataCaret.node);
    if (!(mode instanceof Mode)) {
      throw new Error("expected BTW mode");
    }

    const doc = editor.guiRoot.ownerDocument;
    const mappings = mode.getAbsoluteNamespaceMappings();
    const examples =
      editor.guiRoot.querySelectorAll(domutil.toGUISelector(
        "btw:example, btw:example-explained", mappings));
    const labels: Element[] = [];
    const radios: Element[] = [];
    // tslint:disable-next-line:prefer-for-of
    for (let i = 0; i < examples.length; ++i) {
      const example = examples[i];
      const dataNode = $.data(example, "wed_mirror_node");
      let child = dataNode.firstElementChild;
      let cit;
      while (child) {
        if (child.tagName === "btw:cit") {
          cit = child;
          break;
        }
        child = child.nextElementSibling;
      }

      const abbr = example.querySelector(util.classFromOriginalName("ref",
                                                                    mappings));
      // We skip those examples that do not have a ref in them yet, as links to
      // them are meaningless.
      if (abbr === null) {
        continue;
      }

      const abbrCopy = abbr.cloneNode(true) as Element;
      child = abbrCopy.firstElementChild;
      while (child) {
        const next = child.nextElementSibling;
        if (child.classList.contains("_gui")) {
          abbrCopy.removeChild(child);
        }
        child = next;
      }

      const span = doc.createElement("span");
      span.setAttribute("data-wed-id", example.id);
      span.textContent = ` ${abbrCopy.textContent} ${cit.textContent}`;

      const radio = doc.createElement("input");
      radio.type = "radio";
      radio.name = "example";

      const div = doc.createElement("div");
      div.appendChild(radio);
      div.appendChild(span);

      labels.push(div);
      radios.push(radio);
    }

    const hyperlinkModal = mode.hyperlinkModal;
    const primary = hyperlinkModal.getPrimary()[0] as HTMLButtonElement;
    const body = doc.createElement("div");
    for (const label of labels) {
      body.appendChild(label);
    }

    $(radios).on("click.wed", () => {
      primary.disabled = false;
      primary.classList.remove("disabled");
    });
    primary.disabled = true;
    primary.classList.add("disabled");
    hyperlinkModal.setBody(body);
    hyperlinkModal.modal(() => {
      const clicked = hyperlinkModal.getClickedAsText();
      if (clicked === "Insert") {
        const id = body.querySelector("input[type='radio']:checked")!
              .nextElementSibling!.getAttribute("data-wed-id")!;
        mode.insertPtrTr.execute({ ...data, target: id });
      }
    });
  }
开发者ID:mangalam-research,项目名称:btw,代码行数:87,代码来源:btw-actions.ts

示例3: termsForSense

export function termsForSense(sense: Element,
                              mappings: Record<string, string>):
NodeListOf<Element> {
  return sense.querySelectorAll(
    domutil.toGUISelector("btw:english-rendition>btw:english-term", mappings));
}
开发者ID:mangalam-research,项目名称:btw,代码行数:6,代码来源:btw-util.ts


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