/*!
Copyright (c) 2026 Lenovo SSG BASD. All rights reserved.
@license Proprietary

This software is the confidential and proprietary property of Lenovo SSG BASD.
You shall not disclose such Confidential Information and shall use it only in
accordance with the terms of the license agreement.

--- Build Info ---
Version: 1.1.1
Build Time: 2026/2/26 17:21:00
Build Commit: 81e556ed827e2f043668506dae6fae8dbb9ef395
*/
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../core/dist/index.js"),t=require("../../../prosemirror-state/dist/index.js"),o=require("../../../prosemirror-dropcursor/dist/index.js"),r=require("../../../prosemirror-view/dist/index.js"),n=require("../../../prosemirror-gapcursor/dist/index.js"),s=require("../../../prosemirror-history/dist/index.js");var i=e.Extension.create({name:"characterCount",addOptions:()=>({limit:null,mode:"textSize",textCounter:e=>e.length,wordCounter:e=>e.split(" ").filter(e=>""!==e).length}),addStorage:()=>({characters:()=>0,words:()=>0}),onBeforeCreate(){this.storage.characters=e=>{const t=(null==e?void 0:e.node)||this.editor.state.doc;if("textSize"===((null==e?void 0:e.mode)||this.options.mode)){const e=t.textBetween(0,t.content.size,void 0," ");return this.options.textCounter(e)}return t.nodeSize},this.storage.words=e=>{const t=(null==e?void 0:e.node)||this.editor.state.doc,o=t.textBetween(0,t.content.size," "," ");return this.options.wordCounter(o)}},addProseMirrorPlugins(){let e=!1;return[new t.Plugin({key:new t.PluginKey("characterCount"),appendTransaction:(t,o,r)=>{if(e)return;const n=this.options.limit;if(null==n||0===n)return void(e=!0);const s=this.storage.characters({node:r.doc});if(s>n){const t=0,o=s-n;console.warn(`[CharacterCount] Initial content exceeded limit of ${n} characters. Content was automatically trimmed.`);const i=r.tr.deleteRange(t,o);return e=!0,i}e=!0},filterTransaction:(e,t)=>{const o=this.options.limit;if(!e.docChanged||0===o||null==o)return!0;const r=this.storage.characters({node:t.doc}),n=this.storage.characters({node:e.doc});if(n<=o)return!0;if(r>o&&n>o&&n<=r)return!0;if(r>o&&n>o&&n>r)return!1;if(!e.getMeta("paste"))return!1;const s=e.selection.$head.pos,i=s-(n-o),d=s;e.deleteRange(i,d);return!(this.storage.characters({node:e.doc})>o)}})]}}),d=e.Extension.create({name:"dropCursor",addOptions:()=>({color:"currentColor",width:1,class:void 0}),addProseMirrorPlugins(){return[o.dropCursor(this.options)]}});e.Extension.create({name:"focus",addOptions:()=>({className:"has-focus",mode:"all"}),addProseMirrorPlugins(){return[new t.Plugin({key:new t.PluginKey("focus"),props:{decorations:({doc:e,selection:t})=>{const{isEditable:o,isFocused:n}=this.editor,{anchor:s}=t,i=[];if(!o||!n)return r.DecorationSet.create(e,[]);let d=0;"deepest"===this.options.mode&&e.descendants((e,t)=>{if(e.isText)return;if(!(s>=t&&s<=t+e.nodeSize-1))return!1;d+=1});let a=0;return e.descendants((e,t)=>{if(e.isText)return!1;if(!(s>=t&&s<=t+e.nodeSize-1))return!1;a+=1;if("deepest"===this.options.mode&&d-a>0||"shallowest"===this.options.mode&&a>1)return"deepest"===this.options.mode;i.push(r.Decoration.node(t,t+e.nodeSize,{class:this.options.className}))}),r.DecorationSet.create(e,i)}}})]}});var a=e.Extension.create({name:"gapCursor",addProseMirrorPlugins:()=>[n.gapCursor()],extendNodeSchema(t){var o;const r={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:null!=(o=e.callOrReturn(e.getExtensionField(t,"allowGapCursor",r)))?o:null}}}),c="placeholder";function l(e){return e.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}function u({types:e,node:t}){return t&&Array.isArray(e)&&e.includes(t.type)||(null==t?void 0:t.type)===e}e.Extension.create({name:"placeholder",addOptions:()=>({emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:c,placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}),addProseMirrorPlugins(){const o=this.options.dataAttribute?`data-${l(this.options.dataAttribute)}`:`data-${c}`;return[new t.Plugin({key:new t.PluginKey("placeholder"),props:{decorations:({doc:t,selection:n})=>{const s=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:i}=n,d=[];if(!s)return null;const a=this.editor.isEmpty;return t.descendants((t,n)=>{const s=i>=n&&i<=n+t.nodeSize,c=!t.isLeaf&&e.isNodeEmpty(t);if((s||!this.options.showOnlyCurrent)&&c){const e=[this.options.emptyNodeClass];a&&e.push(this.options.emptyEditorClass);const i=r.Decoration.node(n,n+t.nodeSize,{class:e.join(" "),[o]:"function"==typeof this.options.placeholder?this.options.placeholder({editor:this.editor,node:t,pos:n,hasAnchor:s}):this.options.placeholder});d.push(i)}return this.options.includeChildren}),r.DecorationSet.create(t,d)}}})]}}),e.Extension.create({name:"selection",addOptions:()=>({className:"selection"}),addProseMirrorPlugins(){const{editor:o,options:n}=this;return[new t.Plugin({key:new t.PluginKey("selection"),props:{decorations:t=>t.selection.empty||o.isFocused||!o.isEditable||e.isNodeSelection(t.selection)||o.view.dragging?null:r.DecorationSet.create(t.doc,[r.Decoration.inline(t.selection.from,t.selection.to,{class:n.className})])}})]}});var p=e.Extension.create({name:"trailingNode",addOptions:()=>({node:void 0,notAfter:[]}),addProseMirrorPlugins(){var e;const o=new t.PluginKey(this.name),r=this.options.node||(null==(e=this.editor.schema.topNodeType.contentMatch.defaultType)?void 0:e.name)||"paragraph",n=Object.entries(this.editor.schema.nodes).map(([,e])=>e).filter(e=>(this.options.notAfter||[]).concat(r).includes(e.name));return[new t.Plugin({key:o,appendTransaction:(e,t,n)=>{const{doc:s,tr:i,schema:d}=n,a=o.getState(n),c=s.content.size,l=d.nodes[r];if(a)return i.insert(c,l.create())},state:{init:(e,t)=>!u({node:t.tr.doc.lastChild,types:n}),apply:(e,t)=>{if(!e.docChanged)return t;if(e.getMeta("__uniqueIDTransaction"))return t;return!u({node:e.doc.lastChild,types:n})}}})]}}),h=e.Extension.create({name:"undoRedo",addOptions:()=>({depth:100,newGroupDelay:500}),addCommands:()=>({undo:()=>({state:e,dispatch:t})=>s.undo(e,t),redo:()=>({state:e,dispatch:t})=>s.redo(e,t)}),addProseMirrorPlugins(){return[s.history(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}});exports.CharacterCount=i,exports.Dropcursor=d,exports.Gapcursor=a,exports.TrailingNode=p,exports.UndoRedo=h,exports.preparePlaceholderAttribute=l;