@akilli/editor-src 5.1.5

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.
Files changed (126) hide show
  1. package/abbreviation/Abbreviation.js +32 -0
  2. package/abbreviation/AbbreviationDialog.js +21 -0
  3. package/audio/Audio.js +47 -0
  4. package/audio/AudioDialog.js +18 -0
  5. package/audio/AudioListener.js +50 -0
  6. package/base/AlignCommand.js +34 -0
  7. package/base/AlignableListener.js +45 -0
  8. package/base/Alignment.js +36 -0
  9. package/base/BarListener.js +95 -0
  10. package/base/Base.js +127 -0
  11. package/base/Command.js +139 -0
  12. package/base/CommandManager.js +60 -0
  13. package/base/ContentFilter.js +109 -0
  14. package/base/DeletableListener.js +36 -0
  15. package/base/DeleteCommand.js +18 -0
  16. package/base/Dialog.js +153 -0
  17. package/base/DialogManager.js +44 -0
  18. package/base/Dispatcher.js +88 -0
  19. package/base/Dom.js +790 -0
  20. package/base/EditableListener.js +82 -0
  21. package/base/Editor.js +448 -0
  22. package/base/Filter.js +35 -0
  23. package/base/FilterManager.js +44 -0
  24. package/base/FocusableListener.js +22 -0
  25. package/base/FocusbarListener.js +99 -0
  26. package/base/FormCreator.js +162 -0
  27. package/base/FormatbarListener.js +32 -0
  28. package/base/Key.js +258 -0
  29. package/base/Listener.js +51 -0
  30. package/base/NavigableListener.js +81 -0
  31. package/base/Plugin.js +176 -0
  32. package/base/PluginManager.js +51 -0
  33. package/base/SlotableListener.js +40 -0
  34. package/base/SortCommand.js +30 -0
  35. package/base/SortableListener.js +135 -0
  36. package/base/Sorting.js +36 -0
  37. package/base/Tag.js +113 -0
  38. package/base/TagGroup.js +183 -0
  39. package/base/TagListener.js +34 -0
  40. package/base/TagManager.js +61 -0
  41. package/base/TagName.js +470 -0
  42. package/base/ToolbarListener.js +11 -0
  43. package/base/util.js +59 -0
  44. package/block/Block.js +51 -0
  45. package/block/BlockDialog.js +11 -0
  46. package/block/BlockElement.js +21 -0
  47. package/block/BlockListener.js +60 -0
  48. package/blockquote/Blockquote.js +43 -0
  49. package/blockquote/BlockquoteFilter.js +22 -0
  50. package/blockquote/BlockquoteListener.js +34 -0
  51. package/bold/Bold.js +30 -0
  52. package/break/Break.js +33 -0
  53. package/break/BreakFilter.js +24 -0
  54. package/build/BuildEditor.js +97 -0
  55. package/build/editor.css +548 -0
  56. package/build/editor.woff2 +0 -0
  57. package/cite/Cite.js +30 -0
  58. package/code/Code.js +30 -0
  59. package/data/Data.js +32 -0
  60. package/data/DataDialog.js +13 -0
  61. package/definition/Definition.js +32 -0
  62. package/definition/DefinitionDialog.js +13 -0
  63. package/deletion/Deletion.js +30 -0
  64. package/details/Details.js +63 -0
  65. package/details/DetailsFilter.js +17 -0
  66. package/details/DetailsListener.js +102 -0
  67. package/division/Division.js +53 -0
  68. package/division/DivisionDialog.js +13 -0
  69. package/emphasis/Emphasis.js +30 -0
  70. package/figure/Figure.js +58 -0
  71. package/figure/FigureFilter.js +14 -0
  72. package/figure/FigureListener.js +23 -0
  73. package/heading/Heading.js +38 -0
  74. package/horizontalrule/HorizontalRule.js +37 -0
  75. package/i18n/I18n.js +26 -0
  76. package/i18n/de.js +167 -0
  77. package/iframe/Iframe.js +49 -0
  78. package/iframe/IframeDialog.js +20 -0
  79. package/iframe/IframeListener.js +48 -0
  80. package/image/Image.js +47 -0
  81. package/image/ImageDialog.js +23 -0
  82. package/image/ImageListener.js +47 -0
  83. package/insertion/Insertion.js +30 -0
  84. package/italic/Italic.js +30 -0
  85. package/keyboard/Keyboard.js +30 -0
  86. package/link/Link.js +34 -0
  87. package/link/LinkDialog.js +14 -0
  88. package/link/LinkListener.js +45 -0
  89. package/list/List.js +40 -0
  90. package/list/ListListener.js +91 -0
  91. package/mark/Mark.js +30 -0
  92. package/orderedlist/OrderedList.js +39 -0
  93. package/package.json +24 -0
  94. package/paragraph/Paragraph.js +42 -0
  95. package/paragraph/ParagraphListener.js +40 -0
  96. package/preformat/Preformat.js +43 -0
  97. package/preformat/PreformatFilter.js +22 -0
  98. package/preformat/PreformatListener.js +34 -0
  99. package/quote/Quote.js +30 -0
  100. package/sample/Sample.js +30 -0
  101. package/section/Section.js +55 -0
  102. package/section/SectionDialog.js +13 -0
  103. package/small/Small.js +30 -0
  104. package/strikethrough/Strikethrough.js +30 -0
  105. package/strong/Strong.js +30 -0
  106. package/subheading/Subheading.js +38 -0
  107. package/subscript/Subscript.js +30 -0
  108. package/superscript/Superscript.js +30 -0
  109. package/table/Table.js +113 -0
  110. package/table/TableCellListener.js +125 -0
  111. package/table/TableColumnAddCommand.js +19 -0
  112. package/table/TableColumnListener.js +34 -0
  113. package/table/TableCommand.js +23 -0
  114. package/table/TableDialog.js +14 -0
  115. package/table/TableFilter.js +35 -0
  116. package/table/TableListener.js +39 -0
  117. package/table/TableRowAddCommand.js +18 -0
  118. package/table/TableRowListener.js +34 -0
  119. package/time/Time.js +32 -0
  120. package/time/TimeDialog.js +13 -0
  121. package/underline/Underline.js +30 -0
  122. package/unorderedlist/UnorderedList.js +39 -0
  123. package/variable/Variable.js +30 -0
  124. package/video/Video.js +47 -0
  125. package/video/VideoDialog.js +20 -0
  126. package/video/VideoListener.js +48 -0
