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


TypeScript utility.getMentionRange函数代码示例

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


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

示例1: it

    it("Returns null when quill is not focused.", () => {
        // Sanity check that this would otherwise be a valid mention.
        quill.setContents([{ insert: "@Somebody" }]);
        const selection = { index: 3, length: 0 };
        quill.setSelection(selection);
        expect(getMentionRange(quill, selection)).not.to.eq(null);

        // Actual check.
        button.focus();
        expect(getMentionRange(quill, selection)).to.eq(null);
    });
开发者ID:vanilla,项目名称:vanilla,代码行数:11,代码来源:utility.test.ts

示例2: instanceReducer

export default function instanceReducer(
    state = initialState,
    action: instanceActions.ActionTypes,
): IEditorInstanceState {
    switch (action.type) {
        case instanceActions.CREATE_INSTANCE: {
            validateIDExistance(state, action);
            return {
                ...state,
                [action.payload.editorID]: defaultInstance,
            };
        }
        case instanceActions.DELETE_INSTANCE: {
            validateIDExistance(state, action);
            const newState = { ...state };
            delete newState[action.payload.editorID];
            return newState;
        }
        case instanceActions.SET_SELECTION: {
            validateIDExistance(state, action);
            const { selection, editorID, quill } = action.payload;
            const instanceState = state[editorID];
            const { lastGoodSelection } = instanceState;

            return {
                ...state,
                [editorID]: {
                    ...instanceState,
                    currentSelection: selection,
                    lastGoodSelection: selection !== null ? selection : lastGoodSelection,
                    mentionSelection: getMentionRange(quill, selection),
                },
            };
        }
        default: {
            return state;
        }
    }
}
开发者ID:vanilla,项目名称:vanilla,代码行数:39,代码来源:instanceReducer.ts


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