--- a/dist/defaultBlocks-DE5GNdJH.js +++ b/dist/defaultBlocks-DE5GNdJH.js @@ -2651,17 +2651,23 @@ if (!a && !(o !== void 0 && r !== void 0) && !s) return; if (this.pluginState = s ? o : r, s || !this.editor.isEditable) { - this.state && (this.state.show = !1), this.emitUpdate(this.pluginState.triggerCharacter); + if (!this.state) + return; + this.state.show = !1, this.emitUpdate(this.pluginState.triggerCharacter); return; } const c = (l = this.rootEl) == null ? void 0 : l.querySelector( `[data-decoration-id="${this.pluginState.decorationId}"]` ); - this.editor.isEditable && c && (this.state = { + if (!c) { + this.state && (this.state.show = !1, this.emitUpdate(this.pluginState.triggerCharacter)); + return; + } + this.state = { show: !0, referencePos: c.getBoundingClientRect().toJSON(), query: this.pluginState.query - }, this.emitUpdate(this.pluginState.triggerCharacter)); + }, this.emitUpdate(this.pluginState.triggerCharacter); } destroy() { var t; @@ -2761,7 +2768,7 @@ if (a === s) { const c = r.state.doc; for (const l of t) { - const u = l.length > 1 ? c.textBetween(a - l.length, a) + i : i; + const u = l.length > 1 ? c.textBetween(a - (l.length - 1), a) + i : i; if (l === u) return r.dispatch(r.state.tr.insertText(i)), r.dispatch( r.state.tr.setMeta(B, { --- a/src/editor/managers/ExtensionManager/extensions.ts +++ b/src/editor/managers/ExtensionManager/extensions.ts @@ -84,7 +84,8 @@ }).configure({ defaultProtocol: DEFAULT_LINK_PROTOCOL, // only call this once if we have multiple editors installed. Or fix https://github.com/ueberdosis/tiptap/issues/5450 - protocols: LINKIFY_INITIALIZED ? [] : VALID_LINK_PROTOCOLS, + // Tolaria pre-registers BlockNote's non-native protocols before linkify initializes. + protocols: [], }), ...(Object.values(editor.schema.styleSpecs).map((styleSpec) => { return styleSpec.implementation.mark.configure({ --- a/dist/blocknote.js +++ b/dist/blocknote.js @@ -2037,7 +2037,9 @@ ] }) ); -let fe = !1; +const bnLinkifyProtocolFlag = "__tolariaBlockNoteLinkifyProtocolsRegistered"; +const bnGlobalObject = typeof globalThis > "u" ? void 0 : globalThis; +let fe = Boolean(bnGlobalObject && bnGlobalObject[bnLinkifyProtocolFlag]); function mn(o, e) { const t = [ I.ClipboardTextSerializer, @@ -2062,7 +2064,8 @@ }).configure({ defaultProtocol: Ct, // only call this once if we have multiple editors installed. Or fix https://github.com/ueberdosis/tiptap/issues/5450 - protocols: fe ? [] : Bt + // Tolaria pre-registers BlockNote's non-native protocols before linkify initializes. + protocols: [] }), ...Object.values(o.schema.styleSpecs).map((n) => n.implementation.mark.configure({ editor: o @@ -2112,7 +2115,7 @@ ), Do(o) ]; - return fe = !0, t; + return fe = !0, bnGlobalObject && (bnGlobalObject[bnLinkifyProtocolFlag] = !0), t; } function kn(o, e) { const t = [ --- a/src/extensions/SuggestionMenu/SuggestionMenu.ts +++ b/src/extensions/SuggestionMenu/SuggestionMenu.ts @@ -83,29 +83,38 @@ this.pluginState = stopped ? prev : next; if (stopped || !this.editor.isEditable) { - if (this.state) { - this.state.show = false; - } + if (!this.state) { + return; + } + + this.state.show = false; this.emitUpdate(this.pluginState!.triggerCharacter); return; } const decorationNode = this.rootEl?.querySelector( `[data-decoration-id="${this.pluginState!.decorationId}"]`, ); - if (this.editor.isEditable && decorationNode) { - this.state = { - show: true, - referencePos: decorationNode - .getBoundingClientRect() - .toJSON() as DOMRect, - query: this.pluginState!.query, - }; - - this.emitUpdate(this.pluginState!.triggerCharacter!); + if (!decorationNode) { + if (this.state) { + this.state.show = false; + this.emitUpdate(this.pluginState!.triggerCharacter!); + } + + return; } + + this.state = { + show: true, + referencePos: decorationNode + .getBoundingClientRect() + .toJSON() as DOMRect, + query: this.pluginState!.query, + }; + + this.emitUpdate(this.pluginState!.triggerCharacter!); } destroy() { --- a/src/extensions/TableHandles/TableHandles.ts +++ b/src/extensions/TableHandles/TableHandles.ts @@ -572,9 +572,14 @@ const tableBody = this.tableElement!.querySelector("tbody"); if (!tableBody) { - throw new Error( - "Table block does not contain a 'tbody' HTML element. This should never happen.", - ); + this.state.show = false; + this.state.showAddOrRemoveRowsButton = false; + this.state.showAddOrRemoveColumnsButton = false; + this.state.rowIndex = undefined; + this.state.colIndex = undefined; + this.state.referencePosCell = undefined; + this.emitUpdate(); + return; } if ( --- a/dist/TrailingNode-CxM966vN.js +++ b/dist/TrailingNode-CxM966vN.js @@ -1746,10 +1746,10 @@ ); this.state.rowIndex !== void 0 && this.state.colIndex !== void 0 && (this.state.rowIndex >= e && (this.state.rowIndex = e - 1), this.state.colIndex >= t && (this.state.colIndex = t - 1)); const o = this.tableElement.querySelector("tbody"); - if (!o) - throw new Error( - "Table block does not contain a 'tbody' HTML element. This should never happen." - ); + if (!o) { + this.state.show = !1, this.state.showAddOrRemoveRowsButton = !1, this.state.showAddOrRemoveColumnsButton = !1, this.state.rowIndex = void 0, this.state.colIndex = void 0, this.state.referencePosCell = void 0, this.emitUpdate(); + return; + } if (this.state.rowIndex !== void 0 && this.state.colIndex !== void 0) { const i = o.children[this.state.rowIndex].children[this.state.colIndex]; i ? this.state.referencePosCell = i.getBoundingClientRect() : (this.state.rowIndex = void 0, this.state.colIndex = void 0);