@@ -0,0 +1,470 @@
1
+ export default class TagName {
2
+ /**
3
+ * @return {string}
4
+ */
5
+ static get A() {
6
+ return 'a';
7
+ }
8
+
9
+ /**
10
+ * @return {string}
11
+ */
12
+ static get ABBR() {
13
+ return 'abbr';
14
+ }
15
+
16
+ /**
17
+ * @return {string}
18
+ */
19
+ static get ALL() {
20
+ return '*';
21
+ }
22
+
23
+ /**
24
+ * @return {string}
25
+ */
26
+ static get AUDIO() {
27
+ return 'audio';
28
+ }
29
+
30
+ /**
31
+ * @return {string}
32
+ */
33
+ static get B() {
34
+ return 'b';
35
+ }
36
+
37
+ /**
38
+ * @return {string}
39
+ */
40
+ static get BLOCK() {
41
+ return 'app-block';
42
+ }
43
+
44
+ /**
45
+ * @return {string}
46
+ */
47
+ static get BLOCKQUOTE() {
48
+ return 'blockquote';
49
+ }
50
+
51
+ /**
52
+ * @return {string}
53
+ */
54
+ static get BR() {
55
+ return 'br';
56
+ }
57
+
58
+ /**
59
+ * @return {string}
60
+ */
61
+ static get BUTTON() {
62
+ return 'button';
63
+ }
64
+
65
+ /**
66
+ * @return {string}
67
+ */
68
+ static get CITE() {
69
+ return 'cite';
70
+ }
71
+
72
+ /**
73
+ * @return {string}
74
+ */
75
+ static get CODE() {
76
+ return 'code';
77
+ }
78
+
79
+ /**
80
+ * @return {string}
81
+ */
82
+ static get COL() {
83
+ return 'col';
84
+ }
85
+
86
+ /**
87
+ * @return {string}
88
+ */
89
+ static get COLGROUP() {
90
+ return 'colgroup';
91
+ }
92
+
93
+ /**
94
+ * @return {string}
95
+ */
96
+ static get DATA() {
97
+ return 'data';
98
+ }
99
+
100
+ /**
101
+ * @return {string}
102
+ */
103
+ static get DEL() {
104
+ return 'del';
105
+ }
106
+
107
+ /**
108
+ * @return {string}
109
+ */
110
+ static get DETAILS() {
111
+ return 'details';
112
+ }
113
+
114
+ /**
115
+ * @return {string}
116
+ */
117
+ static get DFN() {
118
+ return 'dfn';
119
+ }
120
+
121
+ /**
122
+ * @return {string}
123
+ */
124
+ static get DIALOG() {
125
+ return 'dialog';
126
+ }
127
+
128
+ /**
129
+ * @return {string}
130
+ */
131
+ static get DIV() {
132
+ return 'div';
133
+ }
134
+
135
+ /**
136
+ * @return {string}
137
+ */
138
+ static get EDITOR() {
139
+ return 'akilli-editor';
140
+ }
141
+
142
+ /**
143
+ * @return {string}
144
+ */
145
+ static get EM() {
146
+ return 'em';
147
+ }
148
+
149
+ /**
150
+ * @return {string}
151
+ */
152
+ static get FIELDSET() {
153
+ return 'fieldset';
154
+ }
155
+
156
+ /**
157
+ * @return {string}
158
+ */
159
+ static get FIGCAPTION() {
160
+ return 'figcaption';
161
+ }
162
+
163
+ /**
164
+ * @return {string}
165
+ */
166
+ static get FIGURE() {
167
+ return 'figure';
168
+ }
169
+
170
+ /**
171
+ * @return {string}
172
+ */
173
+ static get FOCUSBAR() {
174
+ return 'editor-focusbar';
175
+ }
176
+
177
+ /**
178
+ * @return {string}
179
+ */
180
+ static get FORM() {
181
+ return 'form';
182
+ }
183
+
184
+ /**
185
+ * @return {string}
186
+ */
187
+ static get FORMATBAR() {
188
+ return 'editor-formatbar';
189
+ }
190
+
191
+ /**
192
+ * @return {string}
193
+ */
194
+ static get H2() {
195
+ return 'h2';
196
+ }
197
+
198
+ /**
199
+ * @return {string}
200
+ */
201
+ static get H3() {
202
+ return 'h3';
203
+ }
204
+
205
+ /**
206
+ * @return {string}
207
+ */
208
+ static get HR() {
209
+ return 'hr';
210
+ }
211
+
212
+ /**
213
+ * @return {string}
214
+ */
215
+ static get I() {
216
+ return 'i';
217
+ }
218
+
219
+ /**
220
+ * @return {string}
221
+ */
222
+ static get IFRAME() {
223
+ return 'iframe';
224
+ }
225
+
226
+ /**
227
+ * @return {string}
228
+ */
229
+ static get IMG() {
230
+ return 'img';
231
+ }
232
+
233
+ /**
234
+ * @return {string}
235
+ */
236
+ static get INPUT() {
237
+ return 'input';
238
+ }
239
+
240
+ /**
241
+ * @return {string}
242
+ */
243
+ static get INS() {
244
+ return 'ins';
245
+ }
246
+
247
+ /**
248
+ * @return {string}
249
+ */
250
+ static get KBD() {
251
+ return 'kbd';
252
+ }
253
+
254
+ /**
255
+ * @return {string}
256
+ */
257
+ static get LABEL() {
258
+ return 'label';
259
+ }
260
+
261
+ /**
262
+ * @return {string}
263
+ */
264
+ static get LEGEND() {
265
+ return 'legend';
266
+ }
267
+
268
+ /**
269
+ * @return {string}
270
+ */
271
+ static get LI() {
272
+ return 'li';
273
+ }
274
+
275
+ /**
276
+ * @return {string}
277
+ */
278
+ static get MARK() {
279
+ return 'mark';
280
+ }
281
+
282
+ /**
283
+ * @return {string}
284
+ */
285
+ static get OL() {
286
+ return 'ol';
287
+ }
288
+
289
+ /**
290
+ * @return {string}
291
+ */
292
+ static get P() {
293
+ return 'p';
294
+ }
295
+
296
+ /**
297
+ * @return {string}
298
+ */
299
+ static get PRE() {
300
+ return 'pre';
301
+ }
302
+
303
+ /**
304
+ * @return {string}
305
+ */
306
+ static get Q() {
307
+ return 'q';
308
+ }
309
+
310
+ /**
311
+ * @return {string}
312
+ */
313
+ static get ROOT() {
314
+ return 'editor-root';
315
+ }
316
+
317
+ /**
318
+ * @return {string}
319
+ */
320
+ static get S() {
321
+ return 's';
322
+ }
323
+
324
+ /**
325
+ * @return {string}
326
+ */
327
+ static get SAMP() {
328
+ return 'samp';
329
+ }
330
+
331
+ /**
332
+ * @return {string}
333
+ */
334
+ static get SECTION() {
335
+ return 'section';
336
+ }
337
+
338
+ /**
339
+ * @return {string}
340
+ */
341
+ static get SLOT() {
342
+ return 'slot';
343
+ }
344
+
345
+ /**
346
+ * @return {string}
347
+ */
348
+ static get SMALL() {
349
+ return 'small';
350
+ }
351
+
352
+ /**
353
+ * @return {string}
354
+ */
355
+ static get STRONG() {
356
+ return 'strong';
357
+ }
358
+
359
+ /**
360
+ * @return {string}
361
+ */
362
+ static get SUB() {
363
+ return 'sub';
364
+ }
365
+
366
+ /**
367
+ * @return {string}
368
+ */
369
+ static get SUMMARY() {
370
+ return 'summary';
371
+ }
372
+
373
+ /**
374
+ * @return {string}
375
+ */
376
+ static get SUP() {
377
+ return 'sup';
378
+ }
379
+
380
+ /**
381
+ * @return {string}
382
+ */
383
+ static get TABLE() {
384
+ return 'table';
385
+ }
386
+
387
+ /**
388
+ * @return {string}
389
+ */
390
+ static get TBODY() {
391
+ return 'tbody';
392
+ }
393
+
394
+ /**
395
+ * @return {string}
396
+ */
397
+ static get TD() {
398
+ return 'td';
399
+ }
400
+
401
+ /**
402
+ * @return {string}
403
+ */
404
+ static get TFOOT() {
405
+ return 'tfoot';
406
+ }
407
+
408
+ /**
409
+ * @return {string}
410
+ */
411
+ static get TH() {
412
+ return 'th';
413
+ }
414
+
415
+ /**
416
+ * @return {string}
417
+ */
418
+ static get THEAD() {
419
+ return 'thead';
420
+ }
421
+
422
+ /**
423
+ * @return {string}
424
+ */
425
+ static get TIME() {
426
+ return 'time';
427
+ }
428
+
429
+ /**
430
+ * @return {string}
431
+ */
432
+ static get TOOLBAR() {
433
+ return 'editor-toolbar';
434
+ }
435
+
436
+ /**
437
+ * @return {string}
438
+ */
439
+ static get TR() {
440
+ return 'tr';
441
+ }
442
+
443
+ /**
444
+ * @return {string}
445
+ */
446
+ static get U() {
447
+ return 'u';
448
+ }
449
+
450
+ /**
451
+ * @return {string}
452
+ */
453
+ static get UL() {
454
+ return 'ul';
455
+ }
456
+
457
+ /**
458
+ * @return {string}
459
+ */
460
+ static get VAR() {
461
+ return 'var';
462
+ }
463
+
464
+ /**
465
+ * @return {string}
466
+ */
467
+ static get VIDEO() {
468
+ return 'video';
469
+ }
470
+ }
@@ -0,0 +1,11 @@
1
+ import BarListener from './BarListener.js';
2
+
3
+ export default class ToolbarListener extends BarListener {
4
+ /**
5
+ * @param {Editor} editor
6
+ */
7
+ constructor(editor) {
8
+ super(editor);
9
+ this.editor.toolbar.addEventListener('insertbutton', this);
10
+ }
11
+ }
package/base/util.js ADDED
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Indicates if given value is defined
3
+ *
4
+ * @param {any} val
5
+ * @return {boolean}
6
+ */
7
+ export function is(val) {
8
+ return typeof val !== 'undefined';
9
+ }
10
+
11
+ /**
12
+ * Indicates if given value is a function
13
+ *
14
+ * @param {any} val
15
+ * @return {boolean}
16
+ */
17
+ export function isFunction(val) {
18
+ return typeof val === 'function';
19
+ }
20
+
21
+ /**
22
+ * Indicates if given value is a non-empty string
23
+ *
24
+ * @param {any} val
25
+ * @return {boolean}
26
+ */
27
+ export function isString(val) {
28
+ return val && typeof val === 'string';
29
+ }
30
+
31
+ /**
32
+ * Indicates if given value is either undefined or a non-empty string
33
+ *
34
+ * @param {any} val
35
+ * @return {boolean}
36
+ */
37
+ export function isOptString(val) {
38
+ return !is(val) || isString(val);
39
+ }
40
+
41
+ /**
42
+ * Indicates if given value is either undefined or a non-empty array
43
+ *
44
+ * @param {any} val
45
+ * @return {boolean}
46
+ */
47
+ export function isOptArray(val) {
48
+ return !is(val) || (Array.isArray(val) && val.length > 0);
49
+ }
50
+
51
+ /**
52
+ * Indicates if given value is either undefined or an instance of HTMLElement
53
+ *
54
+ * @param {any} val
55
+ * @return {boolean}
56
+ */
57
+ export function isOptHtml(val) {
58
+ return !is(val) || val instanceof HTMLElement;
59
+ }
package/block/Block.js ADDED
@@ -0,0 +1,51 @@
1
+ import Base from '../base/Base.js';
2
+ import BlockDialog from './BlockDialog.js';
3
+ import BlockElement from './BlockElement.js';
4
+ import BlockListener from './BlockListener.js';
5
+ import Plugin from '../base/Plugin.js';
6
+ import TagGroup from '../base/TagGroup.js';
7
+ import TagName from '../base/TagName.js';
8
+
9
+ export default class Block extends Plugin {
10
+ /**
11
+ * @type {string}
12
+ */
13
+ static get name() {
14
+ return 'block';
15
+ }
16
+
17
+ /**
18
+ * @type {Plugin[]}
19
+ */
20
+ static get dependencies() {
21
+ return [Base];
22
+ }
23
+
24
+ /**
25
+ * @type {Object.<string, any>}
26
+ */
27
+ static get config() {
28
+ return { api: undefined, browser: undefined, css: undefined };
29
+ }
30
+
31
+ /**
32
+ * @return {void}
33
+ */
34
+ init() {
35
+ this.editor.dom.registerElement(TagName.BLOCK, BlockElement);
36
+ this._tag({
37
+ name: TagName.BLOCK,
38
+ group: TagGroup.BLOCK,
39
+ attributes: ['id'],
40
+ deletable: true,
41
+ empty: true,
42
+ focusable: true,
43
+ navigable: true,
44
+ sortable: true,
45
+ });
46
+ new BlockListener(this.editor);
47
+ this.editor.dialogs.set(new BlockDialog(this.editor, this.constructor.name, this.editor.config.block.browser));
48
+ this._command(TagName.BLOCK);
49
+ this._toolbar('Block');
50
+ }
51
+ }
@@ -0,0 +1,11 @@
1
+ import Dialog from '../base/Dialog.js';
2
+
3
+ export default class BlockDialog extends Dialog {
4
+ /**
5
+ * @protected
6
+ * @return {void}
7
+ */
8
+ _prepareForm() {
9
+ this.formCreator.addLegend(this._('Block')).addTextInput('id', this._('ID'), { required: 'required' });
10
+ }
11
+ }
@@ -0,0 +1,21 @@
1
+ export default class BlockElement extends HTMLElement {
2
+ /**
3
+ * @return {string}
4
+ */
5
+ get content() {
6
+ return this.shadowRoot.innerHTML;
7
+ }
8
+
9
+ /**
10
+ * @param {string} val
11
+ * @return {void}
12
+ */
13
+ set content(val) {
14
+ this.shadowRoot.innerHTML = val;
15
+ }
16
+
17
+ constructor() {
18
+ super();
19
+ this.attachShadow({ mode: 'open' });
20
+ }
21
+ }
@@ -0,0 +1,60 @@
1
+ import Listener from '../base/Listener.js';
2
+ import TagName from '../base/TagName.js';
3
+
4
+ export default class BlockListener extends Listener {
5
+ /**
6
+ * @param {Editor} editor
7
+ */
8
+ constructor(editor) {
9
+ super(editor);
10
+ this.editor.root.addEventListener('sethtml', this);
11
+ this.editor.root.addEventListener('insertappblock', this);
12
+ }
13
+
14
+ /**
15
+ * @param {CustomEvent} event
16
+ * @param {HTMLElement} event.detail.element
17
+ * @return {void}
18
+ */
19
+ sethtml({ detail: { element } }) {
20
+ Array.from(element.getElementsByTagName(TagName.BLOCK)).forEach(
21
+ /** @param {BlockElement} item */
22
+ (item) => item.id || item.parentElement.removeChild(item)
23
+ );
24
+ }
25
+
26
+ /**
27
+ * @param {CustomEvent} event
28
+ * @param {BlockElement} event.detail.element
29
+ * @return {Promise<void>}
30
+ */
31
+ async insertappblock({ detail: { element } }) {
32
+ if (!element.id) {
33
+ element.parentElement.removeChild(element);
34
+ return;
35
+ }
36
+
37
+ if (!this.editor.config.block.api) {
38
+ return;
39
+ }
40
+
41
+ const url = this.editor.config.block.api.replace('{id}', element.id);
42
+ const response = await fetch(url, { mode: 'no-cors' });
43
+
44
+ if (!response.ok) {
45
+ return;
46
+ }
47
+
48
+ let css = '';
49
+
50
+ if (this.editor.config.block.css) {
51
+ css = this.editor.config.block.css
52
+ .split(',')
53
+ .map((item) => `<link rel="stylesheet" href="${item}">`)
54
+ .join('');
55
+ }
56
+
57
+ const content = await response.text();
58
+ element.content = css + content;
59
+ }
60
+ }
@@ -0,0 +1,43 @@
1
+ import Base from '../base/Base.js';
2
+ import BlockquoteFilter from './BlockquoteFilter.js';
3
+ import BlockquoteListener from './BlockquoteListener.js';
4
+ import Break from '../break/Break.js';
5
+ import Figure from '../figure/Figure.js';
6
+ import Plugin from '../base/Plugin.js';
7
+ import TagGroup from '../base/TagGroup.js';
8
+ import TagName from '../base/TagName.js';
9
+
10
+ export default class Blockquote extends Plugin {
11
+ /**
12
+ * @type {string}
13
+ */
14
+ static get name() {
15
+ return 'blockquote';
16
+ }
17
+
18
+ /**
19
+ * @type {Plugin[]}
20
+ */
21
+ static get dependencies() {
22
+ return [Base, Break, Figure];
23
+ }
24
+
25
+ /**
26
+ * @return {void}
27
+ */
28
+ init() {
29
+ this._tag({
30
+ name: TagName.BLOCKQUOTE,
31
+ group: TagGroup.QUOTE,
32
+ children: [TagGroup.BREAK, TagGroup.FORMAT],
33
+ deletable: true,
34
+ editable: true,
35
+ navigable: true,
36
+ enter: TagName.P,
37
+ });
38
+ new BlockquoteListener(this.editor);
39
+ this._command(TagName.BLOCKQUOTE);
40
+ this._toolbar('Blockquote');
41
+ this.editor.filters.add(new BlockquoteFilter(this.editor));
42
+ }
43
+ }