@ckeditor/ckeditor5-block-quote 48.2.0-alpha.7 → 48.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/augmentation.d.ts +13 -13
- package/dist/blockquote.d.ts +29 -29
- package/dist/blockquotecommand.d.ts +56 -56
- package/dist/blockquoteediting.d.ts +30 -30
- package/dist/blockquoteui.d.ts +29 -29
- package/dist/index.css.map +1 -1
- package/dist/index.d.ts +10 -10
- package/dist/index.js +348 -358
- package/dist/index.js.map +1 -1
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -2,377 +2,367 @@
|
|
|
2
2
|
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
4
|
*/
|
|
5
|
-
import { Command, Plugin } from
|
|
6
|
-
import { Enter } from
|
|
7
|
-
import { Delete } from
|
|
8
|
-
import { first } from
|
|
9
|
-
import { IconQuote } from
|
|
10
|
-
import { ButtonView, MenuBarMenuListItemButtonView } from
|
|
5
|
+
import { Command, Plugin } from "@ckeditor/ckeditor5-core";
|
|
6
|
+
import { Enter } from "@ckeditor/ckeditor5-enter";
|
|
7
|
+
import { Delete } from "@ckeditor/ckeditor5-typing";
|
|
8
|
+
import { first } from "@ckeditor/ckeditor5-utils";
|
|
9
|
+
import { IconQuote } from "@ckeditor/ckeditor5-icons";
|
|
10
|
+
import { ButtonView, MenuBarMenuListItemButtonView } from "@ckeditor/ckeditor5-ui";
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
return currentQuote;
|
|
125
|
-
}
|
|
126
|
-
return nextQuote;
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
}
|
|
13
|
+
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
|
|
14
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* @module block-quote/blockquotecommand
|
|
18
|
+
*/
|
|
19
|
+
/**
|
|
20
|
+
* The block quote command plugin.
|
|
21
|
+
*
|
|
22
|
+
* @extends module:core/command~Command
|
|
23
|
+
*/
|
|
24
|
+
var BlockQuoteCommand = class extends Command {
|
|
25
|
+
/**
|
|
26
|
+
* @inheritDoc
|
|
27
|
+
*/
|
|
28
|
+
refresh() {
|
|
29
|
+
this.value = this._getValue();
|
|
30
|
+
this.isEnabled = this._checkEnabled();
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Executes the command. When the command {@link #value is on}, all top-most block quotes within
|
|
34
|
+
* the selection will be removed. If it is off, all selected blocks will be wrapped with
|
|
35
|
+
* a block quote.
|
|
36
|
+
*
|
|
37
|
+
* @fires execute
|
|
38
|
+
* @param options Command options.
|
|
39
|
+
* @param options.forceValue If set, it will force the command behavior. If `true`, the command will apply a block quote,
|
|
40
|
+
* otherwise the command will remove the block quote. If not set, the command will act basing on its current value.
|
|
41
|
+
*/
|
|
42
|
+
execute(options = {}) {
|
|
43
|
+
const model = this.editor.model;
|
|
44
|
+
const schema = model.schema;
|
|
45
|
+
const selection = model.document.selection;
|
|
46
|
+
const blocks = Array.from(selection.getSelectedBlocks());
|
|
47
|
+
const value = options.forceValue === void 0 ? !this.value : options.forceValue;
|
|
48
|
+
model.change((writer) => {
|
|
49
|
+
if (!value) this._removeQuote(writer, blocks.filter(findQuote));
|
|
50
|
+
else {
|
|
51
|
+
const blocksToQuote = blocks.filter((block) => {
|
|
52
|
+
return findQuote(block) || checkCanBeQuoted(schema, block);
|
|
53
|
+
});
|
|
54
|
+
this._applyQuote(writer, blocksToQuote);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Checks the command's {@link #value}.
|
|
60
|
+
*/
|
|
61
|
+
_getValue() {
|
|
62
|
+
const selection = this.editor.model.document.selection;
|
|
63
|
+
const firstBlock = first(selection.getSelectedBlocks());
|
|
64
|
+
return !!(firstBlock && findQuote(firstBlock));
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Checks whether the command can be enabled in the current context.
|
|
68
|
+
*
|
|
69
|
+
* @returns Whether the command should be enabled.
|
|
70
|
+
*/
|
|
71
|
+
_checkEnabled() {
|
|
72
|
+
if (this.value) return true;
|
|
73
|
+
const selection = this.editor.model.document.selection;
|
|
74
|
+
const schema = this.editor.model.schema;
|
|
75
|
+
const firstBlock = first(selection.getSelectedBlocks());
|
|
76
|
+
if (!firstBlock) return false;
|
|
77
|
+
return checkCanBeQuoted(schema, firstBlock);
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Removes the quote from given blocks.
|
|
81
|
+
*
|
|
82
|
+
* If blocks which are supposed to be "unquoted" are in the middle of a quote,
|
|
83
|
+
* start it or end it, then the quote will be split (if needed) and the blocks
|
|
84
|
+
* will be moved out of it, so other quoted blocks remained quoted.
|
|
85
|
+
*/
|
|
86
|
+
_removeQuote(writer, blocks) {
|
|
87
|
+
getRangesOfBlockGroups(writer, blocks).reverse().forEach((groupRange) => {
|
|
88
|
+
if (groupRange.start.isAtStart && groupRange.end.isAtEnd) {
|
|
89
|
+
writer.unwrap(groupRange.start.parent);
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
if (groupRange.start.isAtStart) {
|
|
93
|
+
const positionBefore = writer.createPositionBefore(groupRange.start.parent);
|
|
94
|
+
writer.move(groupRange, positionBefore);
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
if (!groupRange.end.isAtEnd) writer.split(groupRange.end);
|
|
98
|
+
const positionAfter = writer.createPositionAfter(groupRange.end.parent);
|
|
99
|
+
writer.move(groupRange, positionAfter);
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Applies the quote to given blocks.
|
|
104
|
+
*/
|
|
105
|
+
_applyQuote(writer, blocks) {
|
|
106
|
+
const quotesToMerge = [];
|
|
107
|
+
getRangesOfBlockGroups(writer, blocks).reverse().forEach((groupRange) => {
|
|
108
|
+
let quote = findQuote(groupRange.start);
|
|
109
|
+
if (!quote) {
|
|
110
|
+
quote = writer.createElement("blockQuote");
|
|
111
|
+
writer.wrap(groupRange, quote);
|
|
112
|
+
}
|
|
113
|
+
quotesToMerge.push(quote);
|
|
114
|
+
});
|
|
115
|
+
quotesToMerge.reverse().reduce((currentQuote, nextQuote) => {
|
|
116
|
+
if (currentQuote.nextSibling == nextQuote) {
|
|
117
|
+
writer.merge(writer.createPositionAfter(currentQuote));
|
|
118
|
+
return currentQuote;
|
|
119
|
+
}
|
|
120
|
+
return nextQuote;
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
};
|
|
130
124
|
function findQuote(elementOrPosition) {
|
|
131
|
-
|
|
125
|
+
return elementOrPosition.parent.name == "blockQuote" ? elementOrPosition.parent : null;
|
|
132
126
|
}
|
|
133
127
|
/**
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
return ranges;
|
|
128
|
+
* Returns a minimal array of ranges containing groups of subsequent blocks.
|
|
129
|
+
*
|
|
130
|
+
* content: abcdefgh
|
|
131
|
+
* blocks: [ a, b, d, f, g, h ]
|
|
132
|
+
* output ranges: [ab]c[d]e[fgh]
|
|
133
|
+
*/
|
|
134
|
+
function getRangesOfBlockGroups(writer, blocks) {
|
|
135
|
+
let startPosition;
|
|
136
|
+
let i = 0;
|
|
137
|
+
const ranges = [];
|
|
138
|
+
while (i < blocks.length) {
|
|
139
|
+
const block = blocks[i];
|
|
140
|
+
const nextBlock = blocks[i + 1];
|
|
141
|
+
if (!startPosition) startPosition = writer.createPositionBefore(block);
|
|
142
|
+
if (!nextBlock || block.nextSibling != nextBlock) {
|
|
143
|
+
ranges.push(writer.createRange(startPosition, writer.createPositionAfter(block)));
|
|
144
|
+
startPosition = null;
|
|
145
|
+
}
|
|
146
|
+
i++;
|
|
147
|
+
}
|
|
148
|
+
return ranges;
|
|
156
149
|
}
|
|
157
150
|
/**
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
}
|
|
166
|
-
// Is block allowed inside block-quote.
|
|
167
|
-
if (!schema.checkChild(parentContext.push('blockQuote'), block)) {
|
|
168
|
-
return false;
|
|
169
|
-
}
|
|
170
|
-
return true;
|
|
151
|
+
* Checks whether <bQ> can wrap the block.
|
|
152
|
+
*/
|
|
153
|
+
function checkCanBeQuoted(schema, block) {
|
|
154
|
+
const parentContext = schema.createContext(block.parent);
|
|
155
|
+
if (!schema.checkChild(parentContext, "blockQuote")) return false;
|
|
156
|
+
if (!schema.checkChild(parentContext.push("blockQuote"), block)) return false;
|
|
157
|
+
return true;
|
|
171
158
|
}
|
|
172
159
|
|
|
173
160
|
/**
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
// If Backspace key is pressed with selection collapsed in first empty block inside a quote, break the quote.
|
|
270
|
-
this.listenTo(viewDocument, 'delete', (evt, data)=>{
|
|
271
|
-
if (data.direction != 'backward' || !selection.isCollapsed || !blockQuoteCommand.value) {
|
|
272
|
-
return;
|
|
273
|
-
}
|
|
274
|
-
const positionParent = selection.getLastPosition().parent;
|
|
275
|
-
if (positionParent.isEmpty && !positionParent.previousSibling) {
|
|
276
|
-
editor.execute('blockQuote');
|
|
277
|
-
editor.editing.view.scrollToTheSelection();
|
|
278
|
-
data.preventDefault();
|
|
279
|
-
evt.stop();
|
|
280
|
-
}
|
|
281
|
-
}, {
|
|
282
|
-
context: 'blockquote'
|
|
283
|
-
});
|
|
284
|
-
}
|
|
285
|
-
}
|
|
161
|
+
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
|
|
162
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
163
|
+
*/
|
|
164
|
+
/**
|
|
165
|
+
* @module block-quote/blockquoteediting
|
|
166
|
+
*/
|
|
167
|
+
/**
|
|
168
|
+
* The block quote editing.
|
|
169
|
+
*
|
|
170
|
+
* Introduces the `'blockQuote'` command and the `'blockQuote'` model element.
|
|
171
|
+
*
|
|
172
|
+
* @extends module:core/plugin~Plugin
|
|
173
|
+
*/
|
|
174
|
+
var BlockQuoteEditing = class extends Plugin {
|
|
175
|
+
/**
|
|
176
|
+
* @inheritDoc
|
|
177
|
+
*/
|
|
178
|
+
static get pluginName() {
|
|
179
|
+
return "BlockQuoteEditing";
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* @inheritDoc
|
|
183
|
+
*/
|
|
184
|
+
static get isOfficialPlugin() {
|
|
185
|
+
return true;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* @inheritDoc
|
|
189
|
+
*/
|
|
190
|
+
static get requires() {
|
|
191
|
+
return [Enter, Delete];
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* @inheritDoc
|
|
195
|
+
*/
|
|
196
|
+
init() {
|
|
197
|
+
const editor = this.editor;
|
|
198
|
+
const schema = editor.model.schema;
|
|
199
|
+
editor.commands.add("blockQuote", new BlockQuoteCommand(editor));
|
|
200
|
+
schema.register("blockQuote", { inheritAllFrom: "$container" });
|
|
201
|
+
editor.conversion.elementToElement({
|
|
202
|
+
model: "blockQuote",
|
|
203
|
+
view: "blockquote"
|
|
204
|
+
});
|
|
205
|
+
editor.model.document.registerPostFixer((writer) => {
|
|
206
|
+
const changes = editor.model.document.differ.getChanges();
|
|
207
|
+
for (const entry of changes) if (entry.type == "insert") {
|
|
208
|
+
const element = entry.position.nodeAfter;
|
|
209
|
+
if (!element) continue;
|
|
210
|
+
if (element.is("element", "blockQuote") && element.isEmpty) {
|
|
211
|
+
writer.remove(element);
|
|
212
|
+
return true;
|
|
213
|
+
} else if (element.is("element", "blockQuote") && !schema.checkChild(entry.position, element)) {
|
|
214
|
+
writer.unwrap(element);
|
|
215
|
+
return true;
|
|
216
|
+
} else if (element.is("element")) {
|
|
217
|
+
const range = writer.createRangeIn(element);
|
|
218
|
+
for (const child of range.getItems()) if (child.is("element", "blockQuote") && !schema.checkChild(writer.createPositionBefore(child), child)) {
|
|
219
|
+
writer.unwrap(child);
|
|
220
|
+
return true;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
} else if (entry.type == "remove") {
|
|
224
|
+
const parent = entry.position.parent;
|
|
225
|
+
if (parent.is("element", "blockQuote") && parent.isEmpty) {
|
|
226
|
+
writer.remove(parent);
|
|
227
|
+
return true;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
return false;
|
|
231
|
+
});
|
|
232
|
+
const viewDocument = this.editor.editing.view.document;
|
|
233
|
+
const selection = editor.model.document.selection;
|
|
234
|
+
const blockQuoteCommand = editor.commands.get("blockQuote");
|
|
235
|
+
this.listenTo(viewDocument, "enter", (evt, data) => {
|
|
236
|
+
if (!selection.isCollapsed || !blockQuoteCommand.value) return;
|
|
237
|
+
if (selection.getLastPosition().parent.isEmpty) {
|
|
238
|
+
editor.execute("blockQuote");
|
|
239
|
+
editor.editing.view.scrollToTheSelection();
|
|
240
|
+
data.preventDefault();
|
|
241
|
+
evt.stop();
|
|
242
|
+
}
|
|
243
|
+
}, { context: "blockquote" });
|
|
244
|
+
this.listenTo(viewDocument, "delete", (evt, data) => {
|
|
245
|
+
if (data.direction != "backward" || !selection.isCollapsed || !blockQuoteCommand.value) return;
|
|
246
|
+
const positionParent = selection.getLastPosition().parent;
|
|
247
|
+
if (positionParent.isEmpty && !positionParent.previousSibling) {
|
|
248
|
+
editor.execute("blockQuote");
|
|
249
|
+
editor.editing.view.scrollToTheSelection();
|
|
250
|
+
data.preventDefault();
|
|
251
|
+
evt.stop();
|
|
252
|
+
}
|
|
253
|
+
}, { context: "blockquote" });
|
|
254
|
+
}
|
|
255
|
+
};
|
|
286
256
|
|
|
287
257
|
/**
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
258
|
+
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
|
|
259
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
260
|
+
*/
|
|
261
|
+
/**
|
|
262
|
+
* @module block-quote/blockquoteui
|
|
263
|
+
*/
|
|
264
|
+
/**
|
|
265
|
+
* The block quote UI plugin.
|
|
266
|
+
*
|
|
267
|
+
* It introduces the `'blockQuote'` button.
|
|
268
|
+
*
|
|
269
|
+
* @extends module:core/plugin~Plugin
|
|
270
|
+
*/
|
|
271
|
+
var BlockQuoteUI = class extends Plugin {
|
|
272
|
+
/**
|
|
273
|
+
* @inheritDoc
|
|
274
|
+
*/
|
|
275
|
+
static get pluginName() {
|
|
276
|
+
return "BlockQuoteUI";
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* @inheritDoc
|
|
280
|
+
*/
|
|
281
|
+
static get isOfficialPlugin() {
|
|
282
|
+
return true;
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* @inheritDoc
|
|
286
|
+
*/
|
|
287
|
+
init() {
|
|
288
|
+
const editor = this.editor;
|
|
289
|
+
editor.ui.componentFactory.add("blockQuote", () => {
|
|
290
|
+
const buttonView = this._createButton(ButtonView);
|
|
291
|
+
buttonView.set({ tooltip: true });
|
|
292
|
+
return buttonView;
|
|
293
|
+
});
|
|
294
|
+
editor.ui.componentFactory.add("menuBar:blockQuote", () => {
|
|
295
|
+
const buttonView = this._createButton(MenuBarMenuListItemButtonView);
|
|
296
|
+
buttonView.set({ role: "menuitemcheckbox" });
|
|
297
|
+
return buttonView;
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* Creates a button for block quote command to use either in toolbar or in menu bar.
|
|
302
|
+
*/
|
|
303
|
+
_createButton(ButtonClass) {
|
|
304
|
+
const editor = this.editor;
|
|
305
|
+
const locale = editor.locale;
|
|
306
|
+
const command = editor.commands.get("blockQuote");
|
|
307
|
+
const view = new ButtonClass(editor.locale);
|
|
308
|
+
const t = locale.t;
|
|
309
|
+
view.set({
|
|
310
|
+
label: t("Block quote"),
|
|
311
|
+
icon: IconQuote,
|
|
312
|
+
isToggleable: true
|
|
313
|
+
});
|
|
314
|
+
view.bind("isEnabled").to(command, "isEnabled");
|
|
315
|
+
view.bind("isOn").to(command, "value");
|
|
316
|
+
this.listenTo(view, "execute", () => {
|
|
317
|
+
editor.execute("blockQuote");
|
|
318
|
+
editor.editing.view.focus();
|
|
319
|
+
});
|
|
320
|
+
return view;
|
|
321
|
+
}
|
|
322
|
+
};
|
|
346
323
|
|
|
347
324
|
/**
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
325
|
+
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
|
|
326
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
327
|
+
*/
|
|
328
|
+
/**
|
|
329
|
+
* @module block-quote/blockquote
|
|
330
|
+
*/
|
|
331
|
+
/**
|
|
332
|
+
* The block quote plugin.
|
|
333
|
+
*
|
|
334
|
+
* For more information about this feature check the {@glink api/block-quote package page}.
|
|
335
|
+
*
|
|
336
|
+
* This is a "glue" plugin which loads the {@link module:block-quote/blockquoteediting~BlockQuoteEditing block quote editing feature}
|
|
337
|
+
* and {@link module:block-quote/blockquoteui~BlockQuoteUI block quote UI feature}.
|
|
338
|
+
*
|
|
339
|
+
* @extends module:core/plugin~Plugin
|
|
340
|
+
*/
|
|
341
|
+
var BlockQuote = class extends Plugin {
|
|
342
|
+
/**
|
|
343
|
+
* @inheritDoc
|
|
344
|
+
*/
|
|
345
|
+
static get requires() {
|
|
346
|
+
return [BlockQuoteEditing, BlockQuoteUI];
|
|
347
|
+
}
|
|
348
|
+
/**
|
|
349
|
+
* @inheritDoc
|
|
350
|
+
*/
|
|
351
|
+
static get pluginName() {
|
|
352
|
+
return "BlockQuote";
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* @inheritDoc
|
|
356
|
+
*/
|
|
357
|
+
static get isOfficialPlugin() {
|
|
358
|
+
return true;
|
|
359
|
+
}
|
|
360
|
+
};
|
|
361
|
+
|
|
362
|
+
/**
|
|
363
|
+
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
|
|
364
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
365
|
+
*/
|
|
376
366
|
|
|
377
367
|
export { BlockQuote, BlockQuoteCommand, BlockQuoteEditing, BlockQuoteUI };
|
|
378
|
-
//# sourceMappingURL=index.js.map
|
|
368
|
+
//# sourceMappingURL=index.js.map
|