@blocknote/core
Version:
A "Notion-style" block-based extensible text editor built on top of Prosemirror and Tiptap.
52 lines (51 loc) • 1.58 kB
JavaScript
import { PluginKey as c, Plugin as l } from "prosemirror-state";
import { DecorationSet as r, Decoration as S } from "prosemirror-view";
import { c as d, a as w } from "./BlockNoteExtension-C2X7LW-V.js";
const s = new c("blocknote-show-selection"), b = d(({ editor: a }) => {
const e = w(
{ enabledSet: /* @__PURE__ */ new Set() },
{
onUpdate() {
a.transact((t) => t.setMeta(s, {}));
}
}
);
return {
key: "showSelection",
store: e,
prosemirrorPlugins: [
new l({
key: s,
props: {
decorations: (t) => {
const { doc: o, selection: n } = t;
if (e.state.enabledSet.size === 0)
return r.empty;
const i = S.inline(n.from, n.to, {
"data-show-selection": "true"
});
return r.create(o, [i]);
}
}
})
],
/**
* Show or hide the selection decoration
*
* @param shouldShow - Whether to show the selection decoration
* @param key - The key of the selection to show or hide,
* this is necessary to prevent disabling ShowSelection from one place
* will interfere with other parts of the code that need to show the selection decoration
* (e.g.: CreateLinkButton and AIExtension)
*/
showSelection(t, o) {
e.setState({
enabledSet: t ? /* @__PURE__ */ new Set([...e.state.enabledSet, o]) : new Set([...e.state.enabledSet].filter((n) => n !== o))
});
}
};
});
export {
b as S
};
//# sourceMappingURL=ShowSelection-B0ch3unP.js.map