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


TypeScript core.getSelection函数代码示例

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


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

示例1: new

export function disableAllBlotsInRange<T extends Blot>(
    quill: Quill,
    blotConstructor:
        | {
              new (): T;
          }
        | typeof Blot,
    range: RangeStatic | null = null,
) {
    if (range === null) {
        range = quill.getSelection()!;
    }

    const currentBlots = quill.scroll.descendants(blotConstructor as any, range.index, range.length) as Blot[];
    const firstBlot = currentBlots[0];
    const lastBlot = currentBlots[currentBlots.length - 1];

    const startRange = firstBlot && {
        index: firstBlot.offset(quill.scroll),
        length: firstBlot.length(),
    };

    const endRange = lastBlot && {
        index: lastBlot.offset(quill.scroll),
        length: lastBlot.length(),
    };
    const finalRange = expandRange(range, startRange, endRange);

    if (finalRange) {
        quill.formatText(finalRange.index, finalRange.length, "link", false, Emitter.sources.USER);
    }
}
开发者ID:vanilla,项目名称:vanilla,代码行数:32,代码来源:utility.ts

示例2: it

        it("will place focus on a FocusableEmbedBlot if it is the first element in the editor", async () => {
            const embed = Parchment.create("embed-loading", stubEmbedData) as LoadingBlot;
            quill.scroll.insertBefore(embed, quill.scroll.children.tail!);
            const test = quill.insertText(quill.scroll.length(), "test");

            embedFocusModule.focusFirstLine();

            expect(embed.domNode.contains(document.activeElement) || document.activeElement === embed.domNode).eq(true);
            expect(quill.getSelection().index, "The quill selection was incorrect").eq(0);
        });
开发者ID:vanilla,项目名称:vanilla,代码行数:10,代码来源:FocusModule.test.ts

示例3: rangeContainsBlot

export function rangeContainsBlot(quill: Quill, blotConstructor: any, range: RangeStatic | null = null): boolean {
    if (range === null) {
        range = quill.getSelection();
    }

    if (!range) {
        return false;
    }

    if (range.length > 0) {
        const blots = quill.scroll.descendants(blotConstructor, range.index, range.length);
        return blots.length > 0;
    } else {
        const blot = quill.scroll.descendant(blotConstructor, range.index)[0];
        return !!blot;
    }
}
开发者ID:vanilla,项目名称:vanilla,代码行数:17,代码来源:utility.ts

示例4: setupTestQuill

 const resetQuill = () => {
     quill = setupTestQuill();
     const buttonCont = document.createElement("div");
     buttonCont.innerHTML = `
         <div>
             <button id="indent">Indent</button>
             <button id="outdent">Outdent</button>
         </div>`;
     document.body.appendChild(buttonCont);
     const indent = document.getElementById("indent")!;
     const outdent = document.getElementById("outdent")!;
     const formatter = new Formatter(quill, quill.getSelection());
     indent.addEventListener("click", e => {
         e.preventDefault();
         formatter.indentList();
     });
     outdent.addEventListener("click", e => {
         e.preventDefault();
         formatter.outdentList();
     });
     quillNode = quill.scroll.domNode as HTMLDivElement;
 };
开发者ID:vanilla,项目名称:vanilla,代码行数:22,代码来源:ListBlot.test.ts


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