@threadlabs/looma 0.18.5 → 0.18.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/editor/chunks/extensions.js +15 -0
- package/package.json +1 -1
|
@@ -6050,6 +6050,21 @@ function createLoomaMentionExtension(options = {}) {
|
|
|
6050
6050
|
char: "@",
|
|
6051
6051
|
allowSpaces: false,
|
|
6052
6052
|
startOfLine: false,
|
|
6053
|
+
allow: ({ editor, state, range, isActive }) => {
|
|
6054
|
+
const $from = state.doc.resolve(range.from);
|
|
6055
|
+
const mentionType = state.schema.nodes.mention;
|
|
6056
|
+
if (!mentionType || !$from.parent.type.contentMatch.matchType(mentionType)) return false;
|
|
6057
|
+
for (let depth = $from.depth; depth >= 0; depth -= 1) if ($from.node(depth).type.spec.code) return false;
|
|
6058
|
+
const codeMark = state.schema.marks.code;
|
|
6059
|
+
if (codeMark && state.doc.rangeHasMark(range.from, range.to, codeMark)) return false;
|
|
6060
|
+
const previous = LoomaMentionSuggestionPluginKey.getState(editor.view.state);
|
|
6061
|
+
if (isActive && previous?.range?.from === range.from) return true;
|
|
6062
|
+
const before = editor.view.state.doc.content;
|
|
6063
|
+
const start = before.findDiffStart(state.doc.content);
|
|
6064
|
+
const end = before.findDiffEnd(state.doc.content);
|
|
6065
|
+
if (start === null || !end || range.from < start || range.from >= end.b) return false;
|
|
6066
|
+
return state.doc.textBetween(start, end.b) === "@";
|
|
6067
|
+
},
|
|
6053
6068
|
items: ({ query }) => resolveMentionItems(options.items, query, limit),
|
|
6054
6069
|
render: () => {
|
|
6055
6070
|
let selectedIndex = 0;
|