UNPKG

@blocknote/core

Version:

A "Notion-style" block-based extensible text editor built on top of Prosemirror and Tiptap.

3 lines (2 loc) 817 B
"use strict";const c=require("prosemirror-state"),r=require("prosemirror-view"),s=require("./BlockNoteExtension-BWw0r8Gy.cjs"),i=new c.PluginKey("blocknote-show-selection"),S=s.createExtension(({editor:a})=>{const e=s.createStore({enabledSet:new Set},{onUpdate(){a.transact(t=>t.setMeta(i,{}))}});return{key:"showSelection",store:e,prosemirrorPlugins:[new c.Plugin({key:i,props:{decorations:t=>{const{doc:o,selection:n}=t;if(e.state.enabledSet.size===0)return r.DecorationSet.empty;const l=r.Decoration.inline(n.from,n.to,{"data-show-selection":"true"});return r.DecorationSet.create(o,[l])}}})],showSelection(t,o){e.setState({enabledSet:t?new Set([...e.state.enabledSet,o]):new Set([...e.state.enabledSet].filter(n=>n!==o))})}}});exports.ShowSelectionExtension=S; //# sourceMappingURL=ShowSelection-BxnbRvy4.cjs.map