@progress/kendo-react-editor 8.3.0-develop.9 → 8.4.0-develop.1
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/Editor.js +1 -1
- package/Editor.mjs +45 -47
- package/config/defaultStyles.js +0 -33
- package/config/defaultStyles.mjs +0 -33
- package/dialogs/insertImage.mjs +16 -4
- package/dialogs/insertLink.mjs +16 -4
- package/dist/cdn/js/kendo-react-editor.js +1 -1
- package/index.d.mts +17 -0
- package/index.d.ts +17 -0
- package/package-metadata.mjs +1 -1
- package/package.json +11 -11
- package/tools/insertTable/tool.mjs +35 -26
- package/tools/table-wizard/tablePropsUtils.js +1 -1
- package/tools/table-wizard/tablePropsUtils.mjs +80 -75
package/index.d.mts
CHANGED
|
@@ -191,6 +191,7 @@ export declare class Editor extends React_2.Component<EditorProps, EditorStateIn
|
|
|
191
191
|
onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
192
192
|
onPasteHtml: PropTypes.Requireable<(...args: any[]) => any>;
|
|
193
193
|
onExecute: PropTypes.Requireable<(...args: any[]) => any>;
|
|
194
|
+
onIFrameInit: PropTypes.Requireable<(...args: any[]) => any>;
|
|
194
195
|
};
|
|
195
196
|
/**
|
|
196
197
|
* @hidden
|
|
@@ -251,6 +252,7 @@ export declare class Editor extends React_2.Component<EditorProps, EditorStateIn
|
|
|
251
252
|
private onFocus;
|
|
252
253
|
private onBlur;
|
|
253
254
|
private onPaste;
|
|
255
|
+
private onIFrameInit;
|
|
254
256
|
}
|
|
255
257
|
|
|
256
258
|
/**
|
|
@@ -391,6 +393,16 @@ export declare interface EditorFocusEvent extends EditorEvent {
|
|
|
391
393
|
nativeEvent: FocusEvent;
|
|
392
394
|
}
|
|
393
395
|
|
|
396
|
+
/**
|
|
397
|
+
* Represents the object of the `onIFrameInit` Editor event.
|
|
398
|
+
*/
|
|
399
|
+
export declare interface EditorIFrameInitEvent extends EditorEvent {
|
|
400
|
+
/**
|
|
401
|
+
* The object that represents the iframe element inside the Editor.
|
|
402
|
+
*/
|
|
403
|
+
iframe: HTMLIFrameElement;
|
|
404
|
+
}
|
|
405
|
+
|
|
394
406
|
/**
|
|
395
407
|
* Represents the object of the `onMount` Editor event.
|
|
396
408
|
*/
|
|
@@ -506,6 +518,11 @@ export declare interface EditorProps {
|
|
|
506
518
|
* Fires each time the value of the Editor is about to change.
|
|
507
519
|
*/
|
|
508
520
|
onChange?: (event: EditorChangeEvent) => void;
|
|
521
|
+
/**
|
|
522
|
+
* Fires on the initialization of an Editor with iFrame property set to true.
|
|
523
|
+
* The event is used to access the iFrame document, change its properties or add custom styles.
|
|
524
|
+
*/
|
|
525
|
+
onIFrameInit?: (event: EditorIFrameInitEvent) => void;
|
|
509
526
|
/**
|
|
510
527
|
* The value of the Editor.
|
|
511
528
|
*/
|
package/index.d.ts
CHANGED
|
@@ -191,6 +191,7 @@ export declare class Editor extends React_2.Component<EditorProps, EditorStateIn
|
|
|
191
191
|
onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
192
192
|
onPasteHtml: PropTypes.Requireable<(...args: any[]) => any>;
|
|
193
193
|
onExecute: PropTypes.Requireable<(...args: any[]) => any>;
|
|
194
|
+
onIFrameInit: PropTypes.Requireable<(...args: any[]) => any>;
|
|
194
195
|
};
|
|
195
196
|
/**
|
|
196
197
|
* @hidden
|
|
@@ -251,6 +252,7 @@ export declare class Editor extends React_2.Component<EditorProps, EditorStateIn
|
|
|
251
252
|
private onFocus;
|
|
252
253
|
private onBlur;
|
|
253
254
|
private onPaste;
|
|
255
|
+
private onIFrameInit;
|
|
254
256
|
}
|
|
255
257
|
|
|
256
258
|
/**
|
|
@@ -391,6 +393,16 @@ export declare interface EditorFocusEvent extends EditorEvent {
|
|
|
391
393
|
nativeEvent: FocusEvent;
|
|
392
394
|
}
|
|
393
395
|
|
|
396
|
+
/**
|
|
397
|
+
* Represents the object of the `onIFrameInit` Editor event.
|
|
398
|
+
*/
|
|
399
|
+
export declare interface EditorIFrameInitEvent extends EditorEvent {
|
|
400
|
+
/**
|
|
401
|
+
* The object that represents the iframe element inside the Editor.
|
|
402
|
+
*/
|
|
403
|
+
iframe: HTMLIFrameElement;
|
|
404
|
+
}
|
|
405
|
+
|
|
394
406
|
/**
|
|
395
407
|
* Represents the object of the `onMount` Editor event.
|
|
396
408
|
*/
|
|
@@ -506,6 +518,11 @@ export declare interface EditorProps {
|
|
|
506
518
|
* Fires each time the value of the Editor is about to change.
|
|
507
519
|
*/
|
|
508
520
|
onChange?: (event: EditorChangeEvent) => void;
|
|
521
|
+
/**
|
|
522
|
+
* Fires on the initialization of an Editor with iFrame property set to true.
|
|
523
|
+
* The event is used to access the iFrame document, change its properties or add custom styles.
|
|
524
|
+
*/
|
|
525
|
+
onIFrameInit?: (event: EditorIFrameInitEvent) => void;
|
|
509
526
|
/**
|
|
510
527
|
* The value of the Editor.
|
|
511
528
|
*/
|
package/package-metadata.mjs
CHANGED
|
@@ -10,7 +10,7 @@ const e = {
|
|
|
10
10
|
name: "@progress/kendo-react-editor",
|
|
11
11
|
productName: "KendoReact",
|
|
12
12
|
productCodes: ["KENDOUIREACT", "KENDOUICOMPLETE"],
|
|
13
|
-
publishDate:
|
|
13
|
+
publishDate: 1726728962,
|
|
14
14
|
version: "",
|
|
15
15
|
licensingDocsUrl: "https://www.telerik.com/kendo-react-ui/components/my-license/"
|
|
16
16
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@progress/kendo-react-editor",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.4.0-develop.1",
|
|
4
4
|
"description": "React Editor enables users to create rich text content through a WYSIWYG interface. KendoReact Editor package",
|
|
5
5
|
"author": "Progress",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
@@ -24,16 +24,16 @@
|
|
|
24
24
|
"peerDependencies": {
|
|
25
25
|
"@progress/kendo-drawing": "^1.20.1",
|
|
26
26
|
"@progress/kendo-licensing": "^1.3.4",
|
|
27
|
-
"@progress/kendo-react-buttons": "8.
|
|
28
|
-
"@progress/kendo-react-common": "8.
|
|
29
|
-
"@progress/kendo-react-dialogs": "8.
|
|
30
|
-
"@progress/kendo-react-dropdowns": "8.
|
|
31
|
-
"@progress/kendo-react-form": "8.
|
|
32
|
-
"@progress/kendo-react-inputs": "8.
|
|
33
|
-
"@progress/kendo-react-intl": "8.
|
|
34
|
-
"@progress/kendo-react-layout": "8.
|
|
35
|
-
"@progress/kendo-react-pdf": "8.
|
|
36
|
-
"@progress/kendo-react-popup": "8.
|
|
27
|
+
"@progress/kendo-react-buttons": "8.4.0-develop.1",
|
|
28
|
+
"@progress/kendo-react-common": "8.4.0-develop.1",
|
|
29
|
+
"@progress/kendo-react-dialogs": "8.4.0-develop.1",
|
|
30
|
+
"@progress/kendo-react-dropdowns": "8.4.0-develop.1",
|
|
31
|
+
"@progress/kendo-react-form": "8.4.0-develop.1",
|
|
32
|
+
"@progress/kendo-react-inputs": "8.4.0-develop.1",
|
|
33
|
+
"@progress/kendo-react-intl": "8.4.0-develop.1",
|
|
34
|
+
"@progress/kendo-react-layout": "8.4.0-develop.1",
|
|
35
|
+
"@progress/kendo-react-pdf": "8.4.0-develop.1",
|
|
36
|
+
"@progress/kendo-react-popup": "8.4.0-develop.1",
|
|
37
37
|
"@progress/kendo-svg-icons": "^3.0.0",
|
|
38
38
|
"react": "^16.8.2 || ^17.0.0 || ^18.0.0",
|
|
39
39
|
"react-dom": "^16.8.2 || ^17.0.0 || ^18.0.0"
|
|
@@ -36,32 +36,41 @@ var h;
|
|
|
36
36
|
};
|
|
37
37
|
}
|
|
38
38
|
render() {
|
|
39
|
-
const { view: t, render: a, ...e } = this.props, o = t && t.state, r = N(this), { createTable: n, createTableHint: s } = p.messages, m = r.toLanguageString(
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
39
|
+
const { view: t, render: a, ...e } = this.props, o = t && t.state, r = N(this), { createTable: n, createTableHint: s } = p.messages, m = r.toLanguageString(
|
|
40
|
+
n,
|
|
41
|
+
d[n]
|
|
42
|
+
), g = r.toLanguageString(
|
|
43
|
+
s,
|
|
44
|
+
d[s]
|
|
45
|
+
), l = !!(!o || !k(o, o.schema.nodes.table) || P(o.selection.$from, (i) => i.type.name === "table_caption_external")), b = [
|
|
46
|
+
/* @__PURE__ */ c.createElement(
|
|
47
|
+
f,
|
|
48
|
+
{
|
|
49
|
+
onClick: l ? void 0 : this.togglePopup,
|
|
50
|
+
"aria-disabled": l ? !0 : void 0,
|
|
51
|
+
ref: (i) => this.button = i && i.element,
|
|
52
|
+
key: "InsertTable",
|
|
53
|
+
...I,
|
|
54
|
+
title: m,
|
|
55
|
+
...p.props,
|
|
56
|
+
...e,
|
|
57
|
+
className: y(e.className, p.props.className, { "k-disabled": l })
|
|
58
|
+
}
|
|
59
|
+
),
|
|
60
|
+
t && !l && /* @__PURE__ */ c.createElement(
|
|
61
|
+
w.InsertTablePopup,
|
|
62
|
+
{
|
|
63
|
+
key: "insertTablePopup",
|
|
64
|
+
createTableMessage: m,
|
|
65
|
+
createTableHintMessage: g,
|
|
66
|
+
dir: e.dir,
|
|
67
|
+
anchor: this.button,
|
|
68
|
+
show: this.state.openedPopup,
|
|
69
|
+
onClose: this.closePopup,
|
|
70
|
+
onTableInsert: this.onTableInsert
|
|
71
|
+
}
|
|
72
|
+
) || null
|
|
73
|
+
];
|
|
65
74
|
return a ? a.call(void 0, b, { view: t }) : b;
|
|
66
75
|
}
|
|
67
76
|
};
|
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const w=require("@progress/kendo-editor-common"),k=require("../tableEdit.js"),d=require("./utils.js"),N=require("../utils.js"),E={rows:0,columns:0,width:null,widthUnit:"",height:null,heightUnit:"",position:null,textAlign:"",cellPadding:null,cellSpacing:null,backgroundColor:void 0,borderWidth:null,borderColor:void 0,borderStyle:null,collapseBorders:!1,id:"",className:"",caption:"",captionAlignment:null,captionPosition:null,headerRows:0,headerColumns:0,associateHeaders:"none"},A={left:{"margin-left":"","margin-right":"auto"},center:{"margin-left":"auto","margin-right":"auto"},right:{"margin-left":"auto","margin-right":""},"":{}},M=o=>{const t=[];for(let s=0;s<o.height;s++){const l=s*o.width,e=l+o.width;t.push(o.map.slice(l,e))}return t},$=(o,t)=>{let s=0,l=0;const e=M(t);e.forEach(n=>{let i=!0;n.forEach(r=>{const c=o.nodeAt(r);c&&c.type.name!=="table_header"&&(i=!1)}),i&&s++});for(let n=0;n<t.width;n++){let i=!0;for(let r=0;r<t.height;r++){const c=e[r]&&e[r][n],u=typeof c=="number"&&o.nodeAt(c);u&&u.type.name!=="table_header"&&(i=!1)}i&&l++}return{rows:s,columns:l}},v=o=>{const t=new Set;return o.content.forEach(s=>{s.content.forEach(l=>{t.add(d.parseStyle(l.attrs.style).padding||"")})}),t.size===1?Array.from(t)[0]:""},j=o=>{let t=!0,s=!0;return o.content.forEach(l=>{l.content.forEach(e=>{
|
|
8
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const w=require("@progress/kendo-editor-common"),k=require("../tableEdit.js"),d=require("./utils.js"),N=require("../utils.js"),E={rows:0,columns:0,width:null,widthUnit:"",height:null,heightUnit:"",position:null,textAlign:"",cellPadding:null,cellSpacing:null,backgroundColor:void 0,borderWidth:null,borderColor:void 0,borderStyle:null,collapseBorders:!1,id:"",className:"",caption:"",captionAlignment:null,captionPosition:null,headerRows:0,headerColumns:0,associateHeaders:"none"},A={left:{"margin-left":"","margin-right":"auto"},center:{"margin-left":"auto","margin-right":"auto"},right:{"margin-left":"auto","margin-right":""},"":{}},M=o=>{const t=[];for(let s=0;s<o.height;s++){const l=s*o.width,e=l+o.width;t.push(o.map.slice(l,e))}return t},$=(o,t)=>{let s=0,l=0;const e=M(t);e.forEach(n=>{let i=!0;n.forEach(r=>{const c=o.nodeAt(r);c&&c.type.name!=="table_header"&&(i=!1)}),i&&s++});for(let n=0;n<t.width;n++){let i=!0;for(let r=0;r<t.height;r++){const c=e[r]&&e[r][n],u=typeof c=="number"&&o.nodeAt(c);u&&u.type.name!=="table_header"&&(i=!1)}i&&l++}return{rows:s,columns:l}},v=o=>{const t=new Set;return o.content.forEach(s=>{s.content.forEach(l=>{t.add(d.parseStyle(l.attrs.style).padding||"")})}),t.size===1?Array.from(t)[0]:""},j=o=>{let t=!0,s=!0;return o.content.forEach(l=>{l.content.forEach(e=>{const n=e.type.name==="table_header",i=e.type.name==="table_cell";n&&!e.attrs.scope&&(t=!1),(n&&!e.attrs.id||i&&!e.attrs.headers)&&(s=!1)})}),t?"scope":s?"id":"none"},F=o=>{var a,h,m;const t=d.selectedCells(o),s=o.selection.$from,l=t.length?N.parentNode(s,f=>f.type.spec.tableRole==="table"):null;if(!l)return E;const e=N.parentNode(s,f=>f.type.name==="table_wrapper");let n="",i={},r={};e&&(r=d.parseStyle(e.node.attrs.style),e.node.content.forEach(f=>{if(f.type.name==="table_caption_external"){const S=w.pmDocToFragment(f);n=w.fragmentToHtml(S),n=n==="<img>"?"":n,i=d.parseStyle(f.attrs.style)}}));const c=d.parseStyle(((a=l.node.attrs)==null?void 0:a.style)||""),u=w.TableMap.get(l.node),p=r["margin-left"]==="auto"&&r["margin-right"]==="auto"?"center":r["margin-right"]==="auto"?"left":r["margin-left"]==="auto"?"right":null,y=$(l.node,u),g=v(l.node);return{...E,columns:u.width,rows:u.height,...d.nodeSize(l.node,"width"),...e&&/%/.test(r.width||"")?d.nodeSize(e.node,"width"):{},...d.nodeSize(l.node,"height"),textAlign:c["text-align"]||"",position:p||null,cellPadding:g?parseFloat(g):null,cellSpacing:c["border-spacing"]?parseFloat(c["border-spacing"]):null,backgroundColor:c["background-color"],borderWidth:c["border-width"]?parseFloat(c["border-width"]):null,borderColor:c["border-color"],borderStyle:c["border-style"]||null,collapseBorders:c["border-collapse"]==="collapse",caption:n||void 0,captionAlignment:i["text-align"]||"",captionPosition:i["caption-side"]||null,headerRows:y.rows,headerColumns:y.columns,associateHeaders:y.rows||y.columns?j(l.node):"none",id:((h=l.node.attrs)==null?void 0:h.id)||"",className:((m=l.node.attrs)==null?void 0:m.class)||""}},x=o=>{const s=o.lastChild.lastChild;return{node:s,pos:o.content.size-s.nodeSize}},_=(o,t,s,l,e)=>{const n=x(s),i=t+n.pos;if(!o.doc.nodeAt(i))return o;const c=o.doc.resolve(i),u=new w.CellSelection(c,c),p=o.tr.setSelection(u);let y=o.apply(p);for(let g=0;g<l;g++)e(y,a=>{y=y.apply(a)});return y},R=(o,t,s,l)=>{let e=o;for(let n=0;n<s;n++){const i=e.doc.nodeAt(t);if(i){const r=x(i),c=t+r.pos,u=e.doc.resolve(c),p=new w.CellSelection(u,u),y=e.tr.setSelection(p);e=e.apply(y),l(e,g=>{e=e.apply(g)})}}return e},O=(o,t,s,l)=>{let e=o,n=e.doc.nodeAt(t);if(!n)return e;let i=w.TableMap.get(n);return i.width===l&&i.height===s||(l>i.width?e=_(e,t,n,l-i.width,w.addColumnAfter):l<i.width&&(e=R(e,t,i.width-l,k.deleteColumnCmd)),n=e.doc.nodeAt(t),!n)||(i=w.TableMap.get(n),s>i.height?e=_(e,t,n,s-i.height,w.addRowAfter):s<i.height&&(e=R(e,t,i.height-s,k.deleteRowCmd))),e},q=(o,t,s)=>{const l=o.doc.nodeAt(s);if(!l)return o;let e={...l.attrs};const n=t.width!==null&&(t.widthUnit!=="%"||!t.caption&&!t.position);e=d.setNodeStyle(e,"width",n?t.width+t.widthUnit:""),e=d.setNodeStyle(e,"height",t.height!==null?t.height+t.heightUnit:""),e=d.setNodeStyle(e,"text-align",t.textAlign||""),e=d.setNodeStyle(e,"background-color",t.backgroundColor||""),e=d.setNodeStyle(e,"border-width",t.borderWidth?t.borderWidth+"px":""),e=d.setNodeStyle(e,"border-style",t.borderStyle||""),e=d.setNodeStyle(e,"border-color",t.borderColor||""),e=d.setNodeStyle(e,"border-spacing",t.cellSpacing!==null?t.cellSpacing+"px":""),t.cellSpacing!==null?e=d.setNodeStyle(e,"border-collapse","unset"):e=d.setNodeStyle(e,"border-collapse",t.collapseBorders?"collapse":"");const i=A[t.position||""]||{};Object.keys(i).forEach(c=>{e=d.setNodeStyle(e,c,i[c])}),e.id=t.id||null,e.class=t.className||null;const r=o.tr.setNodeMarkup(s,null,e);return o=o.apply(r),o},z=(o,t,s,l,e)=>{if(t.type.name!==l.name||Object.keys(e).length>0){const n=o.tr.setNodeMarkup(s,l,{...t.attrs,...e});return o.apply(n)}return o},B=(o,t)=>{/^cell-[0-9]+-[0-9]+$/.test(o.attrs.id||"")&&(t.id=null)},P=(o,t,s)=>{const l=o.doc.nodeAt(s),e=l&&w.TableMap.get(l);if(!l||!e)return o;const n=M(e);let i=o;const{table_header:r,table_cell:c}=o.schema.nodes,u=String(new Date().getTime()),p=[],y=(a,h)=>{const m=`cell-${a}${h}-${u}`;return p[a]||p.push([]),p[a][h]||p[a].push([]),p[a][h]=m,m},g=(a,h,m,f)=>{const S=[];if(f)for(let b=0;b<a;b++)p[b]&&p[b][h]&&S.push(p[b][h]);if(m)for(let b=0;b<h;b++)p[a]&&p[a][b]&&S.push(p[a][b]);return S.join(" ")};return n.forEach((a,h)=>{a.forEach((m,f)=>{const S=l.nodeAt(m);if(S){const b=f<t.headerColumns,T=h<t.headerRows,C={...S.attrs};B(S,C),C.headers=null,C.scope=null,T||b?(t.associateHeaders==="scope"&&(C.scope=T?"col":"row"),t.associateHeaders==="id"&&(C.id=y(h,f),(f>0||h>0)&&(C.headers=g(h,f,b,T)||null)),i=z(i,S,s+m+1,r,C)):(t.associateHeaders==="id"&&(C.headers=g(h,f,t.headerColumns>0,t.headerRows>0)||null),i=z(i,S,s+m+1,c,C))}})}),i},G=(o,t,s,l)=>{let e={...t.attrs};return e=d.setNodeStyle(e,"margin-left",""),e=d.setNodeStyle(e,"margin-right",""),Object.keys(l||{}).forEach(n=>{e=d.setNodeStyle(e,n,(l||{})[n]||"")}),o.apply(o.tr.setNodeMarkup(s,null,e))},D=(o,t)=>w.parseContent("<p>"+o+"</p>",t).content.firstChild.content,H=(o,t)=>{if(!o.caption)return;let s={caption:"",style:"display: table-caption"};o.captionAlignment&&(s=d.setNodeStyle(s,"text-align",o.captionAlignment)),o.captionPosition&&(s=d.setNodeStyle(s,"caption-side",o.captionPosition));const l=D(o.caption,t);return l&&t.nodes.table_caption_external.createAndFill(s,l)||void 0},U=o=>o.firstChild&&o.firstChild.type.name==="table_caption_external",J=(o,t,s,l)=>{let e=o,n;const i=s+2,r=s+1,c=e.schema;if(U(t))if(n=t.firstChild,l.caption){const u=D(l.caption,c);if(e=e.apply(e.tr.replaceWith(i,i+n.content.size,u)),n=e.doc.nodeAt(r),n){let p={...n.attrs};p=d.setNodeStyle(p,"text-align",l.captionAlignment||""),p=d.setNodeStyle(p,"caption-side",l.captionPosition||""),e=e.apply(e.tr.setNodeAttribute(r,"style",p.style))}}else e=e.apply(e.tr.deleteRange(i,i+n.content.size));else n=H(l,c),n&&(e=e.apply(e.tr.replaceWith(r,r,n)));return e},K=(o,t,s,l,e)=>{let n={state:o,pos:s};if(!l&&(t.position||t.caption)){let r={table:"",style:"display: table"};const c=[],u=t.position,p=u&&A[u];p&&Object.keys(p).forEach(h=>{r=d.setNodeStyle(r,h,p[h]||"")}),typeof t.width=="number"&&t.widthUnit==="%"&&(r=d.setNodeStyle(r,"width",t.width+t.widthUnit));const y=H(t,o.schema);y&&c.push(y);const g=o.doc.nodeAt(s);c.push(g);const a=o.schema.nodes.table_wrapper.createAndFill(r,c);if(a){const h=o.tr.replaceWith(s,s+g.content.size,a);o=o.apply(h),n={state:o,pos:s}}}else l&&(t.position||t.caption||!t.caption&&U(l.node))?(o=G(o,l.node,e,t.position&&A[t.position]),o=J(o,l.node,e,t),n={state:o,pos:e}):l&&!(t.position||t.caption)?n={state:o,node:l.node,pos:o.selection.$from.start(l.depth)-1}:n={state:o,pos:s};const i=l&&n.state.doc.nodeAt(e);if(i){let r;typeof t.width=="number"&&t.widthUnit==="%"?r=d.setNodeStyle(i.attrs,"width",t.width+t.widthUnit):t.widthUnit!=="%"&&/%/.test(d.parseStyle(i.attrs.style||"").width||"")&&(r=d.setNodeStyle(i.attrs,"width","")),r&&(n.state=n.state.apply(n.state.tr.setNodeMarkup(e,null,r)))}return n},L=(o,t)=>{const s=o.selection.$from,l=N.parentNode(s,f=>f.type.spec.tableRole==="table");if(!l)return;const e=s.start(l.depth)-1;let n=O(o,e,t.rows,t.columns);if(!n)return;const i=n.tr;d.tableCells(n).forEach(f=>{let S={...f.node.attrs};S=d.setNodeStyle(S,"padding",typeof t.cellPadding=="number"?t.cellPadding+"px":""),i.setNodeMarkup(f.pos,null,S)}),n=n.apply(i),n=q(n,t,e),n=P(n,t,e);const r=N.parentNode(s,f=>f.type.name==="table_wrapper"),c=s.start((r==null?void 0:r.depth)||0)-1,u=K(n,t,e,r,c);n=u.state;const p=u.pos,y=n.doc.nodeAt(u.pos);if(!y)return;const g=p+(r||l).node.content.size,a=o.tr.replaceWith(p,g,y),h=w.Selection.atEnd(y),m=w.TextSelection.create(a.doc,p+h.to+1);return a.setSelection(m),a};exports.applyTableData=L;exports.initialTableData=E;exports.tableDefaultData=F;exports.tablePositionStyles=A;
|
|
@@ -41,56 +41,56 @@ const N = {
|
|
|
41
41
|
"": {}
|
|
42
42
|
}, z = (n) => {
|
|
43
43
|
const t = [];
|
|
44
|
-
for (let
|
|
45
|
-
const l =
|
|
44
|
+
for (let s = 0; s < n.height; s++) {
|
|
45
|
+
const l = s * n.width, e = l + n.width;
|
|
46
46
|
t.push(n.map.slice(l, e));
|
|
47
47
|
}
|
|
48
48
|
return t;
|
|
49
49
|
}, V = (n, t) => {
|
|
50
|
-
let
|
|
50
|
+
let s = 0, l = 0;
|
|
51
51
|
const e = z(t);
|
|
52
52
|
e.forEach((o) => {
|
|
53
|
-
let
|
|
53
|
+
let i = !0;
|
|
54
54
|
o.forEach((r) => {
|
|
55
55
|
const c = n.nodeAt(r);
|
|
56
|
-
c && c.type.name !== "table_header" && (
|
|
57
|
-
}),
|
|
56
|
+
c && c.type.name !== "table_header" && (i = !1);
|
|
57
|
+
}), i && s++;
|
|
58
58
|
});
|
|
59
59
|
for (let o = 0; o < t.width; o++) {
|
|
60
|
-
let
|
|
60
|
+
let i = !0;
|
|
61
61
|
for (let r = 0; r < t.height; r++) {
|
|
62
62
|
const c = e[r] && e[r][o], u = typeof c == "number" && n.nodeAt(c);
|
|
63
|
-
u && u.type.name !== "table_header" && (
|
|
63
|
+
u && u.type.name !== "table_header" && (i = !1);
|
|
64
64
|
}
|
|
65
|
-
|
|
65
|
+
i && l++;
|
|
66
66
|
}
|
|
67
|
-
return { rows:
|
|
67
|
+
return { rows: s, columns: l };
|
|
68
68
|
}, X = (n) => {
|
|
69
69
|
const t = /* @__PURE__ */ new Set();
|
|
70
|
-
return n.content.forEach((
|
|
71
|
-
|
|
70
|
+
return n.content.forEach((s) => {
|
|
71
|
+
s.content.forEach((l) => {
|
|
72
72
|
t.add(S(l.attrs.style).padding || "");
|
|
73
73
|
});
|
|
74
74
|
}), t.size === 1 ? Array.from(t)[0] : "";
|
|
75
75
|
}, Y = (n) => {
|
|
76
|
-
let t = !0,
|
|
76
|
+
let t = !0, s = !0;
|
|
77
77
|
return n.content.forEach((l) => {
|
|
78
78
|
l.content.forEach((e) => {
|
|
79
|
-
|
|
80
|
-
o && !e.attrs.scope && (t = !1), (o && !e.attrs.id ||
|
|
79
|
+
const o = e.type.name === "table_header", i = e.type.name === "table_cell";
|
|
80
|
+
o && !e.attrs.scope && (t = !1), (o && !e.attrs.id || i && !e.attrs.headers) && (s = !1);
|
|
81
81
|
});
|
|
82
|
-
}), t ? "scope" :
|
|
82
|
+
}), t ? "scope" : s ? "id" : "none";
|
|
83
83
|
}, ce = (n) => {
|
|
84
84
|
var p, a, b;
|
|
85
|
-
const t = P(n),
|
|
85
|
+
const t = P(n), s = n.selection.$from, l = t.length ? T(s, (f) => f.type.spec.tableRole === "table") : null;
|
|
86
86
|
if (!l)
|
|
87
87
|
return N;
|
|
88
|
-
const e = T(
|
|
89
|
-
let o = "",
|
|
88
|
+
const e = T(s, (f) => f.type.name === "table_wrapper");
|
|
89
|
+
let o = "", i = {}, r = {};
|
|
90
90
|
e && (r = S(e.node.attrs.style), e.node.content.forEach((f) => {
|
|
91
91
|
if (f.type.name === "table_caption_external") {
|
|
92
92
|
const y = F(f);
|
|
93
|
-
o = j(y), o = o === "<img>" ? "" : o,
|
|
93
|
+
o = j(y), o = o === "<img>" ? "" : o, i = S(f.attrs.style);
|
|
94
94
|
}
|
|
95
95
|
}));
|
|
96
96
|
const c = S(((p = l.node.attrs) == null ? void 0 : p.style) || ""), u = A.get(l.node), d = r["margin-left"] === "auto" && r["margin-right"] === "auto" ? "center" : r["margin-right"] === "auto" ? "left" : r["margin-left"] === "auto" ? "right" : null, g = V(l.node, u), m = X(l.node);
|
|
@@ -111,8 +111,8 @@ const N = {
|
|
|
111
111
|
borderStyle: c["border-style"] || null,
|
|
112
112
|
collapseBorders: c["border-collapse"] === "collapse",
|
|
113
113
|
caption: o || void 0,
|
|
114
|
-
captionAlignment:
|
|
115
|
-
captionPosition:
|
|
114
|
+
captionAlignment: i["text-align"] || "",
|
|
115
|
+
captionPosition: i["caption-side"] || null,
|
|
116
116
|
headerRows: g.rows,
|
|
117
117
|
headerColumns: g.columns,
|
|
118
118
|
associateHeaders: g.rows || g.columns ? Y(l.node) : "none",
|
|
@@ -120,64 +120,64 @@ const N = {
|
|
|
120
120
|
className: ((b = l.node.attrs) == null ? void 0 : b.class) || ""
|
|
121
121
|
};
|
|
122
122
|
}, $ = (n) => {
|
|
123
|
-
const
|
|
124
|
-
return { node:
|
|
125
|
-
}, R = (n, t,
|
|
126
|
-
const o = $(
|
|
127
|
-
if (!n.doc.nodeAt(
|
|
123
|
+
const s = n.lastChild.lastChild;
|
|
124
|
+
return { node: s, pos: n.content.size - s.nodeSize };
|
|
125
|
+
}, R = (n, t, s, l, e) => {
|
|
126
|
+
const o = $(s), i = t + o.pos;
|
|
127
|
+
if (!n.doc.nodeAt(i))
|
|
128
128
|
return n;
|
|
129
|
-
const c = n.doc.resolve(
|
|
129
|
+
const c = n.doc.resolve(i), u = new U(c, c), d = n.tr.setSelection(u);
|
|
130
130
|
let g = n.apply(d);
|
|
131
131
|
for (let m = 0; m < l; m++)
|
|
132
132
|
e(g, (p) => {
|
|
133
133
|
g = g.apply(p);
|
|
134
134
|
});
|
|
135
135
|
return g;
|
|
136
|
-
}, x = (n, t,
|
|
136
|
+
}, x = (n, t, s, l) => {
|
|
137
137
|
let e = n;
|
|
138
|
-
for (let o = 0; o <
|
|
139
|
-
const
|
|
140
|
-
if (
|
|
141
|
-
const r = $(
|
|
138
|
+
for (let o = 0; o < s; o++) {
|
|
139
|
+
const i = e.doc.nodeAt(t);
|
|
140
|
+
if (i) {
|
|
141
|
+
const r = $(i), c = t + r.pos, u = e.doc.resolve(c), d = new U(u, u), g = e.tr.setSelection(d);
|
|
142
142
|
e = e.apply(g), l(e, (m) => {
|
|
143
143
|
e = e.apply(m);
|
|
144
144
|
});
|
|
145
145
|
}
|
|
146
146
|
}
|
|
147
147
|
return e;
|
|
148
|
-
}, Z = (n, t,
|
|
148
|
+
}, Z = (n, t, s, l) => {
|
|
149
149
|
let e = n, o = e.doc.nodeAt(t);
|
|
150
150
|
if (!o)
|
|
151
151
|
return e;
|
|
152
|
-
let
|
|
153
|
-
return
|
|
154
|
-
}, W = (n, t,
|
|
155
|
-
const l = n.doc.nodeAt(
|
|
152
|
+
let i = A.get(o);
|
|
153
|
+
return i.width === l && i.height === s || (l > i.width ? e = R(e, t, o, l - i.width, q) : l < i.width && (e = x(e, t, i.width - l, K)), o = e.doc.nodeAt(t), !o) || (i = A.get(o), s > i.height ? e = R(e, t, o, s - i.height, G) : s < i.height && (e = x(e, t, i.height - s, L))), e;
|
|
154
|
+
}, W = (n, t, s) => {
|
|
155
|
+
const l = n.doc.nodeAt(s);
|
|
156
156
|
if (!l)
|
|
157
157
|
return n;
|
|
158
158
|
let e = { ...l.attrs };
|
|
159
159
|
const o = t.width !== null && (t.widthUnit !== "%" || !t.caption && !t.position);
|
|
160
160
|
e = h(e, "width", o ? t.width + t.widthUnit : ""), e = h(e, "height", t.height !== null ? t.height + t.heightUnit : ""), e = h(e, "text-align", t.textAlign || ""), e = h(e, "background-color", t.backgroundColor || ""), e = h(e, "border-width", t.borderWidth ? t.borderWidth + "px" : ""), e = h(e, "border-style", t.borderStyle || ""), e = h(e, "border-color", t.borderColor || ""), e = h(e, "border-spacing", t.cellSpacing !== null ? t.cellSpacing + "px" : ""), t.cellSpacing !== null ? e = h(e, "border-collapse", "unset") : e = h(e, "border-collapse", t.collapseBorders ? "collapse" : "");
|
|
161
|
-
const
|
|
162
|
-
Object.keys(
|
|
163
|
-
e = h(e, c,
|
|
161
|
+
const i = k[t.position || ""] || {};
|
|
162
|
+
Object.keys(i).forEach((c) => {
|
|
163
|
+
e = h(e, c, i[c]);
|
|
164
164
|
}), e.id = t.id || null, e.class = t.className || null;
|
|
165
|
-
const r = n.tr.setNodeMarkup(
|
|
165
|
+
const r = n.tr.setNodeMarkup(s, null, e);
|
|
166
166
|
return n = n.apply(r), n;
|
|
167
|
-
}, H = (n, t,
|
|
167
|
+
}, H = (n, t, s, l, e) => {
|
|
168
168
|
if (t.type.name !== l.name || Object.keys(e).length > 0) {
|
|
169
|
-
const o = n.tr.setNodeMarkup(
|
|
169
|
+
const o = n.tr.setNodeMarkup(s, l, { ...t.attrs, ...e });
|
|
170
170
|
return n.apply(o);
|
|
171
171
|
}
|
|
172
172
|
return n;
|
|
173
173
|
}, I = (n, t) => {
|
|
174
174
|
/^cell-[0-9]+-[0-9]+$/.test(n.attrs.id || "") && (t.id = null);
|
|
175
|
-
}, ee = (n, t,
|
|
176
|
-
const l = n.doc.nodeAt(
|
|
175
|
+
}, ee = (n, t, s) => {
|
|
176
|
+
const l = n.doc.nodeAt(s), e = l && A.get(l);
|
|
177
177
|
if (!l || !e)
|
|
178
178
|
return n;
|
|
179
179
|
const o = z(e);
|
|
180
|
-
let
|
|
180
|
+
let i = n;
|
|
181
181
|
const { table_header: r, table_cell: c } = n.schema.nodes, u = String((/* @__PURE__ */ new Date()).getTime()), d = [], g = (p, a) => {
|
|
182
182
|
const b = `cell-${p}${a}-${u}`;
|
|
183
183
|
return d[p] || d.push([]), d[p][a] || d[p].push([]), d[p][a] = b, b;
|
|
@@ -196,43 +196,45 @@ const N = {
|
|
|
196
196
|
const y = l.nodeAt(b);
|
|
197
197
|
if (y) {
|
|
198
198
|
const w = f < t.headerColumns, E = a < t.headerRows, C = { ...y.attrs };
|
|
199
|
-
I(y, C), C.headers = null, C.scope = null, E || w ? (t.associateHeaders === "scope" && (C.scope = E ? "col" : "row"), t.associateHeaders === "id" && (C.id = g(a, f), (f > 0 || a > 0) && (C.headers = m(a, f, w, E) || null)),
|
|
199
|
+
I(y, C), C.headers = null, C.scope = null, E || w ? (t.associateHeaders === "scope" && (C.scope = E ? "col" : "row"), t.associateHeaders === "id" && (C.id = g(a, f), (f > 0 || a > 0) && (C.headers = m(a, f, w, E) || null)), i = H(i, y, s + b + 1, r, C)) : (t.associateHeaders === "id" && (C.headers = m(a, f, t.headerColumns > 0, t.headerRows > 0) || null), i = H(i, y, s + b + 1, c, C));
|
|
200
200
|
}
|
|
201
201
|
});
|
|
202
|
-
}),
|
|
203
|
-
}, te = (n, t,
|
|
202
|
+
}), i;
|
|
203
|
+
}, te = (n, t, s, l) => {
|
|
204
204
|
let e = { ...t.attrs };
|
|
205
205
|
return e = h(e, "margin-left", ""), e = h(e, "margin-right", ""), Object.keys(l || {}).forEach((o) => {
|
|
206
206
|
e = h(e, o, (l || {})[o] || "");
|
|
207
|
-
}), n.apply(n.tr.setNodeMarkup(
|
|
207
|
+
}), n.apply(n.tr.setNodeMarkup(s, null, e));
|
|
208
208
|
}, v = (n, t) => J("<p>" + n + "</p>", t).content.firstChild.content, M = (n, t) => {
|
|
209
209
|
if (!n.caption)
|
|
210
210
|
return;
|
|
211
|
-
let
|
|
212
|
-
n.captionAlignment && (
|
|
211
|
+
let s = { caption: "", style: "display: table-caption" };
|
|
212
|
+
n.captionAlignment && (s = h(s, "text-align", n.captionAlignment)), n.captionPosition && (s = h(s, "caption-side", n.captionPosition));
|
|
213
213
|
const l = v(n.caption, t);
|
|
214
|
-
return l && t.nodes.table_caption_external.createAndFill(
|
|
215
|
-
}, D = (n) => n.firstChild && n.firstChild.type.name === "table_caption_external", ne = (n, t,
|
|
214
|
+
return l && t.nodes.table_caption_external.createAndFill(s, l) || void 0;
|
|
215
|
+
}, D = (n) => n.firstChild && n.firstChild.type.name === "table_caption_external", ne = (n, t, s, l) => {
|
|
216
216
|
let e = n, o;
|
|
217
|
-
const
|
|
217
|
+
const i = s + 2, r = s + 1, c = e.schema;
|
|
218
218
|
if (D(t))
|
|
219
219
|
if (o = t.firstChild, l.caption) {
|
|
220
220
|
const u = v(l.caption, c);
|
|
221
221
|
if (e = e.apply(
|
|
222
|
-
e.tr.replaceWith(
|
|
222
|
+
e.tr.replaceWith(i, i + o.content.size, u)
|
|
223
223
|
), o = e.doc.nodeAt(r), o) {
|
|
224
224
|
let d = { ...o.attrs };
|
|
225
225
|
d = h(d, "text-align", l.captionAlignment || ""), d = h(d, "caption-side", l.captionPosition || ""), e = e.apply(e.tr.setNodeAttribute(r, "style", d.style));
|
|
226
226
|
}
|
|
227
227
|
} else
|
|
228
|
-
e = e.apply(
|
|
228
|
+
e = e.apply(
|
|
229
|
+
e.tr.deleteRange(i, i + o.content.size)
|
|
230
|
+
);
|
|
229
231
|
else
|
|
230
232
|
o = M(l, c), o && (e = e.apply(e.tr.replaceWith(r, r, o)));
|
|
231
233
|
return e;
|
|
232
|
-
}, oe = (n, t,
|
|
234
|
+
}, oe = (n, t, s, l, e) => {
|
|
233
235
|
let o = {
|
|
234
236
|
state: n,
|
|
235
|
-
pos:
|
|
237
|
+
pos: s
|
|
236
238
|
};
|
|
237
239
|
if (!l && (t.position || t.caption)) {
|
|
238
240
|
let r = { table: "", style: "display: table" };
|
|
@@ -242,37 +244,40 @@ const N = {
|
|
|
242
244
|
}), typeof t.width == "number" && t.widthUnit === "%" && (r = h(r, "width", t.width + t.widthUnit));
|
|
243
245
|
const g = M(t, n.schema);
|
|
244
246
|
g && c.push(g);
|
|
245
|
-
const m = n.doc.nodeAt(
|
|
247
|
+
const m = n.doc.nodeAt(s);
|
|
246
248
|
c.push(m);
|
|
247
249
|
const p = n.schema.nodes.table_wrapper.createAndFill(r, c);
|
|
248
250
|
if (p) {
|
|
249
|
-
const a = n.tr.replaceWith(
|
|
250
|
-
n = n.apply(a), o = { state: n, pos:
|
|
251
|
+
const a = n.tr.replaceWith(s, s + m.content.size, p);
|
|
252
|
+
n = n.apply(a), o = { state: n, pos: s };
|
|
251
253
|
}
|
|
252
254
|
} else
|
|
253
|
-
l && (t.position || t.caption || !t.caption && D(l.node)) ? (n = te(
|
|
254
|
-
|
|
255
|
-
|
|
255
|
+
l && (t.position || t.caption || !t.caption && D(l.node)) ? (n = te(
|
|
256
|
+
n,
|
|
257
|
+
l.node,
|
|
258
|
+
e,
|
|
259
|
+
t.position && k[t.position]
|
|
260
|
+
), n = ne(n, l.node, e, t), o = { state: n, pos: e }) : l && !(t.position || t.caption) ? o = { state: n, node: l.node, pos: n.selection.$from.start(l.depth) - 1 } : o = { state: n, pos: s };
|
|
261
|
+
const i = l && o.state.doc.nodeAt(e);
|
|
262
|
+
if (i) {
|
|
256
263
|
let r;
|
|
257
|
-
typeof t.width == "number" && t.widthUnit === "%" ? r = h(
|
|
264
|
+
typeof t.width == "number" && t.widthUnit === "%" ? r = h(i.attrs, "width", t.width + t.widthUnit) : t.widthUnit !== "%" && /%/.test(S(i.attrs.style || "").width || "") && (r = h(i.attrs, "width", "")), r && (o.state = o.state.apply(o.state.tr.setNodeMarkup(e, null, r)));
|
|
258
265
|
}
|
|
259
266
|
return o;
|
|
260
267
|
}, de = (n, t) => {
|
|
261
|
-
const
|
|
262
|
-
let l = T(i, (f) => f.type.spec.tableRole === "table");
|
|
268
|
+
const s = n.selection.$from, l = T(s, (f) => f.type.spec.tableRole === "table");
|
|
263
269
|
if (!l)
|
|
264
270
|
return;
|
|
265
|
-
const e =
|
|
271
|
+
const e = s.start(l.depth) - 1;
|
|
266
272
|
let o = Z(n, e, t.rows, t.columns);
|
|
267
273
|
if (!o)
|
|
268
274
|
return;
|
|
269
|
-
const
|
|
275
|
+
const i = o.tr;
|
|
270
276
|
Q(o).forEach((f) => {
|
|
271
277
|
let y = { ...f.node.attrs };
|
|
272
|
-
y = h(y, "padding", typeof t.cellPadding == "number" ? t.cellPadding + "px" : ""),
|
|
273
|
-
}), o = o.apply(
|
|
274
|
-
const r = T(
|
|
275
|
-
let u = oe(o, t, e, r, c);
|
|
278
|
+
y = h(y, "padding", typeof t.cellPadding == "number" ? t.cellPadding + "px" : ""), i.setNodeMarkup(f.pos, null, y);
|
|
279
|
+
}), o = o.apply(i), o = W(o, t, e), o = ee(o, t, e);
|
|
280
|
+
const r = T(s, (f) => f.type.name === "table_wrapper"), c = s.start((r == null ? void 0 : r.depth) || 0) - 1, u = oe(o, t, e, r, c);
|
|
276
281
|
o = u.state;
|
|
277
282
|
const d = u.pos, g = o.doc.nodeAt(u.pos);
|
|
278
283
|
if (!g)
|