@ebl-vue/editor-full 2.31.25 → 2.31.28
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/index.d.ts +1 -28
- package/dist/index.mjs +549 -727
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/types/index.d.ts +5 -1
- package/.postcssrc.yml +0 -33
- package/postcss.config.js +0 -15
- package/src/components/Editor/Editor.vue +0 -293
- package/src/components/Editor/EditorRender.vue +0 -274
- package/src/components/index.ts +0 -29
- package/src/constants/index.ts +0 -1
- package/src/i18n/zh-cn.ts +0 -158
- package/src/icons/index.ts +0 -93
- package/src/index.ts +0 -22
- package/src/installer.ts +0 -21
- package/src/plugins/alert/index.css +0 -150
- package/src/plugins/alert/index.ts +0 -456
- package/src/plugins/block-alignment/index.css +0 -9
- package/src/plugins/block-alignment/index.ts +0 -117
- package/src/plugins/block-alignment/readme.md +0 -1
- package/src/plugins/code/LICENSE +0 -21
- package/src/plugins/code/index.css +0 -214
- package/src/plugins/code/index.ts +0 -621
- package/src/plugins/code/utils/string.ts +0 -34
- package/src/plugins/color-picker/index.ts +0 -130
- package/src/plugins/color-picker/styles.css +0 -27
- package/src/plugins/delimiter/index.css +0 -14
- package/src/plugins/delimiter/index.ts +0 -121
- package/src/plugins/drag-drop/index.css +0 -19
- package/src/plugins/drag-drop/index.ts +0 -151
- package/src/plugins/drag-drop/readme.md +0 -1
- package/src/plugins/header/H1.ts +0 -404
- package/src/plugins/header/H2.ts +0 -403
- package/src/plugins/header/H3.ts +0 -404
- package/src/plugins/header/H4.ts +0 -404
- package/src/plugins/header/H5.ts +0 -403
- package/src/plugins/header/H6.ts +0 -404
- package/src/plugins/header/index.css +0 -20
- package/src/plugins/header/index.ts +0 -15
- package/src/plugins/header/types.d.ts +0 -46
- package/src/plugins/imageResizeCrop/ImageTune.ts +0 -916
- package/src/plugins/imageResizeCrop/index.css +0 -230
- package/src/plugins/imageResizeCrop/index.ts +0 -5
- package/src/plugins/imageResizeCrop/types.d.ts +0 -23
- package/src/plugins/imageTool/index.css +0 -156
- package/src/plugins/imageTool/index.ts +0 -538
- package/src/plugins/imageTool/types/codexteam__ajax.d.ts +0 -89
- package/src/plugins/imageTool/types/types.ts +0 -236
- package/src/plugins/imageTool/ui.ts +0 -313
- package/src/plugins/imageTool/uploader.ts +0 -272
- package/src/plugins/imageTool/utils/dom.ts +0 -24
- package/src/plugins/imageTool/utils/index.ts +0 -73
- package/src/plugins/imageTool/utils/isPromise.ts +0 -10
- package/src/plugins/indent/index.css +0 -86
- package/src/plugins/indent/index.ts +0 -695
- package/src/plugins/inline-code/index.css +0 -11
- package/src/plugins/inline-code/index.ts +0 -202
- package/src/plugins/list/ListRenderer/ChecklistRenderer.ts +0 -208
- package/src/plugins/list/ListRenderer/ListRenderer.ts +0 -73
- package/src/plugins/list/ListRenderer/OrderedListRenderer.ts +0 -123
- package/src/plugins/list/ListRenderer/UnorderedListRenderer.ts +0 -123
- package/src/plugins/list/ListRenderer/index.ts +0 -6
- package/src/plugins/list/ListTabulator/index.ts +0 -1179
- package/src/plugins/list/index.ts +0 -480
- package/src/plugins/list/styles/CssPrefix.ts +0 -4
- package/src/plugins/list/styles/input.css +0 -36
- package/src/plugins/list/styles/list.css +0 -165
- package/src/plugins/list/types/Elements.ts +0 -14
- package/src/plugins/list/types/ItemMeta.ts +0 -40
- package/src/plugins/list/types/ListParams.ts +0 -102
- package/src/plugins/list/types/ListRenderer.ts +0 -6
- package/src/plugins/list/types/OlCounterType.ts +0 -63
- package/src/plugins/list/types/index.ts +0 -14
- package/src/plugins/list/utils/focusItem.ts +0 -18
- package/src/plugins/list/utils/getChildItems.ts +0 -40
- package/src/plugins/list/utils/getItemChildWrapper.ts +0 -10
- package/src/plugins/list/utils/getItemContentElement.ts +0 -10
- package/src/plugins/list/utils/getSiblings.ts +0 -52
- package/src/plugins/list/utils/isLastItem.ts +0 -9
- package/src/plugins/list/utils/itemHasSublist.ts +0 -10
- package/src/plugins/list/utils/normalizeData.ts +0 -83
- package/src/plugins/list/utils/removeChildWrapperIfEmpty.ts +0 -31
- package/src/plugins/list/utils/renderToolboxInput.ts +0 -105
- package/src/plugins/list/utils/stripNumbers.ts +0 -7
- package/src/plugins/list/utils/type-guards.ts +0 -8
- package/src/plugins/marker/index.css +0 -4
- package/src/plugins/marker/index.ts +0 -199
- package/src/plugins/outline/index.css +0 -52
- package/src/plugins/outline/index.ts +0 -63
- package/src/plugins/paragraph/index.css +0 -23
- package/src/plugins/paragraph/index.ts +0 -381
- package/src/plugins/paragraph/types/icons.d.ts +0 -4
- package/src/plugins/paragraph/utils/makeFragment.ts +0 -17
- package/src/plugins/quote/index.css +0 -26
- package/src/plugins/quote/index.ts +0 -203
- package/src/plugins/table/index.ts +0 -4
- package/src/plugins/table/plugin.ts +0 -254
- package/src/plugins/table/style.css +0 -388
- package/src/plugins/table/table.ts +0 -1195
- package/src/plugins/table/toolbox.ts +0 -166
- package/src/plugins/table/utils/dom.ts +0 -130
- package/src/plugins/table/utils/popover.ts +0 -185
- package/src/plugins/table/utils/throttled.ts +0 -22
- package/src/plugins/underline/index.css +0 -3
- package/src/plugins/underline/index.ts +0 -214
- package/src/plugins/undo/index.ts +0 -524
- package/src/plugins/undo/observer.ts +0 -101
- package/src/style.css +0 -114
- package/src/types.ts +0 -3
- package/src/utils/AxiosService.ts +0 -87
- package/src/utils/index.ts +0 -15
- package/src/utils/install.ts +0 -19
- package/tsconfig.json +0 -37
- package/vite.config.ts +0 -81
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Create a DocumentFragment and fill it with HTML from a string
|
|
3
|
-
*
|
|
4
|
-
* @param {string} htmlString - A string of valid HTML
|
|
5
|
-
* @returns {DocumentFragment}
|
|
6
|
-
*/
|
|
7
|
-
export default function makeFragment(htmlString: string): DocumentFragment {
|
|
8
|
-
const tempDiv = document.createElement('div');
|
|
9
|
-
|
|
10
|
-
tempDiv.innerHTML = htmlString.trim();
|
|
11
|
-
|
|
12
|
-
const fragment = document.createDocumentFragment();
|
|
13
|
-
|
|
14
|
-
fragment.append(...Array.from(tempDiv.childNodes));
|
|
15
|
-
|
|
16
|
-
return fragment;
|
|
17
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
.cdx-quote {
|
|
3
|
-
overflow: hidden;
|
|
4
|
-
overflow-wrap: break-word;
|
|
5
|
-
margin: 0;
|
|
6
|
-
box-sizing: border-box;
|
|
7
|
-
word-wrap: break-word;
|
|
8
|
-
word-break: break-all;
|
|
9
|
-
}
|
|
10
|
-
.cdx-quote blockquote{
|
|
11
|
-
margin: 0;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
.cdx-block-quote{
|
|
18
|
-
border: solid #acacac;
|
|
19
|
-
border-width: 0 0 0 3px;
|
|
20
|
-
box-shadow: none;
|
|
21
|
-
color: #666;
|
|
22
|
-
line-height: 1.6em;
|
|
23
|
-
padding: 1px 0 0 12px;
|
|
24
|
-
text-align: left;
|
|
25
|
-
}
|
|
26
|
-
|
|
@@ -1,203 +0,0 @@
|
|
|
1
|
-
import "./index.css";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import { make } from "@editorjs/dom";
|
|
5
|
-
import type { API, BlockAPI, BlockTool } from "@ebl-vue/editorjs";
|
|
6
|
-
import { IconQuote } from "../../icons";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Data structure for the Quote block.
|
|
14
|
-
*/
|
|
15
|
-
export interface QuoteData {
|
|
16
|
-
text: string;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Parameters for the Quote constructor.
|
|
21
|
-
*/
|
|
22
|
-
interface QuoteParams {
|
|
23
|
-
data: QuoteData;
|
|
24
|
-
api: API;
|
|
25
|
-
readOnly: boolean;
|
|
26
|
-
block: BlockAPI;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* CSS class names used in the Quote block.
|
|
31
|
-
*/
|
|
32
|
-
interface QuoteCSS {
|
|
33
|
-
baseClass: string;
|
|
34
|
-
wrapper: string;
|
|
35
|
-
input: string;
|
|
36
|
-
text: string;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Quote class representing a customizable quote block for Editor.js.
|
|
43
|
-
*/
|
|
44
|
-
export default class Quote implements BlockTool {
|
|
45
|
-
api: API;
|
|
46
|
-
readOnly: boolean;
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
private _data: QuoteData;
|
|
50
|
-
private _CSS: QuoteCSS;
|
|
51
|
-
private _quoteElement!: HTMLElement;
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Creates an instance of the Quote block.
|
|
55
|
-
* @param params - The parameters for the Quote block.
|
|
56
|
-
*/
|
|
57
|
-
constructor({ data, api, readOnly }: QuoteParams) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
this.api = api;
|
|
61
|
-
this.readOnly = readOnly;
|
|
62
|
-
|
|
63
|
-
this._data = {
|
|
64
|
-
text: data.text || ""
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
this._CSS = {
|
|
68
|
-
baseClass: this.api.styles.block,
|
|
69
|
-
wrapper: "cdx-quote",
|
|
70
|
-
text: "cdx-quote__text",
|
|
71
|
-
input: this.api.styles.input,
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
static get isReadOnlySupported(): boolean {
|
|
77
|
-
return true;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
static get toolbox() {
|
|
81
|
-
return {
|
|
82
|
-
icon: IconQuote,
|
|
83
|
-
title: "Quote",
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
static get contentless(): boolean {
|
|
88
|
-
return true;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
static get enableLineBreaks(): boolean {
|
|
92
|
-
return true;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
static get conversionConfig() {
|
|
98
|
-
return {
|
|
99
|
-
import: "text",
|
|
100
|
-
|
|
101
|
-
export: function (quoteData: QuoteData): string {
|
|
102
|
-
return quoteData.text;
|
|
103
|
-
},
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
get CSS(): QuoteCSS {
|
|
109
|
-
return {
|
|
110
|
-
baseClass: this.api.styles.block,
|
|
111
|
-
wrapper: "cdx-quote",
|
|
112
|
-
text: "cdx-quote__text",
|
|
113
|
-
input: this.api.styles.input,
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
render(): HTMLElement {
|
|
120
|
-
const container = make("div", [this._CSS.baseClass, this._CSS.wrapper]);
|
|
121
|
-
this._quoteElement = make(
|
|
122
|
-
"blockquote",
|
|
123
|
-
[this._CSS.input, this._CSS.text, "cdx-block-quote"],
|
|
124
|
-
{
|
|
125
|
-
contentEditable: !this.readOnly,
|
|
126
|
-
innerHTML: this._data.text,
|
|
127
|
-
}
|
|
128
|
-
);
|
|
129
|
-
|
|
130
|
-
this._quoteElement.addEventListener("keydown", (event: KeyboardEvent) =>
|
|
131
|
-
this.handleKeydown(event)
|
|
132
|
-
);
|
|
133
|
-
|
|
134
|
-
container.appendChild(this._quoteElement);
|
|
135
|
-
return container;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
get currentItem(): HTMLElement {
|
|
140
|
-
let currentNode = window.getSelection()!.anchorNode;
|
|
141
|
-
|
|
142
|
-
if (currentNode!.nodeType !== Node.ELEMENT_NODE) {
|
|
143
|
-
currentNode = currentNode!.parentNode;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
return (currentNode as Element).closest(`.${this.CSS.text}`) as HTMLElement;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
handleKeydown(event: KeyboardEvent) {
|
|
151
|
-
const currentItem = this._quoteElement;
|
|
152
|
-
|
|
153
|
-
if (event.key === "Enter") {
|
|
154
|
-
if (!event.shiftKey) {
|
|
155
|
-
event.preventDefault();
|
|
156
|
-
this.getOutOfQuote();
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
if (
|
|
161
|
-
event.key === "Backspace" &&
|
|
162
|
-
currentItem.textContent?.trim().length === 0
|
|
163
|
-
) {
|
|
164
|
-
event.preventDefault();
|
|
165
|
-
|
|
166
|
-
const currentBlockIndex = this.api.blocks.getCurrentBlockIndex();
|
|
167
|
-
this.api.blocks.delete(currentBlockIndex);
|
|
168
|
-
this.api.blocks.insert("paragraph", { text: "" });
|
|
169
|
-
this.api.caret.setToBlock(currentBlockIndex);
|
|
170
|
-
|
|
171
|
-
return;
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
getOutOfQuote() {
|
|
177
|
-
this.api.blocks.insert();
|
|
178
|
-
this.api.caret.setToBlock(this.api.blocks.getCurrentBlockIndex());
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
save(quoteElement: HTMLDivElement): QuoteData {
|
|
185
|
-
const text = quoteElement.querySelector(`.${this._CSS.text}`);
|
|
186
|
-
|
|
187
|
-
return Object.assign(this._data, {
|
|
188
|
-
text: text?.innerHTML ?? "",
|
|
189
|
-
});
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
static get sanitize() {
|
|
193
|
-
return {
|
|
194
|
-
text: {
|
|
195
|
-
br: true,
|
|
196
|
-
},
|
|
197
|
-
};
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
}
|
|
@@ -1,254 +0,0 @@
|
|
|
1
|
-
import Table from './table';
|
|
2
|
-
import * as $ from './utils/dom';
|
|
3
|
-
|
|
4
|
-
import { IconTable, IconTableWithHeadings, IconTableWithoutHeadings } from '../../icons';
|
|
5
|
-
import type { BlockTool, BlockToolConstructorOptions,PasteEvent } from '@ebl-vue/editorjs';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* @typedef {object} TableData - configuration that the user can set for the table
|
|
9
|
-
* @property {number} rows - number of rows in the table
|
|
10
|
-
* @property {number} cols - number of columns in the table
|
|
11
|
-
*/
|
|
12
|
-
/**
|
|
13
|
-
* @typedef {object} Tune - setting for the table
|
|
14
|
-
* @property {string} name - tune name
|
|
15
|
-
* @property {HTMLElement} icon - icon for the tune
|
|
16
|
-
* @property {boolean} isActive - default state of the tune
|
|
17
|
-
* @property {void} setTune - set tune state to the table data
|
|
18
|
-
*/
|
|
19
|
-
/**
|
|
20
|
-
* @typedef {object} TableConfig - object with the data transferred to form a table
|
|
21
|
-
* @property {boolean} withHeading - setting to use cells of the first row as headings
|
|
22
|
-
* @property {string[][]} content - two-dimensional array which contains table content
|
|
23
|
-
*/
|
|
24
|
-
/**
|
|
25
|
-
* @typedef {object} TableConstructor
|
|
26
|
-
* @property {TableConfig} data — previously saved data
|
|
27
|
-
* @property {TableConfig} config - user config for Tool
|
|
28
|
-
* @property {object} api - Editor.js API
|
|
29
|
-
* @property {boolean} readOnly - read-only mode flag
|
|
30
|
-
*/
|
|
31
|
-
/**
|
|
32
|
-
* @typedef {import('@editorjs/editorjs').PasteEvent} PasteEvent
|
|
33
|
-
*/
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Table block for Editor.js
|
|
38
|
-
*/
|
|
39
|
-
export default class TableBlock implements BlockTool {
|
|
40
|
-
private api: any;
|
|
41
|
-
private data: any;
|
|
42
|
-
private config: any;
|
|
43
|
-
private container: any;
|
|
44
|
-
//private block: any;
|
|
45
|
-
private readOnly: any;
|
|
46
|
-
private table: any;
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Notify core that read-only mode is supported
|
|
50
|
-
*
|
|
51
|
-
* @returns {boolean}
|
|
52
|
-
*/
|
|
53
|
-
static get isReadOnlySupported() {
|
|
54
|
-
return true;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Allow to press Enter inside the CodeTool textarea
|
|
59
|
-
*
|
|
60
|
-
* @returns {boolean}
|
|
61
|
-
* @public
|
|
62
|
-
*/
|
|
63
|
-
static get enableLineBreaks() {
|
|
64
|
-
return true;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* Render plugin`s main Element and fill it with saved data
|
|
69
|
-
*
|
|
70
|
-
* @param {TableConstructor} init
|
|
71
|
-
*/
|
|
72
|
-
constructor({ data, config, api, readOnly, block }: BlockToolConstructorOptions) {
|
|
73
|
-
this.api = api;
|
|
74
|
-
this.readOnly = readOnly;
|
|
75
|
-
this.config = config;
|
|
76
|
-
this.data = {
|
|
77
|
-
withHeadings: this.getConfig('withHeadings', undefined, data),
|
|
78
|
-
stretched: this.getConfig('stretched', undefined, data),
|
|
79
|
-
content: data && data.content ? data.content : [],
|
|
80
|
-
colWidth: data && data.colWidth ? data.colWidth : []
|
|
81
|
-
};
|
|
82
|
-
this.table = null;
|
|
83
|
-
//this.block = block;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Get Tool toolbox settings
|
|
88
|
-
* icon - Tool icon's SVG
|
|
89
|
-
* title - title to show in toolbox
|
|
90
|
-
*
|
|
91
|
-
* @returns {{icon: string, title: string}}
|
|
92
|
-
*/
|
|
93
|
-
static get toolbox() {
|
|
94
|
-
return {
|
|
95
|
-
icon: IconTable,
|
|
96
|
-
title: 'Table'
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* Return Tool's view
|
|
102
|
-
*
|
|
103
|
-
* @returns {HTMLDivElement}
|
|
104
|
-
*/
|
|
105
|
-
render() {
|
|
106
|
-
/** creating table */
|
|
107
|
-
this.table = new Table(this.readOnly, this.api, this.data, this.config);
|
|
108
|
-
|
|
109
|
-
/** creating container around table */
|
|
110
|
-
this.container = $.make('div', this.api.styles.block);
|
|
111
|
-
|
|
112
|
-
this.container.appendChild(this.table.getWrapper());
|
|
113
|
-
|
|
114
|
-
this.table.setHeadingsSetting(this.data.withHeadings);
|
|
115
|
-
|
|
116
|
-
return this.container;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* Returns plugin settings
|
|
121
|
-
*
|
|
122
|
-
* @returns {Array}
|
|
123
|
-
*/
|
|
124
|
-
renderSettings() {
|
|
125
|
-
return [
|
|
126
|
-
{
|
|
127
|
-
label: this.api.i18n.t('With headings'),
|
|
128
|
-
icon: IconTableWithHeadings,
|
|
129
|
-
isActive: this.data.withHeadings,
|
|
130
|
-
closeOnActivate: true,
|
|
131
|
-
toggle: true,
|
|
132
|
-
hint: {
|
|
133
|
-
title: this.api.i18n.t('With headings')
|
|
134
|
-
},
|
|
135
|
-
onActivate: () => {
|
|
136
|
-
this.data.withHeadings = true;
|
|
137
|
-
this.table.setHeadingsSetting(this.data.withHeadings);
|
|
138
|
-
}
|
|
139
|
-
}, {
|
|
140
|
-
label: this.api.i18n.t('Without headings'),
|
|
141
|
-
icon: IconTableWithoutHeadings,
|
|
142
|
-
isActive: !this.data.withHeadings,
|
|
143
|
-
closeOnActivate: true,
|
|
144
|
-
toggle: true,
|
|
145
|
-
hint: {
|
|
146
|
-
title: this.api.i18n.t('Without headings')
|
|
147
|
-
},
|
|
148
|
-
onActivate: () => {
|
|
149
|
-
this.data.withHeadings = false;
|
|
150
|
-
this.table.setHeadingsSetting(this.data.withHeadings);
|
|
151
|
-
}
|
|
152
|
-
},
|
|
153
|
-
// {
|
|
154
|
-
// label: this.data.stretched ? this.api.i18n.t('Collapse') : this.api.i18n.t('Stretch'),
|
|
155
|
-
// icon: this.data.stretched ? IconCollapse : IconStretch,
|
|
156
|
-
// closeOnActivate: true,
|
|
157
|
-
// toggle: true,
|
|
158
|
-
// onActivate: () => {
|
|
159
|
-
// this.data.stretched = !this.data.stretched;
|
|
160
|
-
// this.block.stretched = this.data.stretched;
|
|
161
|
-
// }
|
|
162
|
-
// }
|
|
163
|
-
];
|
|
164
|
-
}
|
|
165
|
-
/**
|
|
166
|
-
* Extract table data from the view
|
|
167
|
-
*
|
|
168
|
-
* @returns {TableData} - saved data
|
|
169
|
-
*/
|
|
170
|
-
save() {
|
|
171
|
-
const tableContent = this.table.getData();
|
|
172
|
-
|
|
173
|
-
const result = {
|
|
174
|
-
withHeadings: this.data.withHeadings,
|
|
175
|
-
stretched: this.data.stretched,
|
|
176
|
-
content: tableContent
|
|
177
|
-
};
|
|
178
|
-
|
|
179
|
-
return result;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
/**
|
|
183
|
-
* Plugin destroyer
|
|
184
|
-
*
|
|
185
|
-
* @returns {void}
|
|
186
|
-
*/
|
|
187
|
-
destroy() {
|
|
188
|
-
this.table.destroy();
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
/**
|
|
192
|
-
* A helper to get config value.
|
|
193
|
-
*
|
|
194
|
-
* @param {string} configName - the key to get from the config.
|
|
195
|
-
* @param {any} defaultValue - default value if config doesn't have passed key
|
|
196
|
-
* @param {object} savedData - previously saved data. If passed, the key will be got from there, otherwise from the config
|
|
197
|
-
* @returns {any} - config value.
|
|
198
|
-
*/
|
|
199
|
-
getConfig(configName: string, defaultValue = undefined, savedData = undefined) {
|
|
200
|
-
const data = this.data || savedData;
|
|
201
|
-
|
|
202
|
-
if (data) {
|
|
203
|
-
return data[configName] ? data[configName] : defaultValue;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
return this.config && this.config[configName] ? this.config[configName] : defaultValue;
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
/**
|
|
210
|
-
* Table onPaste configuration
|
|
211
|
-
*
|
|
212
|
-
* @public
|
|
213
|
-
*/
|
|
214
|
-
static get pasteConfig() {
|
|
215
|
-
return { tags: ['TABLE', 'TR', 'TH', 'TD'] };
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
/**
|
|
219
|
-
* On paste callback that is fired from Editor
|
|
220
|
-
*
|
|
221
|
-
* @param {PasteEvent} event - event with pasted data
|
|
222
|
-
*/
|
|
223
|
-
onPaste(event: PasteEvent) {
|
|
224
|
-
if ('data' in event.detail) {
|
|
225
|
-
const table = event.detail.data as HTMLElement;
|
|
226
|
-
|
|
227
|
-
/** Check if the first row is a header */
|
|
228
|
-
const firstRowHeading = table.querySelector(':scope > thead, tr:first-of-type th');
|
|
229
|
-
|
|
230
|
-
/** Get all rows from the table */
|
|
231
|
-
const rows = Array.from(table.querySelectorAll('tr'));
|
|
232
|
-
|
|
233
|
-
/** Generate a content matrix */
|
|
234
|
-
const content = rows.map((row) => {
|
|
235
|
-
/** Get cells from row */
|
|
236
|
-
const cells = Array.from(row.querySelectorAll('th, td'))
|
|
237
|
-
|
|
238
|
-
/** Return cells content */
|
|
239
|
-
return cells.map((cell) => cell.innerHTML);
|
|
240
|
-
});
|
|
241
|
-
|
|
242
|
-
/** Update Tool's data */
|
|
243
|
-
this.data = {
|
|
244
|
-
withHeadings: firstRowHeading !== null,
|
|
245
|
-
content
|
|
246
|
-
};
|
|
247
|
-
|
|
248
|
-
/** Update table block */
|
|
249
|
-
if (this.table.wrapper) {
|
|
250
|
-
this.table.wrapper.replaceWith(this.render());
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
}
|