@chenyomi/leafer-htmltext-editor 1.0.0 → 1.0.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/dist/TextEditTool/index.d.ts +2 -1
- package/dist/TextEditTool/index.d.ts.map +1 -1
- package/dist/TextEditTool/index.js +43 -69
- package/dist/TextEditTool/utils.d.ts.map +1 -1
- package/dist/TextEditTool/utils.js +96 -13
- package/dist/TextEditor.d.ts +9 -6
- package/dist/TextEditor.d.ts.map +1 -1
- package/dist/TextEditor.js +65 -63
- package/dist/esm/TextEditTool/index.d.ts +2 -1
- package/dist/esm/TextEditTool/index.d.ts.map +1 -1
- package/dist/esm/TextEditTool/index.js +45 -71
- package/dist/esm/TextEditTool/utils.d.ts.map +1 -1
- package/dist/esm/TextEditTool/utils.js +96 -13
- package/dist/esm/TextEditor.d.ts +9 -6
- package/dist/esm/TextEditor.d.ts.map +1 -1
- package/dist/esm/TextEditor.js +65 -63
- package/dist/esm/index.d.ts +17 -6
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/utils.d.ts +1 -1
- package/dist/esm/utils.d.ts.map +1 -1
- package/dist/esm/utils.js +29 -48
- package/dist/index.d.ts +17 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +134 -77
- package/dist/index.js +168 -87
- package/dist/utils.d.ts +1 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +29 -48
- package/package.json +3 -3
- package/src/TextEditTool/index.ts +78 -84
- package/src/TextEditTool/utils.ts +101 -29
- package/src/TextEditor.ts +103 -90
- package/src/index.ts +145 -83
- package/src/utils.ts +140 -178
package/dist/esm/utils.js
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
function getEditorContext() {
|
|
3
|
-
const quill = TextEditor.quill;
|
|
4
|
-
return { quill };
|
|
5
|
-
}
|
|
1
|
+
import { quillManager } from '.';
|
|
6
2
|
export const updataHtmlText = async (e, base64font, fontObj) => {
|
|
7
3
|
const { scaleX, scaleY } = e.worldTransform;
|
|
8
4
|
const zoomScale = Math.max(Math.abs(scaleX), Math.abs(scaleY));
|
|
@@ -22,18 +18,14 @@ export const updataHtmlText = async (e, base64font, fontObj) => {
|
|
|
22
18
|
if (dom && e.data.textData?.textShadow) {
|
|
23
19
|
dom.style.textShadow = e.data.textData.textShadow;
|
|
24
20
|
}
|
|
25
|
-
else
|
|
21
|
+
else {
|
|
26
22
|
dom.style.textShadow = 'none';
|
|
27
23
|
}
|
|
28
24
|
if (dom && e.data.textData?.alignContent) {
|
|
29
25
|
const qlEditor = dom.querySelector('.ql-editor');
|
|
30
|
-
|
|
31
|
-
qlEditor.style.alignContent = e.data.textData.alignContent;
|
|
32
|
-
}
|
|
26
|
+
qlEditor.style.alignContent = e.data.textData.alignContent;
|
|
33
27
|
}
|
|
34
|
-
const
|
|
35
|
-
if (!quill)
|
|
36
|
-
return;
|
|
28
|
+
const quill = quillManager.getQuill();
|
|
37
29
|
const html = quill.getSemanticHTML();
|
|
38
30
|
if (html === '<p></p>') {
|
|
39
31
|
if (e.text.includes('<style>@font-face')) {
|
|
@@ -72,9 +64,6 @@ export const updataHtmlText = async (e, base64font, fontObj) => {
|
|
|
72
64
|
}
|
|
73
65
|
};
|
|
74
66
|
const addFontSizeToP = (e, html, fontSize = 16, lineHeight = '1.5', letterSpacing = '0', textShadow = 'none', alignContent = 'start') => {
|
|
75
|
-
const { quill } = getEditorContext();
|
|
76
|
-
if (!quill)
|
|
77
|
-
return html;
|
|
78
67
|
const { scaleX, scaleY } = e.worldTransform;
|
|
79
68
|
const zoomScale = Math.max(Math.abs(scaleX), Math.abs(scaleY));
|
|
80
69
|
const wrapper = document.createElement('div');
|
|
@@ -94,6 +83,7 @@ const addFontSizeToP = (e, html, fontSize = 16, lineHeight = '1.5', letterSpacin
|
|
|
94
83
|
}
|
|
95
84
|
let height;
|
|
96
85
|
const div = document.querySelector('#textInnerEditor');
|
|
86
|
+
const quill = quillManager.getQuill();
|
|
97
87
|
const actualHeight = Number((quill.scroll.domNode.scrollHeight / zoomScale).toFixed(0));
|
|
98
88
|
const actualWidth = Number((quill.scroll.domNode.scrollWidth / zoomScale).toFixed(0));
|
|
99
89
|
if (['center', 'end'].includes(e.data.textData.alignContent)) {
|
|
@@ -113,7 +103,7 @@ const addFontSizeToP = (e, html, fontSize = 16, lineHeight = '1.5', letterSpacin
|
|
|
113
103
|
height = `${e.parent.height}px`;
|
|
114
104
|
}
|
|
115
105
|
}
|
|
116
|
-
const style = `<style>sub,sup{font-size:63%;}.ql-ui{position:absolute}ol,ul{counter-reset:list-0;padding-left:1.5em;margin:0}ol>li,ul>li{counter-increment:list-0;list-style-type:none;position:relative;padding-left:0;margin:0}ol>li::before{content:counter(list-0,decimal) '. ';position:absolute;left:-1.5em;width:1.2em;text-align:right}ul>li::before{content:'
|
|
106
|
+
const style = `<style>sub,sup{font-size:63%;}.ql-ui{position:absolute}ol,ul{counter-reset:list-0;padding-left:1.5em;margin:0}ol>li,ul>li{counter-increment:list-0;list-style-type:none;position:relative;padding-left:0;margin:0}ol>li::before{content:counter(list-0,decimal) '. ';position:absolute;left:-1.5em;width:1.2em;text-align:right}ul>li::before{content:'\u2022';position:absolute;left:-1.5em;width:1.2em;text-align:right}li[data-list]{counter-set:list-1 list-2 list-3 list-4 list-5 list-6 list-7 list-8 list-9}.ql-align-center{text-align:center}.ql-align-right{text-align:right}.ql-align-left{text-align:left}.ql-align-justify{text-align:justify}</style>`;
|
|
117
107
|
let divBox = '';
|
|
118
108
|
if (e.parent.children[0].tag.includes('Shape')) {
|
|
119
109
|
divBox =
|
|
@@ -136,25 +126,18 @@ const addFontSizeToP = (e, html, fontSize = 16, lineHeight = '1.5', letterSpacin
|
|
|
136
126
|
console.log(divBox, '最终的html内容');
|
|
137
127
|
return divBox;
|
|
138
128
|
};
|
|
139
|
-
export const setHTMLText = (key, value, base64font
|
|
140
|
-
const
|
|
129
|
+
export const setHTMLText = (key, value, base64font) => {
|
|
130
|
+
const quill = quillManager.getQuill();
|
|
131
|
+
const { editor, canvas } = quillManager.getCanvas();
|
|
132
|
+
console.log(editor, quillManager.getCanvas(), 'editor');
|
|
141
133
|
if (!quill) {
|
|
142
|
-
console.error('Quill editor not initialized');
|
|
143
134
|
return;
|
|
144
135
|
}
|
|
145
|
-
const
|
|
146
|
-
|
|
147
|
-
if (range && isInnerEditor) {
|
|
148
|
-
quill.setSelection(range.index, range.length);
|
|
149
|
-
}
|
|
150
|
-
if (!editor || !editor.dateEdit) {
|
|
151
|
-
console.warn('Editor context not available for dateEdit');
|
|
152
|
-
return;
|
|
153
|
-
}
|
|
154
|
-
editor.dateEdit(async (e) => {
|
|
136
|
+
const range = JSON.parse(localStorage.getItem('selection-change') || '{}');
|
|
137
|
+
quillManager.dateEdit(async (e) => {
|
|
155
138
|
if (key === 'font') {
|
|
156
139
|
const fontSimpleName = value.code.replace(/\s+/g, '');
|
|
157
|
-
if (
|
|
140
|
+
if (editor.innerEditing) {
|
|
158
141
|
if (range && range.length) {
|
|
159
142
|
quill.formatText(range.index, range.length, key, fontSimpleName);
|
|
160
143
|
}
|
|
@@ -164,18 +147,18 @@ export const setHTMLText = (key, value, base64font, editor, isInnerEditor) => {
|
|
|
164
147
|
updataHtmlText(e, base64font ?? null, value ?? null);
|
|
165
148
|
}
|
|
166
149
|
else {
|
|
167
|
-
|
|
150
|
+
quillManager.isMultiSelect() && quill.clipboard.dangerouslyPasteHTML(e.text);
|
|
168
151
|
quill.formatText(0, quill.getLength() - 1, key, fontSimpleName);
|
|
169
152
|
updataHtmlText(e, base64font ?? null, value ?? null);
|
|
170
153
|
}
|
|
171
154
|
}
|
|
172
155
|
else if (key === 'fontSize') {
|
|
173
156
|
e.data.textData[key] = value;
|
|
174
|
-
|
|
157
|
+
quillManager.isMultiSelect() && quill.clipboard.dangerouslyPasteHTML(e.text);
|
|
175
158
|
updataHtmlText(e, base64font ?? null);
|
|
176
159
|
}
|
|
177
160
|
else if (key === 'textCase') {
|
|
178
|
-
if (
|
|
161
|
+
if (editor.innerEditing) {
|
|
179
162
|
const text = quill.getText(range.index, range.length);
|
|
180
163
|
const formats = quill.getFormat(range.index, range.length);
|
|
181
164
|
quill.deleteText(range.index, range.length);
|
|
@@ -190,16 +173,14 @@ export const setHTMLText = (key, value, base64font, editor, isInnerEditor) => {
|
|
|
190
173
|
convertedText = text.toUpperCase();
|
|
191
174
|
}
|
|
192
175
|
quill.insertText(range.index, convertedText, formats);
|
|
193
|
-
|
|
194
|
-
quill.setSelection(range.index, range.length);
|
|
195
|
-
}
|
|
176
|
+
range && editor.innerEditing && quill.setSelection(range.index, range.length);
|
|
196
177
|
}
|
|
197
178
|
}
|
|
198
179
|
else if (key === 'script') {
|
|
199
180
|
let val = 'sub';
|
|
200
181
|
if (value === 'super')
|
|
201
182
|
val = 'sup';
|
|
202
|
-
if (
|
|
183
|
+
if (editor.innerEditing) {
|
|
203
184
|
if (range && range.length) {
|
|
204
185
|
quill.formatText(range.index, range.length, key, quill.getFormat(range).script === value ? false : val);
|
|
205
186
|
}
|
|
@@ -208,14 +189,14 @@ export const setHTMLText = (key, value, base64font, editor, isInnerEditor) => {
|
|
|
208
189
|
}
|
|
209
190
|
}
|
|
210
191
|
else {
|
|
211
|
-
|
|
192
|
+
quillManager.isMultiSelect() && quill.clipboard.dangerouslyPasteHTML(e.text);
|
|
212
193
|
quill.formatText(0, quill.getLength() - 1, key, quill.getFormat().script === value ? false : val);
|
|
213
194
|
updataHtmlText(e);
|
|
214
195
|
}
|
|
215
196
|
}
|
|
216
197
|
else if (key === 'align') {
|
|
217
|
-
|
|
218
|
-
if (
|
|
198
|
+
quillManager.isMultiSelect() && quill.clipboard.dangerouslyPasteHTML(e.text);
|
|
199
|
+
if (editor.innerEditing) {
|
|
219
200
|
quill.format(key, value);
|
|
220
201
|
}
|
|
221
202
|
else {
|
|
@@ -224,28 +205,28 @@ export const setHTMLText = (key, value, base64font, editor, isInnerEditor) => {
|
|
|
224
205
|
updataHtmlText(e);
|
|
225
206
|
}
|
|
226
207
|
else if (key === 'alignContent') {
|
|
227
|
-
|
|
208
|
+
quillManager.isMultiSelect() && quill.clipboard.dangerouslyPasteHTML(e.text);
|
|
228
209
|
e.data.textData[key] = value;
|
|
229
210
|
updataHtmlText(e);
|
|
230
211
|
}
|
|
231
212
|
else if (key === 'color') {
|
|
232
|
-
|
|
213
|
+
quillManager.isMultiSelect() && quill.clipboard.dangerouslyPasteHTML(e.text);
|
|
233
214
|
quill.formatText(0, quill.getLength() - 1, key, value);
|
|
234
215
|
if (e.tag === 'HTMLText') {
|
|
235
216
|
updataHtmlText(e);
|
|
236
217
|
}
|
|
237
|
-
else if (e.parent.findOne
|
|
218
|
+
else if (e.parent.findOne('HTMLText')) {
|
|
238
219
|
updataHtmlText(e.parent.findOne('HTMLText'));
|
|
239
220
|
}
|
|
240
221
|
}
|
|
241
222
|
else if (key === 'textShadow') {
|
|
242
|
-
|
|
223
|
+
quillManager.isMultiSelect() && quill.clipboard.dangerouslyPasteHTML(e.text);
|
|
243
224
|
e.data.textData[key] = value;
|
|
244
225
|
updataHtmlText(e);
|
|
245
226
|
}
|
|
246
227
|
else if (key === 'list') {
|
|
247
|
-
|
|
248
|
-
if (
|
|
228
|
+
quillManager.isMultiSelect() && quill.clipboard.dangerouslyPasteHTML(e.text);
|
|
229
|
+
if (editor.innerEditing) {
|
|
249
230
|
const [line] = quill.getLine(range?.index || 0);
|
|
250
231
|
if (line.formats().list) {
|
|
251
232
|
quill.format(key, false);
|
|
@@ -266,7 +247,7 @@ export const setHTMLText = (key, value, base64font, editor, isInnerEditor) => {
|
|
|
266
247
|
updataHtmlText(e);
|
|
267
248
|
}
|
|
268
249
|
else {
|
|
269
|
-
if (
|
|
250
|
+
if (editor.innerEditing) {
|
|
270
251
|
if (range && range.length) {
|
|
271
252
|
quill.formatText(range.index, range.length, key, !quill.getFormat(range)[key]);
|
|
272
253
|
}
|
|
@@ -275,7 +256,7 @@ export const setHTMLText = (key, value, base64font, editor, isInnerEditor) => {
|
|
|
275
256
|
}
|
|
276
257
|
}
|
|
277
258
|
else {
|
|
278
|
-
|
|
259
|
+
quillManager.isMultiSelect() && quill.clipboard.dangerouslyPasteHTML(e.text);
|
|
279
260
|
quill.formatText(0, quill.getLength() - 1, key, !quill.getFormat()[key]);
|
|
280
261
|
updataHtmlText(e);
|
|
281
262
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,18 @@
|
|
|
1
|
-
export { TextEditor } from
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
export { TextEditor } from './TextEditor';
|
|
2
|
+
import './TextEditTool';
|
|
3
|
+
import Quill from 'quill';
|
|
4
|
+
declare class QuillManager {
|
|
5
|
+
private static instance;
|
|
6
|
+
private quill;
|
|
7
|
+
app_: any | null;
|
|
8
|
+
private constructor();
|
|
9
|
+
static getInstance(): QuillManager;
|
|
10
|
+
init(app: any): Quill;
|
|
11
|
+
getQuill(): Quill;
|
|
12
|
+
getCanvas(): any;
|
|
13
|
+
private registerFonts;
|
|
14
|
+
isMultiSelect(): boolean;
|
|
15
|
+
dateEdit(callback: (leaf: any) => void, level?: number, listNew?: any): void;
|
|
16
|
+
}
|
|
17
|
+
export declare const quillManager: QuillManager;
|
|
7
18
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAEzC,OAAO,gBAAgB,CAAA;AAGvB,OAAO,KAAgB,MAAM,OAAO,CAAA;AAEpC,cAAM,YAAY;IAChB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAc;IACrC,OAAO,CAAC,KAAK,CAAqB;IAC3B,IAAI,EAAE,GAAG,GAAG,IAAI,CAAO;IAE9B,OAAO;IAEP,MAAM,CAAC,WAAW;IAQlB,IAAI,CAAC,GAAG,EAAE,GAAG;IAgDb,QAAQ;IAOR,SAAS;IAOT,OAAO,CAAC,aAAa;IA+Bd,aAAa,IAAI,OAAO;IAQxB,QAAQ,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,IAAI,EAAE,KAAK,SAAI,EAAE,OAAO,CAAC,EAAE,GAAG,GAAG,IAAI;CA4B/E;AAED,eAAO,MAAM,YAAY,cAA6B,CAAA"}
|
package/dist/index.esm.js
CHANGED
|
@@ -1,79 +1,136 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
import { Delta } from
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
document.
|
|
1
|
+
export { TextEditor } from './TextEditor';
|
|
2
|
+
import { Plugin } from '@leafer-ui/core';
|
|
3
|
+
import './TextEditTool';
|
|
4
|
+
Plugin.add('text-editor2', 'editor');
|
|
5
|
+
import Quill, { Delta } from 'quill';
|
|
6
|
+
class QuillManager {
|
|
7
|
+
constructor() {
|
|
8
|
+
this.quill = null;
|
|
9
|
+
this.app_ = null;
|
|
10
|
+
}
|
|
11
|
+
static getInstance() {
|
|
12
|
+
if (!QuillManager.instance) {
|
|
13
|
+
QuillManager.instance = new QuillManager();
|
|
14
|
+
}
|
|
15
|
+
return QuillManager.instance;
|
|
16
|
+
}
|
|
17
|
+
init(app) {
|
|
18
|
+
this.app_ = app;
|
|
19
|
+
if (this.quill)
|
|
20
|
+
return this.quill;
|
|
21
|
+
let el = document.getElementById('textInnerEditor');
|
|
22
|
+
if (!el) {
|
|
23
|
+
el = document.createElement('div');
|
|
24
|
+
el.id = 'textInnerEditor';
|
|
25
|
+
el.style.position = 'fixed';
|
|
26
|
+
el.style.transformOrigin = 'left top';
|
|
27
|
+
el.style.overflowWrap = 'break-word';
|
|
28
|
+
el.style.wordBreak = 'break-all';
|
|
29
|
+
el.style.visibility = 'hidden';
|
|
30
|
+
document.body.appendChild(el);
|
|
31
|
+
}
|
|
32
|
+
this.quill = new Quill('#textInnerEditor', {
|
|
33
|
+
theme: undefined,
|
|
34
|
+
modules: {
|
|
35
|
+
toolbar: false,
|
|
36
|
+
keyboard: {
|
|
37
|
+
bindings: {
|
|
38
|
+
enter: {
|
|
39
|
+
key: 'Enter',
|
|
40
|
+
handler: (range) => {
|
|
41
|
+
const [line] = this.quill.getLine(range.index);
|
|
42
|
+
const BlockBlot = Quill.import('blots/block');
|
|
43
|
+
if (!BlockBlot?.bubbleFormats)
|
|
44
|
+
return true;
|
|
45
|
+
const lineFormats = BlockBlot.bubbleFormats(line);
|
|
46
|
+
const delta = new Delta().retain(range.index).delete(range.length).insert('\n', lineFormats);
|
|
47
|
+
this.quill.updateContents(delta, Quill.sources.USER);
|
|
48
|
+
this.quill.setSelection(range.index + 1, Quill.sources.SILENT);
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
this.app_.editor.quill = this.quill;
|
|
57
|
+
this.registerFonts();
|
|
58
|
+
return this.quill;
|
|
59
|
+
}
|
|
60
|
+
getQuill() {
|
|
61
|
+
if (!this.quill) {
|
|
62
|
+
throw new Error('Quill editor not initialized. Call init() first.');
|
|
63
|
+
}
|
|
64
|
+
return this.quill;
|
|
65
|
+
}
|
|
66
|
+
getCanvas() {
|
|
67
|
+
if (!this.app_) {
|
|
68
|
+
throw new Error('app_ editor not initialized. Call init() first.');
|
|
69
|
+
}
|
|
70
|
+
return this.app_;
|
|
71
|
+
}
|
|
72
|
+
registerFonts() {
|
|
73
|
+
const FontAttributor = Quill.import('attributors/class/font');
|
|
74
|
+
FontAttributor.whitelist = [
|
|
75
|
+
'Roboto',
|
|
76
|
+
'RobotoMono',
|
|
77
|
+
'Inter',
|
|
78
|
+
'OpenSans',
|
|
79
|
+
'Montserrat',
|
|
80
|
+
'RobotoCondensed',
|
|
81
|
+
'Arimo',
|
|
82
|
+
'NotoSans',
|
|
83
|
+
'NotoSansSymbols',
|
|
84
|
+
'Merriweather',
|
|
85
|
+
'PlayfairDisplay',
|
|
86
|
+
'NotoSerif',
|
|
87
|
+
'Lato',
|
|
88
|
+
'Spectral',
|
|
89
|
+
'DancingScript',
|
|
90
|
+
'NotoSansSimplifiedChinese',
|
|
91
|
+
'NotoSerifSimplifiedChinese',
|
|
92
|
+
'NotoSansTraditionalChinese',
|
|
93
|
+
'NotoSansHongKong',
|
|
94
|
+
'NotoSerifTraditionalChinese',
|
|
95
|
+
'NotoSerifHongKong',
|
|
96
|
+
'NotoSansJapanese',
|
|
97
|
+
'NotoSansKorean',
|
|
98
|
+
'Poppins'
|
|
99
|
+
];
|
|
100
|
+
Quill.register(FontAttributor, true);
|
|
101
|
+
}
|
|
102
|
+
isMultiSelect() {
|
|
103
|
+
if (!this.app_.editor)
|
|
104
|
+
return false;
|
|
105
|
+
if (this.app_.editor.multiple === true) {
|
|
106
|
+
return true;
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
dateEdit(callback, level = 0, listNew) {
|
|
113
|
+
const { editor } = this.app_;
|
|
114
|
+
const list = listNew ? listNew : editor.leafList.list;
|
|
115
|
+
const applyCallback = (leaf) => {
|
|
116
|
+
if (level && (leaf.tag === 'Box' || leaf.name === 'Text')) {
|
|
117
|
+
callback(leaf.children?.[0] || leaf);
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
callback(leaf);
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
if (!list.length)
|
|
124
|
+
return;
|
|
125
|
+
if (Array.isArray(list) && list.length > 1) {
|
|
126
|
+
this.app_.lockLayout();
|
|
127
|
+
list.forEach(applyCallback);
|
|
128
|
+
this.app_.unlockLayout();
|
|
129
|
+
editor.updateEditBox();
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
applyCallback(list[0]);
|
|
133
|
+
}
|
|
22
134
|
}
|
|
23
|
-
TextEditor.quill = new Quill("#textInnerEditor", {
|
|
24
|
-
theme: null,
|
|
25
|
-
modules: {
|
|
26
|
-
toolbar: false,
|
|
27
|
-
keyboard: {
|
|
28
|
-
bindings: {
|
|
29
|
-
enter: {
|
|
30
|
-
key: "Enter",
|
|
31
|
-
handler: (range, context) => {
|
|
32
|
-
const [line] = TextEditor.quill.getLine(range.index);
|
|
33
|
-
const BlockBlot = Quill.import("blots/block");
|
|
34
|
-
if (!BlockBlot || !BlockBlot.bubbleFormats)
|
|
35
|
-
return;
|
|
36
|
-
const lineFormats = BlockBlot.bubbleFormats(line);
|
|
37
|
-
const delta = new Delta()
|
|
38
|
-
.retain(range.index)
|
|
39
|
-
.delete(range.length)
|
|
40
|
-
.insert("\n", lineFormats);
|
|
41
|
-
TextEditor.quill.updateContents(delta, Quill.sources.USER);
|
|
42
|
-
TextEditor.quill.setSelection(range.index + 1, Quill.sources.SILENT);
|
|
43
|
-
return false;
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
});
|
|
50
|
-
const FontAttributor = Quill.import("attributors/class/font");
|
|
51
|
-
FontAttributor.whitelist = [
|
|
52
|
-
"Roboto",
|
|
53
|
-
"RobotoMono",
|
|
54
|
-
"Inter",
|
|
55
|
-
"OpenSans",
|
|
56
|
-
"Montserrat",
|
|
57
|
-
"RobotoCondensed",
|
|
58
|
-
"Arimo",
|
|
59
|
-
"NotoSans",
|
|
60
|
-
"NotoSansSymbols",
|
|
61
|
-
"Merriweather",
|
|
62
|
-
"PlayfairDisplay",
|
|
63
|
-
"NotoSerif",
|
|
64
|
-
"Lato",
|
|
65
|
-
"Spectral",
|
|
66
|
-
"DancingScript",
|
|
67
|
-
"NotoSansSimplifiedChinese",
|
|
68
|
-
"NotoSerifSimplifiedChinese",
|
|
69
|
-
"NotoSansTraditionalChinese",
|
|
70
|
-
"NotoSansHongKong",
|
|
71
|
-
"NotoSerifTraditionalChinese",
|
|
72
|
-
"NotoSerifHongKong",
|
|
73
|
-
"NotoSansJapanese",
|
|
74
|
-
"NotoSansKorean",
|
|
75
|
-
"Poppins",
|
|
76
|
-
];
|
|
77
|
-
Quill.register(FontAttributor, true);
|
|
78
|
-
return TextEditor.quill;
|
|
79
135
|
}
|
|
136
|
+
export const quillManager = QuillManager.getInstance();
|