@blocknote/xl-multi-column 0.19.1 → 0.19.2
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/dist/blocknote-xl-multi-column.js +2 -0
- package/dist/blocknote-xl-multi-column.js.map +1 -1
- package/dist/blocknote-xl-multi-column.umd.cjs +1 -1
- package/dist/blocknote-xl-multi-column.umd.cjs.map +1 -1
- package/dist/webpack-stats.json +1 -1
- package/package.json +4 -4
- package/src/extensions/ColumnResize/ColumnResizeExtension.ts +4 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(z,F){typeof exports=="object"&&typeof module<"u"?F(exports,require("@blocknote/core"),require("@tiptap/core"),require("prosemirror-state"),require("prosemirror-view"),require("prosemirror-transform")):typeof define=="function"&&define.amd?define(["exports","@blocknote/core","@tiptap/core","prosemirror-state","prosemirror-view","prosemirror-transform"],F):(z=typeof globalThis<"u"?globalThis:z||self,F(z["blocknote-xl-multi-column"]={},z.core$1,z.core,z.prosemirrorState,z.prosemirrorView,z.prosemirrorTransform))})(this,function(z,F,Ve,Pt,ot,$r){"use strict";var Ln=Object.defineProperty;var Bn=(z,F,Ve)=>F in z?Ln(z,F,{enumerable:!0,configurable:!0,writable:!0,value:Ve}):z[F]=Ve;var ce=(z,F,Ve)=>Bn(z,typeof F!="symbol"?F+"":F,Ve);const Ur=Object.freeze(Object.defineProperty({__proto__:null,ar:{slash_menu:{two_columns:{title:"عمودان",subtext:"عمودان جنبًا إلى جنب",aliases:["أعمدة","صف","تقسيم"],group:"الكتل الأساسية"},three_columns:{title:"ثلاثة أعمدة",subtext:"ثلاثة أعمدة جنبًا إلى جنب",aliases:["أعمدة","صف","تقسيم"],group:"الكتل الأساسية"}}},de:{slash_menu:{two_columns:{title:"Zwei Spalten",subtext:"Zwei Spalten nebeneinander",aliases:["Spalten","Reihe","teilen"],group:"Grundlegende blöcke"},three_columns:{title:"Drei Spalten",subtext:"Drei Spalten nebeneinander",aliases:["Spalten","Reihe","teilen"],group:"Grundlegende blöcke"}}},en:{slash_menu:{two_columns:{title:"Two Columns",subtext:"Two columns side by side",aliases:["columns","row","split"],group:"Basic blocks"},three_columns:{title:"Three Columns",subtext:"Three columns side by side",aliases:["columns","row","split"],group:"Basic blocks"}}},es:{slash_menu:{two_columns:{title:"Dos Columnas",subtext:"Dos columnas lado a lado",aliases:["columnas","fila","dividir"],group:"Bloques básicos"},three_columns:{title:"Tres Columnas",subtext:"Tres columnas lado a lado",aliases:["columnas","fila","dividir"],group:"Bloques básicos"}}},fr:{slash_menu:{two_columns:{title:"Deux Colonnes",subtext:"Deux colonnes côte à côte",aliases:["colonnes","rangée","partager"],group:"Blocs de base"},three_columns:{title:"Trois Colonnes",subtext:"Trois colonnes côte à côte",aliases:["colonnes","rangée","partager"],group:"Blocs de base"}}},hr:{slash_menu:{two_columns:{title:"Dva Stupca",subtext:"Dva stupca jedan pored drugog",aliases:["stupci","redak","podijeli"],group:"Osnovni blokovi"},three_columns:{title:"Tri Stupca",subtext:"Tri stupca jedan pored drugog",aliases:["stupci","redak","podijeli"],group:"Osnovni blokovi"}}},is:{slash_menu:{two_columns:{title:"Tvær Dálkar",subtext:"Tvær dálkar hlið við hlið",aliases:["dálkar","röð","skipta"],group:"Grunnblokkar"},three_columns:{title:"Þrír Dálkar",subtext:"Þrír dálkar hlið við hlið",aliases:["dálkar","röð","skipta"],group:"Grunnblokkar"}}},ja:{slash_menu:{two_columns:{title:"二列",subtext:"二列並んで",aliases:["列","行","分割"],group:"基本ブロック"},three_columns:{title:"三列",subtext:"三列並んで",aliases:["列","行","分割"],group:"基本ブロック"}}},ko:{slash_menu:{two_columns:{title:"두 열",subtext:"두 열 나란히",aliases:["열","행","분할"],group:"기본 블록"},three_columns:{title:"세 열",subtext:"세 열 나란히",aliases:["열","행","분할"],group:"기본 블록"}}},nl:{slash_menu:{two_columns:{title:"Twee Kolommen",subtext:"Twee kolommen naast elkaar",aliases:["kolommen","rij","verdelen"],group:"Basisblokken"},three_columns:{title:"Drie Kolommen",subtext:"Drie kolommen naast elkaar",aliases:["kolommen","rij","verdelen"],group:"Basisblokken"}}},pl:{slash_menu:{two_columns:{title:"Dwie Kolumny",subtext:"Dwie kolumny obok siebie",aliases:["kolumny","rząd","podzielić"],group:"Podstawowe bloki"},three_columns:{title:"Trzy Kolumny",subtext:"Trzy kolumny obok siebie",aliases:["kolumny","rząd","podzielić"],group:"Podstawowe bloki"}}},pt:{slash_menu:{two_columns:{title:"Duas Colunas",subtext:"Duas colunas lado a lado",aliases:["colunas","linha","dividir"],group:"Blocos básicos"},three_columns:{title:"Três Colunas",subtext:"Três colunas lado a lado",aliases:["colunas","linha","dividir"],group:"Blocos básicos"}}},ru:{slash_menu:{two_columns:{title:"Два Столбца",subtext:"Два столбца рядом",aliases:["столбцы","ряд","разделить"],group:"Базовые блоки"},three_columns:{title:"Три Столбца",subtext:"Три столбца рядом",aliases:["столбцы","ряд","разделить"],group:"Базовые блоки"}}},vi:{slash_menu:{two_columns:{title:"Hai Cột",subtext:"Hai cột cạnh nhau",aliases:["cột","hàng","chia"],group:"Khối cơ bản"},three_columns:{title:"Ba Cột",subtext:"Ba cột cạnh nhau",aliases:["cột","hàng","chia"],group:"Khối cơ bản"}}},zh:{slash_menu:{two_columns:{title:"两列",subtext:"两列并排",aliases:["列","行","分割"],group:"基础"},three_columns:{title:"三列",subtext:"三列并排",aliases:["列","行","分割"],group:"基础"}}}},Symbol.toStringTag,{value:"Module"}));function jt(u){if(!u.dictionary.multi_column)throw new Error("Multi-column dictionary not found");return u.dictionary.multi_column}const Ee=new Pt.PluginKey("ColumnResizePlugin");class zr{constructor(n,a){ce(this,"editor");ce(this,"view");ce(this,"RESIZE_MARGIN_WIDTH_PX",20);ce(this,"COLUMN_MIN_WIDTH_PERCENT",.5);ce(this,"getColumnHoverOrDefaultState",n=>{const a=n.target;if(!this.view.dom.contains(a))return{type:"default"};const c=a.closest(".bn-block-column");if(!c)return{type:"default"};const R=n.clientX,x=c.getBoundingClientRect(),S=R<x.left+this.RESIZE_MARGIN_WIDTH_PX?"left":R>x.right-this.RESIZE_MARGIN_WIDTH_PX?"right":"none",C=S==="left"?c.previousElementSibling:S==="right"?c.nextElementSibling:void 0;if(!C)return{type:"default"};const m=S==="left"?C:c,Y=S==="left"?c:C,_=m.getAttribute("data-id"),b=Y.getAttribute("data-id"),j=F.getNodeById(_,this.view.state.doc),M=F.getNodeById(b,this.view.state.doc);if(!j||!M||!j.posBeforeNode)throw new Error("Column not found");return{type:"hover",leftColumn:{element:m,id:_,...j},rightColumn:{element:Y,id:b,...M}}});ce(this,"mouseDownHandler",n=>{let a=this.getColumnHoverOrDefaultState(n);if(a.type==="default")return;n.preventDefault();const c=n.clientX,R=a.leftColumn.element.getBoundingClientRect().width,x=a.rightColumn.element.getBoundingClientRect().width,S=a.leftColumn.node.attrs.width,C=a.rightColumn.node.attrs.width;a={type:"resize",startPos:c,leftColumn:{...a.leftColumn,widthPx:R,widthPercent:S},rightColumn:{...a.rightColumn,widthPx:x,widthPercent:C}},this.view.dispatch(this.view.state.tr.setMeta(Ee,a)),this.editor.sideMenu.freezeMenu()});ce(this,"mouseMoveHandler",n=>{var m,Y;const a=Ee.getState(this.view.state);if(!a)return;if(a.type!=="resize"){const _=this.getColumnHoverOrDefaultState(n),b=a.type==="default"&&_.type==="default",j=a.type!=="default"&&_.type!=="default"&&a.leftColumn.id===_.leftColumn.id&&a.rightColumn.id===_.rightColumn.id;if(b||j||_.type==="hover"&&((Y=(m=this.editor.sideMenu.view)==null?void 0:m.state)!=null&&Y.show))return;this.view.dispatch(this.view.state.tr.setMeta(Ee,_));return}const R=(n.clientX-a.startPos)*a.leftColumn.widthPercent,x=(a.leftColumn.widthPx+R)/a.leftColumn.widthPx-1;let S=a.leftColumn.widthPercent+x,C=a.rightColumn.widthPercent-x;S<this.COLUMN_MIN_WIDTH_PERCENT?(C-=this.COLUMN_MIN_WIDTH_PERCENT-S,S=this.COLUMN_MIN_WIDTH_PERCENT):C<this.COLUMN_MIN_WIDTH_PERCENT&&(S-=this.COLUMN_MIN_WIDTH_PERCENT-C,C=this.COLUMN_MIN_WIDTH_PERCENT),this.view.dispatch(this.view.state.tr.setNodeAttribute(a.leftColumn.posBeforeNode,"width",S).setNodeAttribute(a.rightColumn.posBeforeNode,"width",C).setMeta("addToHistory",!1))});ce(this,"mouseUpHandler",n=>{const a=Ee.getState(this.view.state);if(!a||a.type!=="resize")return;const c=this.getColumnHoverOrDefaultState(n);this.view.dispatch(this.view.state.tr.setMeta(Ee,c)),this.editor.sideMenu.unfreezeMenu()});this.editor=n,this.view=a,this.view.dom.addEventListener("mousedown",this.mouseDownHandler),document.body.addEventListener("mousemove",this.mouseMoveHandler),document.body.addEventListener("mouseup",this.mouseUpHandler)}destroy(){this.view.dom.removeEventListener("mousedown",this.mouseDownHandler),document.body.removeEventListener("mousemove",this.mouseMoveHandler),document.body.removeEventListener("mouseup",this.mouseUpHandler)}}const Yr=u=>new Pt.Plugin({key:Ee,props:{decorations:n=>{const a=Ee.getState(n);return!a||a.type==="default"?ot.DecorationSet.empty:ot.DecorationSet.create(n.doc,[ot.Decoration.node(a.leftColumn.posBeforeNode,a.leftColumn.posBeforeNode+a.leftColumn.node.nodeSize,{style:"box-shadow: 4px 0 0 #ccc; cursor: col-resize"}),ot.Decoration.node(a.rightColumn.posBeforeNode,a.rightColumn.posBeforeNode+a.rightColumn.node.nodeSize,{style:"cursor: col-resize"})])}},state:{init:()=>({type:"default"}),apply:(n,a)=>{const c=n.getMeta(Ee);return c===void 0?a:c}},view:n=>new zr(u,n)}),Hr=u=>Ve.Extension.create({name:"columnResize",addProseMirrorPlugins(){return[Yr(u)]}}),qr=F.createStronglyTypedTiptapNode({name:"column",group:"bnBlock childContainer",content:"blockContainer+",priority:40,defining:!0,addAttributes(){return{width:{default:1,parseHTML:u=>{const n=u.getAttribute("data-width");if(n===null)return null;const a=parseFloat(n);return isFinite(a)?a:null},renderHTML:u=>({"data-width":u.width.toString(),style:`flex-grow: ${u.width};`})}}},parseHTML(){return[{tag:"div",getAttrs:u=>typeof u=="string"?!1:u.getAttribute("data-node-type")===this.name?{}:!1}]},renderHTML({HTMLAttributes:u}){const n=document.createElement("div");n.className="bn-block-column",n.setAttribute("data-node-type",this.name);for(const[a,c]of Object.entries(u))n.setAttribute(a,c);return{dom:n,contentDOM:n}},addExtensions(){return[Hr(this.options.editor)]}}),Kr=F.createStronglyTypedTiptapNode({name:"columnList",group:"childContainer bnBlock blockGroupChild",content:"column column+",priority:40,defining:!0,parseHTML(){return[{tag:"div",getAttrs:u=>typeof u=="string"?!1:u.getAttribute("data-node-type")===this.name?{}:!1}]},renderHTML({HTMLAttributes:u}){const n=document.createElement("div");n.className="bn-block-column-list",n.setAttribute("data-node-type",this.name);for(const[a,c]of Object.entries(u))n.setAttribute(a,c);return n.style.display="flex",{dom:n,contentDOM:n}}}),Dt=F.createBlockSpecFromStronglyTypedTiptapNode(qr,{width:{default:1}}),xt=F.createBlockSpecFromStronglyTypedTiptapNode(Kr,{}),It=F.BlockNoteSchema.create({blockSpecs:{column:Dt,columnList:xt}}),Gr=u=>F.BlockNoteSchema.create({blockSpecs:{...u.blockSpecs,column:Dt,columnList:xt},inlineContentSpecs:u.inlineContentSpecs,styleSpecs:u.styleSpecs}),it=.1;function Xr(u){return{left:u.clientX,top:u.clientY}}function Jr(u){const n=u.editor;return new Pt.Plugin({view(a){return new Zr(a,u)},props:{handleDrop(a,c,R,x){const S=a.posAtCoords(Xr(c));if(!S)throw new Error("Could not get event position");const C=ir(a.state,S),m=F.getBlockInfo(C),_=a.nodeDOM(C.posBeforeNode).getBoundingClientRect();let b="regular";if(c.clientX<=_.left+_.width*it&&(b="left"),c.clientX>=_.right-_.width*it&&(b="right"),b==="regular")return!1;const j=F.nodeToBlock(R.content.child(0),n.schema.blockSchema,n.schema.inlineContentSchema,n.schema.styleSchema);if(m.blockNoteType==="column"){const M=a.state.doc.resolve(m.bnBlock.beforePos).node(),N=F.nodeToBlock(M,n.schema.blockSchema,n.schema.inlineContentSchema,n.schema.styleSchema);let re=0;N.children.forEach(ne=>{re+=ne.props.width});const Z=re/N.children.length;if(Z<.99||Z>1.01){const ne=1/Z;N.children.forEach(se=>{se.props.width=se.props.width*ne})}const de=N.children.findIndex(ne=>ne.id===m.bnBlock.node.attrs.id),H=N.children.map(ne=>({...ne,children:ne.children.filter(se=>se.id!==j.id)})).filter(ne=>ne.children.length>0).toSpliced(b==="left"?de:de+1,0,{type:"column",children:[j],props:{},content:void 0,id:F.UniqueID.options.generateID()});n.removeBlocks([j]),n.updateBlock(N,{children:H})}else{const M=F.nodeToBlock(m.bnBlock.node,n.schema.blockSchema,n.schema.inlineContentSchema,n.schema.styleSchema),N=b==="left"?[j,M]:[M,j];n.removeBlocks([j]),n.replaceBlocks([M],[{type:"columnList",children:N.map(re=>({type:"column",children:[re]}))}])}return!0}}})}class Zr{constructor(n,a){ce(this,"width");ce(this,"color");ce(this,"class");ce(this,"cursorPos");ce(this,"element",null);ce(this,"timeout");ce(this,"handlers");this.editorView=n,this.width=a.width??1,this.color=a.color===!1?void 0:a.color||"black",this.class=a.class,this.handlers=["dragover","dragend","drop","dragleave"].map(c=>{const R=x=>{this[c](x)};return n.dom.addEventListener(c,R,c==="drop"?!0:void 0),{name:c,handler:R}})}destroy(){this.handlers.forEach(({name:n,handler:a})=>this.editorView.dom.removeEventListener(n,a,n==="drop"?!0:void 0))}update(n,a){this.cursorPos!=null&&a.doc!==n.state.doc&&(this.cursorPos.pos>n.state.doc.content.size?this.setCursor(void 0):this.updateOverlay())}setCursor(n){var a,c;n===this.cursorPos||(n==null?void 0:n.pos)===((a=this.cursorPos)==null?void 0:a.pos)&&(n==null?void 0:n.position)===((c=this.cursorPos)==null?void 0:c.position)||(this.cursorPos=n,n?this.updateOverlay():(this.element.parentNode.removeChild(this.element),this.element=null))}updateOverlay(){if(!this.cursorPos)throw new Error("updateOverlay called with no cursor position");const n=this.editorView.state.doc.resolve(this.cursorPos.pos),a=!n.parent.inlineContent;let c;const R=this.editorView.dom,x=R.getBoundingClientRect(),S=x.width/R.offsetWidth,C=x.height/R.offsetHeight;if(a){const b=n.nodeBefore,j=n.nodeAfter;if(b||j)if(this.cursorPos.position==="left"||this.cursorPos.position==="right"){const M=this.editorView.nodeDOM(this.cursorPos.pos);if(!M)throw new Error("nodeDOM returned null in updateOverlay");const N=M.getBoundingClientRect(),re=this.width/2*C,Z=this.cursorPos.position==="left"?N.left:N.right;c={left:Z-re,right:Z+re,top:N.top,bottom:N.bottom}}else{const M=this.editorView.nodeDOM(this.cursorPos.pos-(b?b.nodeSize:0));if(M){const N=M.getBoundingClientRect();let re=b?N.bottom:N.top;b&&j&&(re=(re+this.editorView.nodeDOM(this.cursorPos.pos).getBoundingClientRect().top)/2);const Z=this.width/2*C;this.cursorPos.position==="regular"&&(c={left:N.left,right:N.right,top:re-Z,bottom:re+Z})}}}if(!c){const b=this.editorView.coordsAtPos(this.cursorPos.pos),j=this.width/2*S;c={left:b.left-j,right:b.left+j,top:b.top,bottom:b.bottom}}const m=this.editorView.dom.offsetParent;this.element||(this.element=m.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",a),this.element.classList.toggle("prosemirror-dropcursor-vertical",this.cursorPos.position!=="regular"),this.element.classList.toggle("prosemirror-dropcursor-inline",!a);let Y,_;if(!m||m===document.body&&getComputedStyle(m).position==="static")Y=-window.scrollX,_=-window.scrollY;else{const b=m.getBoundingClientRect(),j=b.width/m.offsetWidth,M=b.height/m.offsetHeight;Y=b.left-m.scrollLeft*j,_=b.top-m.scrollTop*M}this.element.style.left=(c.left-Y)/S+"px",this.element.style.top=(c.top-_)/C+"px",this.element.style.width=(c.right-c.left)/S+"px",this.element.style.height=(c.bottom-c.top)/C+"px"}scheduleRemoval(n){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(void 0),n)}dragover(n){if(!this.editorView.editable)return;const a=this.editorView.posAtCoords({left:n.clientX,top:n.clientY}),c=a&&a.inside>=0&&this.editorView.state.doc.nodeAt(a.inside),R=c&&c.type.spec.disableDropCursor,x=typeof R=="function"?R(this.editorView,a,n):R;if(a&&!x){let S="regular",C=a.pos;const m=ir(this.editorView.state,a),_=this.editorView.nodeDOM(m.posBeforeNode).getBoundingClientRect();if(n.clientX<=_.left+_.width*it&&(S="left",C=m.posBeforeNode),n.clientX>=_.right-_.width*it&&(S="right",C=m.posBeforeNode),S==="regular"&&this.editorView.dragging&&this.editorView.dragging.slice){const b=$r.dropPoint(this.editorView.state.doc,C,this.editorView.dragging.slice);b!=null&&(C=b)}this.setCursor({pos:C,position:S}),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.setCursor(void 0)}dragleave(n){(n.target===this.editorView.dom||!this.editorView.dom.contains(n.relatedTarget))&&this.setCursor(void 0)}}function ir(u,n){const a=F.getNearestBlockPos(u.doc,n.pos);let c=u.doc.resolve(a.posBeforeNode);return c.parent.type.name==="column"&&(c=u.doc.resolve(c.before())),{posBeforeNode:c.pos,node:c.nodeAfter}}function Qr(u){return u&&u.__esModule&&Object.prototype.hasOwnProperty.call(u,"default")?u.default:u}var At={exports:{}},Ge={},at={exports:{}},E={};/**
|
|
1
|
+
(function(z,F){typeof exports=="object"&&typeof module<"u"?F(exports,require("@blocknote/core"),require("@tiptap/core"),require("prosemirror-state"),require("prosemirror-view"),require("prosemirror-transform")):typeof define=="function"&&define.amd?define(["exports","@blocknote/core","@tiptap/core","prosemirror-state","prosemirror-view","prosemirror-transform"],F):(z=typeof globalThis<"u"?globalThis:z||self,F(z["blocknote-xl-multi-column"]={},z.core$1,z.core,z.prosemirrorState,z.prosemirrorView,z.prosemirrorTransform))})(this,function(z,F,Ve,Pt,ot,$r){"use strict";var Ln=Object.defineProperty;var Bn=(z,F,Ve)=>F in z?Ln(z,F,{enumerable:!0,configurable:!0,writable:!0,value:Ve}):z[F]=Ve;var ce=(z,F,Ve)=>Bn(z,typeof F!="symbol"?F+"":F,Ve);const Ur=Object.freeze(Object.defineProperty({__proto__:null,ar:{slash_menu:{two_columns:{title:"عمودان",subtext:"عمودان جنبًا إلى جنب",aliases:["أعمدة","صف","تقسيم"],group:"الكتل الأساسية"},three_columns:{title:"ثلاثة أعمدة",subtext:"ثلاثة أعمدة جنبًا إلى جنب",aliases:["أعمدة","صف","تقسيم"],group:"الكتل الأساسية"}}},de:{slash_menu:{two_columns:{title:"Zwei Spalten",subtext:"Zwei Spalten nebeneinander",aliases:["Spalten","Reihe","teilen"],group:"Grundlegende blöcke"},three_columns:{title:"Drei Spalten",subtext:"Drei Spalten nebeneinander",aliases:["Spalten","Reihe","teilen"],group:"Grundlegende blöcke"}}},en:{slash_menu:{two_columns:{title:"Two Columns",subtext:"Two columns side by side",aliases:["columns","row","split"],group:"Basic blocks"},three_columns:{title:"Three Columns",subtext:"Three columns side by side",aliases:["columns","row","split"],group:"Basic blocks"}}},es:{slash_menu:{two_columns:{title:"Dos Columnas",subtext:"Dos columnas lado a lado",aliases:["columnas","fila","dividir"],group:"Bloques básicos"},three_columns:{title:"Tres Columnas",subtext:"Tres columnas lado a lado",aliases:["columnas","fila","dividir"],group:"Bloques básicos"}}},fr:{slash_menu:{two_columns:{title:"Deux Colonnes",subtext:"Deux colonnes côte à côte",aliases:["colonnes","rangée","partager"],group:"Blocs de base"},three_columns:{title:"Trois Colonnes",subtext:"Trois colonnes côte à côte",aliases:["colonnes","rangée","partager"],group:"Blocs de base"}}},hr:{slash_menu:{two_columns:{title:"Dva Stupca",subtext:"Dva stupca jedan pored drugog",aliases:["stupci","redak","podijeli"],group:"Osnovni blokovi"},three_columns:{title:"Tri Stupca",subtext:"Tri stupca jedan pored drugog",aliases:["stupci","redak","podijeli"],group:"Osnovni blokovi"}}},is:{slash_menu:{two_columns:{title:"Tvær Dálkar",subtext:"Tvær dálkar hlið við hlið",aliases:["dálkar","röð","skipta"],group:"Grunnblokkar"},three_columns:{title:"Þrír Dálkar",subtext:"Þrír dálkar hlið við hlið",aliases:["dálkar","röð","skipta"],group:"Grunnblokkar"}}},ja:{slash_menu:{two_columns:{title:"二列",subtext:"二列並んで",aliases:["列","行","分割"],group:"基本ブロック"},three_columns:{title:"三列",subtext:"三列並んで",aliases:["列","行","分割"],group:"基本ブロック"}}},ko:{slash_menu:{two_columns:{title:"두 열",subtext:"두 열 나란히",aliases:["열","행","분할"],group:"기본 블록"},three_columns:{title:"세 열",subtext:"세 열 나란히",aliases:["열","행","분할"],group:"기본 블록"}}},nl:{slash_menu:{two_columns:{title:"Twee Kolommen",subtext:"Twee kolommen naast elkaar",aliases:["kolommen","rij","verdelen"],group:"Basisblokken"},three_columns:{title:"Drie Kolommen",subtext:"Drie kolommen naast elkaar",aliases:["kolommen","rij","verdelen"],group:"Basisblokken"}}},pl:{slash_menu:{two_columns:{title:"Dwie Kolumny",subtext:"Dwie kolumny obok siebie",aliases:["kolumny","rząd","podzielić"],group:"Podstawowe bloki"},three_columns:{title:"Trzy Kolumny",subtext:"Trzy kolumny obok siebie",aliases:["kolumny","rząd","podzielić"],group:"Podstawowe bloki"}}},pt:{slash_menu:{two_columns:{title:"Duas Colunas",subtext:"Duas colunas lado a lado",aliases:["colunas","linha","dividir"],group:"Blocos básicos"},three_columns:{title:"Três Colunas",subtext:"Três colunas lado a lado",aliases:["colunas","linha","dividir"],group:"Blocos básicos"}}},ru:{slash_menu:{two_columns:{title:"Два Столбца",subtext:"Два столбца рядом",aliases:["столбцы","ряд","разделить"],group:"Базовые блоки"},three_columns:{title:"Три Столбца",subtext:"Три столбца рядом",aliases:["столбцы","ряд","разделить"],group:"Базовые блоки"}}},vi:{slash_menu:{two_columns:{title:"Hai Cột",subtext:"Hai cột cạnh nhau",aliases:["cột","hàng","chia"],group:"Khối cơ bản"},three_columns:{title:"Ba Cột",subtext:"Ba cột cạnh nhau",aliases:["cột","hàng","chia"],group:"Khối cơ bản"}}},zh:{slash_menu:{two_columns:{title:"两列",subtext:"两列并排",aliases:["列","行","分割"],group:"基础"},three_columns:{title:"三列",subtext:"三列并排",aliases:["列","行","分割"],group:"基础"}}}},Symbol.toStringTag,{value:"Module"}));function jt(u){if(!u.dictionary.multi_column)throw new Error("Multi-column dictionary not found");return u.dictionary.multi_column}const Ee=new Pt.PluginKey("ColumnResizePlugin");class zr{constructor(n,a){ce(this,"editor");ce(this,"view");ce(this,"RESIZE_MARGIN_WIDTH_PX",20);ce(this,"COLUMN_MIN_WIDTH_PERCENT",.5);ce(this,"getColumnHoverOrDefaultState",n=>{if(!this.editor.isEditable)return{type:"default"};const a=n.target;if(!this.view.dom.contains(a))return{type:"default"};const c=a.closest(".bn-block-column");if(!c)return{type:"default"};const R=n.clientX,x=c.getBoundingClientRect(),S=R<x.left+this.RESIZE_MARGIN_WIDTH_PX?"left":R>x.right-this.RESIZE_MARGIN_WIDTH_PX?"right":"none",C=S==="left"?c.previousElementSibling:S==="right"?c.nextElementSibling:void 0;if(!C)return{type:"default"};const m=S==="left"?C:c,Y=S==="left"?c:C,_=m.getAttribute("data-id"),b=Y.getAttribute("data-id"),j=F.getNodeById(_,this.view.state.doc),M=F.getNodeById(b,this.view.state.doc);if(!j||!M||!j.posBeforeNode)throw new Error("Column not found");return{type:"hover",leftColumn:{element:m,id:_,...j},rightColumn:{element:Y,id:b,...M}}});ce(this,"mouseDownHandler",n=>{let a=this.getColumnHoverOrDefaultState(n);if(a.type==="default")return;n.preventDefault();const c=n.clientX,R=a.leftColumn.element.getBoundingClientRect().width,x=a.rightColumn.element.getBoundingClientRect().width,S=a.leftColumn.node.attrs.width,C=a.rightColumn.node.attrs.width;a={type:"resize",startPos:c,leftColumn:{...a.leftColumn,widthPx:R,widthPercent:S},rightColumn:{...a.rightColumn,widthPx:x,widthPercent:C}},this.view.dispatch(this.view.state.tr.setMeta(Ee,a)),this.editor.sideMenu.freezeMenu()});ce(this,"mouseMoveHandler",n=>{var m,Y;const a=Ee.getState(this.view.state);if(!a)return;if(a.type!=="resize"){const _=this.getColumnHoverOrDefaultState(n),b=a.type==="default"&&_.type==="default",j=a.type!=="default"&&_.type!=="default"&&a.leftColumn.id===_.leftColumn.id&&a.rightColumn.id===_.rightColumn.id;if(b||j||_.type==="hover"&&((Y=(m=this.editor.sideMenu.view)==null?void 0:m.state)!=null&&Y.show))return;this.view.dispatch(this.view.state.tr.setMeta(Ee,_));return}const R=(n.clientX-a.startPos)*a.leftColumn.widthPercent,x=(a.leftColumn.widthPx+R)/a.leftColumn.widthPx-1;let S=a.leftColumn.widthPercent+x,C=a.rightColumn.widthPercent-x;S<this.COLUMN_MIN_WIDTH_PERCENT?(C-=this.COLUMN_MIN_WIDTH_PERCENT-S,S=this.COLUMN_MIN_WIDTH_PERCENT):C<this.COLUMN_MIN_WIDTH_PERCENT&&(S-=this.COLUMN_MIN_WIDTH_PERCENT-C,C=this.COLUMN_MIN_WIDTH_PERCENT),this.view.dispatch(this.view.state.tr.setNodeAttribute(a.leftColumn.posBeforeNode,"width",S).setNodeAttribute(a.rightColumn.posBeforeNode,"width",C).setMeta("addToHistory",!1))});ce(this,"mouseUpHandler",n=>{const a=Ee.getState(this.view.state);if(!a||a.type!=="resize")return;const c=this.getColumnHoverOrDefaultState(n);this.view.dispatch(this.view.state.tr.setMeta(Ee,c)),this.editor.sideMenu.unfreezeMenu()});this.editor=n,this.view=a,this.view.dom.addEventListener("mousedown",this.mouseDownHandler),document.body.addEventListener("mousemove",this.mouseMoveHandler),document.body.addEventListener("mouseup",this.mouseUpHandler)}destroy(){this.view.dom.removeEventListener("mousedown",this.mouseDownHandler),document.body.removeEventListener("mousemove",this.mouseMoveHandler),document.body.removeEventListener("mouseup",this.mouseUpHandler)}}const Yr=u=>new Pt.Plugin({key:Ee,props:{decorations:n=>{const a=Ee.getState(n);return!a||a.type==="default"?ot.DecorationSet.empty:ot.DecorationSet.create(n.doc,[ot.Decoration.node(a.leftColumn.posBeforeNode,a.leftColumn.posBeforeNode+a.leftColumn.node.nodeSize,{style:"box-shadow: 4px 0 0 #ccc; cursor: col-resize"}),ot.Decoration.node(a.rightColumn.posBeforeNode,a.rightColumn.posBeforeNode+a.rightColumn.node.nodeSize,{style:"cursor: col-resize"})])}},state:{init:()=>({type:"default"}),apply:(n,a)=>{const c=n.getMeta(Ee);return c===void 0?a:c}},view:n=>new zr(u,n)}),Hr=u=>Ve.Extension.create({name:"columnResize",addProseMirrorPlugins(){return[Yr(u)]}}),qr=F.createStronglyTypedTiptapNode({name:"column",group:"bnBlock childContainer",content:"blockContainer+",priority:40,defining:!0,addAttributes(){return{width:{default:1,parseHTML:u=>{const n=u.getAttribute("data-width");if(n===null)return null;const a=parseFloat(n);return isFinite(a)?a:null},renderHTML:u=>({"data-width":u.width.toString(),style:`flex-grow: ${u.width};`})}}},parseHTML(){return[{tag:"div",getAttrs:u=>typeof u=="string"?!1:u.getAttribute("data-node-type")===this.name?{}:!1}]},renderHTML({HTMLAttributes:u}){const n=document.createElement("div");n.className="bn-block-column",n.setAttribute("data-node-type",this.name);for(const[a,c]of Object.entries(u))n.setAttribute(a,c);return{dom:n,contentDOM:n}},addExtensions(){return[Hr(this.options.editor)]}}),Kr=F.createStronglyTypedTiptapNode({name:"columnList",group:"childContainer bnBlock blockGroupChild",content:"column column+",priority:40,defining:!0,parseHTML(){return[{tag:"div",getAttrs:u=>typeof u=="string"?!1:u.getAttribute("data-node-type")===this.name?{}:!1}]},renderHTML({HTMLAttributes:u}){const n=document.createElement("div");n.className="bn-block-column-list",n.setAttribute("data-node-type",this.name);for(const[a,c]of Object.entries(u))n.setAttribute(a,c);return n.style.display="flex",{dom:n,contentDOM:n}}}),Dt=F.createBlockSpecFromStronglyTypedTiptapNode(qr,{width:{default:1}}),xt=F.createBlockSpecFromStronglyTypedTiptapNode(Kr,{}),It=F.BlockNoteSchema.create({blockSpecs:{column:Dt,columnList:xt}}),Gr=u=>F.BlockNoteSchema.create({blockSpecs:{...u.blockSpecs,column:Dt,columnList:xt},inlineContentSpecs:u.inlineContentSpecs,styleSpecs:u.styleSpecs}),it=.1;function Xr(u){return{left:u.clientX,top:u.clientY}}function Jr(u){const n=u.editor;return new Pt.Plugin({view(a){return new Zr(a,u)},props:{handleDrop(a,c,R,x){const S=a.posAtCoords(Xr(c));if(!S)throw new Error("Could not get event position");const C=ir(a.state,S),m=F.getBlockInfo(C),_=a.nodeDOM(C.posBeforeNode).getBoundingClientRect();let b="regular";if(c.clientX<=_.left+_.width*it&&(b="left"),c.clientX>=_.right-_.width*it&&(b="right"),b==="regular")return!1;const j=F.nodeToBlock(R.content.child(0),n.schema.blockSchema,n.schema.inlineContentSchema,n.schema.styleSchema);if(m.blockNoteType==="column"){const M=a.state.doc.resolve(m.bnBlock.beforePos).node(),N=F.nodeToBlock(M,n.schema.blockSchema,n.schema.inlineContentSchema,n.schema.styleSchema);let re=0;N.children.forEach(ne=>{re+=ne.props.width});const Z=re/N.children.length;if(Z<.99||Z>1.01){const ne=1/Z;N.children.forEach(se=>{se.props.width=se.props.width*ne})}const de=N.children.findIndex(ne=>ne.id===m.bnBlock.node.attrs.id),H=N.children.map(ne=>({...ne,children:ne.children.filter(se=>se.id!==j.id)})).filter(ne=>ne.children.length>0).toSpliced(b==="left"?de:de+1,0,{type:"column",children:[j],props:{},content:void 0,id:F.UniqueID.options.generateID()});n.removeBlocks([j]),n.updateBlock(N,{children:H})}else{const M=F.nodeToBlock(m.bnBlock.node,n.schema.blockSchema,n.schema.inlineContentSchema,n.schema.styleSchema),N=b==="left"?[j,M]:[M,j];n.removeBlocks([j]),n.replaceBlocks([M],[{type:"columnList",children:N.map(re=>({type:"column",children:[re]}))}])}return!0}}})}class Zr{constructor(n,a){ce(this,"width");ce(this,"color");ce(this,"class");ce(this,"cursorPos");ce(this,"element",null);ce(this,"timeout");ce(this,"handlers");this.editorView=n,this.width=a.width??1,this.color=a.color===!1?void 0:a.color||"black",this.class=a.class,this.handlers=["dragover","dragend","drop","dragleave"].map(c=>{const R=x=>{this[c](x)};return n.dom.addEventListener(c,R,c==="drop"?!0:void 0),{name:c,handler:R}})}destroy(){this.handlers.forEach(({name:n,handler:a})=>this.editorView.dom.removeEventListener(n,a,n==="drop"?!0:void 0))}update(n,a){this.cursorPos!=null&&a.doc!==n.state.doc&&(this.cursorPos.pos>n.state.doc.content.size?this.setCursor(void 0):this.updateOverlay())}setCursor(n){var a,c;n===this.cursorPos||(n==null?void 0:n.pos)===((a=this.cursorPos)==null?void 0:a.pos)&&(n==null?void 0:n.position)===((c=this.cursorPos)==null?void 0:c.position)||(this.cursorPos=n,n?this.updateOverlay():(this.element.parentNode.removeChild(this.element),this.element=null))}updateOverlay(){if(!this.cursorPos)throw new Error("updateOverlay called with no cursor position");const n=this.editorView.state.doc.resolve(this.cursorPos.pos),a=!n.parent.inlineContent;let c;const R=this.editorView.dom,x=R.getBoundingClientRect(),S=x.width/R.offsetWidth,C=x.height/R.offsetHeight;if(a){const b=n.nodeBefore,j=n.nodeAfter;if(b||j)if(this.cursorPos.position==="left"||this.cursorPos.position==="right"){const M=this.editorView.nodeDOM(this.cursorPos.pos);if(!M)throw new Error("nodeDOM returned null in updateOverlay");const N=M.getBoundingClientRect(),re=this.width/2*C,Z=this.cursorPos.position==="left"?N.left:N.right;c={left:Z-re,right:Z+re,top:N.top,bottom:N.bottom}}else{const M=this.editorView.nodeDOM(this.cursorPos.pos-(b?b.nodeSize:0));if(M){const N=M.getBoundingClientRect();let re=b?N.bottom:N.top;b&&j&&(re=(re+this.editorView.nodeDOM(this.cursorPos.pos).getBoundingClientRect().top)/2);const Z=this.width/2*C;this.cursorPos.position==="regular"&&(c={left:N.left,right:N.right,top:re-Z,bottom:re+Z})}}}if(!c){const b=this.editorView.coordsAtPos(this.cursorPos.pos),j=this.width/2*S;c={left:b.left-j,right:b.left+j,top:b.top,bottom:b.bottom}}const m=this.editorView.dom.offsetParent;this.element||(this.element=m.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",a),this.element.classList.toggle("prosemirror-dropcursor-vertical",this.cursorPos.position!=="regular"),this.element.classList.toggle("prosemirror-dropcursor-inline",!a);let Y,_;if(!m||m===document.body&&getComputedStyle(m).position==="static")Y=-window.scrollX,_=-window.scrollY;else{const b=m.getBoundingClientRect(),j=b.width/m.offsetWidth,M=b.height/m.offsetHeight;Y=b.left-m.scrollLeft*j,_=b.top-m.scrollTop*M}this.element.style.left=(c.left-Y)/S+"px",this.element.style.top=(c.top-_)/C+"px",this.element.style.width=(c.right-c.left)/S+"px",this.element.style.height=(c.bottom-c.top)/C+"px"}scheduleRemoval(n){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(void 0),n)}dragover(n){if(!this.editorView.editable)return;const a=this.editorView.posAtCoords({left:n.clientX,top:n.clientY}),c=a&&a.inside>=0&&this.editorView.state.doc.nodeAt(a.inside),R=c&&c.type.spec.disableDropCursor,x=typeof R=="function"?R(this.editorView,a,n):R;if(a&&!x){let S="regular",C=a.pos;const m=ir(this.editorView.state,a),_=this.editorView.nodeDOM(m.posBeforeNode).getBoundingClientRect();if(n.clientX<=_.left+_.width*it&&(S="left",C=m.posBeforeNode),n.clientX>=_.right-_.width*it&&(S="right",C=m.posBeforeNode),S==="regular"&&this.editorView.dragging&&this.editorView.dragging.slice){const b=$r.dropPoint(this.editorView.state.doc,C,this.editorView.dragging.slice);b!=null&&(C=b)}this.setCursor({pos:C,position:S}),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.setCursor(void 0)}dragleave(n){(n.target===this.editorView.dom||!this.editorView.dom.contains(n.relatedTarget))&&this.setCursor(void 0)}}function ir(u,n){const a=F.getNearestBlockPos(u.doc,n.pos);let c=u.doc.resolve(a.posBeforeNode);return c.parent.type.name==="column"&&(c=u.doc.resolve(c.before())),{posBeforeNode:c.pos,node:c.nodeAfter}}function Qr(u){return u&&u.__esModule&&Object.prototype.hasOwnProperty.call(u,"default")?u.default:u}var At={exports:{}},Ge={},at={exports:{}},E={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react.production.min.js
|
|
4
4
|
*
|