@ckeditor/ckeditor5-block-quote 0.0.0-internal-20241017.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/CHANGELOG.md +4 -0
- package/LICENSE.md +17 -0
- package/README.md +26 -0
- package/build/block-quote.js +5 -0
- package/build/translations/af.js +1 -0
- package/build/translations/ar.js +1 -0
- package/build/translations/az.js +1 -0
- package/build/translations/bg.js +1 -0
- package/build/translations/bn.js +1 -0
- package/build/translations/bs.js +1 -0
- package/build/translations/ca.js +1 -0
- package/build/translations/cs.js +1 -0
- package/build/translations/da.js +1 -0
- package/build/translations/de-ch.js +1 -0
- package/build/translations/de.js +1 -0
- package/build/translations/el.js +1 -0
- package/build/translations/en-au.js +1 -0
- package/build/translations/en-gb.js +1 -0
- package/build/translations/es-co.js +1 -0
- package/build/translations/es.js +1 -0
- package/build/translations/et.js +1 -0
- package/build/translations/eu.js +1 -0
- package/build/translations/fa.js +1 -0
- package/build/translations/fi.js +1 -0
- package/build/translations/fr.js +1 -0
- package/build/translations/gl.js +1 -0
- package/build/translations/gu.js +1 -0
- package/build/translations/he.js +1 -0
- package/build/translations/hi.js +1 -0
- package/build/translations/hr.js +1 -0
- package/build/translations/hu.js +1 -0
- package/build/translations/id.js +1 -0
- package/build/translations/it.js +1 -0
- package/build/translations/ja.js +1 -0
- package/build/translations/km.js +1 -0
- package/build/translations/kn.js +1 -0
- package/build/translations/ko.js +1 -0
- package/build/translations/ku.js +1 -0
- package/build/translations/lt.js +1 -0
- package/build/translations/lv.js +1 -0
- package/build/translations/ms.js +1 -0
- package/build/translations/nb.js +1 -0
- package/build/translations/ne.js +1 -0
- package/build/translations/nl.js +1 -0
- package/build/translations/no.js +1 -0
- package/build/translations/pl.js +1 -0
- package/build/translations/pt-br.js +1 -0
- package/build/translations/pt.js +1 -0
- package/build/translations/ro.js +1 -0
- package/build/translations/ru.js +1 -0
- package/build/translations/sk.js +1 -0
- package/build/translations/sl.js +1 -0
- package/build/translations/sq.js +1 -0
- package/build/translations/sr-latn.js +1 -0
- package/build/translations/sr.js +1 -0
- package/build/translations/sv.js +1 -0
- package/build/translations/th.js +1 -0
- package/build/translations/tk.js +1 -0
- package/build/translations/tr.js +1 -0
- package/build/translations/ug.js +1 -0
- package/build/translations/uk.js +1 -0
- package/build/translations/ur.js +1 -0
- package/build/translations/uz.js +1 -0
- package/build/translations/vi.js +1 -0
- package/build/translations/zh-cn.js +1 -0
- package/build/translations/zh.js +1 -0
- package/ckeditor5-metadata.json +23 -0
- package/dist/augmentation.d.ts +19 -0
- package/dist/blockquote.d.ts +38 -0
- package/dist/blockquotecommand.d.ts +65 -0
- package/dist/blockquoteediting.d.ts +39 -0
- package/dist/blockquoteui.d.ts +38 -0
- package/dist/index-content.css +19 -0
- package/dist/index-editor.css +4 -0
- package/dist/index.css +29 -0
- package/dist/index.css.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +373 -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/af.umd.js +11 -0
- package/dist/translations/ar.d.ts +8 -0
- package/dist/translations/ar.js +5 -0
- package/dist/translations/ar.umd.js +11 -0
- package/dist/translations/az.d.ts +8 -0
- package/dist/translations/az.js +5 -0
- package/dist/translations/az.umd.js +11 -0
- package/dist/translations/bg.d.ts +8 -0
- package/dist/translations/bg.js +5 -0
- package/dist/translations/bg.umd.js +11 -0
- package/dist/translations/bn.d.ts +8 -0
- package/dist/translations/bn.js +5 -0
- package/dist/translations/bn.umd.js +11 -0
- package/dist/translations/bs.d.ts +8 -0
- package/dist/translations/bs.js +5 -0
- package/dist/translations/bs.umd.js +11 -0
- package/dist/translations/ca.d.ts +8 -0
- package/dist/translations/ca.js +5 -0
- package/dist/translations/ca.umd.js +11 -0
- package/dist/translations/cs.d.ts +8 -0
- package/dist/translations/cs.js +5 -0
- package/dist/translations/cs.umd.js +11 -0
- package/dist/translations/da.d.ts +8 -0
- package/dist/translations/da.js +5 -0
- package/dist/translations/da.umd.js +11 -0
- package/dist/translations/de-ch.d.ts +8 -0
- package/dist/translations/de-ch.js +5 -0
- package/dist/translations/de-ch.umd.js +11 -0
- package/dist/translations/de.d.ts +8 -0
- package/dist/translations/de.js +5 -0
- package/dist/translations/de.umd.js +11 -0
- package/dist/translations/el.d.ts +8 -0
- package/dist/translations/el.js +5 -0
- package/dist/translations/el.umd.js +11 -0
- package/dist/translations/en-au.d.ts +8 -0
- package/dist/translations/en-au.js +5 -0
- package/dist/translations/en-au.umd.js +11 -0
- package/dist/translations/en-gb.d.ts +8 -0
- package/dist/translations/en-gb.js +5 -0
- package/dist/translations/en-gb.umd.js +11 -0
- package/dist/translations/en.d.ts +8 -0
- package/dist/translations/en.js +5 -0
- package/dist/translations/en.umd.js +11 -0
- package/dist/translations/es-co.d.ts +8 -0
- package/dist/translations/es-co.js +5 -0
- package/dist/translations/es-co.umd.js +11 -0
- package/dist/translations/es.d.ts +8 -0
- package/dist/translations/es.js +5 -0
- package/dist/translations/es.umd.js +11 -0
- package/dist/translations/et.d.ts +8 -0
- package/dist/translations/et.js +5 -0
- package/dist/translations/et.umd.js +11 -0
- package/dist/translations/eu.d.ts +8 -0
- package/dist/translations/eu.js +5 -0
- package/dist/translations/eu.umd.js +11 -0
- package/dist/translations/fa.d.ts +8 -0
- package/dist/translations/fa.js +5 -0
- package/dist/translations/fa.umd.js +11 -0
- package/dist/translations/fi.d.ts +8 -0
- package/dist/translations/fi.js +5 -0
- package/dist/translations/fi.umd.js +11 -0
- package/dist/translations/fr.d.ts +8 -0
- package/dist/translations/fr.js +5 -0
- package/dist/translations/fr.umd.js +11 -0
- package/dist/translations/gl.d.ts +8 -0
- package/dist/translations/gl.js +5 -0
- package/dist/translations/gl.umd.js +11 -0
- package/dist/translations/gu.d.ts +8 -0
- package/dist/translations/gu.js +5 -0
- package/dist/translations/gu.umd.js +11 -0
- package/dist/translations/he.d.ts +8 -0
- package/dist/translations/he.js +5 -0
- package/dist/translations/he.umd.js +11 -0
- package/dist/translations/hi.d.ts +8 -0
- package/dist/translations/hi.js +5 -0
- package/dist/translations/hi.umd.js +11 -0
- package/dist/translations/hr.d.ts +8 -0
- package/dist/translations/hr.js +5 -0
- package/dist/translations/hr.umd.js +11 -0
- package/dist/translations/hu.d.ts +8 -0
- package/dist/translations/hu.js +5 -0
- package/dist/translations/hu.umd.js +11 -0
- package/dist/translations/id.d.ts +8 -0
- package/dist/translations/id.js +5 -0
- package/dist/translations/id.umd.js +11 -0
- package/dist/translations/it.d.ts +8 -0
- package/dist/translations/it.js +5 -0
- package/dist/translations/it.umd.js +11 -0
- package/dist/translations/ja.d.ts +8 -0
- package/dist/translations/ja.js +5 -0
- package/dist/translations/ja.umd.js +11 -0
- package/dist/translations/km.d.ts +8 -0
- package/dist/translations/km.js +5 -0
- package/dist/translations/km.umd.js +11 -0
- package/dist/translations/kn.d.ts +8 -0
- package/dist/translations/kn.js +5 -0
- package/dist/translations/kn.umd.js +11 -0
- package/dist/translations/ko.d.ts +8 -0
- package/dist/translations/ko.js +5 -0
- package/dist/translations/ko.umd.js +11 -0
- package/dist/translations/ku.d.ts +8 -0
- package/dist/translations/ku.js +5 -0
- package/dist/translations/ku.umd.js +11 -0
- package/dist/translations/lt.d.ts +8 -0
- package/dist/translations/lt.js +5 -0
- package/dist/translations/lt.umd.js +11 -0
- package/dist/translations/lv.d.ts +8 -0
- package/dist/translations/lv.js +5 -0
- package/dist/translations/lv.umd.js +11 -0
- package/dist/translations/ms.d.ts +8 -0
- package/dist/translations/ms.js +5 -0
- package/dist/translations/ms.umd.js +11 -0
- package/dist/translations/nb.d.ts +8 -0
- package/dist/translations/nb.js +5 -0
- package/dist/translations/nb.umd.js +11 -0
- package/dist/translations/ne.d.ts +8 -0
- package/dist/translations/ne.js +5 -0
- package/dist/translations/ne.umd.js +11 -0
- package/dist/translations/nl.d.ts +8 -0
- package/dist/translations/nl.js +5 -0
- package/dist/translations/nl.umd.js +11 -0
- package/dist/translations/no.d.ts +8 -0
- package/dist/translations/no.js +5 -0
- package/dist/translations/no.umd.js +11 -0
- package/dist/translations/pl.d.ts +8 -0
- package/dist/translations/pl.js +5 -0
- package/dist/translations/pl.umd.js +11 -0
- package/dist/translations/pt-br.d.ts +8 -0
- package/dist/translations/pt-br.js +5 -0
- package/dist/translations/pt-br.umd.js +11 -0
- package/dist/translations/pt.d.ts +8 -0
- package/dist/translations/pt.js +5 -0
- package/dist/translations/pt.umd.js +11 -0
- package/dist/translations/ro.d.ts +8 -0
- package/dist/translations/ro.js +5 -0
- package/dist/translations/ro.umd.js +11 -0
- package/dist/translations/ru.d.ts +8 -0
- package/dist/translations/ru.js +5 -0
- package/dist/translations/ru.umd.js +11 -0
- package/dist/translations/sk.d.ts +8 -0
- package/dist/translations/sk.js +5 -0
- package/dist/translations/sk.umd.js +11 -0
- package/dist/translations/sl.d.ts +8 -0
- package/dist/translations/sl.js +5 -0
- package/dist/translations/sl.umd.js +11 -0
- package/dist/translations/sq.d.ts +8 -0
- package/dist/translations/sq.js +5 -0
- package/dist/translations/sq.umd.js +11 -0
- package/dist/translations/sr-latn.d.ts +8 -0
- package/dist/translations/sr-latn.js +5 -0
- package/dist/translations/sr-latn.umd.js +11 -0
- package/dist/translations/sr.d.ts +8 -0
- package/dist/translations/sr.js +5 -0
- package/dist/translations/sr.umd.js +11 -0
- package/dist/translations/sv.d.ts +8 -0
- package/dist/translations/sv.js +5 -0
- package/dist/translations/sv.umd.js +11 -0
- package/dist/translations/th.d.ts +8 -0
- package/dist/translations/th.js +5 -0
- package/dist/translations/th.umd.js +11 -0
- package/dist/translations/tk.d.ts +8 -0
- package/dist/translations/tk.js +5 -0
- package/dist/translations/tk.umd.js +11 -0
- package/dist/translations/tr.d.ts +8 -0
- package/dist/translations/tr.js +5 -0
- package/dist/translations/tr.umd.js +11 -0
- package/dist/translations/ug.d.ts +8 -0
- package/dist/translations/ug.js +5 -0
- package/dist/translations/ug.umd.js +11 -0
- package/dist/translations/uk.d.ts +8 -0
- package/dist/translations/uk.js +5 -0
- package/dist/translations/uk.umd.js +11 -0
- package/dist/translations/ur.d.ts +8 -0
- package/dist/translations/ur.js +5 -0
- package/dist/translations/ur.umd.js +11 -0
- package/dist/translations/uz.d.ts +8 -0
- package/dist/translations/uz.js +5 -0
- package/dist/translations/uz.umd.js +11 -0
- package/dist/translations/vi.d.ts +8 -0
- package/dist/translations/vi.js +5 -0
- package/dist/translations/vi.umd.js +11 -0
- package/dist/translations/zh-cn.d.ts +8 -0
- package/dist/translations/zh-cn.js +5 -0
- package/dist/translations/zh-cn.umd.js +11 -0
- package/dist/translations/zh.d.ts +8 -0
- package/dist/translations/zh.js +5 -0
- package/dist/translations/zh.umd.js +11 -0
- package/lang/contexts.json +3 -0
- package/lang/translations/af.po +22 -0
- package/lang/translations/ar.po +22 -0
- package/lang/translations/az.po +22 -0
- package/lang/translations/bg.po +22 -0
- package/lang/translations/bn.po +22 -0
- package/lang/translations/bs.po +22 -0
- package/lang/translations/ca.po +22 -0
- package/lang/translations/cs.po +22 -0
- package/lang/translations/da.po +22 -0
- package/lang/translations/de-ch.po +22 -0
- package/lang/translations/de.po +22 -0
- package/lang/translations/el.po +22 -0
- package/lang/translations/en-au.po +22 -0
- package/lang/translations/en-gb.po +22 -0
- package/lang/translations/en.po +22 -0
- package/lang/translations/es-co.po +22 -0
- package/lang/translations/es.po +22 -0
- package/lang/translations/et.po +22 -0
- package/lang/translations/eu.po +22 -0
- package/lang/translations/fa.po +22 -0
- package/lang/translations/fi.po +22 -0
- package/lang/translations/fr.po +22 -0
- package/lang/translations/gl.po +22 -0
- package/lang/translations/gu.po +22 -0
- package/lang/translations/he.po +22 -0
- package/lang/translations/hi.po +22 -0
- package/lang/translations/hr.po +22 -0
- package/lang/translations/hu.po +22 -0
- package/lang/translations/id.po +22 -0
- package/lang/translations/it.po +22 -0
- package/lang/translations/ja.po +22 -0
- package/lang/translations/km.po +22 -0
- package/lang/translations/kn.po +22 -0
- package/lang/translations/ko.po +22 -0
- package/lang/translations/ku.po +22 -0
- package/lang/translations/lt.po +22 -0
- package/lang/translations/lv.po +22 -0
- package/lang/translations/ms.po +22 -0
- package/lang/translations/nb.po +22 -0
- package/lang/translations/ne.po +22 -0
- package/lang/translations/nl.po +22 -0
- package/lang/translations/no.po +22 -0
- package/lang/translations/pl.po +22 -0
- package/lang/translations/pt-br.po +22 -0
- package/lang/translations/pt.po +22 -0
- package/lang/translations/ro.po +22 -0
- package/lang/translations/ru.po +22 -0
- package/lang/translations/sk.po +22 -0
- package/lang/translations/sl.po +22 -0
- package/lang/translations/sq.po +22 -0
- package/lang/translations/sr-latn.po +22 -0
- package/lang/translations/sr.po +22 -0
- package/lang/translations/sv.po +22 -0
- package/lang/translations/th.po +22 -0
- package/lang/translations/tk.po +22 -0
- package/lang/translations/tr.po +22 -0
- package/lang/translations/ug.po +22 -0
- package/lang/translations/uk.po +22 -0
- package/lang/translations/ur.po +22 -0
- package/lang/translations/uz.po +22 -0
- package/lang/translations/vi.po +22 -0
- package/lang/translations/zh-cn.po +22 -0
- package/lang/translations/zh.po +22 -0
- package/package.json +43 -0
- package/src/augmentation.d.ts +15 -0
- package/src/augmentation.js +5 -0
- package/src/blockquote.d.ts +34 -0
- package/src/blockquote.js +40 -0
- package/src/blockquotecommand.d.ts +61 -0
- package/src/blockquotecommand.js +172 -0
- package/src/blockquoteediting.d.ts +35 -0
- package/src/blockquoteediting.js +124 -0
- package/src/blockquoteui.d.ts +34 -0
- package/src/blockquoteui.js +74 -0
- package/src/index.d.ts +12 -0
- package/src/index.js +11 -0
- package/theme/blockquote.css +23 -0
|
@@ -0,0 +1,124 @@
|
|
|
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
|
+
/**
|
|
6
|
+
* @module block-quote/blockquoteediting
|
|
7
|
+
*/
|
|
8
|
+
import { Plugin } from 'ckeditor5/src/core.js';
|
|
9
|
+
import { Enter } from 'ckeditor5/src/enter.js';
|
|
10
|
+
import { Delete } from 'ckeditor5/src/typing.js';
|
|
11
|
+
import BlockQuoteCommand from './blockquotecommand.js';
|
|
12
|
+
/**
|
|
13
|
+
* The block quote editing.
|
|
14
|
+
*
|
|
15
|
+
* Introduces the `'blockQuote'` command and the `'blockQuote'` model element.
|
|
16
|
+
*
|
|
17
|
+
* @extends module:core/plugin~Plugin
|
|
18
|
+
*/
|
|
19
|
+
export default class BlockQuoteEditing extends Plugin {
|
|
20
|
+
/**
|
|
21
|
+
* @inheritDoc
|
|
22
|
+
*/
|
|
23
|
+
static get pluginName() {
|
|
24
|
+
return 'BlockQuoteEditing';
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* @inheritDoc
|
|
28
|
+
*/
|
|
29
|
+
static get isOfficialPlugin() {
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* @inheritDoc
|
|
34
|
+
*/
|
|
35
|
+
static get requires() {
|
|
36
|
+
return [Enter, Delete];
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* @inheritDoc
|
|
40
|
+
*/
|
|
41
|
+
init() {
|
|
42
|
+
const editor = this.editor;
|
|
43
|
+
const schema = editor.model.schema;
|
|
44
|
+
editor.commands.add('blockQuote', new BlockQuoteCommand(editor));
|
|
45
|
+
schema.register('blockQuote', {
|
|
46
|
+
inheritAllFrom: '$container'
|
|
47
|
+
});
|
|
48
|
+
editor.conversion.elementToElement({ model: 'blockQuote', view: 'blockquote' });
|
|
49
|
+
// Postfixer which cleans incorrect model states connected with block quotes.
|
|
50
|
+
editor.model.document.registerPostFixer(writer => {
|
|
51
|
+
const changes = editor.model.document.differ.getChanges();
|
|
52
|
+
for (const entry of changes) {
|
|
53
|
+
if (entry.type == 'insert') {
|
|
54
|
+
const element = entry.position.nodeAfter;
|
|
55
|
+
if (!element) {
|
|
56
|
+
// We are inside a text node.
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
if (element.is('element', 'blockQuote') && element.isEmpty) {
|
|
60
|
+
// Added an empty blockQuote - remove it.
|
|
61
|
+
writer.remove(element);
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
else if (element.is('element', 'blockQuote') && !schema.checkChild(entry.position, element)) {
|
|
65
|
+
// Added a blockQuote in incorrect place. Unwrap it so the content inside is not lost.
|
|
66
|
+
writer.unwrap(element);
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
else if (element.is('element')) {
|
|
70
|
+
// Just added an element. Check that all children meet the scheme rules.
|
|
71
|
+
const range = writer.createRangeIn(element);
|
|
72
|
+
for (const child of range.getItems()) {
|
|
73
|
+
if (child.is('element', 'blockQuote') &&
|
|
74
|
+
!schema.checkChild(writer.createPositionBefore(child), child)) {
|
|
75
|
+
writer.unwrap(child);
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
else if (entry.type == 'remove') {
|
|
82
|
+
const parent = entry.position.parent;
|
|
83
|
+
if (parent.is('element', 'blockQuote') && parent.isEmpty) {
|
|
84
|
+
// Something got removed and now blockQuote is empty. Remove the blockQuote as well.
|
|
85
|
+
writer.remove(parent);
|
|
86
|
+
return true;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return false;
|
|
91
|
+
});
|
|
92
|
+
const viewDocument = this.editor.editing.view.document;
|
|
93
|
+
const selection = editor.model.document.selection;
|
|
94
|
+
const blockQuoteCommand = editor.commands.get('blockQuote');
|
|
95
|
+
// Overwrite default Enter key behavior.
|
|
96
|
+
// If Enter key is pressed with selection collapsed in empty block inside a quote, break the quote.
|
|
97
|
+
this.listenTo(viewDocument, 'enter', (evt, data) => {
|
|
98
|
+
if (!selection.isCollapsed || !blockQuoteCommand.value) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
const positionParent = selection.getLastPosition().parent;
|
|
102
|
+
if (positionParent.isEmpty) {
|
|
103
|
+
editor.execute('blockQuote');
|
|
104
|
+
editor.editing.view.scrollToTheSelection();
|
|
105
|
+
data.preventDefault();
|
|
106
|
+
evt.stop();
|
|
107
|
+
}
|
|
108
|
+
}, { context: 'blockquote' });
|
|
109
|
+
// Overwrite default Backspace key behavior.
|
|
110
|
+
// If Backspace key is pressed with selection collapsed in first empty block inside a quote, break the quote.
|
|
111
|
+
this.listenTo(viewDocument, 'delete', (evt, data) => {
|
|
112
|
+
if (data.direction != 'backward' || !selection.isCollapsed || !blockQuoteCommand.value) {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
const positionParent = selection.getLastPosition().parent;
|
|
116
|
+
if (positionParent.isEmpty && !positionParent.previousSibling) {
|
|
117
|
+
editor.execute('blockQuote');
|
|
118
|
+
editor.editing.view.scrollToTheSelection();
|
|
119
|
+
data.preventDefault();
|
|
120
|
+
evt.stop();
|
|
121
|
+
}
|
|
122
|
+
}, { context: 'blockquote' });
|
|
123
|
+
}
|
|
124
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
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
|
+
/**
|
|
6
|
+
* @module block-quote/blockquoteui
|
|
7
|
+
*/
|
|
8
|
+
import { Plugin } from 'ckeditor5/src/core.js';
|
|
9
|
+
import '../theme/blockquote.css';
|
|
10
|
+
/**
|
|
11
|
+
* The block quote UI plugin.
|
|
12
|
+
*
|
|
13
|
+
* It introduces the `'blockQuote'` button.
|
|
14
|
+
*
|
|
15
|
+
* @extends module:core/plugin~Plugin
|
|
16
|
+
*/
|
|
17
|
+
export default class BlockQuoteUI extends Plugin {
|
|
18
|
+
/**
|
|
19
|
+
* @inheritDoc
|
|
20
|
+
*/
|
|
21
|
+
static get pluginName(): "BlockQuoteUI";
|
|
22
|
+
/**
|
|
23
|
+
* @inheritDoc
|
|
24
|
+
*/
|
|
25
|
+
static get isOfficialPlugin(): true;
|
|
26
|
+
/**
|
|
27
|
+
* @inheritDoc
|
|
28
|
+
*/
|
|
29
|
+
init(): void;
|
|
30
|
+
/**
|
|
31
|
+
* Creates a button for block quote command to use either in toolbar or in menu bar.
|
|
32
|
+
*/
|
|
33
|
+
private _createButton;
|
|
34
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
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
|
+
/**
|
|
6
|
+
* @module block-quote/blockquoteui
|
|
7
|
+
*/
|
|
8
|
+
import { Plugin, icons } from 'ckeditor5/src/core.js';
|
|
9
|
+
import { ButtonView, MenuBarMenuListItemButtonView } from 'ckeditor5/src/ui.js';
|
|
10
|
+
import '../theme/blockquote.css';
|
|
11
|
+
/**
|
|
12
|
+
* The block quote UI plugin.
|
|
13
|
+
*
|
|
14
|
+
* It introduces the `'blockQuote'` button.
|
|
15
|
+
*
|
|
16
|
+
* @extends module:core/plugin~Plugin
|
|
17
|
+
*/
|
|
18
|
+
export default class BlockQuoteUI extends Plugin {
|
|
19
|
+
/**
|
|
20
|
+
* @inheritDoc
|
|
21
|
+
*/
|
|
22
|
+
static get pluginName() {
|
|
23
|
+
return 'BlockQuoteUI';
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* @inheritDoc
|
|
27
|
+
*/
|
|
28
|
+
static get isOfficialPlugin() {
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* @inheritDoc
|
|
33
|
+
*/
|
|
34
|
+
init() {
|
|
35
|
+
const editor = this.editor;
|
|
36
|
+
editor.ui.componentFactory.add('blockQuote', () => {
|
|
37
|
+
const buttonView = this._createButton(ButtonView);
|
|
38
|
+
buttonView.set({
|
|
39
|
+
tooltip: true
|
|
40
|
+
});
|
|
41
|
+
return buttonView;
|
|
42
|
+
});
|
|
43
|
+
editor.ui.componentFactory.add('menuBar:blockQuote', () => {
|
|
44
|
+
const buttonView = this._createButton(MenuBarMenuListItemButtonView);
|
|
45
|
+
buttonView.set({
|
|
46
|
+
role: 'menuitemcheckbox'
|
|
47
|
+
});
|
|
48
|
+
return buttonView;
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Creates a button for block quote command to use either in toolbar or in menu bar.
|
|
53
|
+
*/
|
|
54
|
+
_createButton(ButtonClass) {
|
|
55
|
+
const editor = this.editor;
|
|
56
|
+
const locale = editor.locale;
|
|
57
|
+
const command = editor.commands.get('blockQuote');
|
|
58
|
+
const view = new ButtonClass(editor.locale);
|
|
59
|
+
const t = locale.t;
|
|
60
|
+
view.set({
|
|
61
|
+
label: t('Block quote'),
|
|
62
|
+
icon: icons.quote,
|
|
63
|
+
isToggleable: true
|
|
64
|
+
});
|
|
65
|
+
view.bind('isEnabled').to(command, 'isEnabled');
|
|
66
|
+
view.bind('isOn').to(command, 'value');
|
|
67
|
+
// Execute the command.
|
|
68
|
+
this.listenTo(view, 'execute', () => {
|
|
69
|
+
editor.execute('blockQuote');
|
|
70
|
+
editor.editing.view.focus();
|
|
71
|
+
});
|
|
72
|
+
return view;
|
|
73
|
+
}
|
|
74
|
+
}
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
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
|
+
/**
|
|
6
|
+
* @module block-quote
|
|
7
|
+
*/
|
|
8
|
+
export { default as BlockQuote } from './blockquote.js';
|
|
9
|
+
export { default as BlockQuoteEditing } from './blockquoteediting.js';
|
|
10
|
+
export { default as BlockQuoteUI } from './blockquoteui.js';
|
|
11
|
+
export type { default as BlockQuoteCommand } from './blockquotecommand.js';
|
|
12
|
+
import './augmentation.js';
|
package/src/index.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
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
|
+
/**
|
|
6
|
+
* @module block-quote
|
|
7
|
+
*/
|
|
8
|
+
export { default as BlockQuote } from './blockquote.js';
|
|
9
|
+
export { default as BlockQuoteEditing } from './blockquoteediting.js';
|
|
10
|
+
export { default as BlockQuoteUI } from './blockquoteui.js';
|
|
11
|
+
import './augmentation.js';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* 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
|
+
|
|
6
|
+
.ck-content blockquote {
|
|
7
|
+
/* See #12 */
|
|
8
|
+
overflow: hidden;
|
|
9
|
+
|
|
10
|
+
/* https://github.com/ckeditor/ckeditor5-block-quote/issues/15 */
|
|
11
|
+
padding-right: 1.5em;
|
|
12
|
+
padding-left: 1.5em;
|
|
13
|
+
|
|
14
|
+
margin-left: 0;
|
|
15
|
+
margin-right: 0;
|
|
16
|
+
font-style: italic;
|
|
17
|
+
border-left: solid 5px hsl(0, 0%, 80%);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.ck-content[dir="rtl"] blockquote {
|
|
21
|
+
border-left: 0;
|
|
22
|
+
border-right: solid 5px hsl(0, 0%, 80%);
|
|
23
|
+
}
|