@ckeditor/ckeditor5-basic-styles 41.3.1 → 41.4.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-content.css +9 -0
- package/dist/index-editor.css +7 -0
- package/dist/index.css +20 -0
- package/dist/index.css.map +1 -0
- package/dist/index.js +831 -0
- package/dist/index.js.map +1 -0
- package/dist/translations/af.d.ts +8 -0
- package/dist/translations/af.js +5 -0
- package/dist/translations/ar.d.ts +8 -0
- package/dist/translations/ar.js +5 -0
- package/dist/translations/ast.d.ts +8 -0
- package/dist/translations/ast.js +5 -0
- package/dist/translations/az.d.ts +8 -0
- package/dist/translations/az.js +5 -0
- package/dist/translations/bg.d.ts +8 -0
- package/dist/translations/bg.js +5 -0
- package/dist/translations/bn.d.ts +8 -0
- package/dist/translations/bn.js +5 -0
- package/dist/translations/bs.d.ts +8 -0
- package/dist/translations/bs.js +5 -0
- package/dist/translations/ca.d.ts +8 -0
- package/dist/translations/ca.js +5 -0
- package/dist/translations/cs.d.ts +8 -0
- package/dist/translations/cs.js +5 -0
- package/dist/translations/da.d.ts +8 -0
- package/dist/translations/da.js +5 -0
- package/dist/translations/de-ch.d.ts +8 -0
- package/dist/translations/de-ch.js +5 -0
- package/dist/translations/de.d.ts +8 -0
- package/dist/translations/de.js +5 -0
- package/dist/translations/el.d.ts +8 -0
- package/dist/translations/el.js +5 -0
- package/dist/translations/en-au.d.ts +8 -0
- package/dist/translations/en-au.js +5 -0
- package/dist/translations/en-gb.d.ts +8 -0
- package/dist/translations/en-gb.js +5 -0
- package/dist/translations/en.d.ts +8 -0
- package/dist/translations/en.js +5 -0
- package/dist/translations/eo.d.ts +8 -0
- package/dist/translations/eo.js +5 -0
- package/dist/translations/es-co.d.ts +8 -0
- package/dist/translations/es-co.js +5 -0
- package/dist/translations/es.d.ts +8 -0
- package/dist/translations/es.js +5 -0
- package/dist/translations/et.d.ts +8 -0
- package/dist/translations/et.js +5 -0
- package/dist/translations/eu.d.ts +8 -0
- package/dist/translations/eu.js +5 -0
- package/dist/translations/fa.d.ts +8 -0
- package/dist/translations/fa.js +5 -0
- package/dist/translations/fi.d.ts +8 -0
- package/dist/translations/fi.js +5 -0
- package/dist/translations/fr.d.ts +8 -0
- package/dist/translations/fr.js +5 -0
- package/dist/translations/gl.d.ts +8 -0
- package/dist/translations/gl.js +5 -0
- package/dist/translations/gu.d.ts +8 -0
- package/dist/translations/gu.js +5 -0
- package/dist/translations/he.d.ts +8 -0
- package/dist/translations/he.js +5 -0
- package/dist/translations/hi.d.ts +8 -0
- package/dist/translations/hi.js +5 -0
- package/dist/translations/hr.d.ts +8 -0
- package/dist/translations/hr.js +5 -0
- package/dist/translations/hu.d.ts +8 -0
- package/dist/translations/hu.js +5 -0
- package/dist/translations/hy.d.ts +8 -0
- package/dist/translations/hy.js +5 -0
- package/dist/translations/id.d.ts +8 -0
- package/dist/translations/id.js +5 -0
- package/dist/translations/it.d.ts +8 -0
- package/dist/translations/it.js +5 -0
- package/dist/translations/ja.d.ts +8 -0
- package/dist/translations/ja.js +5 -0
- package/dist/translations/jv.d.ts +8 -0
- package/dist/translations/jv.js +5 -0
- package/dist/translations/km.d.ts +8 -0
- package/dist/translations/km.js +5 -0
- package/dist/translations/kn.d.ts +8 -0
- package/dist/translations/kn.js +5 -0
- package/dist/translations/ko.d.ts +8 -0
- package/dist/translations/ko.js +5 -0
- package/dist/translations/ku.d.ts +8 -0
- package/dist/translations/ku.js +5 -0
- package/dist/translations/lt.d.ts +8 -0
- package/dist/translations/lt.js +5 -0
- package/dist/translations/lv.d.ts +8 -0
- package/dist/translations/lv.js +5 -0
- package/dist/translations/ms.d.ts +8 -0
- package/dist/translations/ms.js +5 -0
- package/dist/translations/nb.d.ts +8 -0
- package/dist/translations/nb.js +5 -0
- package/dist/translations/ne.d.ts +8 -0
- package/dist/translations/ne.js +5 -0
- package/dist/translations/nl.d.ts +8 -0
- package/dist/translations/nl.js +5 -0
- package/dist/translations/no.d.ts +8 -0
- package/dist/translations/no.js +5 -0
- package/dist/translations/oc.d.ts +8 -0
- package/dist/translations/oc.js +5 -0
- package/dist/translations/pl.d.ts +8 -0
- package/dist/translations/pl.js +5 -0
- package/dist/translations/pt-br.d.ts +8 -0
- package/dist/translations/pt-br.js +5 -0
- package/dist/translations/pt.d.ts +8 -0
- package/dist/translations/pt.js +5 -0
- package/dist/translations/ro.d.ts +8 -0
- package/dist/translations/ro.js +5 -0
- package/dist/translations/ru.d.ts +8 -0
- package/dist/translations/ru.js +5 -0
- package/dist/translations/si.d.ts +8 -0
- package/dist/translations/si.js +5 -0
- package/dist/translations/sk.d.ts +8 -0
- package/dist/translations/sk.js +5 -0
- package/dist/translations/sl.d.ts +8 -0
- package/dist/translations/sl.js +5 -0
- package/dist/translations/sq.d.ts +8 -0
- package/dist/translations/sq.js +5 -0
- package/dist/translations/sr-latn.d.ts +8 -0
- package/dist/translations/sr-latn.js +5 -0
- package/dist/translations/sr.d.ts +8 -0
- package/dist/translations/sr.js +5 -0
- package/dist/translations/sv.d.ts +8 -0
- package/dist/translations/sv.js +5 -0
- package/dist/translations/th.d.ts +8 -0
- package/dist/translations/th.js +5 -0
- package/dist/translations/tk.d.ts +8 -0
- package/dist/translations/tk.js +5 -0
- package/dist/translations/tr.d.ts +8 -0
- package/dist/translations/tr.js +5 -0
- package/dist/translations/tt.d.ts +8 -0
- package/dist/translations/tt.js +5 -0
- package/dist/translations/ug.d.ts +8 -0
- package/dist/translations/ug.js +5 -0
- package/dist/translations/uk.d.ts +8 -0
- package/dist/translations/uk.js +5 -0
- package/dist/translations/ur.d.ts +8 -0
- package/dist/translations/ur.js +5 -0
- package/dist/translations/uz.d.ts +8 -0
- package/dist/translations/uz.js +5 -0
- package/dist/translations/vi.d.ts +8 -0
- package/dist/translations/vi.js +5 -0
- package/dist/translations/zh-cn.d.ts +8 -0
- package/dist/translations/zh-cn.js +5 -0
- package/dist/translations/zh.d.ts +8 -0
- package/dist/translations/zh.js +5 -0
- package/dist/types/attributecommand.d.ts +78 -0
- package/dist/types/augmentation.d.ts +44 -0
- package/dist/types/bold/boldediting.d.ts +28 -0
- package/dist/types/bold/boldui.d.ts +25 -0
- package/dist/types/bold.d.ts +33 -0
- package/dist/types/code/codeediting.d.ts +33 -0
- package/dist/types/code/codeui.d.ts +26 -0
- package/dist/types/code.d.ts +34 -0
- package/dist/types/index.d.ts +34 -0
- package/dist/types/italic/italicediting.d.ts +28 -0
- package/dist/types/italic/italicui.d.ts +25 -0
- package/dist/types/italic.d.ts +33 -0
- package/dist/types/strikethrough/strikethroughediting.d.ts +29 -0
- package/dist/types/strikethrough/strikethroughui.d.ts +25 -0
- package/dist/types/strikethrough.d.ts +33 -0
- package/dist/types/subscript/subscriptediting.d.ts +28 -0
- package/dist/types/subscript/subscriptui.d.ts +25 -0
- package/dist/types/subscript.d.ts +30 -0
- package/dist/types/superscript/superscriptediting.d.ts +28 -0
- package/dist/types/superscript/superscriptui.d.ts +25 -0
- package/dist/types/superscript.d.ts +30 -0
- package/dist/types/underline/underlineediting.d.ts +28 -0
- package/dist/types/underline/underlineui.d.ts +25 -0
- package/dist/types/underline.d.ts +33 -0
- package/dist/types/utils.d.ts +24 -0
- package/package.json +3 -2
package/dist/index.js
ADDED
|
@@ -0,0 +1,831 @@
|
|
|
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, MenuBarMenuListItemButtonView } from '@ckeditor/ckeditor5-ui/dist/index.js';
|
|
7
|
+
import { TwoStepCaretMovement, inlineHighlight } from '@ckeditor/ckeditor5-typing/dist/index.js';
|
|
8
|
+
|
|
9
|
+
class AttributeCommand extends Command {
|
|
10
|
+
/**
|
|
11
|
+
* Updates the command's {@link #value} and {@link #isEnabled} based on the current selection.
|
|
12
|
+
*/ refresh() {
|
|
13
|
+
const model = this.editor.model;
|
|
14
|
+
const doc = model.document;
|
|
15
|
+
this.value = this._getValueFromFirstAllowedNode();
|
|
16
|
+
this.isEnabled = model.schema.checkAttributeInSelection(doc.selection, this.attributeKey);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Executes the command – applies the attribute to the selection or removes it from the selection.
|
|
20
|
+
*
|
|
21
|
+
* If the command is active (`value == true`), it will remove attributes. Otherwise, it will set attributes.
|
|
22
|
+
*
|
|
23
|
+
* The execution result differs, depending on the {@link module:engine/model/document~Document#selection}:
|
|
24
|
+
*
|
|
25
|
+
* * If the selection is on a range, the command applies the attribute to all nodes in that range
|
|
26
|
+
* (if they are allowed to have this attribute by the {@link module:engine/model/schema~Schema schema}).
|
|
27
|
+
* * If the selection is collapsed in a non-empty node, the command applies the attribute to the
|
|
28
|
+
* {@link module:engine/model/document~Document#selection} itself (note that typed characters copy attributes from the selection).
|
|
29
|
+
* * If the selection is collapsed in an empty node, the command applies the attribute to the parent node of the selection (note
|
|
30
|
+
* that the selection inherits all attributes from a node if it is in an empty node).
|
|
31
|
+
*
|
|
32
|
+
* @fires execute
|
|
33
|
+
* @param options Command options.
|
|
34
|
+
* @param options.forceValue If set, it will force the command behavior. If `true`,
|
|
35
|
+
* the command will apply the attribute, otherwise the command will remove the attribute.
|
|
36
|
+
* If not set, the command will look for its current value to decide what it should do.
|
|
37
|
+
*/ execute(options = {}) {
|
|
38
|
+
const model = this.editor.model;
|
|
39
|
+
const doc = model.document;
|
|
40
|
+
const selection = doc.selection;
|
|
41
|
+
const value = options.forceValue === undefined ? !this.value : options.forceValue;
|
|
42
|
+
model.change((writer)=>{
|
|
43
|
+
if (selection.isCollapsed) {
|
|
44
|
+
if (value) {
|
|
45
|
+
writer.setSelectionAttribute(this.attributeKey, true);
|
|
46
|
+
} else {
|
|
47
|
+
writer.removeSelectionAttribute(this.attributeKey);
|
|
48
|
+
}
|
|
49
|
+
} else {
|
|
50
|
+
const ranges = model.schema.getValidRanges(selection.getRanges(), this.attributeKey);
|
|
51
|
+
for (const range of ranges){
|
|
52
|
+
if (value) {
|
|
53
|
+
writer.setAttribute(this.attributeKey, value, range);
|
|
54
|
+
} else {
|
|
55
|
+
writer.removeAttribute(this.attributeKey, range);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Checks the attribute value of the first node in the selection that allows the attribute.
|
|
63
|
+
* For the collapsed selection returns the selection attribute.
|
|
64
|
+
*
|
|
65
|
+
* @returns The attribute value.
|
|
66
|
+
*/ _getValueFromFirstAllowedNode() {
|
|
67
|
+
const model = this.editor.model;
|
|
68
|
+
const schema = model.schema;
|
|
69
|
+
const selection = model.document.selection;
|
|
70
|
+
if (selection.isCollapsed) {
|
|
71
|
+
return selection.hasAttribute(this.attributeKey);
|
|
72
|
+
}
|
|
73
|
+
for (const range of selection.getRanges()){
|
|
74
|
+
for (const item of range.getItems()){
|
|
75
|
+
if (schema.checkAttribute(item, this.attributeKey)) {
|
|
76
|
+
return item.hasAttribute(this.attributeKey);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* @param attributeKey Attribute that will be set by the command.
|
|
84
|
+
*/ constructor(editor, attributeKey){
|
|
85
|
+
super(editor);
|
|
86
|
+
this.attributeKey = attributeKey;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const BOLD$1 = 'bold';
|
|
91
|
+
class BoldEditing extends Plugin {
|
|
92
|
+
/**
|
|
93
|
+
* @inheritDoc
|
|
94
|
+
*/ static get pluginName() {
|
|
95
|
+
return 'BoldEditing';
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* @inheritDoc
|
|
99
|
+
*/ init() {
|
|
100
|
+
const editor = this.editor;
|
|
101
|
+
const t = this.editor.t;
|
|
102
|
+
// Allow bold attribute on text nodes.
|
|
103
|
+
editor.model.schema.extend('$text', {
|
|
104
|
+
allowAttributes: BOLD$1
|
|
105
|
+
});
|
|
106
|
+
editor.model.schema.setAttributeProperties(BOLD$1, {
|
|
107
|
+
isFormatting: true,
|
|
108
|
+
copyOnEnter: true
|
|
109
|
+
});
|
|
110
|
+
// Build converter from model to view for data and editing pipelines.
|
|
111
|
+
editor.conversion.attributeToElement({
|
|
112
|
+
model: BOLD$1,
|
|
113
|
+
view: 'strong',
|
|
114
|
+
upcastAlso: [
|
|
115
|
+
'b',
|
|
116
|
+
(viewElement)=>{
|
|
117
|
+
const fontWeight = viewElement.getStyle('font-weight');
|
|
118
|
+
if (!fontWeight) {
|
|
119
|
+
return null;
|
|
120
|
+
}
|
|
121
|
+
// Value of the `font-weight` attribute can be defined as a string or a number.
|
|
122
|
+
if (fontWeight == 'bold' || Number(fontWeight) >= 600) {
|
|
123
|
+
return {
|
|
124
|
+
name: true,
|
|
125
|
+
styles: [
|
|
126
|
+
'font-weight'
|
|
127
|
+
]
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
return null;
|
|
131
|
+
}
|
|
132
|
+
]
|
|
133
|
+
});
|
|
134
|
+
// Create bold command.
|
|
135
|
+
editor.commands.add(BOLD$1, new AttributeCommand(editor, BOLD$1));
|
|
136
|
+
// Set the Ctrl+B keystroke.
|
|
137
|
+
editor.keystrokes.set('CTRL+B', BOLD$1);
|
|
138
|
+
// Add the information about the keystroke to the accessibility database.
|
|
139
|
+
editor.accessibility.addKeystrokeInfos({
|
|
140
|
+
keystrokes: [
|
|
141
|
+
{
|
|
142
|
+
label: t('Bold text'),
|
|
143
|
+
keystroke: 'CTRL+B'
|
|
144
|
+
}
|
|
145
|
+
]
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
|
152
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
153
|
+
*/ /**
|
|
154
|
+
* Returns a function that creates a (toolbar or menu bar) button for a basic style feature.
|
|
155
|
+
*/ function getButtonCreator({ editor, commandName, plugin, icon, label, keystroke }) {
|
|
156
|
+
return (ButtonClass)=>{
|
|
157
|
+
const command = editor.commands.get(commandName);
|
|
158
|
+
const view = new ButtonClass(editor.locale);
|
|
159
|
+
view.set({
|
|
160
|
+
label,
|
|
161
|
+
icon,
|
|
162
|
+
keystroke,
|
|
163
|
+
isToggleable: true
|
|
164
|
+
});
|
|
165
|
+
view.bind('isEnabled').to(command, 'isEnabled');
|
|
166
|
+
// Execute the command.
|
|
167
|
+
plugin.listenTo(view, 'execute', ()=>{
|
|
168
|
+
editor.execute(commandName);
|
|
169
|
+
editor.editing.view.focus();
|
|
170
|
+
});
|
|
171
|
+
return view;
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
const BOLD = 'bold';
|
|
176
|
+
class BoldUI extends Plugin {
|
|
177
|
+
/**
|
|
178
|
+
* @inheritDoc
|
|
179
|
+
*/ static get pluginName() {
|
|
180
|
+
return 'BoldUI';
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* @inheritDoc
|
|
184
|
+
*/ init() {
|
|
185
|
+
const editor = this.editor;
|
|
186
|
+
const t = editor.locale.t;
|
|
187
|
+
const command = editor.commands.get(BOLD);
|
|
188
|
+
const createButton = getButtonCreator({
|
|
189
|
+
editor,
|
|
190
|
+
commandName: BOLD,
|
|
191
|
+
plugin: this,
|
|
192
|
+
icon: icons.bold,
|
|
193
|
+
label: t('Bold'),
|
|
194
|
+
keystroke: 'CTRL+B'
|
|
195
|
+
});
|
|
196
|
+
// Add bold button to feature components.
|
|
197
|
+
editor.ui.componentFactory.add(BOLD, ()=>{
|
|
198
|
+
const buttonView = createButton(ButtonView);
|
|
199
|
+
buttonView.set({
|
|
200
|
+
tooltip: true
|
|
201
|
+
});
|
|
202
|
+
buttonView.bind('isOn').to(command, 'value');
|
|
203
|
+
return buttonView;
|
|
204
|
+
});
|
|
205
|
+
editor.ui.componentFactory.add('menuBar:' + BOLD, ()=>{
|
|
206
|
+
return createButton(MenuBarMenuListItemButtonView);
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
class Bold extends Plugin {
|
|
212
|
+
/**
|
|
213
|
+
* @inheritDoc
|
|
214
|
+
*/ static get requires() {
|
|
215
|
+
return [
|
|
216
|
+
BoldEditing,
|
|
217
|
+
BoldUI
|
|
218
|
+
];
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* @inheritDoc
|
|
222
|
+
*/ static get pluginName() {
|
|
223
|
+
return 'Bold';
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
const CODE$1 = 'code';
|
|
228
|
+
const HIGHLIGHT_CLASS = 'ck-code_selected';
|
|
229
|
+
class CodeEditing extends Plugin {
|
|
230
|
+
/**
|
|
231
|
+
* @inheritDoc
|
|
232
|
+
*/ static get pluginName() {
|
|
233
|
+
return 'CodeEditing';
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* @inheritDoc
|
|
237
|
+
*/ static get requires() {
|
|
238
|
+
return [
|
|
239
|
+
TwoStepCaretMovement
|
|
240
|
+
];
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* @inheritDoc
|
|
244
|
+
*/ init() {
|
|
245
|
+
const editor = this.editor;
|
|
246
|
+
const t = this.editor.t;
|
|
247
|
+
// Allow code attribute on text nodes.
|
|
248
|
+
editor.model.schema.extend('$text', {
|
|
249
|
+
allowAttributes: CODE$1
|
|
250
|
+
});
|
|
251
|
+
editor.model.schema.setAttributeProperties(CODE$1, {
|
|
252
|
+
isFormatting: true,
|
|
253
|
+
copyOnEnter: false
|
|
254
|
+
});
|
|
255
|
+
editor.conversion.attributeToElement({
|
|
256
|
+
model: CODE$1,
|
|
257
|
+
view: 'code',
|
|
258
|
+
upcastAlso: {
|
|
259
|
+
styles: {
|
|
260
|
+
'word-wrap': 'break-word'
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
});
|
|
264
|
+
// Create code command.
|
|
265
|
+
editor.commands.add(CODE$1, new AttributeCommand(editor, CODE$1));
|
|
266
|
+
// Enable two-step caret movement for `code` attribute.
|
|
267
|
+
editor.plugins.get(TwoStepCaretMovement).registerAttribute(CODE$1);
|
|
268
|
+
// Setup highlight over selected element.
|
|
269
|
+
inlineHighlight(editor, CODE$1, 'code', HIGHLIGHT_CLASS);
|
|
270
|
+
// Add the information about the keystroke to the accessibility database.
|
|
271
|
+
editor.accessibility.addKeystrokeInfos({
|
|
272
|
+
keystrokes: [
|
|
273
|
+
{
|
|
274
|
+
label: t('Move out of an inline code style'),
|
|
275
|
+
keystroke: [
|
|
276
|
+
[
|
|
277
|
+
'arrowleft',
|
|
278
|
+
'arrowleft'
|
|
279
|
+
],
|
|
280
|
+
[
|
|
281
|
+
'arrowright',
|
|
282
|
+
'arrowright'
|
|
283
|
+
]
|
|
284
|
+
]
|
|
285
|
+
}
|
|
286
|
+
]
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
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>";
|
|
292
|
+
|
|
293
|
+
const CODE = 'code';
|
|
294
|
+
class CodeUI extends Plugin {
|
|
295
|
+
/**
|
|
296
|
+
* @inheritDoc
|
|
297
|
+
*/ static get pluginName() {
|
|
298
|
+
return 'CodeUI';
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* @inheritDoc
|
|
302
|
+
*/ init() {
|
|
303
|
+
const editor = this.editor;
|
|
304
|
+
const t = editor.locale.t;
|
|
305
|
+
const createButton = getButtonCreator({
|
|
306
|
+
editor,
|
|
307
|
+
commandName: CODE,
|
|
308
|
+
plugin: this,
|
|
309
|
+
icon: codeIcon,
|
|
310
|
+
label: t('Code')
|
|
311
|
+
});
|
|
312
|
+
// Add code button to feature components.
|
|
313
|
+
editor.ui.componentFactory.add(CODE, ()=>{
|
|
314
|
+
const buttonView = createButton(ButtonView);
|
|
315
|
+
const command = editor.commands.get(CODE);
|
|
316
|
+
buttonView.set({
|
|
317
|
+
tooltip: true
|
|
318
|
+
});
|
|
319
|
+
// Bind button model to command.
|
|
320
|
+
buttonView.bind('isOn').to(command, 'value');
|
|
321
|
+
return buttonView;
|
|
322
|
+
});
|
|
323
|
+
editor.ui.componentFactory.add('menuBar:' + CODE, ()=>{
|
|
324
|
+
return createButton(MenuBarMenuListItemButtonView);
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
class Code extends Plugin {
|
|
330
|
+
/**
|
|
331
|
+
* @inheritDoc
|
|
332
|
+
*/ static get requires() {
|
|
333
|
+
return [
|
|
334
|
+
CodeEditing,
|
|
335
|
+
CodeUI
|
|
336
|
+
];
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* @inheritDoc
|
|
340
|
+
*/ static get pluginName() {
|
|
341
|
+
return 'Code';
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
const ITALIC$1 = 'italic';
|
|
346
|
+
class ItalicEditing extends Plugin {
|
|
347
|
+
/**
|
|
348
|
+
* @inheritDoc
|
|
349
|
+
*/ static get pluginName() {
|
|
350
|
+
return 'ItalicEditing';
|
|
351
|
+
}
|
|
352
|
+
/**
|
|
353
|
+
* @inheritDoc
|
|
354
|
+
*/ init() {
|
|
355
|
+
const editor = this.editor;
|
|
356
|
+
const t = this.editor.t;
|
|
357
|
+
// Allow italic attribute on text nodes.
|
|
358
|
+
editor.model.schema.extend('$text', {
|
|
359
|
+
allowAttributes: ITALIC$1
|
|
360
|
+
});
|
|
361
|
+
editor.model.schema.setAttributeProperties(ITALIC$1, {
|
|
362
|
+
isFormatting: true,
|
|
363
|
+
copyOnEnter: true
|
|
364
|
+
});
|
|
365
|
+
editor.conversion.attributeToElement({
|
|
366
|
+
model: ITALIC$1,
|
|
367
|
+
view: 'i',
|
|
368
|
+
upcastAlso: [
|
|
369
|
+
'em',
|
|
370
|
+
{
|
|
371
|
+
styles: {
|
|
372
|
+
'font-style': 'italic'
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
]
|
|
376
|
+
});
|
|
377
|
+
// Create italic command.
|
|
378
|
+
editor.commands.add(ITALIC$1, new AttributeCommand(editor, ITALIC$1));
|
|
379
|
+
// Set the Ctrl+I keystroke.
|
|
380
|
+
editor.keystrokes.set('CTRL+I', ITALIC$1);
|
|
381
|
+
// Add the information about the keystroke to the accessibility database.
|
|
382
|
+
editor.accessibility.addKeystrokeInfos({
|
|
383
|
+
keystrokes: [
|
|
384
|
+
{
|
|
385
|
+
label: t('Italic text'),
|
|
386
|
+
keystroke: 'CTRL+I'
|
|
387
|
+
}
|
|
388
|
+
]
|
|
389
|
+
});
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
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>";
|
|
394
|
+
|
|
395
|
+
const ITALIC = 'italic';
|
|
396
|
+
class ItalicUI extends Plugin {
|
|
397
|
+
/**
|
|
398
|
+
* @inheritDoc
|
|
399
|
+
*/ static get pluginName() {
|
|
400
|
+
return 'ItalicUI';
|
|
401
|
+
}
|
|
402
|
+
/**
|
|
403
|
+
* @inheritDoc
|
|
404
|
+
*/ init() {
|
|
405
|
+
const editor = this.editor;
|
|
406
|
+
const command = editor.commands.get(ITALIC);
|
|
407
|
+
const t = editor.locale.t;
|
|
408
|
+
const createButton = getButtonCreator({
|
|
409
|
+
editor,
|
|
410
|
+
commandName: ITALIC,
|
|
411
|
+
plugin: this,
|
|
412
|
+
icon: italicIcon,
|
|
413
|
+
keystroke: 'CTRL+I',
|
|
414
|
+
label: t('Italic')
|
|
415
|
+
});
|
|
416
|
+
// Add bold button to feature components.
|
|
417
|
+
editor.ui.componentFactory.add(ITALIC, ()=>{
|
|
418
|
+
const buttonView = createButton(ButtonView);
|
|
419
|
+
buttonView.set({
|
|
420
|
+
tooltip: true
|
|
421
|
+
});
|
|
422
|
+
buttonView.bind('isOn').to(command, 'value');
|
|
423
|
+
return buttonView;
|
|
424
|
+
});
|
|
425
|
+
editor.ui.componentFactory.add('menuBar:' + ITALIC, ()=>{
|
|
426
|
+
return createButton(MenuBarMenuListItemButtonView);
|
|
427
|
+
});
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
class Italic extends Plugin {
|
|
432
|
+
/**
|
|
433
|
+
* @inheritDoc
|
|
434
|
+
*/ static get requires() {
|
|
435
|
+
return [
|
|
436
|
+
ItalicEditing,
|
|
437
|
+
ItalicUI
|
|
438
|
+
];
|
|
439
|
+
}
|
|
440
|
+
/**
|
|
441
|
+
* @inheritDoc
|
|
442
|
+
*/ static get pluginName() {
|
|
443
|
+
return 'Italic';
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
const STRIKETHROUGH$1 = 'strikethrough';
|
|
448
|
+
class StrikethroughEditing extends Plugin {
|
|
449
|
+
/**
|
|
450
|
+
* @inheritDoc
|
|
451
|
+
*/ static get pluginName() {
|
|
452
|
+
return 'StrikethroughEditing';
|
|
453
|
+
}
|
|
454
|
+
/**
|
|
455
|
+
* @inheritDoc
|
|
456
|
+
*/ init() {
|
|
457
|
+
const editor = this.editor;
|
|
458
|
+
const t = this.editor.t;
|
|
459
|
+
// Allow strikethrough attribute on text nodes.
|
|
460
|
+
editor.model.schema.extend('$text', {
|
|
461
|
+
allowAttributes: STRIKETHROUGH$1
|
|
462
|
+
});
|
|
463
|
+
editor.model.schema.setAttributeProperties(STRIKETHROUGH$1, {
|
|
464
|
+
isFormatting: true,
|
|
465
|
+
copyOnEnter: true
|
|
466
|
+
});
|
|
467
|
+
editor.conversion.attributeToElement({
|
|
468
|
+
model: STRIKETHROUGH$1,
|
|
469
|
+
view: 's',
|
|
470
|
+
upcastAlso: [
|
|
471
|
+
'del',
|
|
472
|
+
'strike',
|
|
473
|
+
{
|
|
474
|
+
styles: {
|
|
475
|
+
'text-decoration': 'line-through'
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
]
|
|
479
|
+
});
|
|
480
|
+
// Create strikethrough command.
|
|
481
|
+
editor.commands.add(STRIKETHROUGH$1, new AttributeCommand(editor, STRIKETHROUGH$1));
|
|
482
|
+
// Set the Ctrl+Shift+X keystroke.
|
|
483
|
+
editor.keystrokes.set('CTRL+SHIFT+X', 'strikethrough');
|
|
484
|
+
// Add the information about the keystroke to the accessibility database.
|
|
485
|
+
editor.accessibility.addKeystrokeInfos({
|
|
486
|
+
keystrokes: [
|
|
487
|
+
{
|
|
488
|
+
label: t('Strikethrough text'),
|
|
489
|
+
keystroke: 'CTRL+SHIFT+X'
|
|
490
|
+
}
|
|
491
|
+
]
|
|
492
|
+
});
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
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>";
|
|
497
|
+
|
|
498
|
+
const STRIKETHROUGH = 'strikethrough';
|
|
499
|
+
class StrikethroughUI extends Plugin {
|
|
500
|
+
/**
|
|
501
|
+
* @inheritDoc
|
|
502
|
+
*/ static get pluginName() {
|
|
503
|
+
return 'StrikethroughUI';
|
|
504
|
+
}
|
|
505
|
+
/**
|
|
506
|
+
* @inheritDoc
|
|
507
|
+
*/ init() {
|
|
508
|
+
const editor = this.editor;
|
|
509
|
+
const t = editor.locale.t;
|
|
510
|
+
const createButton = getButtonCreator({
|
|
511
|
+
editor,
|
|
512
|
+
commandName: STRIKETHROUGH,
|
|
513
|
+
plugin: this,
|
|
514
|
+
icon: strikethroughIcon,
|
|
515
|
+
keystroke: 'CTRL+SHIFT+X',
|
|
516
|
+
label: t('Strikethrough')
|
|
517
|
+
});
|
|
518
|
+
// Add strikethrough button to feature components.
|
|
519
|
+
editor.ui.componentFactory.add(STRIKETHROUGH, ()=>{
|
|
520
|
+
const buttonView = createButton(ButtonView);
|
|
521
|
+
const command = editor.commands.get(STRIKETHROUGH);
|
|
522
|
+
buttonView.set({
|
|
523
|
+
tooltip: true
|
|
524
|
+
});
|
|
525
|
+
// Bind button model to command.
|
|
526
|
+
buttonView.bind('isOn').to(command, 'value');
|
|
527
|
+
return buttonView;
|
|
528
|
+
});
|
|
529
|
+
editor.ui.componentFactory.add('menuBar:' + STRIKETHROUGH, ()=>{
|
|
530
|
+
return createButton(MenuBarMenuListItemButtonView);
|
|
531
|
+
});
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
class Strikethrough extends Plugin {
|
|
536
|
+
/**
|
|
537
|
+
* @inheritDoc
|
|
538
|
+
*/ static get requires() {
|
|
539
|
+
return [
|
|
540
|
+
StrikethroughEditing,
|
|
541
|
+
StrikethroughUI
|
|
542
|
+
];
|
|
543
|
+
}
|
|
544
|
+
/**
|
|
545
|
+
* @inheritDoc
|
|
546
|
+
*/ static get pluginName() {
|
|
547
|
+
return 'Strikethrough';
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
const SUBSCRIPT$1 = 'subscript';
|
|
552
|
+
class SubscriptEditing extends Plugin {
|
|
553
|
+
/**
|
|
554
|
+
* @inheritDoc
|
|
555
|
+
*/ static get pluginName() {
|
|
556
|
+
return 'SubscriptEditing';
|
|
557
|
+
}
|
|
558
|
+
/**
|
|
559
|
+
* @inheritDoc
|
|
560
|
+
*/ init() {
|
|
561
|
+
const editor = this.editor;
|
|
562
|
+
// Allow sub attribute on text nodes.
|
|
563
|
+
editor.model.schema.extend('$text', {
|
|
564
|
+
allowAttributes: SUBSCRIPT$1
|
|
565
|
+
});
|
|
566
|
+
editor.model.schema.setAttributeProperties(SUBSCRIPT$1, {
|
|
567
|
+
isFormatting: true,
|
|
568
|
+
copyOnEnter: true
|
|
569
|
+
});
|
|
570
|
+
// Build converter from model to view for data and editing pipelines.
|
|
571
|
+
editor.conversion.attributeToElement({
|
|
572
|
+
model: SUBSCRIPT$1,
|
|
573
|
+
view: 'sub',
|
|
574
|
+
upcastAlso: [
|
|
575
|
+
{
|
|
576
|
+
styles: {
|
|
577
|
+
'vertical-align': 'sub'
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
]
|
|
581
|
+
});
|
|
582
|
+
// Create sub command.
|
|
583
|
+
editor.commands.add(SUBSCRIPT$1, new AttributeCommand(editor, SUBSCRIPT$1));
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
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>";
|
|
588
|
+
|
|
589
|
+
const SUBSCRIPT = 'subscript';
|
|
590
|
+
class SubscriptUI extends Plugin {
|
|
591
|
+
/**
|
|
592
|
+
* @inheritDoc
|
|
593
|
+
*/ static get pluginName() {
|
|
594
|
+
return 'SubscriptUI';
|
|
595
|
+
}
|
|
596
|
+
/**
|
|
597
|
+
* @inheritDoc
|
|
598
|
+
*/ init() {
|
|
599
|
+
const editor = this.editor;
|
|
600
|
+
const t = editor.locale.t;
|
|
601
|
+
const createButton = getButtonCreator({
|
|
602
|
+
editor,
|
|
603
|
+
commandName: SUBSCRIPT,
|
|
604
|
+
plugin: this,
|
|
605
|
+
icon: subscriptIcon,
|
|
606
|
+
label: t('Subscript')
|
|
607
|
+
});
|
|
608
|
+
// Add subscript button to feature components.
|
|
609
|
+
editor.ui.componentFactory.add(SUBSCRIPT, ()=>{
|
|
610
|
+
const buttonView = createButton(ButtonView);
|
|
611
|
+
const command = editor.commands.get(SUBSCRIPT);
|
|
612
|
+
buttonView.set({
|
|
613
|
+
tooltip: true
|
|
614
|
+
});
|
|
615
|
+
// Bind button model to command.
|
|
616
|
+
buttonView.bind('isOn').to(command, 'value');
|
|
617
|
+
return buttonView;
|
|
618
|
+
});
|
|
619
|
+
editor.ui.componentFactory.add('menuBar:' + SUBSCRIPT, ()=>{
|
|
620
|
+
return createButton(MenuBarMenuListItemButtonView);
|
|
621
|
+
});
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
class Subscript extends Plugin {
|
|
626
|
+
/**
|
|
627
|
+
* @inheritDoc
|
|
628
|
+
*/ static get requires() {
|
|
629
|
+
return [
|
|
630
|
+
SubscriptEditing,
|
|
631
|
+
SubscriptUI
|
|
632
|
+
];
|
|
633
|
+
}
|
|
634
|
+
/**
|
|
635
|
+
* @inheritDoc
|
|
636
|
+
*/ static get pluginName() {
|
|
637
|
+
return 'Subscript';
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
const SUPERSCRIPT$1 = 'superscript';
|
|
642
|
+
class SuperscriptEditing extends Plugin {
|
|
643
|
+
/**
|
|
644
|
+
* @inheritDoc
|
|
645
|
+
*/ static get pluginName() {
|
|
646
|
+
return 'SuperscriptEditing';
|
|
647
|
+
}
|
|
648
|
+
/**
|
|
649
|
+
* @inheritDoc
|
|
650
|
+
*/ init() {
|
|
651
|
+
const editor = this.editor;
|
|
652
|
+
// Allow super attribute on text nodes.
|
|
653
|
+
editor.model.schema.extend('$text', {
|
|
654
|
+
allowAttributes: SUPERSCRIPT$1
|
|
655
|
+
});
|
|
656
|
+
editor.model.schema.setAttributeProperties(SUPERSCRIPT$1, {
|
|
657
|
+
isFormatting: true,
|
|
658
|
+
copyOnEnter: true
|
|
659
|
+
});
|
|
660
|
+
// Build converter from model to view for data and editing pipelines.
|
|
661
|
+
editor.conversion.attributeToElement({
|
|
662
|
+
model: SUPERSCRIPT$1,
|
|
663
|
+
view: 'sup',
|
|
664
|
+
upcastAlso: [
|
|
665
|
+
{
|
|
666
|
+
styles: {
|
|
667
|
+
'vertical-align': 'super'
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
]
|
|
671
|
+
});
|
|
672
|
+
// Create super command.
|
|
673
|
+
editor.commands.add(SUPERSCRIPT$1, new AttributeCommand(editor, SUPERSCRIPT$1));
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
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>";
|
|
678
|
+
|
|
679
|
+
const SUPERSCRIPT = 'superscript';
|
|
680
|
+
class SuperscriptUI extends Plugin {
|
|
681
|
+
/**
|
|
682
|
+
* @inheritDoc
|
|
683
|
+
*/ static get pluginName() {
|
|
684
|
+
return 'SuperscriptUI';
|
|
685
|
+
}
|
|
686
|
+
/**
|
|
687
|
+
* @inheritDoc
|
|
688
|
+
*/ init() {
|
|
689
|
+
const editor = this.editor;
|
|
690
|
+
const t = editor.locale.t;
|
|
691
|
+
const createButton = getButtonCreator({
|
|
692
|
+
editor,
|
|
693
|
+
commandName: SUPERSCRIPT,
|
|
694
|
+
plugin: this,
|
|
695
|
+
icon: superscriptIcon,
|
|
696
|
+
label: t('Superscript')
|
|
697
|
+
});
|
|
698
|
+
// Add superscript button to feature components.
|
|
699
|
+
editor.ui.componentFactory.add(SUPERSCRIPT, ()=>{
|
|
700
|
+
const buttonView = createButton(ButtonView);
|
|
701
|
+
const command = editor.commands.get(SUPERSCRIPT);
|
|
702
|
+
buttonView.set({
|
|
703
|
+
tooltip: true
|
|
704
|
+
});
|
|
705
|
+
// Bind button model to command.
|
|
706
|
+
buttonView.bind('isOn').to(command, 'value');
|
|
707
|
+
return buttonView;
|
|
708
|
+
});
|
|
709
|
+
editor.ui.componentFactory.add('menuBar:' + SUPERSCRIPT, ()=>{
|
|
710
|
+
return createButton(MenuBarMenuListItemButtonView);
|
|
711
|
+
});
|
|
712
|
+
}
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
class Superscript extends Plugin {
|
|
716
|
+
/**
|
|
717
|
+
* @inheritDoc
|
|
718
|
+
*/ static get requires() {
|
|
719
|
+
return [
|
|
720
|
+
SuperscriptEditing,
|
|
721
|
+
SuperscriptUI
|
|
722
|
+
];
|
|
723
|
+
}
|
|
724
|
+
/**
|
|
725
|
+
* @inheritDoc
|
|
726
|
+
*/ static get pluginName() {
|
|
727
|
+
return 'Superscript';
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
const UNDERLINE$1 = 'underline';
|
|
732
|
+
class UnderlineEditing extends Plugin {
|
|
733
|
+
/**
|
|
734
|
+
* @inheritDoc
|
|
735
|
+
*/ static get pluginName() {
|
|
736
|
+
return 'UnderlineEditing';
|
|
737
|
+
}
|
|
738
|
+
/**
|
|
739
|
+
* @inheritDoc
|
|
740
|
+
*/ init() {
|
|
741
|
+
const editor = this.editor;
|
|
742
|
+
const t = this.editor.t;
|
|
743
|
+
// Allow strikethrough attribute on text nodes.
|
|
744
|
+
editor.model.schema.extend('$text', {
|
|
745
|
+
allowAttributes: UNDERLINE$1
|
|
746
|
+
});
|
|
747
|
+
editor.model.schema.setAttributeProperties(UNDERLINE$1, {
|
|
748
|
+
isFormatting: true,
|
|
749
|
+
copyOnEnter: true
|
|
750
|
+
});
|
|
751
|
+
editor.conversion.attributeToElement({
|
|
752
|
+
model: UNDERLINE$1,
|
|
753
|
+
view: 'u',
|
|
754
|
+
upcastAlso: {
|
|
755
|
+
styles: {
|
|
756
|
+
'text-decoration': 'underline'
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
});
|
|
760
|
+
// Create underline command.
|
|
761
|
+
editor.commands.add(UNDERLINE$1, new AttributeCommand(editor, UNDERLINE$1));
|
|
762
|
+
// Set the Ctrl+U keystroke.
|
|
763
|
+
editor.keystrokes.set('CTRL+U', 'underline');
|
|
764
|
+
// Add the information about the keystroke to the accessibility database.
|
|
765
|
+
editor.accessibility.addKeystrokeInfos({
|
|
766
|
+
keystrokes: [
|
|
767
|
+
{
|
|
768
|
+
label: t('Underline text'),
|
|
769
|
+
keystroke: 'CTRL+U'
|
|
770
|
+
}
|
|
771
|
+
]
|
|
772
|
+
});
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
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>";
|
|
777
|
+
|
|
778
|
+
const UNDERLINE = 'underline';
|
|
779
|
+
class UnderlineUI extends Plugin {
|
|
780
|
+
/**
|
|
781
|
+
* @inheritDoc
|
|
782
|
+
*/ static get pluginName() {
|
|
783
|
+
return 'UnderlineUI';
|
|
784
|
+
}
|
|
785
|
+
/**
|
|
786
|
+
* @inheritDoc
|
|
787
|
+
*/ init() {
|
|
788
|
+
const editor = this.editor;
|
|
789
|
+
const command = editor.commands.get(UNDERLINE);
|
|
790
|
+
const t = editor.locale.t;
|
|
791
|
+
const createButton = getButtonCreator({
|
|
792
|
+
editor,
|
|
793
|
+
commandName: UNDERLINE,
|
|
794
|
+
plugin: this,
|
|
795
|
+
icon: underlineIcon,
|
|
796
|
+
label: t('Underline'),
|
|
797
|
+
keystroke: 'CTRL+U'
|
|
798
|
+
});
|
|
799
|
+
// Add bold button to feature components.
|
|
800
|
+
editor.ui.componentFactory.add(UNDERLINE, ()=>{
|
|
801
|
+
const buttonView = createButton(ButtonView);
|
|
802
|
+
buttonView.set({
|
|
803
|
+
tooltip: true
|
|
804
|
+
});
|
|
805
|
+
buttonView.bind('isOn').to(command, 'value');
|
|
806
|
+
return buttonView;
|
|
807
|
+
});
|
|
808
|
+
editor.ui.componentFactory.add('menuBar:' + UNDERLINE, ()=>{
|
|
809
|
+
return createButton(MenuBarMenuListItemButtonView);
|
|
810
|
+
});
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
|
|
814
|
+
class Underline extends Plugin {
|
|
815
|
+
/**
|
|
816
|
+
* @inheritDoc
|
|
817
|
+
*/ static get requires() {
|
|
818
|
+
return [
|
|
819
|
+
UnderlineEditing,
|
|
820
|
+
UnderlineUI
|
|
821
|
+
];
|
|
822
|
+
}
|
|
823
|
+
/**
|
|
824
|
+
* @inheritDoc
|
|
825
|
+
*/ static get pluginName() {
|
|
826
|
+
return 'Underline';
|
|
827
|
+
}
|
|
828
|
+
}
|
|
829
|
+
|
|
830
|
+
export { Bold, BoldEditing, BoldUI, Code, CodeEditing, CodeUI, Italic, ItalicEditing, ItalicUI, Strikethrough, StrikethroughEditing, StrikethroughUI, Subscript, SubscriptEditing, SubscriptUI, Superscript, SuperscriptEditing, SuperscriptUI, Underline, UnderlineEditing, UnderlineUI };
|
|
831
|
+
//# sourceMappingURL=index.js.map
|