@ckeditor/ckeditor5-basic-styles 41.2.0 → 41.3.0-alpha.0

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.js ADDED
@@ -0,0 +1,1078 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ import { Command, Plugin, icons } from '@ckeditor/ckeditor5-core/dist/index.js';
6
+ import { ButtonView } from '@ckeditor/ckeditor5-ui/dist/index.js';
7
+ import { TwoStepCaretMovement, inlineHighlight } from '@ckeditor/ckeditor5-typing/dist/index.js';
8
+
9
+ /**
10
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
11
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
12
+ */
13
+ /**
14
+ * @module basic-styles/attributecommand
15
+ */
16
+ /**
17
+ * An extension of the base {@link module:core/command~Command} class, which provides utilities for a command
18
+ * that toggles a single attribute on a text or an element.
19
+ *
20
+ * `AttributeCommand` uses {@link module:engine/model/document~Document#selection}
21
+ * to decide which nodes (if any) should be changed, and applies or removes the attribute from them.
22
+ *
23
+ * The command checks the {@link module:engine/model/model~Model#schema} to decide if it can be enabled
24
+ * for the current selection and to which nodes the attribute can be applied.
25
+ */
26
+ class AttributeCommand extends Command {
27
+ /**
28
+ * @param attributeKey Attribute that will be set by the command.
29
+ */
30
+ constructor(editor, attributeKey) {
31
+ super(editor);
32
+ this.attributeKey = attributeKey;
33
+ }
34
+ /**
35
+ * Updates the command's {@link #value} and {@link #isEnabled} based on the current selection.
36
+ */
37
+ refresh() {
38
+ const model = this.editor.model;
39
+ const doc = model.document;
40
+ this.value = this._getValueFromFirstAllowedNode();
41
+ this.isEnabled = model.schema.checkAttributeInSelection(doc.selection, this.attributeKey);
42
+ }
43
+ /**
44
+ * Executes the command – applies the attribute to the selection or removes it from the selection.
45
+ *
46
+ * If the command is active (`value == true`), it will remove attributes. Otherwise, it will set attributes.
47
+ *
48
+ * The execution result differs, depending on the {@link module:engine/model/document~Document#selection}:
49
+ *
50
+ * * If the selection is on a range, the command applies the attribute to all nodes in that range
51
+ * (if they are allowed to have this attribute by the {@link module:engine/model/schema~Schema schema}).
52
+ * * If the selection is collapsed in a non-empty node, the command applies the attribute to the
53
+ * {@link module:engine/model/document~Document#selection} itself (note that typed characters copy attributes from the selection).
54
+ * * If the selection is collapsed in an empty node, the command applies the attribute to the parent node of the selection (note
55
+ * that the selection inherits all attributes from a node if it is in an empty node).
56
+ *
57
+ * @fires execute
58
+ * @param options Command options.
59
+ * @param options.forceValue If set, it will force the command behavior. If `true`,
60
+ * the command will apply the attribute, otherwise the command will remove the attribute.
61
+ * If not set, the command will look for its current value to decide what it should do.
62
+ */
63
+ execute(options = {}) {
64
+ const model = this.editor.model;
65
+ const doc = model.document;
66
+ const selection = doc.selection;
67
+ const value = (options.forceValue === undefined) ? !this.value : options.forceValue;
68
+ model.change(writer => {
69
+ if (selection.isCollapsed) {
70
+ if (value) {
71
+ writer.setSelectionAttribute(this.attributeKey, true);
72
+ }
73
+ else {
74
+ writer.removeSelectionAttribute(this.attributeKey);
75
+ }
76
+ }
77
+ else {
78
+ const ranges = model.schema.getValidRanges(selection.getRanges(), this.attributeKey);
79
+ for (const range of ranges) {
80
+ if (value) {
81
+ writer.setAttribute(this.attributeKey, value, range);
82
+ }
83
+ else {
84
+ writer.removeAttribute(this.attributeKey, range);
85
+ }
86
+ }
87
+ }
88
+ });
89
+ }
90
+ /**
91
+ * Checks the attribute value of the first node in the selection that allows the attribute.
92
+ * For the collapsed selection returns the selection attribute.
93
+ *
94
+ * @returns The attribute value.
95
+ */
96
+ _getValueFromFirstAllowedNode() {
97
+ const model = this.editor.model;
98
+ const schema = model.schema;
99
+ const selection = model.document.selection;
100
+ if (selection.isCollapsed) {
101
+ return selection.hasAttribute(this.attributeKey);
102
+ }
103
+ for (const range of selection.getRanges()) {
104
+ for (const item of range.getItems()) {
105
+ if (schema.checkAttribute(item, this.attributeKey)) {
106
+ return item.hasAttribute(this.attributeKey);
107
+ }
108
+ }
109
+ }
110
+ return false;
111
+ }
112
+ }
113
+
114
+ /**
115
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
116
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
117
+ */
118
+ /**
119
+ * @module basic-styles/bold/boldediting
120
+ */
121
+ const BOLD$1 = 'bold';
122
+ /**
123
+ * The bold editing feature.
124
+ *
125
+ * It registers the `'bold'` command and introduces the `bold` attribute in the model which renders to the view
126
+ * as a `<strong>` element.
127
+ */
128
+ class BoldEditing extends Plugin {
129
+ /**
130
+ * @inheritDoc
131
+ */
132
+ static get pluginName() {
133
+ return 'BoldEditing';
134
+ }
135
+ /**
136
+ * @inheritDoc
137
+ */
138
+ init() {
139
+ const editor = this.editor;
140
+ const t = this.editor.t;
141
+ // Allow bold attribute on text nodes.
142
+ editor.model.schema.extend('$text', { allowAttributes: BOLD$1 });
143
+ editor.model.schema.setAttributeProperties(BOLD$1, {
144
+ isFormatting: true,
145
+ copyOnEnter: true
146
+ });
147
+ // Build converter from model to view for data and editing pipelines.
148
+ editor.conversion.attributeToElement({
149
+ model: BOLD$1,
150
+ view: 'strong',
151
+ upcastAlso: [
152
+ 'b',
153
+ viewElement => {
154
+ const fontWeight = viewElement.getStyle('font-weight');
155
+ if (!fontWeight) {
156
+ return null;
157
+ }
158
+ // Value of the `font-weight` attribute can be defined as a string or a number.
159
+ if (fontWeight == 'bold' || Number(fontWeight) >= 600) {
160
+ return {
161
+ name: true,
162
+ styles: ['font-weight']
163
+ };
164
+ }
165
+ return null;
166
+ }
167
+ ]
168
+ });
169
+ // Create bold command.
170
+ editor.commands.add(BOLD$1, new AttributeCommand(editor, BOLD$1));
171
+ // Set the Ctrl+B keystroke.
172
+ editor.keystrokes.set('CTRL+B', BOLD$1);
173
+ // Add the information about the keystroke to the accessibility database.
174
+ editor.accessibility.addKeystrokeInfos({
175
+ keystrokes: [
176
+ {
177
+ label: t('Bold text'),
178
+ keystroke: 'CTRL+B'
179
+ }
180
+ ]
181
+ });
182
+ }
183
+ }
184
+
185
+ /**
186
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
187
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
188
+ */
189
+ /**
190
+ * @module basic-styles/bold/boldui
191
+ */
192
+ const BOLD = 'bold';
193
+ /**
194
+ * The bold UI feature. It introduces the Bold button.
195
+ */
196
+ class BoldUI extends Plugin {
197
+ /**
198
+ * @inheritDoc
199
+ */
200
+ static get pluginName() {
201
+ return 'BoldUI';
202
+ }
203
+ /**
204
+ * @inheritDoc
205
+ */
206
+ init() {
207
+ const editor = this.editor;
208
+ const t = editor.t;
209
+ // Add bold button to feature components.
210
+ editor.ui.componentFactory.add(BOLD, locale => {
211
+ const command = editor.commands.get(BOLD);
212
+ const view = new ButtonView(locale);
213
+ view.set({
214
+ label: t('Bold'),
215
+ icon: icons.bold,
216
+ keystroke: 'CTRL+B',
217
+ tooltip: true,
218
+ isToggleable: true
219
+ });
220
+ view.bind('isOn', 'isEnabled').to(command, 'value', 'isEnabled');
221
+ // Execute command.
222
+ this.listenTo(view, 'execute', () => {
223
+ editor.execute(BOLD);
224
+ editor.editing.view.focus();
225
+ });
226
+ return view;
227
+ });
228
+ }
229
+ }
230
+
231
+ /**
232
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
233
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
234
+ */
235
+ /**
236
+ * @module basic-styles/bold
237
+ */
238
+ /**
239
+ * The bold feature.
240
+ *
241
+ * For a detailed overview check the {@glink features/basic-styles Basic styles feature} guide
242
+ * and the {@glink api/basic-styles package page}.
243
+ *
244
+ * This is a "glue" plugin which loads the {@link module:basic-styles/bold/boldediting~BoldEditing bold editing feature}
245
+ * and {@link module:basic-styles/bold/boldui~BoldUI bold UI feature}.
246
+ */
247
+ class Bold extends Plugin {
248
+ /**
249
+ * @inheritDoc
250
+ */
251
+ static get requires() {
252
+ return [BoldEditing, BoldUI];
253
+ }
254
+ /**
255
+ * @inheritDoc
256
+ */
257
+ static get pluginName() {
258
+ return 'Bold';
259
+ }
260
+ }
261
+
262
+ /**
263
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
264
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
265
+ */
266
+ /**
267
+ * @module basic-styles/code/codeediting
268
+ */
269
+ const CODE$1 = 'code';
270
+ const HIGHLIGHT_CLASS = 'ck-code_selected';
271
+ /**
272
+ * The code editing feature.
273
+ *
274
+ * It registers the `'code'` command and introduces the `code` attribute in the model which renders to the view
275
+ * as a `<code>` element.
276
+ */
277
+ class CodeEditing extends Plugin {
278
+ /**
279
+ * @inheritDoc
280
+ */
281
+ static get pluginName() {
282
+ return 'CodeEditing';
283
+ }
284
+ /**
285
+ * @inheritDoc
286
+ */
287
+ static get requires() {
288
+ return [TwoStepCaretMovement];
289
+ }
290
+ /**
291
+ * @inheritDoc
292
+ */
293
+ init() {
294
+ const editor = this.editor;
295
+ const t = this.editor.t;
296
+ // Allow code attribute on text nodes.
297
+ editor.model.schema.extend('$text', { allowAttributes: CODE$1 });
298
+ editor.model.schema.setAttributeProperties(CODE$1, {
299
+ isFormatting: true,
300
+ copyOnEnter: false
301
+ });
302
+ editor.conversion.attributeToElement({
303
+ model: CODE$1,
304
+ view: 'code',
305
+ upcastAlso: {
306
+ styles: {
307
+ 'word-wrap': 'break-word'
308
+ }
309
+ }
310
+ });
311
+ // Create code command.
312
+ editor.commands.add(CODE$1, new AttributeCommand(editor, CODE$1));
313
+ // Enable two-step caret movement for `code` attribute.
314
+ editor.plugins.get(TwoStepCaretMovement).registerAttribute(CODE$1);
315
+ // Setup highlight over selected element.
316
+ inlineHighlight(editor, CODE$1, 'code', HIGHLIGHT_CLASS);
317
+ // Add the information about the keystroke to the accessibility database.
318
+ editor.accessibility.addKeystrokeInfos({
319
+ keystrokes: [
320
+ {
321
+ label: t('Move out of an inline code style'),
322
+ keystroke: [
323
+ ['arrowleft', 'arrowleft'],
324
+ ['arrowright', 'arrowright']
325
+ ]
326
+ }
327
+ ]
328
+ });
329
+ }
330
+ }
331
+
332
+ var codeIcon = "<svg viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"m12.5 5.7 5.2 3.9v1.3l-5.6 4c-.1.2-.3.2-.5.2-.3-.1-.6-.7-.6-1l.3-.4 4.7-3.5L11.5 7l-.2-.2c-.1-.3-.1-.6 0-.8.2-.2.5-.4.8-.4a.8.8 0 0 1 .4.1zm-5.2 0L2 9.6v1.3l5.6 4c.1.2.3.2.5.2.3-.1.7-.7.6-1 0-.1 0-.3-.2-.4l-5-3.5L8.2 7l.2-.2c.1-.3.1-.6 0-.8-.2-.2-.5-.4-.8-.4a.8.8 0 0 0-.3.1z\"/></svg>";
333
+
334
+ /**
335
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
336
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
337
+ */
338
+ /**
339
+ * @module basic-styles/code/codeui
340
+ */
341
+ const CODE = 'code';
342
+ /**
343
+ * The code UI feature. It introduces the Code button.
344
+ */
345
+ class CodeUI extends Plugin {
346
+ /**
347
+ * @inheritDoc
348
+ */
349
+ static get pluginName() {
350
+ return 'CodeUI';
351
+ }
352
+ /**
353
+ * @inheritDoc
354
+ */
355
+ init() {
356
+ const editor = this.editor;
357
+ const t = editor.t;
358
+ // Add code button to feature components.
359
+ editor.ui.componentFactory.add(CODE, locale => {
360
+ const command = editor.commands.get(CODE);
361
+ const view = new ButtonView(locale);
362
+ view.set({
363
+ label: t('Code'),
364
+ icon: codeIcon,
365
+ tooltip: true,
366
+ isToggleable: true
367
+ });
368
+ view.bind('isOn', 'isEnabled').to(command, 'value', 'isEnabled');
369
+ // Execute command.
370
+ this.listenTo(view, 'execute', () => {
371
+ editor.execute(CODE);
372
+ editor.editing.view.focus();
373
+ });
374
+ return view;
375
+ });
376
+ }
377
+ }
378
+
379
+ /**
380
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
381
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
382
+ */
383
+ /**
384
+ * @module basic-styles/code
385
+ */
386
+ /**
387
+ * The code feature.
388
+ *
389
+ * For a detailed overview check the {@glink features/basic-styles Basic styles feature} guide
390
+ * and the {@glink api/basic-styles package page}.
391
+ *
392
+ * This is a "glue" plugin which loads the {@link module:basic-styles/code/codeediting~CodeEditing code editing feature}
393
+ * and {@link module:basic-styles/code/codeui~CodeUI code UI feature}.
394
+ */
395
+ class Code extends Plugin {
396
+ /**
397
+ * @inheritDoc
398
+ */
399
+ static get requires() {
400
+ return [CodeEditing, CodeUI];
401
+ }
402
+ /**
403
+ * @inheritDoc
404
+ */
405
+ static get pluginName() {
406
+ return 'Code';
407
+ }
408
+ }
409
+
410
+ /**
411
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
412
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
413
+ */
414
+ /**
415
+ * @module basic-styles/italic/italicediting
416
+ */
417
+ const ITALIC$1 = 'italic';
418
+ /**
419
+ * The italic editing feature.
420
+ *
421
+ * It registers the `'italic'` command, the <kbd>Ctrl+I</kbd> keystroke and introduces the `italic` attribute in the model
422
+ * which renders to the view as an `<i>` element.
423
+ */
424
+ class ItalicEditing extends Plugin {
425
+ /**
426
+ * @inheritDoc
427
+ */
428
+ static get pluginName() {
429
+ return 'ItalicEditing';
430
+ }
431
+ /**
432
+ * @inheritDoc
433
+ */
434
+ init() {
435
+ const editor = this.editor;
436
+ const t = this.editor.t;
437
+ // Allow italic attribute on text nodes.
438
+ editor.model.schema.extend('$text', { allowAttributes: ITALIC$1 });
439
+ editor.model.schema.setAttributeProperties(ITALIC$1, {
440
+ isFormatting: true,
441
+ copyOnEnter: true
442
+ });
443
+ editor.conversion.attributeToElement({
444
+ model: ITALIC$1,
445
+ view: 'i',
446
+ upcastAlso: [
447
+ 'em',
448
+ {
449
+ styles: {
450
+ 'font-style': 'italic'
451
+ }
452
+ }
453
+ ]
454
+ });
455
+ // Create italic command.
456
+ editor.commands.add(ITALIC$1, new AttributeCommand(editor, ITALIC$1));
457
+ // Set the Ctrl+I keystroke.
458
+ editor.keystrokes.set('CTRL+I', ITALIC$1);
459
+ // Add the information about the keystroke to the accessibility database.
460
+ editor.accessibility.addKeystrokeInfos({
461
+ keystrokes: [
462
+ {
463
+ label: t('Italic text'),
464
+ keystroke: 'CTRL+I'
465
+ }
466
+ ]
467
+ });
468
+ }
469
+ }
470
+
471
+ var italicIcon = "<svg viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"m9.586 14.633.021.004c-.036.335.095.655.393.962.082.083.173.15.274.201h1.474a.6.6 0 1 1 0 1.2H5.304a.6.6 0 0 1 0-1.2h1.15c.474-.07.809-.182 1.005-.334.157-.122.291-.32.404-.597l2.416-9.55a1.053 1.053 0 0 0-.281-.823 1.12 1.12 0 0 0-.442-.296H8.15a.6.6 0 0 1 0-1.2h6.443a.6.6 0 1 1 0 1.2h-1.195c-.376.056-.65.155-.823.296-.215.175-.423.439-.623.79l-2.366 9.347z\"/></svg>";
472
+
473
+ /**
474
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
475
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
476
+ */
477
+ /**
478
+ * @module basic-styles/italic/italicui
479
+ */
480
+ const ITALIC = 'italic';
481
+ /**
482
+ * The italic UI feature. It introduces the Italic button.
483
+ */
484
+ class ItalicUI extends Plugin {
485
+ /**
486
+ * @inheritDoc
487
+ */
488
+ static get pluginName() {
489
+ return 'ItalicUI';
490
+ }
491
+ /**
492
+ * @inheritDoc
493
+ */
494
+ init() {
495
+ const editor = this.editor;
496
+ const t = editor.t;
497
+ // Add bold button to feature components.
498
+ editor.ui.componentFactory.add(ITALIC, locale => {
499
+ const command = editor.commands.get(ITALIC);
500
+ const view = new ButtonView(locale);
501
+ view.set({
502
+ label: t('Italic'),
503
+ icon: italicIcon,
504
+ keystroke: 'CTRL+I',
505
+ tooltip: true,
506
+ isToggleable: true
507
+ });
508
+ view.bind('isOn', 'isEnabled').to(command, 'value', 'isEnabled');
509
+ // Execute command.
510
+ this.listenTo(view, 'execute', () => {
511
+ editor.execute(ITALIC);
512
+ editor.editing.view.focus();
513
+ });
514
+ return view;
515
+ });
516
+ }
517
+ }
518
+
519
+ /**
520
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
521
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
522
+ */
523
+ /**
524
+ * @module basic-styles/italic
525
+ */
526
+ /**
527
+ * The italic feature.
528
+ *
529
+ * For a detailed overview check the {@glink features/basic-styles Basic styles feature} guide
530
+ * and the {@glink api/basic-styles package page}.
531
+ *
532
+ * This is a "glue" plugin which loads the {@link module:basic-styles/italic/italicediting~ItalicEditing} and
533
+ * {@link module:basic-styles/italic/italicui~ItalicUI} plugins.
534
+ */
535
+ class Italic extends Plugin {
536
+ /**
537
+ * @inheritDoc
538
+ */
539
+ static get requires() {
540
+ return [ItalicEditing, ItalicUI];
541
+ }
542
+ /**
543
+ * @inheritDoc
544
+ */
545
+ static get pluginName() {
546
+ return 'Italic';
547
+ }
548
+ }
549
+
550
+ /**
551
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
552
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
553
+ */
554
+ /**
555
+ * @module basic-styles/strikethrough/strikethroughediting
556
+ */
557
+ const STRIKETHROUGH$1 = 'strikethrough';
558
+ /**
559
+ * The strikethrough editing feature.
560
+ *
561
+ * It registers the `'strikethrough'` command, the <kbd>Ctrl+Shift+X</kbd> keystroke and introduces the
562
+ * `strikethroughsthrough` attribute in the model which renders to the view
563
+ * as a `<s>` element.
564
+ */
565
+ class StrikethroughEditing extends Plugin {
566
+ /**
567
+ * @inheritDoc
568
+ */
569
+ static get pluginName() {
570
+ return 'StrikethroughEditing';
571
+ }
572
+ /**
573
+ * @inheritDoc
574
+ */
575
+ init() {
576
+ const editor = this.editor;
577
+ const t = this.editor.t;
578
+ // Allow strikethrough attribute on text nodes.
579
+ editor.model.schema.extend('$text', { allowAttributes: STRIKETHROUGH$1 });
580
+ editor.model.schema.setAttributeProperties(STRIKETHROUGH$1, {
581
+ isFormatting: true,
582
+ copyOnEnter: true
583
+ });
584
+ editor.conversion.attributeToElement({
585
+ model: STRIKETHROUGH$1,
586
+ view: 's',
587
+ upcastAlso: [
588
+ 'del',
589
+ 'strike',
590
+ {
591
+ styles: {
592
+ 'text-decoration': 'line-through'
593
+ }
594
+ }
595
+ ]
596
+ });
597
+ // Create strikethrough command.
598
+ editor.commands.add(STRIKETHROUGH$1, new AttributeCommand(editor, STRIKETHROUGH$1));
599
+ // Set the Ctrl+Shift+X keystroke.
600
+ editor.keystrokes.set('CTRL+SHIFT+X', 'strikethrough');
601
+ // Add the information about the keystroke to the accessibility database.
602
+ editor.accessibility.addKeystrokeInfos({
603
+ keystrokes: [
604
+ {
605
+ label: t('Strikethrough text'),
606
+ keystroke: 'CTRL+SHIFT+X'
607
+ }
608
+ ]
609
+ });
610
+ }
611
+ }
612
+
613
+ var strikethroughIcon = "<svg viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M7 16.4c-.8-.4-1.5-.9-2.2-1.5a.6.6 0 0 1-.2-.5l.3-.6h1c1 1.2 2.1 1.7 3.7 1.7 1 0 1.8-.3 2.3-.6.6-.4.6-1.2.6-1.3.2-1.2-.9-2.1-.9-2.1h2.1c.3.7.4 1.2.4 1.7v.8l-.6 1.2c-.6.8-1.1 1-1.6 1.2a6 6 0 0 1-2.4.6c-1 0-1.8-.3-2.5-.6zM6.8 9 6 8.3c-.4-.5-.5-.8-.5-1.6 0-.7.1-1.3.5-1.8.4-.6 1-1 1.6-1.3a6.3 6.3 0 0 1 4.7 0 4 4 0 0 1 1.7 1l.3.7c0 .1.2.4-.2.7-.4.2-.9.1-1 0a3 3 0 0 0-1.2-1c-.4-.2-1-.3-2-.4-.7 0-1.4.2-2 .6-.8.6-1 .8-1 1.5 0 .8.5 1 1.2 1.5.6.4 1.1.7 1.9 1H6.8z\"/><path d=\"M3 10.5V9h14v1.5z\"/></svg>";
614
+
615
+ /**
616
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
617
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
618
+ */
619
+ /**
620
+ * @module basic-styles/strikethrough/strikethroughui
621
+ */
622
+ const STRIKETHROUGH = 'strikethrough';
623
+ /**
624
+ * The strikethrough UI feature. It introduces the Strikethrough button.
625
+ */
626
+ class StrikethroughUI extends Plugin {
627
+ /**
628
+ * @inheritDoc
629
+ */
630
+ static get pluginName() {
631
+ return 'StrikethroughUI';
632
+ }
633
+ /**
634
+ * @inheritDoc
635
+ */
636
+ init() {
637
+ const editor = this.editor;
638
+ const t = editor.t;
639
+ // Add strikethrough button to feature components.
640
+ editor.ui.componentFactory.add(STRIKETHROUGH, locale => {
641
+ const command = editor.commands.get(STRIKETHROUGH);
642
+ const view = new ButtonView(locale);
643
+ view.set({
644
+ label: t('Strikethrough'),
645
+ icon: strikethroughIcon,
646
+ keystroke: 'CTRL+SHIFT+X',
647
+ tooltip: true,
648
+ isToggleable: true
649
+ });
650
+ view.bind('isOn', 'isEnabled').to(command, 'value', 'isEnabled');
651
+ // Execute command.
652
+ this.listenTo(view, 'execute', () => {
653
+ editor.execute(STRIKETHROUGH);
654
+ editor.editing.view.focus();
655
+ });
656
+ return view;
657
+ });
658
+ }
659
+ }
660
+
661
+ /**
662
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
663
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
664
+ */
665
+ /**
666
+ * @module basic-styles/strikethrough
667
+ */
668
+ /**
669
+ * The strikethrough feature.
670
+ *
671
+ * For a detailed overview check the {@glink features/basic-styles Basic styles feature} guide
672
+ * and the {@glink api/basic-styles package page}.
673
+ *
674
+ * This is a "glue" plugin which loads the {@link module:basic-styles/strikethrough/strikethroughediting~StrikethroughEditing} and
675
+ * {@link module:basic-styles/strikethrough/strikethroughui~StrikethroughUI} plugins.
676
+ */
677
+ class Strikethrough extends Plugin {
678
+ /**
679
+ * @inheritDoc
680
+ */
681
+ static get requires() {
682
+ return [StrikethroughEditing, StrikethroughUI];
683
+ }
684
+ /**
685
+ * @inheritDoc
686
+ */
687
+ static get pluginName() {
688
+ return 'Strikethrough';
689
+ }
690
+ }
691
+
692
+ /**
693
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
694
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
695
+ */
696
+ /**
697
+ * @module basic-styles/subscript/subscriptediting
698
+ */
699
+ const SUBSCRIPT$1 = 'subscript';
700
+ /**
701
+ * The subscript editing feature.
702
+ *
703
+ * It registers the `sub` command and introduces the `sub` attribute in the model which renders to the view
704
+ * as a `<sub>` element.
705
+ */
706
+ class SubscriptEditing extends Plugin {
707
+ /**
708
+ * @inheritDoc
709
+ */
710
+ static get pluginName() {
711
+ return 'SubscriptEditing';
712
+ }
713
+ /**
714
+ * @inheritDoc
715
+ */
716
+ init() {
717
+ const editor = this.editor;
718
+ // Allow sub attribute on text nodes.
719
+ editor.model.schema.extend('$text', { allowAttributes: SUBSCRIPT$1 });
720
+ editor.model.schema.setAttributeProperties(SUBSCRIPT$1, {
721
+ isFormatting: true,
722
+ copyOnEnter: true
723
+ });
724
+ // Build converter from model to view for data and editing pipelines.
725
+ editor.conversion.attributeToElement({
726
+ model: SUBSCRIPT$1,
727
+ view: 'sub',
728
+ upcastAlso: [
729
+ {
730
+ styles: {
731
+ 'vertical-align': 'sub'
732
+ }
733
+ }
734
+ ]
735
+ });
736
+ // Create sub command.
737
+ editor.commands.add(SUBSCRIPT$1, new AttributeCommand(editor, SUBSCRIPT$1));
738
+ }
739
+ }
740
+
741
+ var subscriptIcon = "<svg viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"m7.03 10.349 3.818-3.819a.8.8 0 1 1 1.132 1.132L8.16 11.48l3.819 3.818a.8.8 0 1 1-1.132 1.132L7.03 12.61l-3.818 3.82a.8.8 0 1 1-1.132-1.132L5.9 11.48 2.08 7.662A.8.8 0 1 1 3.212 6.53l3.818 3.82zm8.147 7.829h2.549c.254 0 .447.05.58.152a.49.49 0 0 1 .201.413.54.54 0 0 1-.159.393c-.105.108-.266.162-.48.162h-3.594c-.245 0-.435-.066-.572-.197a.621.621 0 0 1-.205-.463c0-.114.044-.265.132-.453a1.62 1.62 0 0 1 .288-.444c.433-.436.824-.81 1.172-1.122.348-.312.597-.517.747-.615.267-.183.49-.368.667-.553.177-.185.312-.375.405-.57.093-.194.139-.384.139-.57a1.008 1.008 0 0 0-.554-.917 1.197 1.197 0 0 0-.56-.133c-.426 0-.761.182-1.005.546a2.332 2.332 0 0 0-.164.39 1.609 1.609 0 0 1-.258.488c-.096.114-.237.17-.423.17a.558.558 0 0 1-.405-.156.568.568 0 0 1-.161-.427c0-.218.05-.446.151-.683.101-.238.252-.453.452-.646s.454-.349.762-.467a2.998 2.998 0 0 1 1.081-.178c.498 0 .923.076 1.274.228a1.916 1.916 0 0 1 1.004 1.032 1.984 1.984 0 0 1-.156 1.794c-.2.32-.405.572-.613.754-.208.182-.558.468-1.048.857-.49.39-.826.691-1.008.906a2.703 2.703 0 0 0-.24.309z\"/></svg>";
742
+
743
+ /**
744
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
745
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
746
+ */
747
+ /**
748
+ * @module basic-styles/subscript/subscriptui
749
+ */
750
+ const SUBSCRIPT = 'subscript';
751
+ /**
752
+ * The subscript UI feature. It introduces the Subscript button.
753
+ */
754
+ class SubscriptUI extends Plugin {
755
+ /**
756
+ * @inheritDoc
757
+ */
758
+ static get pluginName() {
759
+ return 'SubscriptUI';
760
+ }
761
+ /**
762
+ * @inheritDoc
763
+ */
764
+ init() {
765
+ const editor = this.editor;
766
+ const t = editor.t;
767
+ // Add subscript button to feature components.
768
+ editor.ui.componentFactory.add(SUBSCRIPT, locale => {
769
+ const command = editor.commands.get(SUBSCRIPT);
770
+ const view = new ButtonView(locale);
771
+ view.set({
772
+ label: t('Subscript'),
773
+ icon: subscriptIcon,
774
+ tooltip: true,
775
+ isToggleable: true
776
+ });
777
+ view.bind('isOn', 'isEnabled').to(command, 'value', 'isEnabled');
778
+ // Execute command.
779
+ this.listenTo(view, 'execute', () => {
780
+ editor.execute(SUBSCRIPT);
781
+ editor.editing.view.focus();
782
+ });
783
+ return view;
784
+ });
785
+ }
786
+ }
787
+
788
+ /**
789
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
790
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
791
+ */
792
+ /**
793
+ * @module basic-styles/subscript
794
+ */
795
+ /**
796
+ * The subscript feature.
797
+ *
798
+ * It loads the {@link module:basic-styles/subscript/subscriptediting~SubscriptEditing} and
799
+ * {@link module:basic-styles/subscript/subscriptui~SubscriptUI} plugins.
800
+ */
801
+ class Subscript extends Plugin {
802
+ /**
803
+ * @inheritDoc
804
+ */
805
+ static get requires() {
806
+ return [SubscriptEditing, SubscriptUI];
807
+ }
808
+ /**
809
+ * @inheritDoc
810
+ */
811
+ static get pluginName() {
812
+ return 'Subscript';
813
+ }
814
+ }
815
+
816
+ /**
817
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
818
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
819
+ */
820
+ /**
821
+ * @module basic-styles/superscript/superscriptediting
822
+ */
823
+ const SUPERSCRIPT$1 = 'superscript';
824
+ /**
825
+ * The superscript editing feature.
826
+ *
827
+ * It registers the `super` command and introduces the `super` attribute in the model which renders to the view
828
+ * as a `<super>` element.
829
+ */
830
+ class SuperscriptEditing extends Plugin {
831
+ /**
832
+ * @inheritDoc
833
+ */
834
+ static get pluginName() {
835
+ return 'SuperscriptEditing';
836
+ }
837
+ /**
838
+ * @inheritDoc
839
+ */
840
+ init() {
841
+ const editor = this.editor;
842
+ // Allow super attribute on text nodes.
843
+ editor.model.schema.extend('$text', { allowAttributes: SUPERSCRIPT$1 });
844
+ editor.model.schema.setAttributeProperties(SUPERSCRIPT$1, {
845
+ isFormatting: true,
846
+ copyOnEnter: true
847
+ });
848
+ // Build converter from model to view for data and editing pipelines.
849
+ editor.conversion.attributeToElement({
850
+ model: SUPERSCRIPT$1,
851
+ view: 'sup',
852
+ upcastAlso: [
853
+ {
854
+ styles: {
855
+ 'vertical-align': 'super'
856
+ }
857
+ }
858
+ ]
859
+ });
860
+ // Create super command.
861
+ editor.commands.add(SUPERSCRIPT$1, new AttributeCommand(editor, SUPERSCRIPT$1));
862
+ }
863
+ }
864
+
865
+ var superscriptIcon = "<svg viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M15.677 8.678h2.549c.254 0 .447.05.58.152a.49.49 0 0 1 .201.413.54.54 0 0 1-.159.393c-.105.108-.266.162-.48.162h-3.594c-.245 0-.435-.066-.572-.197a.621.621 0 0 1-.205-.463c0-.114.044-.265.132-.453a1.62 1.62 0 0 1 .288-.444c.433-.436.824-.81 1.172-1.122.348-.312.597-.517.747-.615.267-.183.49-.368.667-.553.177-.185.312-.375.405-.57.093-.194.139-.384.139-.57a1.008 1.008 0 0 0-.554-.917 1.197 1.197 0 0 0-.56-.133c-.426 0-.761.182-1.005.546a2.332 2.332 0 0 0-.164.39 1.609 1.609 0 0 1-.258.488c-.096.114-.237.17-.423.17a.558.558 0 0 1-.405-.156.568.568 0 0 1-.161-.427c0-.218.05-.446.151-.683.101-.238.252-.453.452-.646s.454-.349.762-.467a2.998 2.998 0 0 1 1.081-.178c.498 0 .923.076 1.274.228a1.916 1.916 0 0 1 1.004 1.032 1.984 1.984 0 0 1-.156 1.794c-.2.32-.405.572-.613.754-.208.182-.558.468-1.048.857-.49.39-.826.691-1.008.906a2.703 2.703 0 0 0-.24.309zM7.03 10.349l3.818-3.819a.8.8 0 1 1 1.132 1.132L8.16 11.48l3.819 3.818a.8.8 0 1 1-1.132 1.132L7.03 12.61l-3.818 3.82a.8.8 0 1 1-1.132-1.132L5.9 11.48 2.08 7.662A.8.8 0 1 1 3.212 6.53l3.818 3.82z\"/></svg>";
866
+
867
+ /**
868
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
869
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
870
+ */
871
+ /**
872
+ * @module basic-styles/superscript/superscriptui
873
+ */
874
+ const SUPERSCRIPT = 'superscript';
875
+ /**
876
+ * The superscript UI feature. It introduces the Superscript button.
877
+ */
878
+ class SuperscriptUI extends Plugin {
879
+ /**
880
+ * @inheritDoc
881
+ */
882
+ static get pluginName() {
883
+ return 'SuperscriptUI';
884
+ }
885
+ /**
886
+ * @inheritDoc
887
+ */
888
+ init() {
889
+ const editor = this.editor;
890
+ const t = editor.t;
891
+ // Add superscript button to feature components.
892
+ editor.ui.componentFactory.add(SUPERSCRIPT, locale => {
893
+ const command = editor.commands.get(SUPERSCRIPT);
894
+ const view = new ButtonView(locale);
895
+ view.set({
896
+ label: t('Superscript'),
897
+ icon: superscriptIcon,
898
+ tooltip: true,
899
+ isToggleable: true
900
+ });
901
+ view.bind('isOn', 'isEnabled').to(command, 'value', 'isEnabled');
902
+ // Execute command.
903
+ this.listenTo(view, 'execute', () => {
904
+ editor.execute(SUPERSCRIPT);
905
+ editor.editing.view.focus();
906
+ });
907
+ return view;
908
+ });
909
+ }
910
+ }
911
+
912
+ /**
913
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
914
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
915
+ */
916
+ /**
917
+ * @module basic-styles/superscript
918
+ */
919
+ /**
920
+ * The superscript feature.
921
+ *
922
+ * It loads the {@link module:basic-styles/superscript/superscriptediting~SuperscriptEditing} and
923
+ * {@link module:basic-styles/superscript/superscriptui~SuperscriptUI} plugins.
924
+ */
925
+ class Superscript extends Plugin {
926
+ /**
927
+ * @inheritDoc
928
+ */
929
+ static get requires() {
930
+ return [SuperscriptEditing, SuperscriptUI];
931
+ }
932
+ /**
933
+ * @inheritDoc
934
+ */
935
+ static get pluginName() {
936
+ return 'Superscript';
937
+ }
938
+ }
939
+
940
+ /**
941
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
942
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
943
+ */
944
+ /**
945
+ * @module basic-styles/underline/underlineediting
946
+ */
947
+ const UNDERLINE$1 = 'underline';
948
+ /**
949
+ * The underline editing feature.
950
+ *
951
+ * It registers the `'underline'` command, the <kbd>Ctrl+U</kbd> keystroke
952
+ * and introduces the `underline` attribute in the model which renders to the view as an `<u>` element.
953
+ */
954
+ class UnderlineEditing extends Plugin {
955
+ /**
956
+ * @inheritDoc
957
+ */
958
+ static get pluginName() {
959
+ return 'UnderlineEditing';
960
+ }
961
+ /**
962
+ * @inheritDoc
963
+ */
964
+ init() {
965
+ const editor = this.editor;
966
+ const t = this.editor.t;
967
+ // Allow strikethrough attribute on text nodes.
968
+ editor.model.schema.extend('$text', { allowAttributes: UNDERLINE$1 });
969
+ editor.model.schema.setAttributeProperties(UNDERLINE$1, {
970
+ isFormatting: true,
971
+ copyOnEnter: true
972
+ });
973
+ editor.conversion.attributeToElement({
974
+ model: UNDERLINE$1,
975
+ view: 'u',
976
+ upcastAlso: {
977
+ styles: {
978
+ 'text-decoration': 'underline'
979
+ }
980
+ }
981
+ });
982
+ // Create underline command.
983
+ editor.commands.add(UNDERLINE$1, new AttributeCommand(editor, UNDERLINE$1));
984
+ // Set the Ctrl+U keystroke.
985
+ editor.keystrokes.set('CTRL+U', 'underline');
986
+ // Add the information about the keystroke to the accessibility database.
987
+ editor.accessibility.addKeystrokeInfos({
988
+ keystrokes: [
989
+ {
990
+ label: t('Underline text'),
991
+ keystroke: 'CTRL+U'
992
+ }
993
+ ]
994
+ });
995
+ }
996
+ }
997
+
998
+ var underlineIcon = "<svg viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M3 18v-1.5h14V18zm2.2-8V3.6c0-.4.4-.6.8-.6.3 0 .7.2.7.6v6.2c0 2 1.3 2.8 3.2 2.8 1.9 0 3.4-.9 3.4-2.9V3.6c0-.3.4-.5.8-.5.3 0 .7.2.7.5V10c0 2.7-2.2 4-4.9 4-2.6 0-4.7-1.2-4.7-4z\"/></svg>";
999
+
1000
+ /**
1001
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
1002
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
1003
+ */
1004
+ /**
1005
+ * @module basic-styles/underline/underlineui
1006
+ */
1007
+ const UNDERLINE = 'underline';
1008
+ /**
1009
+ * The underline UI feature. It introduces the Underline button.
1010
+ */
1011
+ class UnderlineUI extends Plugin {
1012
+ /**
1013
+ * @inheritDoc
1014
+ */
1015
+ static get pluginName() {
1016
+ return 'UnderlineUI';
1017
+ }
1018
+ /**
1019
+ * @inheritDoc
1020
+ */
1021
+ init() {
1022
+ const editor = this.editor;
1023
+ const t = editor.t;
1024
+ // Add bold button to feature components.
1025
+ editor.ui.componentFactory.add(UNDERLINE, locale => {
1026
+ const command = editor.commands.get(UNDERLINE);
1027
+ const view = new ButtonView(locale);
1028
+ view.set({
1029
+ label: t('Underline'),
1030
+ icon: underlineIcon,
1031
+ keystroke: 'CTRL+U',
1032
+ tooltip: true,
1033
+ isToggleable: true
1034
+ });
1035
+ view.bind('isOn', 'isEnabled').to(command, 'value', 'isEnabled');
1036
+ // Execute command.
1037
+ this.listenTo(view, 'execute', () => {
1038
+ editor.execute(UNDERLINE);
1039
+ editor.editing.view.focus();
1040
+ });
1041
+ return view;
1042
+ });
1043
+ }
1044
+ }
1045
+
1046
+ /**
1047
+ * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
1048
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
1049
+ */
1050
+ /**
1051
+ * @module basic-styles/underline
1052
+ */
1053
+ /**
1054
+ * The underline feature.
1055
+ *
1056
+ * For a detailed overview check the {@glink features/basic-styles Basic styles feature} guide
1057
+ * and the {@glink api/basic-styles package page}.
1058
+ *
1059
+ * This is a "glue" plugin which loads the {@link module:basic-styles/underline/underlineediting~UnderlineEditing} and
1060
+ * {@link module:basic-styles/underline/underlineui~UnderlineUI} plugins.
1061
+ */
1062
+ class Underline extends Plugin {
1063
+ /**
1064
+ * @inheritDoc
1065
+ */
1066
+ static get requires() {
1067
+ return [UnderlineEditing, UnderlineUI];
1068
+ }
1069
+ /**
1070
+ * @inheritDoc
1071
+ */
1072
+ static get pluginName() {
1073
+ return 'Underline';
1074
+ }
1075
+ }
1076
+
1077
+ export { Bold, BoldEditing, BoldUI, Code, CodeEditing, CodeUI, Italic, ItalicEditing, ItalicUI, Strikethrough, StrikethroughEditing, StrikethroughUI, Subscript, SubscriptEditing, SubscriptUI, Superscript, SuperscriptEditing, SuperscriptUI, Underline, UnderlineEditing, UnderlineUI };
1078
+ //# sourceMappingURL=index.js.map