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


TypeScript util.classFromOriginalName方法代码示例

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


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

示例1: addHandlers

  addHandlers(): void {
    this.domlistener.addHandler(
      "included-element",
      util.classFromOriginalName("*", {}),
      (root: Node, _tree: Node, _parent: Node, _prev: Node | null,
       _next: Node | null, el: Element) => {
         // Skip elements which would already have been removed from the
         // tree. Unlikely but...
         if (!root.contains(el)) {
           return;
         }

         this.elementDecorator(root as Element, el);

         const klass = this.getAdditionalClasses(el);
         if (klass.length > 0) {
           el.className += ` ${klass}`;
         }
       });

    this.domlistener.addHandler(
      "children-changed",
      util.classFromOriginalName("*", {}),
      (root: Node, added: Node[], removed: Node[],
       _previousSibling: Node | null, _nextSibling: Node | null,
       el: Element) => {
         for (const child of added.concat(removed)) {
           if (isText(child) || (isElement(child) &&
                                 (child.classList.contains("_real") ||
                                  child.classList.contains("_phantom_wrap")))) {
             this.elementDecorator(root as Element, el);
             break;
           }
         }
       });

    this.domlistener.addHandler("text-changed",
                                util.classFromOriginalName("*", {}),
                                (root: Node, node: Text) => {
                                  this.elementDecorator(
                                    root as Element,
                                    node.parentNode! as Element);
                                });

    this.domlistener.addHandler("attribute-changed",
                                util.classFromOriginalName("*", {}),
                                (root: Node, el: Element) => {
                                  this.elementDecorator(root as Element, el);
                                });
  }
开发者ID:lddubeau,项目名称:wed,代码行数:50,代码来源:generic-decorator.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 decorator = editor.modeTree.getDecorator(dataCaret.node);
    if (!(decorator instanceof BTWDecorator)) {
      throw new Error("our decorator must be a BTWDecorator");
    }

    const doc = editor.guiRoot.ownerDocument;
    const mappings = mode.getAbsoluteNamespaceMappings();
    const senses = editor.guiRoot.querySelectorAll(
      util.classFromOriginalName("btw:sense", mappings));
    const labels: Element[] = [];
    const radios: Element[] = [];
    // tslint:disable-next-line:prefer-for-of
    for (let i = 0; i < senses.length; ++i) {
      const sense = senses[i];
      let dataNode = $.data(sense, "wed_mirror_node");
      const termNodes = btwUtil.termsForSense(sense, mappings);
      const terms: string[] = [];
      // tslint:disable-next-line:prefer-for-of
      for (let tix = 0; tix < termNodes.length; ++tix) {
        terms.push($.data(termNodes[tix], "wed_mirror_node").textContent);
      }
      const senseLabel = decorator.refmans.getSenseLabel(sense);

      let span = doc.createElement("span");
      span.textContent = ` [${senseLabel}] ${terms.join(", ")}`;
      span.setAttribute("data-wed-id", sense.id);

      let radio = doc.createElement("input");
      radio.type = "radio";
      radio.name = "sense";

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

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

      const subsenses = domutil.childrenByClass(sense, "btw:subsense");
      for (const subsense of subsenses) {
        dataNode = $.data(subsense, "wed_mirror_node");
        const subsenseLabel = decorator.refmans.getSubsenseLabel(subsense);
        let child = dataNode.firstElementChild;
        let explanation;
        while (child) {
          if (child.tagName === "btw:explanation") {
            explanation = child;
            break;
          }
          child = child.nextElementSibling;
        }

        span = doc.createElement("span");
        span.textContent = ` [${subsenseLabel}] ${explanation.textContent}`;
        span.setAttribute("data-wed-id", subsense.id);

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

        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,代码行数:100,代码来源:btw-actions.ts

示例3: classFromOriginalName

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


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