本文整理汇总了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);
});
示例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;
}
}
}