ados-rcm 1.1.923 → 1.1.925
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/AModule/AComponents/AEditor/AEditorLayout.d.ts +1 -1
- package/dist/AModule/AComponents/AEditor/modules/TableSelection.d.ts +1 -1
- package/dist/AModule/AComponents/AEditor/modules/TableUp.d.ts +8 -4
- package/dist/AModule/AComponents/AEditor/modules/TableUpLogical.d.ts +10 -0
- package/dist/{Copy-6mR6HJXS.cjs → Copy-BOXnPTyQ.cjs} +1 -1
- package/dist/{Copy-LKloNfLz.js → Copy-UNuHstjJ.js} +1 -1
- package/dist/{Divider-CHDVrDUx.cjs → Divider-BirH8clG.cjs} +1 -1
- package/dist/{Divider-BVBanTlF.js → Divider-h_FJ5vfo.js} +1 -1
- package/dist/{ImageResizer-C2nM6iwj.js → ImageResizer-CRaSVfIo.js} +1 -1
- package/dist/{ImageResizer-DwXLh7nD.cjs → ImageResizer-DnU2mypj.cjs} +1 -1
- package/dist/{TableClipboard-C-KYYaFD.js → TableClipboard-Bv58536M.js} +3 -3
- package/dist/{TableClipboard-CZqyYzXt.cjs → TableClipboard-VFBFjlAm.cjs} +1 -1
- package/dist/TableSelection-DOL9Nmlo.js +150 -0
- package/dist/TableSelection-DvJPyeQ8.cjs +1 -0
- package/dist/TableUp-BB5sIpp1.js +124 -0
- package/dist/TableUp-DDEBIGjz.cjs +1 -0
- package/dist/TableUpLogical-Cvks-qgX.js +140 -0
- package/dist/TableUpLogical-D2BMVJiy.cjs +1 -0
- package/dist/{Video-FcoRVz5U.js → Video-Cr9HNjYE.js} +1 -1
- package/dist/{Video-BU8dqZsf.cjs → Video-jqOPig5H.cjs} +1 -1
- package/dist/{index-CcbYx7lO.cjs → index-3cY5fR4B.cjs} +1 -1
- package/dist/{index-DZVpV90f.js → index-B7G8Zc2n.js} +17 -16
- package/dist/{index-BX7053-U.js → index-BmRxkoLz.js} +1 -1
- package/dist/{index-DEkL9qvd.js → index-DTYmDae7.js} +1 -1
- package/dist/{index-BbLYxbgj.cjs → index-DprVE3Wh.cjs} +110 -110
- package/dist/{index-bW3-D_Yb.cjs → index-DyVQWGfz.cjs} +1 -1
- package/dist/index.cjs.js +2 -2
- package/dist/index.es.js +2 -2
- package/package.json +1 -1
- package/dist/TableSelection-BKeLhTjX.js +0 -132
- package/dist/TableSelection-VOANme54.cjs +0 -1
- package/dist/TableUp-2LZ9wUN8.cjs +0 -1
- package/dist/TableUp-DBGSbBGA.js +0 -98
- package/dist/TableUpLogical-98hsWR63.cjs +0 -1
- package/dist/TableUpLogical-CbqjSDMT.js +0 -391
|
@@ -58,7 +58,7 @@ interface IAEditorWrapStyleParams {
|
|
|
58
58
|
export declare function resolveAEditorLayoutMetrics({ contentHeight, currentHeight, extMaxHeight, extMinHeight, extType, isReadonly, style, toolbarHeight, wrapStyle, }: IAEditorLayoutMetricsParams): IAEditorResolvedLayoutMetrics;
|
|
59
59
|
export declare function resolveAEditorLabelStyle({ hasLabel, labelStyle }: IAEditorLabelStyleParams): CSSProperties;
|
|
60
60
|
export declare function resolveAEditorWrapDimensions({ hasFixedContentHeight, isRawMode, wrapStyle }: IAEditorWrapDimensionsParams): {
|
|
61
|
-
flex: import("csstype").Property.Flex<string | number
|
|
61
|
+
flex: import("csstype").Property.Flex<string | number> | undefined;
|
|
62
62
|
height: string | number | undefined;
|
|
63
63
|
};
|
|
64
64
|
export declare function resolveAEditorWrapStyle({ layoutMetrics, wrapStyle }: IAEditorWrapStyleParams): CSSProperties;
|
|
@@ -4,7 +4,7 @@ type TPoint = {
|
|
|
4
4
|
y: number;
|
|
5
5
|
};
|
|
6
6
|
declare class AEditorTableSelection extends TableSelection {
|
|
7
|
-
private
|
|
7
|
+
private resolveSelectedCellsFromBoundary;
|
|
8
8
|
computeSelectedTds(startPoint: TPoint, endPoint: TPoint): TableCellInnerFormat[];
|
|
9
9
|
tableSelectHandler(mousedownEvent: MouseEvent): void;
|
|
10
10
|
updateWithSelectedTds(): void;
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import { default as TableUp, TableCellInnerFormat } from 'quill-table-up';
|
|
2
2
|
declare class JaeKanTableUp extends TableUp {
|
|
3
|
-
private createRelativeBoundary;
|
|
4
3
|
private getTableSelectionModule;
|
|
5
4
|
private resolveSelectedCells;
|
|
6
5
|
private moveSelectionToCell;
|
|
7
|
-
private
|
|
8
|
-
private syncDisplayedSelection;
|
|
6
|
+
private clearDisplayedSelection;
|
|
9
7
|
private resolveSplitTargetCell;
|
|
10
|
-
private
|
|
8
|
+
private resolveTableCellNode;
|
|
9
|
+
private resolveCellInnerFromNode;
|
|
10
|
+
private readElementHeight;
|
|
11
|
+
private applyCellHeight;
|
|
12
|
+
private resolveStableMergeSelection;
|
|
13
|
+
private resolveSplitCellHeights;
|
|
14
|
+
private syncSplitCellHeights;
|
|
11
15
|
mergeCells(selectedTds: TableCellInnerFormat[]): void;
|
|
12
16
|
splitCell(selectedTds: TableCellInnerFormat[]): void;
|
|
13
17
|
}
|
|
@@ -24,8 +24,18 @@ export interface IDomTableMergePlan {
|
|
|
24
24
|
rowEndIndex: number;
|
|
25
25
|
rowStartIndex: number;
|
|
26
26
|
}
|
|
27
|
+
export interface IDomTableBounds {
|
|
28
|
+
colEndIndex: number;
|
|
29
|
+
colStartIndex: number;
|
|
30
|
+
rowEndIndex: number;
|
|
31
|
+
rowStartIndex: number;
|
|
32
|
+
}
|
|
33
|
+
export interface IDomTableRectSelection extends IDomTableBounds {
|
|
34
|
+
cells: HTMLTableCellElement[];
|
|
35
|
+
}
|
|
27
36
|
export declare function buildDomTableGrid(table: HTMLTableElement): IDomTableGrid | null;
|
|
28
37
|
export declare function normalizeSelectedCells(cells: Array<HTMLTableCellElement | null>): HTMLTableCellElement[];
|
|
38
|
+
export declare function resolveRectangularSelection(tableGrid: IDomTableGrid, selectedCells: HTMLTableCellElement[]): IDomTableRectSelection | null;
|
|
29
39
|
export declare function resolveMergePlan(tableGrid: IDomTableGrid, selectedCells: HTMLTableCellElement[]): IDomTableMergePlan | null;
|
|
30
40
|
export declare function mergeTableHtml(html: string, selectedIdentities: ITableCellIdentity[]): {
|
|
31
41
|
anchorIdentity: ITableCellIdentity;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var y=Object.defineProperty;var x=(i,t,r)=>t in i?y(i,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):i[t]=r;var d=(i,t,r)=>x(i,typeof t!="symbol"?t+"":t,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./index-
|
|
1
|
+
"use strict";var y=Object.defineProperty;var x=(i,t,r)=>t in i?y(i,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):i[t]=r;var d=(i,t,r)=>x(i,typeof t!="symbol"?t+"":t,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./index-DprVE3Wh.cjs"),u={capture:!0},p=new Set(["P","DIV","LI","BLOCKQUOTE","PRE","TR","TD","TH","SECTION","ARTICLE","H1","H2","H3","H4","H5","H6"]),m=/<(?:br|p|div|li|blockquote|pre|tr|td|th|section|article|h[1-6])\b|[\r\n\t]/i,T=/[\r\n\t]+/g,h=/\s{2,}/g;function E(i){return typeof i.insert=="string"?i.insert.length:1}class b{constructor(t,r={}){d(this,"clipboard");d(this,"quill");d(this,"cleanupFunctions",[]);this.clipboard=t.getModule("clipboard"),this.quill=t,r.isTitleMode&&this.setupTitleModePaste()}setupTitleModePaste(){const t=this.quill.root,r=e=>{if(e.preventDefault(),!e.clipboardData)return;const l=e.clipboardData.getData("text/html"),n=e.clipboardData.getData("text/plain"),a=this.quill.getSelection(!0);if(!a)return;if(l){const f=this.normalizeTitlePasteHtml(l),o=this.clipboard.convert({html:f});this.applyPasteDelta(a.index,a.length,o),this.scheduleSelection(a.index+this.getDeltaLength(o));return}const c=this.normalizeTitlePasteText(n);this.applyPasteText(a.index,a.length,c),this.scheduleSelection(a.index+c.length)};t.addEventListener("paste",r,u),this.cleanupFunctions.push(()=>{t.removeEventListener("paste",r,u)})}normalizeTitlePasteText(t){return t.replaceAll(T," ").replaceAll(h," ").trim()}normalizeTitlePasteHtml(t){var a,c;if(!m.test(t))return t;const r=document.createElement("div");r.innerHTML=t,this.flattenTitlePasteNode(r);const e=document.createTreeWalker(r,NodeFilter.SHOW_TEXT);let l=e.nextNode();for(;l;)l.textContent=((a=l.textContent)==null?void 0:a.replaceAll(h," "))??"",l=e.nextNode();const n=this.findLastTextNode(r);return n&&(n.textContent=((c=n.textContent)==null?void 0:c.replaceAll(/\s+$/g,""))??""),r.innerHTML}flattenTitlePasteNode(t){var e;const r=Array.from(t.childNodes);for(const l of r){if(l.nodeType===Node.TEXT_NODE){l.textContent=((e=l.textContent)==null?void 0:e.replaceAll(T," "))??"";continue}if(l instanceof HTMLElement){if(l.tagName==="BR"){l.replaceWith(document.createTextNode(" "));continue}this.flattenTitlePasteNode(l),p.has(l.tagName)&&l.nextSibling&&!this.endsWithWhitespace(l)&&l.appendChild(document.createTextNode(" "))}}}endsWithWhitespace(t){var r;return/\s$/.test(((r=this.findLastTextNode(t))==null?void 0:r.textContent)??"")}findLastTextNode(t){const r=Array.from(t.childNodes).reverse();for(const e of r){if(e.nodeType===Node.TEXT_NODE)return e;const l=this.findLastTextNode(e);if(l)return l}return null}getDeltaLength(t){var r;return((r=t.ops)==null?void 0:r.reduce((e,l)=>e+E(l),0))??0}applyPasteDelta(t,r,e){const l=new s.Delta().retain(t).delete(r).concat(e);this.quill.updateContents(l,s.Quill.sources.USER)}applyPasteText(t,r,e){const l=new s.Delta().retain(t).delete(r);e&&l.insert(e),this.quill.updateContents(l,s.Quill.sources.USER)}scheduleSelection(t){const r=()=>this.quill.setSelection(t,0,s.Quill.sources.SILENT);if(typeof queueMicrotask=="function"){queueMicrotask(r);return}setTimeout(r,0)}destroy(){this.cleanupFunctions.forEach(t=>t()),this.cleanupFunctions=[]}async copyContent(t){var r;try{const e=this.quill.getText(),l=this.quill.root.innerHTML;return this.copyToClipboard(e,l,t)}catch(e){return console.error("Error in copyContent:",e),(r=t==null?void 0:t.onError)==null||r.call(t),!1}}async copyToClipboard(t,r,e){var l,n;try{return await this.tryModernClipboardWithHtml(t,r,e)||await this.tryModernClipboardText(t,e)||r&&this.tryLegacyClipboardWithHtml(r,e)||this.tryLegacyClipboardText(t,e)?!0:((l=e==null?void 0:e.onError)==null||l.call(e),!1)}catch(a){return console.error("복사 중 오류 발생:",a),(n=e==null?void 0:e.onError)==null||n.call(e),!1}}async tryModernClipboardWithHtml(t,r,e){var l;if(!navigator.clipboard||!r||!globalThis.ClipboardItem||!globalThis.isSecureContext)return!1;try{return await navigator.clipboard.write([new ClipboardItem({"text/html":new Blob([r],{type:"text/html"}),"text/plain":new Blob([t],{type:"text/plain"})})]),(l=e==null?void 0:e.onSuccess)==null||l.call(e),!0}catch{return!1}}async tryModernClipboardText(t,r){var e;if(!navigator.clipboard||!globalThis.isSecureContext)return!1;try{return await navigator.clipboard.writeText(t),(e=r==null?void 0:r.onSuccess)==null||e.call(r),!0}catch{return!1}}tryLegacyClipboardWithHtml(t,r){const e=document.createElement("div");e.innerHTML=t,e.style.cssText="position:fixed;left:-9999px;top:-9999px;opacity:0;",document.body.appendChild(e);try{const l=document.createRange();l.selectNodeContents(e);const n=globalThis.getSelection();return n?(n.removeAllRanges(),n.addRange(l),this.tryClipboardEventCopy({html:t,text:e.textContent??""},r)):!1}finally{e.remove()}}tryLegacyClipboardText(t,r){const e=document.createElement("textarea");e.value=t,e.style.cssText="position:fixed;left:-9999px;top:-9999px;opacity:0;",document.body.appendChild(e);try{return e.focus(),e.select(),this.tryClipboardEventCopy({text:t},r)}finally{e.remove()}}tryClipboardEventCopy(t,r){var n;let e=!1;const l=a=>{a.preventDefault(),a.clipboardData&&(a.clipboardData.setData("text/plain",t.text),t.html&&a.clipboardData.setData("text/html",t.html),e=!0)};document.addEventListener("copy",l);try{const a=new ClipboardEvent("copy",{clipboardData:new DataTransfer});if(document.dispatchEvent(a),e)return(n=r==null?void 0:r.onSuccess)==null||n.call(r),!0}catch{return!1}finally{document.removeEventListener("copy",l)}return!1}}exports.default=b;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var x = Object.defineProperty;
|
|
2
2
|
var p = (i, t, r) => t in i ? x(i, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : i[t] = r;
|
|
3
3
|
var s = (i, t, r) => p(i, typeof t != "symbol" ? t + "" : t, r);
|
|
4
|
-
import { D as u, Q as o } from "./index-
|
|
4
|
+
import { D as u, Q as o } from "./index-B7G8Zc2n.js";
|
|
5
5
|
const T = {
|
|
6
6
|
capture: !0
|
|
7
7
|
}, m = /* @__PURE__ */ new Set(["P", "DIV", "LI", "BLOCKQUOTE", "PRE", "TR", "TD", "TH", "SECTION", "ARTICLE", "H1", "H2", "H3", "H4", "H5", "H6"]), E = /<(?:br|p|div|li|blockquote|pre|tr|td|th|section|article|h[1-6])\b|[\r\n\t]/i, h = /[\r\n\t]+/g, f = /\s{2,}/g;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var n=Object.defineProperty;var c=(e,t,o)=>t in e?n(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o;var i=(e,t,o)=>c(e,typeof t!="symbol"?t+"":t,o);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./index-
|
|
1
|
+
"use strict";var n=Object.defineProperty;var c=(e,t,o)=>t in e?n(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o;var i=(e,t,o)=>c(e,typeof t!="symbol"?t+"":t,o);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./index-DprVE3Wh.cjs"),d=r.Quill.import("blots/block/embed"),a=r.Quill.import("ui/icons"),l="border: var(--AEditor_Addon_Primary_border); border-bottom: none; transition: border var(--Transition);";a.divider=r.ReactDOMServer.renderToString(r.jsxRuntimeExports.jsx(r.AIcon,{icon:"Minus",strokeWidth:2.5,width:"100%"}));class s extends d{static create(){const t=super.create(!0);return t.style.cssText=l,t}}i(s,"blotName","divider"),i(s,"tagName","hr");exports.default=s;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var n = Object.defineProperty;
|
|
2
2
|
var a = (r, t, e) => t in r ? n(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
|
|
3
3
|
var o = (r, t, e) => a(r, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
-
import { Q as i, R as c, j as d, A as m } from "./index-
|
|
4
|
+
import { Q as i, R as c, j as d, A as m } from "./index-B7G8Zc2n.js";
|
|
5
5
|
const b = i.import("blots/block/embed"), l = i.import("ui/icons"), u = "border: var(--AEditor_Addon_Primary_border); border-bottom: none; transition: border var(--Transition);";
|
|
6
6
|
l.divider = c.renderToString(/* @__PURE__ */ d.jsx(m, { icon: "Minus", strokeWidth: 2.5, width: "100%" }));
|
|
7
7
|
class s extends b {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var w = Object.defineProperty;
|
|
2
2
|
var q = (a, i, t) => i in a ? w(a, i, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[i] = t;
|
|
3
3
|
var l = (a, i, t) => q(a, typeof i != "symbol" ? i + "" : i, t);
|
|
4
|
-
import { S as f, a as T, Q as D, R as F, j as M, A as N } from "./index-
|
|
4
|
+
import { S as f, a as T, Q as D, R as F, j as M, A as N } from "./index-B7G8Zc2n.js";
|
|
5
5
|
const g = {
|
|
6
6
|
OVERLAY: "ql-image-resizer-overlay",
|
|
7
7
|
HANDLE: "ql-image-resizer-handle",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var P=Object.defineProperty;var w=(a,i,t)=>i in a?P(a,i,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[i]=t;var l=(a,i,t)=>w(a,typeof i!="symbol"?i+"":i,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("./index-BbLYxbgj.cjs"),g={OVERLAY:"ql-image-resizer-overlay",HANDLE:"ql-image-resizer-handle",DISPLAY:"ql-image-resizer-display",TOOLBAR:"ql-image-resizer-toolbar",TOOLBAR_BUTTON:"ql-image-resizer-toolbar-button"},d={BACKSPACE:8,DELETE:46,LEFT:37,UP:38,RIGHT:39,DOWN:40};function q(a){switch(a.key){case"Backspace":return d.BACKSPACE;case"Delete":return d.DELETE;case"ArrowLeft":return d.LEFT;case"ArrowUp":return d.UP;case"ArrowRight":return d.RIGHT;case"ArrowDown":return d.DOWN;default:return 0}}const F=["tl","tr","br","bl"],M=8;function N(a){var t;const i=new Uint32Array(a);if(typeof((t=globalThis.crypto)==null?void 0:t.getRandomValues)=="function")globalThis.crypto.getRandomValues(i);else{let e=Date.now();for(let s=0;s<a;s++)e=e*1103515245+12345&2147483647,i[s]=e}return Array.from(i,e=>e%62).join("")}const v=(a,i)=>{const t=a?"top":"bottom",e=i?"left":"right",s=a===i?"nwse-resize":"nesw-resize";return{[t]:"-5px",[e]:"-5px",cursor:s}},R={tl:v(!0,!0),tr:v(!0,!1),bl:v(!1,!0),br:v(!1,!1)},C=new Map,L=globalThis;function B(a){const i=C.get(a);if(i)return i;const t=u.ReactDOMServer.renderToString(u.jsxRuntimeExports.jsx(u.AIcon,{icon:a,size:"xs"}));return C.set(a,t),t}const k={modules:["DisplaySize","Toolbar","Resize","Keyboard"],embedTags:["VIDEO","IFRAME"],tools:["left","center","right","justify"],contentOptions:[{attribute:["width"],limit:{minWidth:100},blotName:"image"},{attribute:["width","height"],limit:{minWidth:200,ratio:.5625},blotName:"video"}]},z=u.Quill.import("formats/image");class E extends z{static get ATTRIBUTES(){return["alt","height","width","class","style","data-align"]}static formats(i){return this.ATTRIBUTES.reduce((t,e)=>(i.hasAttribute(e)&&(t[e]=i.getAttribute(e)??""),t),{})}format(i,t){this.constructor.ATTRIBUTES.includes(i)?t?this.domNode.setAttribute(i,t):this.domNode.removeAttribute(i):super.format(i,t)}}l(E,"blotName","image"),l(E,"tagName","img"),l(E,"scope",u.Scope.INLINE);function I(){L.__AEDITOR_IMAGE_BLOT_REGISTERED__||(u.Quill.register("formats/image",E,!0),L.__AEDITOR_IMAGE_BLOT_REGISTERED__=!0)}class y{constructor(i){l(this,"resizer");l(this,"quill");l(this,"overlay");l(this,"activeEle");l(this,"blot");l(this,"options");l(this,"requestUpdate");this.resizer=i,this.quill=i.quill,this.overlay=i.overlay,this.activeEle=i.activeEle,this.blot=i.blot,this.options=i.options,this.requestUpdate=()=>i.scheduleUpdate(!0)}onCreate(){}onDestroy(){}onUpdate(){}}class U extends y{constructor(){super(...arguments);l(this,"display")}onCreate(){var t;this.display=document.createElement("div"),this.display.className=u.S[g.DISPLAY],(t=this.overlay)==null||t.appendChild(this.display)}onUpdate(){if(!this.display||!this.activeEle)return;const[t,e]=[this.activeEle.offsetWidth,this.activeEle.offsetHeight];this.display.textContent=`${t} × ${e}`,this.positionDisplay(t,e)}positionDisplay(t,e){var p;if(!this.display)return;const s=this.display.getBoundingClientRect(),o=t>120&&e>30,n=((p=this.activeEle)==null?void 0:p.style.float)==="right";let r,h,c;o?(r="4px",h="4px",c="auto"):(h=`-${s.height+4}px`,n?(r="auto",c=`-${s.width+4}px`):(r=`-${s.width+4}px`,c="auto")),Object.assign(this.display.style,{right:r,bottom:h,left:c})}}class j extends y{constructor(){super(...arguments);l(this,"boxes",[]);l(this,"dragBox",null);l(this,"dragStartX",0);l(this,"dragStartY",0);l(this,"contentOption");l(this,"preDragSize",{width:0,height:0});l(this,"naturalSize",[0,0]);l(this,"handleDragProxy",null);l(this,"handleMouseupProxy",null);l(this,"dragAnimationFrame",null);l(this,"pendingDragEvent",null);l(this,"handleMousedown",t=>{t.button!==0||!this.blot||!this.activeEle||(t.preventDefault(),t.stopPropagation(),this.cancelDragFrame(),this.removeEventListeners(),this.dragBox=t.target,this.dragStartX=t.clientX,this.dragStartY=t.clientY,this.preDragSize={width:this.activeEle.offsetWidth,height:this.activeEle.offsetHeight},this.naturalSize=this.getNaturalSize(),this.setCursor(globalThis.getComputedStyle(this.dragBox).cursor),this.handleDragProxy=this.handleDrag,this.handleMouseupProxy=this.handleMouseup,document.addEventListener("mousemove",this.handleDragProxy,!0),document.addEventListener("mouseup",this.handleMouseupProxy,!0))});l(this,"handleMouseup",t=>{if(!this.activeEle||!this.blot||!this.contentOption)return;this.cancelDragFrame();const e=this.calcSize(t,this.contentOption.limit);Object.assign(this.activeEle,e),Object.assign(this.activeEle.style,{width:null,height:null}),this.setCursor(""),this.removeEventListeners()});l(this,"handleDrag",t=>{!this.activeEle||!this.blot||!this.contentOption||(t.preventDefault(),this.pendingDragEvent=t,this.dragAnimationFrame===null&&(this.dragAnimationFrame=requestAnimationFrame(()=>{this.dragAnimationFrame=null;const e=this.pendingDragEvent;this.pendingDragEvent=null,!(!e||!this.activeEle||!this.contentOption)&&(Object.assign(this.activeEle.style,this.calcSize(e,{...this.contentOption.limit,unit:!0})),this.requestUpdate())})))});l(this,"handleDoubleClick",t=>{if(!this.blot||!this.activeEle||!this.contentOption)return;t.stopPropagation();const[e,s]=this.naturalSize,o={};this.contentOption.attribute.includes("width")&&(o.width=e),this.contentOption.attribute.includes("height")&&(o.height=s);const n=this.applyConstraints(o,this.contentOption.limit);Object.assign(this.activeEle,n),this.requestUpdate()})}onCreate(){!this.blot||!this.options.contentOptions||(this.contentOption=this.options.contentOptions.find(t=>t.blotName===this.blot.statics.blotName),this.boxes=[],F.forEach(t=>this.addBox(t)))}onDestroy(){this.setCursor(""),this.cancelDragFrame(),this.removeEventListeners(),this.boxes.forEach(t=>{t.removeEventListener("mousedown",this.handleMousedown,!1),t.removeEventListener("dblclick",this.handleDoubleClick,!1)}),this.boxes=[]}addBox(t){var s;const e=document.createElement("div");e.className=`${u.S[g.HANDLE]} ${t}`,e.addEventListener("mousedown",this.handleMousedown,!1),e.addEventListener("dblclick",this.handleDoubleClick,!1),Object.assign(e.style,R[t]),(s=this.overlay)==null||s.appendChild(e),this.boxes.push(e)}removeEventListeners(){this.handleDragProxy&&(document.removeEventListener("mousemove",this.handleDragProxy,!0),this.handleDragProxy=null),this.handleMouseupProxy&&(document.removeEventListener("mouseup",this.handleMouseupProxy,!0),this.handleMouseupProxy=null)}calcSize(t,e={}){var h;if(!this.dragBox||!this.activeEle)return{};const s=t.clientX-this.dragStartX,o=t.clientY-this.dragStartY,n=this.dragBox===this.boxes[0]||this.dragBox===this.boxes[3]?-1:1,r={};return(h=this.contentOption)!=null&&h.attribute?this.contentOption.attribute.forEach(c=>r[c]=this.preDragSize[c]):r.width=this.preDragSize.width,r.width&&(r.width=Math.round(this.preDragSize.width+s*n)),r.height&&(r.height=Math.round(this.preDragSize.height+o*n)),this.applyConstraints(r,e)}constrainDimensionsWithRatio(t,e){const s=e.ratio;let o=this.applyLimit(t,e.minWidth,e.maxWidth),n=o*s;const r=this.applyLimit(n,e.minHeight,e.maxHeight);return r!==n&&(n=r,o=n/s),{rw:o,rh:n}}applyConstraints(t,e={}){const s=typeof t.width=="string"?Number.parseInt(t.width,10):t.width||0,o=typeof t.height=="string"?Number.parseInt(t.height,10):t.height||0;let n=s,r=o;e.ratio?{rw:n,rh:r}=this.constrainDimensionsWithRatio(n,e):(s&&(n=this.applyLimit(n,e.minWidth,e.maxWidth)),o&&(r=this.applyLimit(r,e.minHeight,e.maxHeight)));const h={};return t.width!==void 0&&(h.width=e.unit?`${n}px`:n),t.height!==void 0&&(h.height=e.unit?`${r}px`:r),h}applyLimit(t,e,s){let o=t;return e!==void 0&&(o=Math.max(e,o)),s!==void 0&&(o=Math.min(s,o)),o}getNaturalSize(){if(!this.activeEle)return[0,0];const t=this.activeEle.dataset.size;if(!t){const e=this.activeEle,s=[e.offsetWidth,e.offsetHeight];return e.dataset.size=s.join(","),s}return t.split(",").map(Number)}setCursor(t){[document.body,this.activeEle].forEach(e=>e&&(e.style.cursor=t))}cancelDragFrame(){this.dragAnimationFrame!==null&&(cancelAnimationFrame(this.dragAnimationFrame),this.dragAnimationFrame=null),this.pendingDragEvent=null}}const m=class m extends y{constructor(){super(...arguments);l(this,"keyboardProxy",t=>this.keyboardHandle(t))}static injectInit(t){var s;if(m.injectedQuills.has(t))return;const e=(s=t.keyboard)==null?void 0:s.bindings;e&&([m.keys.LEFT,m.keys.RIGHT].forEach(o=>(e[o]||[]).unshift(m.makeArrowHandler(o))),m.injectedQuills.add(t))}static makeArrowHandler(t){const e=t===m.keys.LEFT;return{key:t,shiftKey:!1,altKey:null,[e?"prefix":"suffix"]:/^$/,handler(s){const o=this.quill;if(!o.resizer)return!0;let n=s.index;const r=t===m.keys.RIGHT,[h]=o.getLine(n+(e?-1:0));if(!h)return!0;if(o.resizer.judgeShow(h))return!1;const c=o.getIndex(h);if(r&&c+h.length()-1===n)return!0;r&&(n+=s.length+1);const[p]=o.getLeaf(n);if(!p)return!0;const x=p.offset(p.parent),D=p.constructor&&"scope"in p.constructor&&p.constructor.scope===u.Scope.BLOCK_BLOT;if(e&&(D&&n===x||n===0||n===c))return!0;let S=p;if(e&&x===0){const[O]=o.getLeaf(n-1);O&&(S=O)}return!S||!o.resizer.judgeShow(S)}}}onCreate(){document.addEventListener("keydown",this.keyboardProxy,!0)}onDestroy(){document.removeEventListener("keydown",this.keyboardProxy,!0)}keyboardHandle(t){if(t.defaultPrevented||t.shiftKey||t.ctrlKey||t.altKey||!this.activeEle||!this.blot)return;const e=q(t);let s=this.blot.offset(this.quill.scroll),o=null,n=!1;e===d.BACKSPACE||e===d.DELETE?(this.handleDelete(),n=!0):e>=d.LEFT&&e<=d.DOWN&&([s,o]=this.handleArrowKeys(e,s),n=!0),n&&(t.stopPropagation(),t.preventDefault()),!(o&&this.resizer.judgeShow(o,o.domNode))&&(this.quill.setSelection(s),this.resizer.hide())}handleDelete(){if(!this.blot)return;const t=this.blot.length();this.blot.deleteAt(0,t),this.blot=void 0,this.activeEle=void 0,this.resizer.hide()}handleArrowKeys(t,e){let s=null;return t===d.RIGHT?e+=this.blot.length()||1:t===d.UP?(e=this.getOtherLineIndex(-1),s=this.quill.getLeaf(e)[0]):t===d.DOWN&&(e=this.getOtherLineIndex(1),s=this.quill.getLeaf(e)[0]),[e,s]}getOtherLineIndex(t){if(!this.blot)return 0;const e=this.blot.offset(this.quill.scroll),[s]=this.quill.getLine(e);if(!s)return e;const o=this.blot.offset(s)+1,n=t>0?s.next:s.prev;if(!n)return e;let r=n.length();return n.statics.blotName==="block"&&r--,n.offset(this.quill.scroll)+Math.min(r,o)}};l(m,"keys",d),l(m,"injectedQuills",new WeakSet);let b=m;const f=class f extends y{constructor(t){super(t);l(this,"toolbar");l(this,"blot");l(this,"tools",{});l(this,"toolbarClickProxy",t=>this.handleToolbarClick(t));this.blot=t.blot}createStyleTool(t,e){const s={left:{float:"left"},right:{float:"right"},center:{display:"block",margin:"0 auto",float:"none"},justify:{display:"block",float:"none",margin:"0",width:"100%"}};return{icon:t,apply:o=>{this.clearAlignmentStyles(o);const n=s[e];Object.assign(o.style,n),o.dataset.align=e},isApplied:o=>{const n=o.style;switch(e){case"center":return n.float==="none";case"justify":return n.display==="block"&&n.width==="100%";case"left":case"right":return n.float===e;default:return!1}}}}clearAlignmentStyles(t){const e=t.dataset.align;t.style.removeProperty("display"),t.style.removeProperty("float"),t.style.removeProperty("margin"),e==="justify"&&t.style.removeProperty("width"),delete t.dataset.align}onCreate(){var t;this.toolbar=document.createElement("div"),this.toolbar.className=u.S[g.TOOLBAR],this.toolbar.addEventListener("click",this.toolbarClickProxy),(t=this.overlay)==null||t.appendChild(this.toolbar),this.initializeTools(),this._addToolbarButtons()}onDestroy(){var t;(t=this.toolbar)==null||t.removeEventListener("click",this.toolbarClickProxy),this.toolbar=void 0}initializeTools(){Object.keys(f.Tools).forEach(t=>{const e=t;this.tools[e]=this.createStyleTool(f.Tools[e].icon,e)})}_addToolbarButtons(){!this.toolbar||!this.activeEle||this.options.tools.forEach(t=>{const e=this.tools[t];if(!e)return;const s=document.createElement("button");s.type="button",s.className=u.S[g.TOOLBAR_BUTTON],s.innerHTML=B(e.icon),s.dataset.tool=t,e.isApplied&&this.activeEle&&e.isApplied.call(this,this.activeEle)&&(s.style.backgroundColor="var(--AEditor_Addon_Secondary_color)"),this.toolbar.appendChild(s)})}handleToolbarClick(t){var r,h;if(!this.activeEle||!this.blot||!this.toolbar)return;const e=(r=t.target)==null?void 0:r.closest("button[data-tool]");if(!e||!this.toolbar.contains(e))return;const s=e.dataset.tool;if(!s)return;const o=this.tools[s];if(!o||(t.stopPropagation(),o.handler&&o.handler.call(this,t,e,this.activeEle)!==!0))return;const n=o.isApplied?o.isApplied.call(this,this.activeEle):!1;Array.from(this.toolbar.querySelectorAll("button")).forEach(c=>c.style.backgroundColor=""),n?this.clearAlignmentStyles(this.activeEle):(e.style.backgroundColor="var(--AEditor_Addon_Secondary_color)",(h=o.apply)==null||h.call(o,this.activeEle)),this.requestUpdate()}};l(f,"Tools",{left:{icon:"AlignLeft"},center:{icon:"AlignCenter"},right:{icon:"AlignRight"},justify:{icon:"AlignJustify"}});let A=f;class T{constructor(i,t={}){l(this,"quill");l(this,"options");l(this,"moduleClasses");l(this,"modules",[]);l(this,"blot");l(this,"selectedBlots",[]);l(this,"embedClassName","");l(this,"activeEle");l(this,"overlay");l(this,"updateFromModule",!1);l(this,"hideProxy",null);l(this,"updateOverlayPositionProxy",null);l(this,"embedStyleElement",null);l(this,"updateAnimationFrame",null);l(this,"overlayScrollAnimationFrame",null);l(this,"pendingOverlayMarginTop",null);l(this,"scheduledFromModule",!1);l(this,"previousBodyUserSelect",null);l(this,"previousRootUserSelect",null);l(this,"handleClickProxy",i=>this.handleClick(i));l(this,"handleChangeProxy",(i,t,e)=>this.handleChange(i,t,e));l(this,"handleSelectionChangeProxy",i=>this.addBlotsSelectedClass(i));var s;I(),i.resizer=this,this.quill=i;const e=t.modules?[...t.modules]:null;this.options={...k,...t},e&&(this.options.modules=e),this.moduleClasses=this.options.modules,this.quill.root.addEventListener("mousedown",this.handleClickProxy,!1),this.quill.on("text-change",this.handleChangeProxy),this.quill.container.style.position=this.quill.container.style.position||"relative",this.quill.on("selection-change",this.handleSelectionChangeProxy),b.injectInit(this.quill),(s=this.options.embedTags)!=null&&s.length&&this.initializeEmbed()}destroy(){var i;this.updateAnimationFrame!==null&&(cancelAnimationFrame(this.updateAnimationFrame),this.updateAnimationFrame=null),this.overlayScrollAnimationFrame!==null&&(cancelAnimationFrame(this.overlayScrollAnimationFrame),this.overlayScrollAnimationFrame=null),this.pendingOverlayMarginTop=null,this.hide(),this.quill.root.removeEventListener("mousedown",this.handleClickProxy,!1),this.quill.off("text-change",this.handleChangeProxy),this.quill.off("selection-change",this.handleSelectionChangeProxy),(i=this.embedStyleElement)==null||i.remove(),this.embedStyleElement=null,this.embedClassName&&this.quill.root.classList.remove(this.embedClassName)}initializeModules(){this.modules.forEach(i=>i.onDestroy()),this.modules=[],this.modules=this.moduleClasses.map(i=>new(this.constructor.Modules[i]||i)(this)),this.modules.forEach(i=>i.onCreate()),this.repositionElements(),this.modules.forEach(i=>i.onUpdate())}initializeEmbed(){if(!this.options.embedTags.length)return;this.embedClassName=`ql-${N(M)}`;const i=[""].concat(this.options.embedTags).join(`, .${this.embedClassName} `).slice(2)+"{pointer-events: none;}",t=document.createElement("style");t.textContent=i,this.embedStyleElement=t,this.quill.container.appendChild(t),this.quill.root.classList.add(this.embedClassName)}scheduleUpdate(i){this.scheduledFromModule=this.scheduledFromModule||!!i,this.updateAnimationFrame===null&&(this.updateAnimationFrame=requestAnimationFrame(()=>{this.updateAnimationFrame=null;const t=this.scheduledFromModule;this.scheduledFromModule=!1,this.onUpdate(t)}))}onUpdate(i){this.updateFromModule=!!i,this.repositionElements(),this.modules.forEach(t=>t.onUpdate())}handleClick(i){if(this.overlay&&(i.target===this.overlay||this.overlay.contains(i.target)))return;let t=i.target;if(t=this.getEventTarget(i,t),t!=null&&t.tagName){const e=this.quill.scroll.find(t);if(e&&this.judgeShow(e,t)){i.preventDefault();return}}this.activeEle&&this.hide()}getEventTarget(i,t){var o;const e=(o=this.options.embedTags)==null?void 0:o.join();if(!e)return t;const s=this.quill.root;return(t===s||t.querySelectorAll(e).length)&&(s.classList.remove(this.embedClassName),t=document.elementFromPoint(i.clientX,i.clientY),s.classList.add(this.embedClassName)),t}judgeShow(i,t){if(!i||!this.options.contentOptions)return!1;!t&&i.domNode&&(t=i.domNode);const e=this.options.contentOptions.find(o=>o.blotName===i.statics.blotName);if(!e)return!1;if(this.activeEle===t)return!0;const s=e.limit||{};return!s.minWidth||s.minWidth&&t.offsetWidth>=s.minWidth?(this.activeEle&&this.hide(),this.activeEle=t,this.blot=i,this.showOverlay(),this.initializeModules(),!0):!1}handleChange(i,t,e){if(this.updateFromModule){this.updateFromModule=!1;return}e!=="user"||!this.overlay||!this.activeEle||this.onUpdate()}showOverlay(){this.overlay&&this.hideOverlay(),this.quill.setSelection(null),this.previousBodyUserSelect=document.body.style.userSelect,this.previousRootUserSelect=this.quill.root.style.userSelect,document.body.style.userSelect="none",this.quill.root.style.userSelect="none",this.overlay=document.createElement("div"),this.overlay.className=`${u.S[g.OVERLAY]}`,this.quill.container.appendChild(this.overlay),this.hideProxy=()=>this.activeEle&&this.hide(),this.updateOverlayPositionProxy=()=>this.scheduleOverlayMarginSync(),this.quill.root.addEventListener("input",this.hideProxy,!0),this.quill.root.addEventListener("scroll",this.updateOverlayPositionProxy,{passive:!0}),this.repositionElements()}hideOverlay(){this.overlay&&(this.overlayScrollAnimationFrame!==null&&(cancelAnimationFrame(this.overlayScrollAnimationFrame),this.overlayScrollAnimationFrame=null),this.pendingOverlayMarginTop=null,this.overlay.remove(),this.overlay=void 0,this.hideProxy&&this.quill.root.removeEventListener("input",this.hideProxy,!0),this.updateOverlayPositionProxy&&this.quill.root.removeEventListener("scroll",this.updateOverlayPositionProxy),this.hideProxy=null,this.updateOverlayPositionProxy=null,this.previousBodyUserSelect!==null&&(document.body.style.userSelect=this.previousBodyUserSelect,this.previousBodyUserSelect=null),this.previousRootUserSelect!==null&&(this.quill.root.style.userSelect=this.previousRootUserSelect,this.previousRootUserSelect=null))}repositionElements(){if(!this.overlay||!this.activeEle)return;const i=this.quill.container,t=this.activeEle.getBoundingClientRect(),e=i.getBoundingClientRect();Object.assign(this.overlay.style,{left:`${t.left-e.left-1+i.scrollLeft}px`,top:`${t.top-e.top+this.quill.root.scrollTop}px`,width:`${t.width}px`,height:`${t.height}px`,marginTop:-1*this.quill.root.scrollTop+"px"})}addBlotsSelectedClass(i){if(!i){this.selectedBlots=[];return}try{const t=s=>{var o;return["image","iframe","video"].includes((o=s.statics)==null?void 0:o.blotName)},e=this.quill.scroll.descendants(t,i.index,i.length);this.selectedBlots=e.filter(s=>!s.statics||!this.options.contentOptions?!1:this.options.contentOptions.some(o=>o.blotName===s.statics.blotName))}catch(t){console.warn("Error during blot selection:",t)}}hide(){this.hideOverlay(),this.modules.forEach(i=>i.onDestroy()),this.modules=[],this.activeEle=void 0,this.blot=void 0}scheduleOverlayMarginSync(){this.overlay&&(this.pendingOverlayMarginTop=-1*this.quill.root.scrollTop,this.overlayScrollAnimationFrame===null&&(this.overlayScrollAnimationFrame=requestAnimationFrame(()=>{this.overlayScrollAnimationFrame=null,!(!this.overlay||this.pendingOverlayMarginTop===null)&&(this.overlay.style.marginTop=`${this.pendingOverlayMarginTop}px`,this.pendingOverlayMarginTop=null)})))}}l(T,"Modules",{Base:y,DisplaySize:U,Toolbar:A,Resize:j,Keyboard:b});exports.default=T;
|
|
1
|
+
"use strict";var P=Object.defineProperty;var w=(a,i,t)=>i in a?P(a,i,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[i]=t;var l=(a,i,t)=>w(a,typeof i!="symbol"?i+"":i,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("./index-DprVE3Wh.cjs"),g={OVERLAY:"ql-image-resizer-overlay",HANDLE:"ql-image-resizer-handle",DISPLAY:"ql-image-resizer-display",TOOLBAR:"ql-image-resizer-toolbar",TOOLBAR_BUTTON:"ql-image-resizer-toolbar-button"},d={BACKSPACE:8,DELETE:46,LEFT:37,UP:38,RIGHT:39,DOWN:40};function q(a){switch(a.key){case"Backspace":return d.BACKSPACE;case"Delete":return d.DELETE;case"ArrowLeft":return d.LEFT;case"ArrowUp":return d.UP;case"ArrowRight":return d.RIGHT;case"ArrowDown":return d.DOWN;default:return 0}}const F=["tl","tr","br","bl"],M=8;function N(a){var t;const i=new Uint32Array(a);if(typeof((t=globalThis.crypto)==null?void 0:t.getRandomValues)=="function")globalThis.crypto.getRandomValues(i);else{let e=Date.now();for(let s=0;s<a;s++)e=e*1103515245+12345&2147483647,i[s]=e}return Array.from(i,e=>e%62).join("")}const v=(a,i)=>{const t=a?"top":"bottom",e=i?"left":"right",s=a===i?"nwse-resize":"nesw-resize";return{[t]:"-5px",[e]:"-5px",cursor:s}},R={tl:v(!0,!0),tr:v(!0,!1),bl:v(!1,!0),br:v(!1,!1)},C=new Map,L=globalThis;function B(a){const i=C.get(a);if(i)return i;const t=u.ReactDOMServer.renderToString(u.jsxRuntimeExports.jsx(u.AIcon,{icon:a,size:"xs"}));return C.set(a,t),t}const k={modules:["DisplaySize","Toolbar","Resize","Keyboard"],embedTags:["VIDEO","IFRAME"],tools:["left","center","right","justify"],contentOptions:[{attribute:["width"],limit:{minWidth:100},blotName:"image"},{attribute:["width","height"],limit:{minWidth:200,ratio:.5625},blotName:"video"}]},z=u.Quill.import("formats/image");class E extends z{static get ATTRIBUTES(){return["alt","height","width","class","style","data-align"]}static formats(i){return this.ATTRIBUTES.reduce((t,e)=>(i.hasAttribute(e)&&(t[e]=i.getAttribute(e)??""),t),{})}format(i,t){this.constructor.ATTRIBUTES.includes(i)?t?this.domNode.setAttribute(i,t):this.domNode.removeAttribute(i):super.format(i,t)}}l(E,"blotName","image"),l(E,"tagName","img"),l(E,"scope",u.Scope.INLINE);function I(){L.__AEDITOR_IMAGE_BLOT_REGISTERED__||(u.Quill.register("formats/image",E,!0),L.__AEDITOR_IMAGE_BLOT_REGISTERED__=!0)}class y{constructor(i){l(this,"resizer");l(this,"quill");l(this,"overlay");l(this,"activeEle");l(this,"blot");l(this,"options");l(this,"requestUpdate");this.resizer=i,this.quill=i.quill,this.overlay=i.overlay,this.activeEle=i.activeEle,this.blot=i.blot,this.options=i.options,this.requestUpdate=()=>i.scheduleUpdate(!0)}onCreate(){}onDestroy(){}onUpdate(){}}class U extends y{constructor(){super(...arguments);l(this,"display")}onCreate(){var t;this.display=document.createElement("div"),this.display.className=u.S[g.DISPLAY],(t=this.overlay)==null||t.appendChild(this.display)}onUpdate(){if(!this.display||!this.activeEle)return;const[t,e]=[this.activeEle.offsetWidth,this.activeEle.offsetHeight];this.display.textContent=`${t} × ${e}`,this.positionDisplay(t,e)}positionDisplay(t,e){var p;if(!this.display)return;const s=this.display.getBoundingClientRect(),o=t>120&&e>30,n=((p=this.activeEle)==null?void 0:p.style.float)==="right";let r,h,c;o?(r="4px",h="4px",c="auto"):(h=`-${s.height+4}px`,n?(r="auto",c=`-${s.width+4}px`):(r=`-${s.width+4}px`,c="auto")),Object.assign(this.display.style,{right:r,bottom:h,left:c})}}class j extends y{constructor(){super(...arguments);l(this,"boxes",[]);l(this,"dragBox",null);l(this,"dragStartX",0);l(this,"dragStartY",0);l(this,"contentOption");l(this,"preDragSize",{width:0,height:0});l(this,"naturalSize",[0,0]);l(this,"handleDragProxy",null);l(this,"handleMouseupProxy",null);l(this,"dragAnimationFrame",null);l(this,"pendingDragEvent",null);l(this,"handleMousedown",t=>{t.button!==0||!this.blot||!this.activeEle||(t.preventDefault(),t.stopPropagation(),this.cancelDragFrame(),this.removeEventListeners(),this.dragBox=t.target,this.dragStartX=t.clientX,this.dragStartY=t.clientY,this.preDragSize={width:this.activeEle.offsetWidth,height:this.activeEle.offsetHeight},this.naturalSize=this.getNaturalSize(),this.setCursor(globalThis.getComputedStyle(this.dragBox).cursor),this.handleDragProxy=this.handleDrag,this.handleMouseupProxy=this.handleMouseup,document.addEventListener("mousemove",this.handleDragProxy,!0),document.addEventListener("mouseup",this.handleMouseupProxy,!0))});l(this,"handleMouseup",t=>{if(!this.activeEle||!this.blot||!this.contentOption)return;this.cancelDragFrame();const e=this.calcSize(t,this.contentOption.limit);Object.assign(this.activeEle,e),Object.assign(this.activeEle.style,{width:null,height:null}),this.setCursor(""),this.removeEventListeners()});l(this,"handleDrag",t=>{!this.activeEle||!this.blot||!this.contentOption||(t.preventDefault(),this.pendingDragEvent=t,this.dragAnimationFrame===null&&(this.dragAnimationFrame=requestAnimationFrame(()=>{this.dragAnimationFrame=null;const e=this.pendingDragEvent;this.pendingDragEvent=null,!(!e||!this.activeEle||!this.contentOption)&&(Object.assign(this.activeEle.style,this.calcSize(e,{...this.contentOption.limit,unit:!0})),this.requestUpdate())})))});l(this,"handleDoubleClick",t=>{if(!this.blot||!this.activeEle||!this.contentOption)return;t.stopPropagation();const[e,s]=this.naturalSize,o={};this.contentOption.attribute.includes("width")&&(o.width=e),this.contentOption.attribute.includes("height")&&(o.height=s);const n=this.applyConstraints(o,this.contentOption.limit);Object.assign(this.activeEle,n),this.requestUpdate()})}onCreate(){!this.blot||!this.options.contentOptions||(this.contentOption=this.options.contentOptions.find(t=>t.blotName===this.blot.statics.blotName),this.boxes=[],F.forEach(t=>this.addBox(t)))}onDestroy(){this.setCursor(""),this.cancelDragFrame(),this.removeEventListeners(),this.boxes.forEach(t=>{t.removeEventListener("mousedown",this.handleMousedown,!1),t.removeEventListener("dblclick",this.handleDoubleClick,!1)}),this.boxes=[]}addBox(t){var s;const e=document.createElement("div");e.className=`${u.S[g.HANDLE]} ${t}`,e.addEventListener("mousedown",this.handleMousedown,!1),e.addEventListener("dblclick",this.handleDoubleClick,!1),Object.assign(e.style,R[t]),(s=this.overlay)==null||s.appendChild(e),this.boxes.push(e)}removeEventListeners(){this.handleDragProxy&&(document.removeEventListener("mousemove",this.handleDragProxy,!0),this.handleDragProxy=null),this.handleMouseupProxy&&(document.removeEventListener("mouseup",this.handleMouseupProxy,!0),this.handleMouseupProxy=null)}calcSize(t,e={}){var h;if(!this.dragBox||!this.activeEle)return{};const s=t.clientX-this.dragStartX,o=t.clientY-this.dragStartY,n=this.dragBox===this.boxes[0]||this.dragBox===this.boxes[3]?-1:1,r={};return(h=this.contentOption)!=null&&h.attribute?this.contentOption.attribute.forEach(c=>r[c]=this.preDragSize[c]):r.width=this.preDragSize.width,r.width&&(r.width=Math.round(this.preDragSize.width+s*n)),r.height&&(r.height=Math.round(this.preDragSize.height+o*n)),this.applyConstraints(r,e)}constrainDimensionsWithRatio(t,e){const s=e.ratio;let o=this.applyLimit(t,e.minWidth,e.maxWidth),n=o*s;const r=this.applyLimit(n,e.minHeight,e.maxHeight);return r!==n&&(n=r,o=n/s),{rw:o,rh:n}}applyConstraints(t,e={}){const s=typeof t.width=="string"?Number.parseInt(t.width,10):t.width||0,o=typeof t.height=="string"?Number.parseInt(t.height,10):t.height||0;let n=s,r=o;e.ratio?{rw:n,rh:r}=this.constrainDimensionsWithRatio(n,e):(s&&(n=this.applyLimit(n,e.minWidth,e.maxWidth)),o&&(r=this.applyLimit(r,e.minHeight,e.maxHeight)));const h={};return t.width!==void 0&&(h.width=e.unit?`${n}px`:n),t.height!==void 0&&(h.height=e.unit?`${r}px`:r),h}applyLimit(t,e,s){let o=t;return e!==void 0&&(o=Math.max(e,o)),s!==void 0&&(o=Math.min(s,o)),o}getNaturalSize(){if(!this.activeEle)return[0,0];const t=this.activeEle.dataset.size;if(!t){const e=this.activeEle,s=[e.offsetWidth,e.offsetHeight];return e.dataset.size=s.join(","),s}return t.split(",").map(Number)}setCursor(t){[document.body,this.activeEle].forEach(e=>e&&(e.style.cursor=t))}cancelDragFrame(){this.dragAnimationFrame!==null&&(cancelAnimationFrame(this.dragAnimationFrame),this.dragAnimationFrame=null),this.pendingDragEvent=null}}const m=class m extends y{constructor(){super(...arguments);l(this,"keyboardProxy",t=>this.keyboardHandle(t))}static injectInit(t){var s;if(m.injectedQuills.has(t))return;const e=(s=t.keyboard)==null?void 0:s.bindings;e&&([m.keys.LEFT,m.keys.RIGHT].forEach(o=>(e[o]||[]).unshift(m.makeArrowHandler(o))),m.injectedQuills.add(t))}static makeArrowHandler(t){const e=t===m.keys.LEFT;return{key:t,shiftKey:!1,altKey:null,[e?"prefix":"suffix"]:/^$/,handler(s){const o=this.quill;if(!o.resizer)return!0;let n=s.index;const r=t===m.keys.RIGHT,[h]=o.getLine(n+(e?-1:0));if(!h)return!0;if(o.resizer.judgeShow(h))return!1;const c=o.getIndex(h);if(r&&c+h.length()-1===n)return!0;r&&(n+=s.length+1);const[p]=o.getLeaf(n);if(!p)return!0;const x=p.offset(p.parent),D=p.constructor&&"scope"in p.constructor&&p.constructor.scope===u.Scope.BLOCK_BLOT;if(e&&(D&&n===x||n===0||n===c))return!0;let S=p;if(e&&x===0){const[O]=o.getLeaf(n-1);O&&(S=O)}return!S||!o.resizer.judgeShow(S)}}}onCreate(){document.addEventListener("keydown",this.keyboardProxy,!0)}onDestroy(){document.removeEventListener("keydown",this.keyboardProxy,!0)}keyboardHandle(t){if(t.defaultPrevented||t.shiftKey||t.ctrlKey||t.altKey||!this.activeEle||!this.blot)return;const e=q(t);let s=this.blot.offset(this.quill.scroll),o=null,n=!1;e===d.BACKSPACE||e===d.DELETE?(this.handleDelete(),n=!0):e>=d.LEFT&&e<=d.DOWN&&([s,o]=this.handleArrowKeys(e,s),n=!0),n&&(t.stopPropagation(),t.preventDefault()),!(o&&this.resizer.judgeShow(o,o.domNode))&&(this.quill.setSelection(s),this.resizer.hide())}handleDelete(){if(!this.blot)return;const t=this.blot.length();this.blot.deleteAt(0,t),this.blot=void 0,this.activeEle=void 0,this.resizer.hide()}handleArrowKeys(t,e){let s=null;return t===d.RIGHT?e+=this.blot.length()||1:t===d.UP?(e=this.getOtherLineIndex(-1),s=this.quill.getLeaf(e)[0]):t===d.DOWN&&(e=this.getOtherLineIndex(1),s=this.quill.getLeaf(e)[0]),[e,s]}getOtherLineIndex(t){if(!this.blot)return 0;const e=this.blot.offset(this.quill.scroll),[s]=this.quill.getLine(e);if(!s)return e;const o=this.blot.offset(s)+1,n=t>0?s.next:s.prev;if(!n)return e;let r=n.length();return n.statics.blotName==="block"&&r--,n.offset(this.quill.scroll)+Math.min(r,o)}};l(m,"keys",d),l(m,"injectedQuills",new WeakSet);let b=m;const f=class f extends y{constructor(t){super(t);l(this,"toolbar");l(this,"blot");l(this,"tools",{});l(this,"toolbarClickProxy",t=>this.handleToolbarClick(t));this.blot=t.blot}createStyleTool(t,e){const s={left:{float:"left"},right:{float:"right"},center:{display:"block",margin:"0 auto",float:"none"},justify:{display:"block",float:"none",margin:"0",width:"100%"}};return{icon:t,apply:o=>{this.clearAlignmentStyles(o);const n=s[e];Object.assign(o.style,n),o.dataset.align=e},isApplied:o=>{const n=o.style;switch(e){case"center":return n.float==="none";case"justify":return n.display==="block"&&n.width==="100%";case"left":case"right":return n.float===e;default:return!1}}}}clearAlignmentStyles(t){const e=t.dataset.align;t.style.removeProperty("display"),t.style.removeProperty("float"),t.style.removeProperty("margin"),e==="justify"&&t.style.removeProperty("width"),delete t.dataset.align}onCreate(){var t;this.toolbar=document.createElement("div"),this.toolbar.className=u.S[g.TOOLBAR],this.toolbar.addEventListener("click",this.toolbarClickProxy),(t=this.overlay)==null||t.appendChild(this.toolbar),this.initializeTools(),this._addToolbarButtons()}onDestroy(){var t;(t=this.toolbar)==null||t.removeEventListener("click",this.toolbarClickProxy),this.toolbar=void 0}initializeTools(){Object.keys(f.Tools).forEach(t=>{const e=t;this.tools[e]=this.createStyleTool(f.Tools[e].icon,e)})}_addToolbarButtons(){!this.toolbar||!this.activeEle||this.options.tools.forEach(t=>{const e=this.tools[t];if(!e)return;const s=document.createElement("button");s.type="button",s.className=u.S[g.TOOLBAR_BUTTON],s.innerHTML=B(e.icon),s.dataset.tool=t,e.isApplied&&this.activeEle&&e.isApplied.call(this,this.activeEle)&&(s.style.backgroundColor="var(--AEditor_Addon_Secondary_color)"),this.toolbar.appendChild(s)})}handleToolbarClick(t){var r,h;if(!this.activeEle||!this.blot||!this.toolbar)return;const e=(r=t.target)==null?void 0:r.closest("button[data-tool]");if(!e||!this.toolbar.contains(e))return;const s=e.dataset.tool;if(!s)return;const o=this.tools[s];if(!o||(t.stopPropagation(),o.handler&&o.handler.call(this,t,e,this.activeEle)!==!0))return;const n=o.isApplied?o.isApplied.call(this,this.activeEle):!1;Array.from(this.toolbar.querySelectorAll("button")).forEach(c=>c.style.backgroundColor=""),n?this.clearAlignmentStyles(this.activeEle):(e.style.backgroundColor="var(--AEditor_Addon_Secondary_color)",(h=o.apply)==null||h.call(o,this.activeEle)),this.requestUpdate()}};l(f,"Tools",{left:{icon:"AlignLeft"},center:{icon:"AlignCenter"},right:{icon:"AlignRight"},justify:{icon:"AlignJustify"}});let A=f;class T{constructor(i,t={}){l(this,"quill");l(this,"options");l(this,"moduleClasses");l(this,"modules",[]);l(this,"blot");l(this,"selectedBlots",[]);l(this,"embedClassName","");l(this,"activeEle");l(this,"overlay");l(this,"updateFromModule",!1);l(this,"hideProxy",null);l(this,"updateOverlayPositionProxy",null);l(this,"embedStyleElement",null);l(this,"updateAnimationFrame",null);l(this,"overlayScrollAnimationFrame",null);l(this,"pendingOverlayMarginTop",null);l(this,"scheduledFromModule",!1);l(this,"previousBodyUserSelect",null);l(this,"previousRootUserSelect",null);l(this,"handleClickProxy",i=>this.handleClick(i));l(this,"handleChangeProxy",(i,t,e)=>this.handleChange(i,t,e));l(this,"handleSelectionChangeProxy",i=>this.addBlotsSelectedClass(i));var s;I(),i.resizer=this,this.quill=i;const e=t.modules?[...t.modules]:null;this.options={...k,...t},e&&(this.options.modules=e),this.moduleClasses=this.options.modules,this.quill.root.addEventListener("mousedown",this.handleClickProxy,!1),this.quill.on("text-change",this.handleChangeProxy),this.quill.container.style.position=this.quill.container.style.position||"relative",this.quill.on("selection-change",this.handleSelectionChangeProxy),b.injectInit(this.quill),(s=this.options.embedTags)!=null&&s.length&&this.initializeEmbed()}destroy(){var i;this.updateAnimationFrame!==null&&(cancelAnimationFrame(this.updateAnimationFrame),this.updateAnimationFrame=null),this.overlayScrollAnimationFrame!==null&&(cancelAnimationFrame(this.overlayScrollAnimationFrame),this.overlayScrollAnimationFrame=null),this.pendingOverlayMarginTop=null,this.hide(),this.quill.root.removeEventListener("mousedown",this.handleClickProxy,!1),this.quill.off("text-change",this.handleChangeProxy),this.quill.off("selection-change",this.handleSelectionChangeProxy),(i=this.embedStyleElement)==null||i.remove(),this.embedStyleElement=null,this.embedClassName&&this.quill.root.classList.remove(this.embedClassName)}initializeModules(){this.modules.forEach(i=>i.onDestroy()),this.modules=[],this.modules=this.moduleClasses.map(i=>new(this.constructor.Modules[i]||i)(this)),this.modules.forEach(i=>i.onCreate()),this.repositionElements(),this.modules.forEach(i=>i.onUpdate())}initializeEmbed(){if(!this.options.embedTags.length)return;this.embedClassName=`ql-${N(M)}`;const i=[""].concat(this.options.embedTags).join(`, .${this.embedClassName} `).slice(2)+"{pointer-events: none;}",t=document.createElement("style");t.textContent=i,this.embedStyleElement=t,this.quill.container.appendChild(t),this.quill.root.classList.add(this.embedClassName)}scheduleUpdate(i){this.scheduledFromModule=this.scheduledFromModule||!!i,this.updateAnimationFrame===null&&(this.updateAnimationFrame=requestAnimationFrame(()=>{this.updateAnimationFrame=null;const t=this.scheduledFromModule;this.scheduledFromModule=!1,this.onUpdate(t)}))}onUpdate(i){this.updateFromModule=!!i,this.repositionElements(),this.modules.forEach(t=>t.onUpdate())}handleClick(i){if(this.overlay&&(i.target===this.overlay||this.overlay.contains(i.target)))return;let t=i.target;if(t=this.getEventTarget(i,t),t!=null&&t.tagName){const e=this.quill.scroll.find(t);if(e&&this.judgeShow(e,t)){i.preventDefault();return}}this.activeEle&&this.hide()}getEventTarget(i,t){var o;const e=(o=this.options.embedTags)==null?void 0:o.join();if(!e)return t;const s=this.quill.root;return(t===s||t.querySelectorAll(e).length)&&(s.classList.remove(this.embedClassName),t=document.elementFromPoint(i.clientX,i.clientY),s.classList.add(this.embedClassName)),t}judgeShow(i,t){if(!i||!this.options.contentOptions)return!1;!t&&i.domNode&&(t=i.domNode);const e=this.options.contentOptions.find(o=>o.blotName===i.statics.blotName);if(!e)return!1;if(this.activeEle===t)return!0;const s=e.limit||{};return!s.minWidth||s.minWidth&&t.offsetWidth>=s.minWidth?(this.activeEle&&this.hide(),this.activeEle=t,this.blot=i,this.showOverlay(),this.initializeModules(),!0):!1}handleChange(i,t,e){if(this.updateFromModule){this.updateFromModule=!1;return}e!=="user"||!this.overlay||!this.activeEle||this.onUpdate()}showOverlay(){this.overlay&&this.hideOverlay(),this.quill.setSelection(null),this.previousBodyUserSelect=document.body.style.userSelect,this.previousRootUserSelect=this.quill.root.style.userSelect,document.body.style.userSelect="none",this.quill.root.style.userSelect="none",this.overlay=document.createElement("div"),this.overlay.className=`${u.S[g.OVERLAY]}`,this.quill.container.appendChild(this.overlay),this.hideProxy=()=>this.activeEle&&this.hide(),this.updateOverlayPositionProxy=()=>this.scheduleOverlayMarginSync(),this.quill.root.addEventListener("input",this.hideProxy,!0),this.quill.root.addEventListener("scroll",this.updateOverlayPositionProxy,{passive:!0}),this.repositionElements()}hideOverlay(){this.overlay&&(this.overlayScrollAnimationFrame!==null&&(cancelAnimationFrame(this.overlayScrollAnimationFrame),this.overlayScrollAnimationFrame=null),this.pendingOverlayMarginTop=null,this.overlay.remove(),this.overlay=void 0,this.hideProxy&&this.quill.root.removeEventListener("input",this.hideProxy,!0),this.updateOverlayPositionProxy&&this.quill.root.removeEventListener("scroll",this.updateOverlayPositionProxy),this.hideProxy=null,this.updateOverlayPositionProxy=null,this.previousBodyUserSelect!==null&&(document.body.style.userSelect=this.previousBodyUserSelect,this.previousBodyUserSelect=null),this.previousRootUserSelect!==null&&(this.quill.root.style.userSelect=this.previousRootUserSelect,this.previousRootUserSelect=null))}repositionElements(){if(!this.overlay||!this.activeEle)return;const i=this.quill.container,t=this.activeEle.getBoundingClientRect(),e=i.getBoundingClientRect();Object.assign(this.overlay.style,{left:`${t.left-e.left-1+i.scrollLeft}px`,top:`${t.top-e.top+this.quill.root.scrollTop}px`,width:`${t.width}px`,height:`${t.height}px`,marginTop:-1*this.quill.root.scrollTop+"px"})}addBlotsSelectedClass(i){if(!i){this.selectedBlots=[];return}try{const t=s=>{var o;return["image","iframe","video"].includes((o=s.statics)==null?void 0:o.blotName)},e=this.quill.scroll.descendants(t,i.index,i.length);this.selectedBlots=e.filter(s=>!s.statics||!this.options.contentOptions?!1:this.options.contentOptions.some(o=>o.blotName===s.statics.blotName))}catch(t){console.warn("Error during blot selection:",t)}}hide(){this.hideOverlay(),this.modules.forEach(i=>i.onDestroy()),this.modules=[],this.activeEle=void 0,this.blot=void 0}scheduleOverlayMarginSync(){this.overlay&&(this.pendingOverlayMarginTop=-1*this.quill.root.scrollTop,this.overlayScrollAnimationFrame===null&&(this.overlayScrollAnimationFrame=requestAnimationFrame(()=>{this.overlayScrollAnimationFrame=null,!(!this.overlay||this.pendingOverlayMarginTop===null)&&(this.overlay.style.marginTop=`${this.pendingOverlayMarginTop}px`,this.pendingOverlayMarginTop=null)})))}}l(T,"Modules",{Base:y,DisplaySize:U,Toolbar:A,Resize:j,Keyboard:b});exports.default=T;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
var O = Object.defineProperty;
|
|
2
2
|
var F = (s, i, e) => i in s ? O(s, i, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[i] = e;
|
|
3
3
|
var p = (s, i, e) => F(s, typeof i != "symbol" ? i + "" : i, e);
|
|
4
|
-
import { m as S, T as x, l as C, r as B, b as P, s as q, Q as W, c as H, p as U } from "./index-
|
|
5
|
-
import { randomId as T, blotName as h, TableColFormat as j, TableCellFormat as A, TableCellInnerFormat as L, tableUpSize as E } from "./index-
|
|
6
|
-
import { normalizeVideoUrl as N } from "./Video-
|
|
4
|
+
import { m as S, T as x, l as C, r as B, b as P, s as q, Q as W, c as H, p as U } from "./index-B7G8Zc2n.js";
|
|
5
|
+
import { randomId as T, blotName as h, TableColFormat as j, TableCellFormat as A, TableCellInnerFormat as L, tableUpSize as E } from "./index-BmRxkoLz.js";
|
|
6
|
+
import { normalizeVideoUrl as N } from "./Video-Cr9HNjYE.js";
|
|
7
7
|
const g = W.import("delta"), Y = W.import("modules/clipboard"), z = /(Excel\.Sheet|xmlns:x=|xmlns:o=|office:excel|mso-|x:str)/i, G = /<table[\s>]/i, k = /(?:youtube\.com\/watch.*v=|youtu\.be\/)([a-zA-Z0-9_-]+)/, M = /vimeo\.com\/(\d+)/, _ = /* @__PURE__ */ new Set(["", "transparent", "rgba(0,0,0,0)", "rgba(0, 0, 0, 0)"]), v = globalThis;
|
|
8
8
|
function X() {
|
|
9
9
|
if (v.__AEDITOR_TABLE_CLIPBOARD_STYLES_PATCHED__) return;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var L=Object.defineProperty;var H=(a,i,e)=>i in a?L(a,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[i]=e;var p=(a,i,e)=>H(a,typeof i!="symbol"?i+"":i,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=require("./index-
|
|
1
|
+
"use strict";var L=Object.defineProperty;var H=(a,i,e)=>i in a?L(a,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[i]=e;var p=(a,i,e)=>H(a,typeof i!="symbol"?i+"":i,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=require("./index-DprVE3Wh.cjs"),s=require("./index-DyVQWGfz.cjs"),E=require("./Video-jqOPig5H.cjs"),g=b.Quill.import("delta"),M=b.Quill.import("modules/clipboard"),R=/(Excel\.Sheet|xmlns:x=|xmlns:o=|office:excel|mso-|x:str)/i,k=/<table[\s>]/i,w=/(?:youtube\.com\/watch.*v=|youtu\.be\/)([a-zA-Z0-9_-]+)/,A=/vimeo\.com\/(\d+)/,I=new Set(["","transparent","rgba(0,0,0,0)","rgba(0, 0, 0, 0)"]),N=globalThis;function v(){if(N.__AEDITOR_TABLE_CLIPBOARD_STYLES_PATCHED__)return;const a=new Set([...s.TableCellFormat.allowStyle,...b.TABLE_CELL_ALLOWED_STYLE_PREFIXES]);s.TableCellFormat.allowStyle=a,s.TableCellInnerFormat.allowStyle=new Set([...s.TableCellInnerFormat.allowStyle,...b.TABLE_CELL_ALLOWED_STYLE_PREFIXES]),N.__AEDITOR_TABLE_CLIPBOARD_STYLES_PATCHED__=!0}function x(a){let i=Number.parseFloat(a.getAttribute("width")||"");if(Number.isNaN(i)){const e=a.style.width;i=e?Number.parseFloat(e):a.offsetWidth}return i||s.tableUpSize.colDefaultWidth}function D(a,i){const e=Number.parseFloat(i.getComputedStyle(a).width);return Number.isFinite(e)&&e>0?e:x(a)}function F(a){const i=Array.from(a.querySelectorAll("col")).reduce((t,r)=>{const o=Number.parseInt(r.getAttribute("span")||"1",10);return t+(Number.isNaN(o)||o<1?1:o)},0),e=Array.from(a.rows).reduce((t,r)=>{const o=Array.from(r.cells).reduce((l,n)=>l+Math.max(n.colSpan||1,1),0);return Math.max(t,o)},0);return Math.max(i,e)}function _(a,i,e=x){const t=new Array(i).fill(s.tableUpSize.colDefaultWidth),r=Array.from(a.querySelectorAll("tr"));for(const o of r){const l=Array.from(o.querySelectorAll("td, th"));let n=0;for(const u of l){const c=Math.max(u.colSpan||1,1);if(n>=i)break;const m=e(u)/c;for(let h=0;h<c&&n+h<i;h+=1)t[n+h]=m||t[n+h];n+=c}}return t}function T(a){const i=Math.round(a*100)/100;return Number.isFinite(i)&&i>0?i:s.tableUpSize.colDefaultWidth}function O(a,i){const e=a==null?void 0:a.width;let t;if(typeof e=="number")t=e;else if(typeof e=="string")t=Number.parseFloat(e);else return T(i);return Number.isFinite(t)&&t>0?T(t):T(i)}function W(a,i){return typeof(a==null?void 0:a.full)=="boolean"?a.full:Object.hasOwn(i.dataset,"full")||i.querySelector("col[data-full], colgroup[data-full]")!==null}function B(a){if(!a)return;const i=b.parseInlineStyleText(a)["background-color"];if(!(!i||I.has(i)))return i}function P(a,i,e){let t=a;for(;t;){const r=t===a?e.getComputedStyle(t).getPropertyValue("background-color").trim():e.getComputedStyle(t).backgroundColor.trim();if(r&&!I.has(r))return r;if(t===i)break;t=t.parentElement}}class U extends M{constructor(e,t){v();super(e,t);p(this,"matchCaptionHandler",(e,t)=>this.matchCaption(e,t));p(this,"matchColHandler",(e,t)=>this.matchCol(e,t));p(this,"matchColgroupHandler",(e,t)=>this.matchColgroup(e,t));p(this,"matchTableHandler",(e,t)=>this.matchTable(e,t));p(this,"matchTbodyHandler",(e,t)=>this.matchTbody(e,t));p(this,"matchTdAttributorHandler",(e,t)=>this.matchTdAttributor(e,t));p(this,"matchTdHandler",(e,t)=>this.matchTd(e,t));p(this,"matchTheadHandler",(e,t)=>this.matchThead(e,t));p(this,"matchTrHandler",(e,t)=>this.matchTr(e,t));p(this,"matchTfootHandler",(e,t)=>this.matchTfoot(e,t));p(this,"matchYouTubeLinkHandler",(e,t)=>this.matchYouTubeLink(e,t));p(this,"tableId",s.randomId());p(this,"rowId",s.randomId());p(this,"colIds",[]);p(this,"rowspanCount",[]);p(this,"cellCount",0);p(this,"colCount",0);this.quill=e,this.addMatcher("a",this.matchYouTubeLinkHandler),this.addMatcher("table",this.matchTableHandler),this.addMatcher("thead",this.matchTheadHandler),this.addMatcher("tbody",this.matchTbodyHandler),this.addMatcher("tfoot",this.matchTfootHandler),this.addMatcher("colgroup",this.matchColgroupHandler),this.addMatcher("col",this.matchColHandler),this.addMatcher("tr",this.matchTrHandler),this.addMatcher("td",this.matchTdHandler),this.addMatcher("th",this.matchTdHandler),this.addMatcher("caption",this.matchCaptionHandler),this.addMatcher(Node.ELEMENT_NODE,this.matchTdAttributorHandler)}getStyleBackgroundColor(e,t){var o;const r=e.style.backgroundColor;if(r)for(const l of t.ops){if(!((o=l.attributes)!=null&&o[s.blotName.tableCellInner]))continue;const{style:n,...u}=l.attributes[s.blotName.tableCellInner];if(B(n))continue;const c=b.mergeInlineStyles(n,`background-color:${r}`);l.attributes[s.blotName.tableCellInner]={...u,style:c}}}matchYouTubeLink(e,t){const o=e.getAttribute("href")||"";if(w.test(o)||A.test(o)){const l=E.normalizeVideoUrl(o);return new g().insert({video:l}).insert(`
|
|
2
2
|
`)}return t}readPreprocessedColumnWidths(e){const t=e.getAttribute(b.TABLE_COLUMN_WIDTHS_DATA_ATTRIBUTE);if(!t)return null;const r=t.split(",").map(o=>Number.parseFloat(o)).filter(o=>Number.isFinite(o)&&o>0).map(o=>T(o));return r.length?r:null}matchTable(e,t){if(t.ops.length===0)return t;const r=[],o=[];let l=-1;for(const m of t.ops){const{attributes:h,insert:f}=m;if(!b.lodashExports.isObject(f)&&(!h||!h[s.blotName.tableCellInner]&&!h[s.blotName.tableCaption]))continue;const{table:y,[s.blotName.tableCell]:S,...C}=h||{};if(b.lodashExports.isObject(f)&&f[s.blotName.tableCol]){o.push({insert:f});continue}r.push({attributes:C,insert:f}),!(C!=null&&C[s.blotName.tableCellInner])&&!(C!=null&&C[s.blotName.tableCaption])&&b.lodashExports.isString(f)&&f.trim().length>0&&(l=r.length-1)}const n=e,c=(this.readPreprocessedColumnWidths(n)??_(n,this.colIds.length)).map((m,h)=>{var C;const f=(C=o[h])==null?void 0:C.insert,y=b.lodashExports.isObject(f)?f[s.blotName.tableCol]:void 0,S=b.lodashExports.isObject(y)?y:void 0;return{insert:{[s.blotName.tableCol]:{...S,tableId:this.tableId,colId:this.colIds[h],width:O(S,m),full:W(S,n)}}}});r.splice(l+1,0,...c);const d=new g(r);return this.getStyleBackgroundColor(e,d),this.tableId=s.randomId(),this.colIds=[],this.rowspanCount=[],this.cellCount=0,this.colCount=0,d}createEmptyRowIdsForPlainInsert(e){let t=0;e&&(t=b.lodashExports.isString(e)?e.split(`
|
|
3
3
|
`).length-1:1);const r=[];for(let o=0;o<t;o+=1)r.push(s.randomId());return r}mergeEmptyRowsIntoCellValue(e,t){t.length!==0&&(e.emptyRow??(e.emptyRow=[]),t.length>e.emptyRow.length&&e.emptyRow.push(...t.slice(e.emptyRow.length-t.length)))}matchTbody(e,t){var o;this.getStyleBackgroundColor(e,t);let r=[];for(let l=t.ops.length-1;l>=0;l-=1){const n=t.ops[l];if(!((o=n.attributes)!=null&&o[s.blotName.tableCellInner])){r=this.createEmptyRowIdsForPlainInsert(n.insert);continue}const u=n.attributes[s.blotName.tableCellInner];if(u.rowspan===1){r=[];continue}this.mergeEmptyRowsIntoCellValue(u,r)}return this.rowspanCount=[],t}matchThead(e,t){var o;const r=this.matchTbody(e,t);for(const l of r.ops)(o=l.attributes)!=null&&o[s.blotName.tableCellInner]&&(l.attributes[s.blotName.tableCellInner].wrapTag="thead");return r}matchTfoot(e,t){var o;const r=this.matchTbody(e,t);for(const l of r.ops)(o=l.attributes)!=null&&o[s.blotName.tableCellInner]&&(l.attributes[s.blotName.tableCellInner].wrapTag="tfoot");return r}matchColgroup(e,t){const r=t.ops.filter(o=>b.lodashExports.isObject(o.insert)&&o.insert[s.blotName.tableCol]);return new g(r)}matchCol(e,t){let r=Number.parseInt(e.getAttribute("span")||"1",10);(Number.isNaN(r)||r<1)&&(r=1);const o=new g;for(let l=0;l<r;l+=1)this.colIds[this.colCount]=s.randomId(),o.insert({[s.blotName.tableCol]:Object.assign(s.TableColFormat.value(e),{tableId:this.tableId,colId:this.colIds[this.colCount]})}),this.colCount+=1;return o}matchTr(e,t){this.rowId=s.randomId(),this.cellCount=0;for(const[r,o]of this.rowspanCount.entries())o.rowspan>0&&(o.rowspan-=1),o.rowspan<=0&&(this.rowspanCount[r]={rowspan:0,colspan:0});return this.getStyleBackgroundColor(e,t),t.ops.length===0?new g([{insert:`
|
|
4
4
|
`}]):t}matchTd(e,t){const r=e,o=s.TableCellFormat.formats(r);if(!this.colIds[this.cellCount]||!this.rowspanCount[this.cellCount])for(let d=this.cellCount;d>=0;d-=1)this.colIds[d]||(this.colIds[d]=s.randomId()),this.rowspanCount[d]||(this.rowspanCount[d]={rowspan:0,colspan:0});for(let d=this.cellCount;d<this.rowspanCount.length;d+=1){const{rowspan:m,colspan:h}=this.rowspanCount[d];if(m===0)break;this.cellCount+=h}o.rowspan>1&&(this.rowspanCount[this.cellCount]={rowspan:o.rowspan,colspan:o.colspan});const l=this.colIds[this.cellCount];this.cellCount+=o.colspan;const n=Object.assign(o,{tableId:this.tableId,rowId:this.rowId,colId:l});this.handleBorderNoneStyles(r,n);const u=t.ops.map(d=>{const{attributes:m={},...h}=d,{[s.blotName.tableCell]:f,...y}=m;return{...h,attributes:{...y,[s.blotName.tableCellInner]:n}}}),c=u.at(-1);return(!u.length||!b.lodashExports.isString(c==null?void 0:c.insert)||!c.insert.endsWith(`
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { Q as E } from "./index-B7G8Zc2n.js";
|
|
2
|
+
import { TableSelection as L } from "./index-BmRxkoLz.js";
|
|
3
|
+
import { a as w, b as H } from "./TableUpLogical-Cvks-qgX.js";
|
|
4
|
+
function m(s) {
|
|
5
|
+
return H(s);
|
|
6
|
+
}
|
|
7
|
+
function M(s, n) {
|
|
8
|
+
const e = n.map((r) => (r.domNode.closest("td, th") || r.domNode).getBoundingClientRect()).filter((r) => r.width > 0 || r.height > 0);
|
|
9
|
+
if (e.length === 0) return null;
|
|
10
|
+
const l = s.getBoundingClientRect(), t = Math.min(...e.map((r) => r.left)), a = Math.min(...e.map((r) => r.top)), o = Math.max(...e.map((r) => r.right)), i = Math.max(...e.map((r) => r.bottom)), d = t - l.left + s.scrollLeft, c = a - l.top + s.scrollTop;
|
|
11
|
+
return {
|
|
12
|
+
height: i - a,
|
|
13
|
+
width: o - t,
|
|
14
|
+
x: d,
|
|
15
|
+
x1: d + (o - t),
|
|
16
|
+
y: c,
|
|
17
|
+
y1: c + (i - a)
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
function S(s, n) {
|
|
21
|
+
const e = n.getBoundingClientRect();
|
|
22
|
+
return e.width <= 0 || e.height <= 0 ? null : {
|
|
23
|
+
x: Math.min(Math.max(s.x, e.left + 0.5), e.right - 0.5),
|
|
24
|
+
y: Math.min(Math.max(s.y, e.top + 0.5), e.bottom - 0.5)
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function v(s, n, e) {
|
|
28
|
+
const l = S(s, e), t = S(n, e);
|
|
29
|
+
return !l || !t ? null : {
|
|
30
|
+
x: Math.min(l.x, t.x),
|
|
31
|
+
x1: Math.max(l.x, t.x),
|
|
32
|
+
y: Math.min(l.y, t.y),
|
|
33
|
+
y1: Math.max(l.y, t.y)
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
function I(s, n, e) {
|
|
37
|
+
if (e) {
|
|
38
|
+
const a = s.x1 < n.left || s.x > n.right, o = s.y1 < n.top || s.y > n.bottom;
|
|
39
|
+
return !(a || o);
|
|
40
|
+
}
|
|
41
|
+
const l = s.x1 <= n.left || s.x >= n.right, t = s.y1 <= n.top || s.y >= n.bottom;
|
|
42
|
+
return !(l || t);
|
|
43
|
+
}
|
|
44
|
+
function X(s, n) {
|
|
45
|
+
const e = [], l = Array.from(n.placements.values()).map((o, i) => ({
|
|
46
|
+
cell: o.cell,
|
|
47
|
+
index: i
|
|
48
|
+
}));
|
|
49
|
+
let t = s, a = !0;
|
|
50
|
+
for (; a; ) {
|
|
51
|
+
a = !1;
|
|
52
|
+
for (let o = 0; o < l.length; o += 1) {
|
|
53
|
+
const i = l[o], d = i.cell.getBoundingClientRect(), c = {
|
|
54
|
+
bottom: Math.floor(d.bottom),
|
|
55
|
+
left: Math.floor(d.left),
|
|
56
|
+
right: Math.floor(d.right),
|
|
57
|
+
top: Math.floor(d.top)
|
|
58
|
+
}, r = {
|
|
59
|
+
x: Math.floor(t.x),
|
|
60
|
+
x1: Math.floor(t.x1),
|
|
61
|
+
y: Math.floor(t.y),
|
|
62
|
+
y1: Math.floor(t.y1)
|
|
63
|
+
};
|
|
64
|
+
if (I(r, c, e.length === 0)) {
|
|
65
|
+
e.push(i), l.splice(o, 1), t = {
|
|
66
|
+
x: Math.min(t.x, c.left),
|
|
67
|
+
x1: Math.max(t.x1, c.right),
|
|
68
|
+
y: Math.min(t.y, c.top),
|
|
69
|
+
y1: Math.max(t.y1, c.bottom)
|
|
70
|
+
}, a = !0;
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return e.toSorted((o, i) => o.index - i.index).map(({
|
|
76
|
+
cell: o
|
|
77
|
+
}) => o);
|
|
78
|
+
}
|
|
79
|
+
class q extends L {
|
|
80
|
+
resolveSelectedCellsFromBoundary(n, e, l) {
|
|
81
|
+
const t = l ?? m(n);
|
|
82
|
+
if (!t) return [];
|
|
83
|
+
const a = w(t, X(e, t));
|
|
84
|
+
if (!a) return [];
|
|
85
|
+
const o = a.cells.reduce((d, c) => {
|
|
86
|
+
const r = E.find(c);
|
|
87
|
+
return r && d.push(r.getCellInner()), d;
|
|
88
|
+
}, []), i = M(this.quill.root, o);
|
|
89
|
+
return !i || o.length === 0 ? [] : (this.boundary = i, o);
|
|
90
|
+
}
|
|
91
|
+
computeSelectedTds(n, e) {
|
|
92
|
+
if (!this.table) return [];
|
|
93
|
+
const l = this.table, t = m(l);
|
|
94
|
+
if (!t) return [];
|
|
95
|
+
const a = v(n, e, l);
|
|
96
|
+
return a ? this.resolveSelectedCellsFromBoundary(l, a, t) : [];
|
|
97
|
+
}
|
|
98
|
+
tableSelectHandler(n) {
|
|
99
|
+
const {
|
|
100
|
+
button: e,
|
|
101
|
+
target: l,
|
|
102
|
+
clientX: t,
|
|
103
|
+
clientY: a
|
|
104
|
+
} = n, o = l instanceof HTMLElement ? l : null, i = o == null ? void 0 : o.closest("table"), d = o == null ? void 0 : o.closest("caption");
|
|
105
|
+
if (e !== 0 || !i || d) return;
|
|
106
|
+
const c = {
|
|
107
|
+
x: t,
|
|
108
|
+
y: a
|
|
109
|
+
};
|
|
110
|
+
this.setSelectionTable(i);
|
|
111
|
+
const r = i.dataset.tableId;
|
|
112
|
+
this.recordScrollPosition(), this.setSelectedTds(this.computeSelectedTds(c, c)), this.show();
|
|
113
|
+
const u = (T) => {
|
|
114
|
+
this.dragging = !0;
|
|
115
|
+
const {
|
|
116
|
+
button: B,
|
|
117
|
+
target: x,
|
|
118
|
+
clientX: y,
|
|
119
|
+
clientY: g
|
|
120
|
+
} = T, h = x instanceof HTMLElement ? x : null, C = h == null ? void 0 : h.closest("caption");
|
|
121
|
+
if (B !== 0 || C || i.dataset.tableId !== r)
|
|
122
|
+
return;
|
|
123
|
+
const P = {
|
|
124
|
+
x: y,
|
|
125
|
+
y: g
|
|
126
|
+
}, R = m(i), b = v(c, P, i);
|
|
127
|
+
b && (this.setSelectedTds(this.resolveSelectedCellsFromBoundary(i, b, R)), this.selectedTds.length > 1 && this.quill.blur(), this.update(), this.autoScroller.updateMousePosition(y, g));
|
|
128
|
+
}, f = () => {
|
|
129
|
+
document.body.removeEventListener("mousemove", u, !1), document.body.removeEventListener("mouseup", f, !1), this.autoScroller.stop(), this.dragging = !1, this.clearRecordScrollPosition();
|
|
130
|
+
};
|
|
131
|
+
document.body.addEventListener("mousemove", u, !1), document.body.addEventListener("mouseup", f, !1);
|
|
132
|
+
const p = i.parentElement;
|
|
133
|
+
p && (this.autoScroller.updateMousePosition(t, a), this.autoScroller.start(p));
|
|
134
|
+
}
|
|
135
|
+
updateWithSelectedTds() {
|
|
136
|
+
if (this.selectedTds.length <= 0) {
|
|
137
|
+
this.hide();
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
const n = M(this.quill.root, this.selectedTds);
|
|
141
|
+
if (!n) {
|
|
142
|
+
this.hide();
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
this.boundary = n, this.update();
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
export {
|
|
149
|
+
q as default
|
|
150
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const E=require("./index-DprVE3Wh.cjs"),q=require("./index-DyVQWGfz.cjs"),T=require("./TableUpLogical-D2BMVJiy.cjs");function m(s){return T.buildDomTableGrid(s)}function M(s,n){const e=n.map(r=>(r.domNode.closest("td, th")||r.domNode).getBoundingClientRect()).filter(r=>r.width>0||r.height>0);if(e.length===0)return null;const l=s.getBoundingClientRect(),t=Math.min(...e.map(r=>r.left)),a=Math.min(...e.map(r=>r.top)),o=Math.max(...e.map(r=>r.right)),i=Math.max(...e.map(r=>r.bottom)),d=t-l.left+s.scrollLeft,c=a-l.top+s.scrollTop;return{height:i-a,width:o-t,x:d,x1:d+(o-t),y:c,y1:c+(i-a)}}function S(s,n){const e=n.getBoundingClientRect();return e.width<=0||e.height<=0?null:{x:Math.min(Math.max(s.x,e.left+.5),e.right-.5),y:Math.min(Math.max(s.y,e.top+.5),e.bottom-.5)}}function v(s,n,e){const l=S(s,e),t=S(n,e);return!l||!t?null:{x:Math.min(l.x,t.x),x1:Math.max(l.x,t.x),y:Math.min(l.y,t.y),y1:Math.max(l.y,t.y)}}function w(s,n,e){if(e){const a=s.x1<n.left||s.x>n.right,o=s.y1<n.top||s.y>n.bottom;return!(a||o)}const l=s.x1<=n.left||s.x>=n.right,t=s.y1<=n.top||s.y>=n.bottom;return!(l||t)}function H(s,n){const e=[],l=Array.from(n.placements.values()).map((o,i)=>({cell:o.cell,index:i}));let t=s,a=!0;for(;a;){a=!1;for(let o=0;o<l.length;o+=1){const i=l[o],d=i.cell.getBoundingClientRect(),c={bottom:Math.floor(d.bottom),left:Math.floor(d.left),right:Math.floor(d.right),top:Math.floor(d.top)},r={x:Math.floor(t.x),x1:Math.floor(t.x1),y:Math.floor(t.y),y1:Math.floor(t.y1)};if(w(r,c,e.length===0)){e.push(i),l.splice(o,1),t={x:Math.min(t.x,c.left),x1:Math.max(t.x1,c.right),y:Math.min(t.y,c.top),y1:Math.max(t.y1,c.bottom)},a=!0;break}}}return e.toSorted((o,i)=>o.index-i.index).map(({cell:o})=>o)}class I extends q.TableSelection{resolveSelectedCellsFromBoundary(n,e,l){const t=l??m(n);if(!t)return[];const a=T.resolveRectangularSelection(t,H(e,t));if(!a)return[];const o=a.cells.reduce((d,c)=>{const r=E.Quill.find(c);return r&&d.push(r.getCellInner()),d},[]),i=M(this.quill.root,o);return!i||o.length===0?[]:(this.boundary=i,o)}computeSelectedTds(n,e){if(!this.table)return[];const l=this.table,t=m(l);if(!t)return[];const a=v(n,e,l);return a?this.resolveSelectedCellsFromBoundary(l,a,t):[]}tableSelectHandler(n){const{button:e,target:l,clientX:t,clientY:a}=n,o=l instanceof HTMLElement?l:null,i=o==null?void 0:o.closest("table"),d=o==null?void 0:o.closest("caption");if(e!==0||!i||d)return;const c={x:t,y:a};this.setSelectionTable(i);const r=i.dataset.tableId;this.recordScrollPosition(),this.setSelectedTds(this.computeSelectedTds(c,c)),this.show();const u=B=>{this.dragging=!0;const{button:C,target:x,clientX:g,clientY:y}=B,h=x instanceof HTMLElement?x:null,P=h==null?void 0:h.closest("caption");if(C!==0||P||i.dataset.tableId!==r)return;const R={x:g,y},L=m(i),b=v(c,R,i);b&&(this.setSelectedTds(this.resolveSelectedCellsFromBoundary(i,b,L)),this.selectedTds.length>1&&this.quill.blur(),this.update(),this.autoScroller.updateMousePosition(g,y))},f=()=>{document.body.removeEventListener("mousemove",u,!1),document.body.removeEventListener("mouseup",f,!1),this.autoScroller.stop(),this.dragging=!1,this.clearRecordScrollPosition()};document.body.addEventListener("mousemove",u,!1),document.body.addEventListener("mouseup",f,!1);const p=i.parentElement;p&&(this.autoScroller.updateMousePosition(t,a),this.autoScroller.start(p))}updateWithSelectedTds(){if(this.selectedTds.length<=0){this.hide();return}const n=M(this.quill.root,this.selectedTds);if(!n){this.hide();return}this.boundary=n,this.update()}}exports.default=I;
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { Q as f } from "./index-B7G8Zc2n.js";
|
|
2
|
+
import C, { TableSelection as m, findParentBlot as b, blotName as g, findParentBlots as p } from "./index-BmRxkoLz.js";
|
|
3
|
+
import { b as S, r as T } from "./TableUpLogical-Cvks-qgX.js";
|
|
4
|
+
class M extends C {
|
|
5
|
+
getTableSelectionModule() {
|
|
6
|
+
return this.getModule(m.moduleName);
|
|
7
|
+
}
|
|
8
|
+
resolveSelectedCells(l) {
|
|
9
|
+
var e;
|
|
10
|
+
return l.length > 0 ? l : ((e = this.getTableSelectionModule()) == null ? void 0 : e.selectedTds) || [];
|
|
11
|
+
}
|
|
12
|
+
moveSelectionToCell(l) {
|
|
13
|
+
const e = this.quill.getIndex(l);
|
|
14
|
+
this.quill.focus(), this.quill.setSelection({
|
|
15
|
+
index: e,
|
|
16
|
+
length: 0
|
|
17
|
+
}, f.sources.SILENT);
|
|
18
|
+
}
|
|
19
|
+
clearDisplayedSelection() {
|
|
20
|
+
const l = this.getTableSelectionModule();
|
|
21
|
+
l && l.hide();
|
|
22
|
+
}
|
|
23
|
+
resolveSplitTargetCell(l) {
|
|
24
|
+
if (l.length === 1) return l[0];
|
|
25
|
+
const e = this.getTableSelectionModule();
|
|
26
|
+
if ((e == null ? void 0 : e.selectedTds.length) === 1) return e.selectedTds[0];
|
|
27
|
+
const n = this.quill.getSelection();
|
|
28
|
+
if (!n) return null;
|
|
29
|
+
const [o] = this.quill.getLine(n.index);
|
|
30
|
+
if (!o) return null;
|
|
31
|
+
try {
|
|
32
|
+
return b(o, g.tableCellInner);
|
|
33
|
+
} catch {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
resolveTableCellNode(l) {
|
|
38
|
+
const e = l.domNode.closest("td, th");
|
|
39
|
+
return e instanceof HTMLTableCellElement ? e : null;
|
|
40
|
+
}
|
|
41
|
+
resolveCellInnerFromNode(l) {
|
|
42
|
+
const e = f.find(l);
|
|
43
|
+
return (e == null ? void 0 : e.getCellInner()) ?? null;
|
|
44
|
+
}
|
|
45
|
+
readElementHeight(l) {
|
|
46
|
+
if (!(l instanceof HTMLElement)) return null;
|
|
47
|
+
const e = l.getBoundingClientRect().height;
|
|
48
|
+
return Number.isFinite(e) && e > 0 ? Math.round(e * 100) / 100 : null;
|
|
49
|
+
}
|
|
50
|
+
applyCellHeight(l, e) {
|
|
51
|
+
e === null || e <= 0 || l.setFormatValue("height", `${Math.round(e * 100) / 100}px`, !0);
|
|
52
|
+
}
|
|
53
|
+
resolveStableMergeSelection(l) {
|
|
54
|
+
const e = this.resolveSelectedCells(l);
|
|
55
|
+
if (e.length <= 1) return null;
|
|
56
|
+
const n = b(e[0], g.tableMain);
|
|
57
|
+
if (!n) return null;
|
|
58
|
+
const o = n.domNode;
|
|
59
|
+
if (!(o instanceof HTMLTableElement)) return null;
|
|
60
|
+
const i = S(o);
|
|
61
|
+
if (!i) return null;
|
|
62
|
+
const d = e.reduce((t, c) => {
|
|
63
|
+
const s = this.resolveTableCellNode(c);
|
|
64
|
+
return s && t.push(s), t;
|
|
65
|
+
}, []), r = T(i, d);
|
|
66
|
+
if (!r) return null;
|
|
67
|
+
const u = r.cells.reduce((t, c) => {
|
|
68
|
+
const s = this.resolveCellInnerFromNode(c);
|
|
69
|
+
return s && t.push(s), t;
|
|
70
|
+
}, []), h = this.resolveCellInnerFromNode(r.baseCell);
|
|
71
|
+
if (!h || u.length !== r.cells.length) return null;
|
|
72
|
+
const a = i.rows.slice(r.rowStartIndex, r.rowEndIndex + 1).reduce((t, c) => {
|
|
73
|
+
const s = this.readElementHeight(c);
|
|
74
|
+
return s === null ? t : (t ?? 0) + s;
|
|
75
|
+
}, null);
|
|
76
|
+
return {
|
|
77
|
+
baseCell: h,
|
|
78
|
+
cells: u,
|
|
79
|
+
totalHeight: a
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
resolveSplitCellHeights(l) {
|
|
83
|
+
const [e, n] = p(l, [g.tableMain, g.tableRow]), o = e.getRows(), i = o.indexOf(n);
|
|
84
|
+
if (i < 0) return null;
|
|
85
|
+
const d = Array.from({
|
|
86
|
+
length: l.rowspan
|
|
87
|
+
}, (h, a) => {
|
|
88
|
+
const t = o[i + a], c = this.readElementHeight((t == null ? void 0 : t.domNode) ?? null);
|
|
89
|
+
if (c !== null) return c;
|
|
90
|
+
const s = this.readElementHeight(this.resolveTableCellNode(l));
|
|
91
|
+
return s !== null && l.rowspan > 0 ? s / l.rowspan : null;
|
|
92
|
+
}), r = l.getColumnIndex(), u = e.getColIds().slice(r, r + l.colspan);
|
|
93
|
+
return u.length === 0 ? null : {
|
|
94
|
+
colIds: u,
|
|
95
|
+
rowHeights: d,
|
|
96
|
+
startRowIndex: i,
|
|
97
|
+
tableBlot: e
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
syncSplitCellHeights(l, e, n, o) {
|
|
101
|
+
const i = l.getRows();
|
|
102
|
+
o.forEach((d, r) => {
|
|
103
|
+
if (d === null) return;
|
|
104
|
+
const u = i[e + r];
|
|
105
|
+
u && n.forEach((h) => {
|
|
106
|
+
const a = u.getCellByColId(h, "next"), t = a == null ? void 0 : a.getCellInner();
|
|
107
|
+
!t || t.rowId !== u.rowId || t.colId !== h || this.applyCellHeight(t, d);
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
mergeCells(l) {
|
|
112
|
+
const e = this.resolveStableMergeSelection(l);
|
|
113
|
+
e && (this.clearDisplayedSelection(), super.mergeCells(e.cells), this.applyCellHeight(e.baseCell, e.totalHeight), this.moveSelectionToCell(e.baseCell));
|
|
114
|
+
}
|
|
115
|
+
splitCell(l) {
|
|
116
|
+
const e = this.resolveSplitTargetCell(l);
|
|
117
|
+
if (!e) return;
|
|
118
|
+
const n = this.resolveSplitCellHeights(e);
|
|
119
|
+
this.clearDisplayedSelection(), super.splitCell([e]), n && this.syncSplitCellHeights(n.tableBlot, n.startRowIndex, n.colIds, n.rowHeights), this.moveSelectionToCell(e);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
export {
|
|
123
|
+
M as default
|
|
124
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("./index-DprVE3Wh.cjs"),c=require("./index-DyVQWGfz.cjs"),b=require("./TableUpLogical-D2BMVJiy.cjs");class C extends c.default{getTableSelectionModule(){return this.getModule(c.TableSelection.moduleName)}resolveSelectedCells(l){var e;return l.length>0?l:((e=this.getTableSelectionModule())==null?void 0:e.selectedTds)||[]}moveSelectionToCell(l){const e=this.quill.getIndex(l);this.quill.focus(),this.quill.setSelection({index:e,length:0},f.Quill.sources.SILENT)}clearDisplayedSelection(){const l=this.getTableSelectionModule();l&&l.hide()}resolveSplitTargetCell(l){if(l.length===1)return l[0];const e=this.getTableSelectionModule();if((e==null?void 0:e.selectedTds.length)===1)return e.selectedTds[0];const n=this.quill.getSelection();if(!n)return null;const[s]=this.quill.getLine(n.index);if(!s)return null;try{return c.findParentBlot(s,c.blotName.tableCellInner)}catch{return null}}resolveTableCellNode(l){const e=l.domNode.closest("td, th");return e instanceof HTMLTableCellElement?e:null}resolveCellInnerFromNode(l){const e=f.Quill.find(l);return(e==null?void 0:e.getCellInner())??null}readElementHeight(l){if(!(l instanceof HTMLElement))return null;const e=l.getBoundingClientRect().height;return Number.isFinite(e)&&e>0?Math.round(e*100)/100:null}applyCellHeight(l,e){e===null||e<=0||l.setFormatValue("height",`${Math.round(e*100)/100}px`,!0)}resolveStableMergeSelection(l){const e=this.resolveSelectedCells(l);if(e.length<=1)return null;const n=c.findParentBlot(e[0],c.blotName.tableMain);if(!n)return null;const s=n.domNode;if(!(s instanceof HTMLTableElement))return null;const i=b.buildDomTableGrid(s);if(!i)return null;const h=e.reduce((t,a)=>{const o=this.resolveTableCellNode(a);return o&&t.push(o),t},[]),r=b.resolveMergePlan(i,h);if(!r)return null;const u=r.cells.reduce((t,a)=>{const o=this.resolveCellInnerFromNode(a);return o&&t.push(o),t},[]),g=this.resolveCellInnerFromNode(r.baseCell);if(!g||u.length!==r.cells.length)return null;const d=i.rows.slice(r.rowStartIndex,r.rowEndIndex+1).reduce((t,a)=>{const o=this.readElementHeight(a);return o===null?t:(t??0)+o},null);return{baseCell:g,cells:u,totalHeight:d}}resolveSplitCellHeights(l){const[e,n]=c.findParentBlots(l,[c.blotName.tableMain,c.blotName.tableRow]),s=e.getRows(),i=s.indexOf(n);if(i<0)return null;const h=Array.from({length:l.rowspan},(g,d)=>{const t=s[i+d],a=this.readElementHeight((t==null?void 0:t.domNode)??null);if(a!==null)return a;const o=this.readElementHeight(this.resolveTableCellNode(l));return o!==null&&l.rowspan>0?o/l.rowspan:null}),r=l.getColumnIndex(),u=e.getColIds().slice(r,r+l.colspan);return u.length===0?null:{colIds:u,rowHeights:h,startRowIndex:i,tableBlot:e}}syncSplitCellHeights(l,e,n,s){const i=l.getRows();s.forEach((h,r)=>{if(h===null)return;const u=i[e+r];u&&n.forEach(g=>{const d=u.getCellByColId(g,"next"),t=d==null?void 0:d.getCellInner();!t||t.rowId!==u.rowId||t.colId!==g||this.applyCellHeight(t,h)})})}mergeCells(l){const e=this.resolveStableMergeSelection(l);e&&(this.clearDisplayedSelection(),super.mergeCells(e.cells),this.applyCellHeight(e.baseCell,e.totalHeight),this.moveSelectionToCell(e.baseCell))}splitCell(l){const e=this.resolveSplitTargetCell(l);if(!e)return;const n=this.resolveSplitCellHeights(e);this.clearDisplayedSelection(),super.splitCell([e]),n&&this.syncSplitCellHeights(n.tableBlot,n.startRowIndex,n.colIds,n.rowHeights),this.moveSelectionToCell(e)}}exports.default=C;
|