當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。