qms-angular 1.1.70 → 1.1.71
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/bundles/qms-angular.umd.js +59 -7
- package/bundles/qms-angular.umd.js.map +1 -1
- package/esm2015/lib/model/en.js +13 -2
- package/esm2015/lib/model/no.js +12 -1
- package/esm2015/lib/model/sv.js +12 -1
- package/esm2015/lib/qms-ckeditor-components/common/functions/common.function.js +2 -1
- package/esm2015/lib/qms-ckeditor-components/common/functions/resource.function.js +17 -6
- package/esm2015/lib/qms-ckeditor-components/qms-ckeditor.component.js +9 -2
- package/fesm2015/qms-angular.js +59 -7
- package/fesm2015/qms-angular.js.map +1 -1
- package/lib/model/en.d.ts +11 -0
- package/lib/model/no.d.ts +11 -0
- package/lib/model/sv.d.ts +11 -0
- package/lib/qms-ckeditor-components/common/functions/resource.function.d.ts +15 -4
- package/package.json +1 -1
- package/qms-angular.metadata.json +1 -1
- package/src/assets/qms-ckeditor-plugin/src/ckeditor.js +242 -152
- package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/index.js +62 -16
- package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharacters.js +255 -254
- package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharactersarrows.js +154 -60
- package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharactersbasiclatin.js +137 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharactersblockelements.js +74 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharactersbopomofo.js +90 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharactersboxdrawing.js +170 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharactersbraillepatterns.js +298 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharacterscjkradicalssupplement.js +170 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharacterscjksymbolsandpunctuation.js +106 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharacterscombiningdiacriticalmarks.js +139 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharacterscombiningdiacriticalmarksforsymbols.js +90 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharacterscontrolpictures.js +106 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharacterscurrencysymbols.js +90 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharacterscyrillic.js +298 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharacterscyrillicsupplementary.js +90 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharactersdingbats.js +234 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharactersenclosedalphanumerics.js +202 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharactersgeneralpunctuation.js +160 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharactersgeometricshapes.js +138 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharactersgreekandcoptic.js +186 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharactersgreekextended.js +154 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharactershiragana.js +138 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharactersideographicdescriptioncharacters.js +58 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharactersipaextensions.js +174 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharacterskangxiradicals.js +266 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharacterskatakana.js +138 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharacterslatin1supplement.js +144 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharacterslatinextendeda.js +179 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharacterslatinextendedadditional.js +327 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharacterslatinextendedb.js +340 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharactersletterlikesymbols.js +122 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharactersmathematicaloperatorssymbol.js +300 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharactersmestbrukte.js +99 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharactersmiscellaneousmathematicalsymbolsa.js +90 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharactersmiscellaneousmathematicalsymbolsb.js +170 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharactersmiscellaneoussymbols.js +297 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharactersmiscellaneoussymbolsandarrows.js +298 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharactersmiscellaneoustechnical.js +298 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharactersnumberforms.js +106 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharactersopticalcharacterrecognition.js +74 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharactersphoneticextensions.js +179 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharactersspacingmodifierletters.js +139 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharactersspecials.js +46 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharacterssuperscriptsandsubscripts.js +92 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharacterssupplementalarrowsa.js +58 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharacterssupplementalarrowsb.js +170 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharacterssupplementalmathematicaloperators.js +298 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/theme/charactergrid.css +14 -12
- package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/theme/specialcharacters.css +15 -10
- package/src/assets/qms-ckeditor-plugin/src/plugins/clipboard/clipboardPlugin.js +161 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/clipboard/qms-clipboardcommand-paste.js +20 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/clipboard/qms-clipboardcommand.js +21 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/showBlocks/showBlocksPlugin.js +131 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/showBlocks/showBlockscommand.js +13 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/softHyphen/softHyphenPlugin.js +91 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/softHyphen/softHyphencommand.js +13 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/table/verticalAlign/verticalAlignPlugin.js +102 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/table/verticalAlign/verticalAligncommand.js +13 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/tableofcontents/tableofcontentscommand.js +87 -87
- package/src/assets/qms-ckeditor-plugin/src/plugins/tableofcontents/tableofcontentsediting.js +59 -59
- package/src/assets/qms-ckeditor-plugin/src/plugins/tableofcontents/tableofcontentsui.js +34 -34
- package/src/assets/qms-ckeditor-plugin/src/themes/icons/copy.svg +1 -0
- package/src/assets/qms-ckeditor-plugin/src/themes/icons/cut.svg +1 -0
- package/src/assets/qms-ckeditor-plugin/src/themes/icons/paste.svg +1 -0
- package/src/assets/qms-ckeditor-plugin/src/themes/icons/pasteText.svg +3 -0
- package/src/assets/qms-ckeditor-plugin/src/themes/icons/pasteWord.svg +3 -0
- package/src/assets/qms-ckeditor-plugin/src/themes/icons/show-blocks.svg +24 -0
- package/src/assets/qms-ckeditor-plugin/src/themes/icons/soft-hyphen.svg +1 -0
- package/src/assets/qms-ckeditor-plugin/src/themes/icons/table-excel.svg +1 -44
- package/src/lib/qms-ckeditor-components/qms-ckeditor.component.scss +50 -4
@@ -0,0 +1,161 @@
|
|
1
|
+
import Plugin from "@ckeditor/ckeditor5-core/src/plugin";
|
2
|
+
import ButtonView from "@ckeditor/ckeditor5-ui/src/button/buttonview";
|
3
|
+
import cut from "../../themes/icons/cut.svg";
|
4
|
+
import copy from "../../themes/icons/copy.svg";
|
5
|
+
import paste from "../../themes/icons/paste.svg";
|
6
|
+
import pasteText from "../../themes/icons/pasteText.svg";
|
7
|
+
import pasteWord from "../../themes/icons/pasteWord.svg";
|
8
|
+
import QMSClipboardCommand from "./qms-clipboardcommand";
|
9
|
+
import QMSClipboardCommandPaste from "./qms-clipboardcommand-paste";
|
10
|
+
|
11
|
+
export default class QMSClipboardPlugin extends Plugin {
|
12
|
+
|
13
|
+
init() {
|
14
|
+
const editor = this.editor;
|
15
|
+
const t = this.editor.locale.t;
|
16
|
+
editor.commands.add('QMSClipboard', new QMSClipboardCommand(editor));
|
17
|
+
editor.commands.add('QMSClipboardPaste', new QMSClipboardCommandPaste(editor));
|
18
|
+
|
19
|
+
//COPY
|
20
|
+
editor.ui.componentFactory.add('copy', locale => {
|
21
|
+
const view = new ButtonView(locale);
|
22
|
+
view.set({
|
23
|
+
label: t('Copy'),
|
24
|
+
icon: copy,
|
25
|
+
tooltip: true,
|
26
|
+
});
|
27
|
+
view.bind('isEnabled').to(editor.commands.get('QMSClipboard'));
|
28
|
+
|
29
|
+
const viewDocument = editor.editing.view.document;
|
30
|
+
viewDocument.on('keydown', (event, data) => {
|
31
|
+
if (data.ctrlKey && data.keyCode === 67) {
|
32
|
+
document.execCommand('copy');
|
33
|
+
}
|
34
|
+
});
|
35
|
+
view.on('execute', () => {
|
36
|
+
editor.editing.view.focus();
|
37
|
+
document.execCommand('copy');
|
38
|
+
});
|
39
|
+
return view;
|
40
|
+
});
|
41
|
+
|
42
|
+
//CUT
|
43
|
+
editor.ui.componentFactory.add('cut', locale => {
|
44
|
+
const view = new ButtonView(locale);
|
45
|
+
view.set({
|
46
|
+
label: t('Cut'),
|
47
|
+
icon: cut,
|
48
|
+
tooltip: true,
|
49
|
+
});
|
50
|
+
view.bind('isEnabled').to(editor.commands.get('QMSClipboard'));
|
51
|
+
|
52
|
+
const viewDocument = editor.editing.view.document;
|
53
|
+
viewDocument.on('keydown', (event, data) => {
|
54
|
+
if (data.ctrlKey && data.keyCode === 88) {
|
55
|
+
document.execCommand('cut');
|
56
|
+
}
|
57
|
+
});
|
58
|
+
view.on('execute', () => {
|
59
|
+
document.execCommand('cut');
|
60
|
+
});
|
61
|
+
return view;
|
62
|
+
});
|
63
|
+
|
64
|
+
//PASTE
|
65
|
+
editor.ui.componentFactory.add('paste', locale => {
|
66
|
+
const view = new ButtonView(locale);
|
67
|
+
view.set({
|
68
|
+
label: t('Paste'),
|
69
|
+
icon: paste,
|
70
|
+
tooltip: true,
|
71
|
+
});
|
72
|
+
view.bind('isEnabled').to(editor.commands.get('QMSClipboardPaste'));
|
73
|
+
|
74
|
+
view.on('execute', async () => {
|
75
|
+
editor.editing.view.focus();
|
76
|
+
const clipboardData = await navigator.clipboard.read();
|
77
|
+
|
78
|
+
clipboardData.forEach(item => {
|
79
|
+
if (item.types.includes('text/html')) {
|
80
|
+
item.getType('text/html').then(blob => {
|
81
|
+
const reader = new FileReader();
|
82
|
+
reader.onload = () => {
|
83
|
+
let htmlString = reader.result;
|
84
|
+
const fragment = editor.data.processor.toView(htmlString);
|
85
|
+
const modelFragment = editor.data.toModel(fragment);
|
86
|
+
editor.model.insertContent(modelFragment);
|
87
|
+
};
|
88
|
+
reader.readAsText(blob);
|
89
|
+
});
|
90
|
+
}
|
91
|
+
});
|
92
|
+
});
|
93
|
+
return view;
|
94
|
+
});
|
95
|
+
|
96
|
+
//PASTE TEXT
|
97
|
+
editor.ui.componentFactory.add('pasteText', locale => {
|
98
|
+
const view = new ButtonView(locale);
|
99
|
+
view.set({
|
100
|
+
label: t('Paste as plain text'),
|
101
|
+
icon: pasteText,
|
102
|
+
tooltip: true,
|
103
|
+
});
|
104
|
+
|
105
|
+
view.bind('isEnabled').to(editor.commands.get('QMSClipboardPaste'));
|
106
|
+
|
107
|
+
view.on('execute', async () => {
|
108
|
+
editor.editing.view.focus();
|
109
|
+
const htmlString = await navigator.clipboard.readText();
|
110
|
+
if (htmlString) {
|
111
|
+
const lines = htmlString.split('\n');
|
112
|
+
editor.model.change(writer => {
|
113
|
+
const fragment = writer.createDocumentFragment();
|
114
|
+
lines.forEach((line, index) => {
|
115
|
+
writer.appendText(line, fragment);
|
116
|
+
if (index < lines.length - 1) {
|
117
|
+
const softBreak = writer.createElement('softBreak');
|
118
|
+
writer.append(softBreak, fragment);
|
119
|
+
}
|
120
|
+
});
|
121
|
+
editor.model.insertContent(fragment, editor.model.document.selection);
|
122
|
+
});
|
123
|
+
}
|
124
|
+
});
|
125
|
+
return view;
|
126
|
+
});
|
127
|
+
|
128
|
+
//PASTE WORD
|
129
|
+
editor.ui.componentFactory.add('pasteWord', locale => {
|
130
|
+
const view = new ButtonView(locale);
|
131
|
+
view.set({
|
132
|
+
label: t('Paste from Word'),
|
133
|
+
icon: pasteWord,
|
134
|
+
tooltip: true,
|
135
|
+
});
|
136
|
+
|
137
|
+
view.bind('isEnabled').to(editor.commands.get('QMSClipboardPaste'));
|
138
|
+
|
139
|
+
view.on('execute', async () => {
|
140
|
+
editor.editing.view.focus();
|
141
|
+
const clipboardData = await navigator.clipboard.read();
|
142
|
+
|
143
|
+
clipboardData.forEach(item => {
|
144
|
+
if (item.types.includes('text/html')) {
|
145
|
+
item.getType('text/html').then(blob => {
|
146
|
+
const reader = new FileReader();
|
147
|
+
reader.onload = () => {
|
148
|
+
let htmlString = reader.result;
|
149
|
+
const fragment = editor.data.processor.toView(htmlString);
|
150
|
+
const modelFragment = editor.data.toModel(fragment);
|
151
|
+
editor.model.insertContent(modelFragment);
|
152
|
+
};
|
153
|
+
reader.readAsText(blob);
|
154
|
+
});
|
155
|
+
}
|
156
|
+
});
|
157
|
+
});
|
158
|
+
return view;
|
159
|
+
});
|
160
|
+
}
|
161
|
+
}
|
@@ -0,0 +1,20 @@
|
|
1
|
+
import { Command } from '@ckeditor/ckeditor5-core';
|
2
|
+
|
3
|
+
export default class QMSClipboardCommandPaste extends Command {
|
4
|
+
|
5
|
+
constructor(editor) {
|
6
|
+
super(editor);
|
7
|
+
|
8
|
+
}
|
9
|
+
|
10
|
+
refresh() {
|
11
|
+
const selection = this.editor.model.document.selection;
|
12
|
+
this.isEnabled = !this.editor.isReadOnly;
|
13
|
+
}
|
14
|
+
|
15
|
+
// disable button in toolbar
|
16
|
+
execute() {
|
17
|
+
|
18
|
+
}
|
19
|
+
}
|
20
|
+
|
@@ -0,0 +1,21 @@
|
|
1
|
+
import { Command } from '@ckeditor/ckeditor5-core';
|
2
|
+
|
3
|
+
export default class QMSClipboardCommand extends Command {
|
4
|
+
|
5
|
+
constructor(editor) {
|
6
|
+
super(editor);
|
7
|
+
|
8
|
+
}
|
9
|
+
|
10
|
+
refresh() {
|
11
|
+
const selection = this.editor.model.document.selection;
|
12
|
+
this.isEnabled = !this.editor.isReadOnly && !selection.isCollapsed;
|
13
|
+
}
|
14
|
+
|
15
|
+
// disable button in toolbar
|
16
|
+
execute() {
|
17
|
+
|
18
|
+
}
|
19
|
+
}
|
20
|
+
|
21
|
+
|
@@ -0,0 +1,131 @@
|
|
1
|
+
import Plugin from "@ckeditor/ckeditor5-core/src/plugin";
|
2
|
+
import ButtonView from "@ckeditor/ckeditor5-ui/src/button/buttonview";
|
3
|
+
import showblocksIcon from "../../themes/icons/show-blocks.svg";
|
4
|
+
import ShowBlockscommand from "./showBlockscommand";
|
5
|
+
|
6
|
+
export default class ShowBlocksnPlugin extends Plugin {
|
7
|
+
init() {
|
8
|
+
const editor = this.editor;
|
9
|
+
const t = this.editor.locale.t;
|
10
|
+
editor.commands.add('showblocks', new ShowBlockscommand(editor));
|
11
|
+
this.isActive = false;
|
12
|
+
//
|
13
|
+
editor.ui.componentFactory.add('showblocks', locale => {
|
14
|
+
const view = new ButtonView(locale);
|
15
|
+
view.set({
|
16
|
+
label: t('Showblocks'),
|
17
|
+
icon: showblocksIcon,
|
18
|
+
tooltip: true,
|
19
|
+
});
|
20
|
+
view.bind('isEnabled').to(editor.commands.get('showblocks'));
|
21
|
+
this.updateButtonIcon(view);
|
22
|
+
|
23
|
+
view.on('execute', () => {
|
24
|
+
this.isActive = !this.isActive;
|
25
|
+
editor.editing.view.focus();
|
26
|
+
this.executeEvent(editor);
|
27
|
+
this.updateButtonIcon(view);
|
28
|
+
});
|
29
|
+
return view;
|
30
|
+
});
|
31
|
+
|
32
|
+
}
|
33
|
+
|
34
|
+
executeEvent(editor) {
|
35
|
+
// If "Show Blocks" is active, add classes to outline blocks.
|
36
|
+
if (this.isActive) {
|
37
|
+
editor.editing.view.change(writer => {
|
38
|
+
for (const element of editor.editing.view.document.getRoot().getChildren()) {
|
39
|
+
if (this.isBlockElement(element)) {
|
40
|
+
writer.addClass('show-block-outline', element);
|
41
|
+
|
42
|
+
const labelText = this.getBlockLabel(element);
|
43
|
+
const labelElement = writer.createUIElement('span', {
|
44
|
+
class: 'block-label'
|
45
|
+
}, function (domDocument) {
|
46
|
+
const domElement = this.toDomElement(domDocument);
|
47
|
+
domElement.textContent = labelText;
|
48
|
+
return domElement;
|
49
|
+
});
|
50
|
+
|
51
|
+
writer.insert(writer.createPositionAt(element, 0), labelElement);
|
52
|
+
}
|
53
|
+
|
54
|
+
var childs = Array.from(element.getChildren());
|
55
|
+
if (childs.length > 0) {
|
56
|
+
for (const child of childs) {
|
57
|
+
if (this.isBlockElement(child) && Array.from(child.getChildren()).length > 0) {
|
58
|
+
writer.addClass('show-block-outline', child);
|
59
|
+
|
60
|
+
const labelText = this.getBlockLabel(child);
|
61
|
+
const labelElement = writer.createUIElement('span', {
|
62
|
+
class: 'block-label'
|
63
|
+
}, function (domDocument) {
|
64
|
+
const domElement = this.toDomElement(domDocument);
|
65
|
+
domElement.textContent = labelText;
|
66
|
+
return domElement;
|
67
|
+
});
|
68
|
+
|
69
|
+
writer.insert(writer.createPositionAt(child, 0), labelElement);
|
70
|
+
}
|
71
|
+
}
|
72
|
+
}
|
73
|
+
}
|
74
|
+
});
|
75
|
+
} else {
|
76
|
+
// Remove classes to hide block outlines.
|
77
|
+
editor.editing.view.change(writer => {
|
78
|
+
for (const element of editor.editing.view.document.getRoot().getChildren()) {
|
79
|
+
writer.removeClass('show-block-outline', element);
|
80
|
+
|
81
|
+
for (const child of element.getChildren()) {
|
82
|
+
if (child.hasClass && child.hasClass('block-label')) {
|
83
|
+
writer.remove(child);
|
84
|
+
}
|
85
|
+
}
|
86
|
+
var childs = Array.from(element.getChildren());
|
87
|
+
if (childs.length > 0) {
|
88
|
+
for (const children of childs) {
|
89
|
+
if (children.hasClass && children.hasClass('show-block-outline')) {
|
90
|
+
writer.removeClass('show-block-outline', children);
|
91
|
+
const items = Array.from(children.getChildren());
|
92
|
+
if (items.length > 0) {
|
93
|
+
for (const item of items) {
|
94
|
+
if (item.hasClass && item.hasClass('block-label')) {
|
95
|
+
writer.remove(item);
|
96
|
+
}
|
97
|
+
}
|
98
|
+
}
|
99
|
+
}
|
100
|
+
}
|
101
|
+
}
|
102
|
+
}
|
103
|
+
});
|
104
|
+
}
|
105
|
+
}
|
106
|
+
|
107
|
+
isBlockElement(element) {
|
108
|
+
// Define which elements are considered blocks.
|
109
|
+
return ['p', 'h1', 'h2', 'h3', 'div', 'blockquote', 'table'].includes(element.name);
|
110
|
+
}
|
111
|
+
|
112
|
+
getBlockLabel(element) {
|
113
|
+
const labels = {
|
114
|
+
paragraph: 'P',
|
115
|
+
heading1: 'H1',
|
116
|
+
heading2: 'H2',
|
117
|
+
heading3: 'H3',
|
118
|
+
div: 'DIV',
|
119
|
+
blockquote: 'BLOCKQUOTE'
|
120
|
+
};
|
121
|
+
return labels[element.name] || element.name.toUpperCase();
|
122
|
+
}
|
123
|
+
|
124
|
+
updateButtonIcon(view) {
|
125
|
+
if (this.isActive) {
|
126
|
+
view.class = 'show-block-button-active';
|
127
|
+
} else {
|
128
|
+
view.class = 'show-block-button';
|
129
|
+
}
|
130
|
+
}
|
131
|
+
}
|
@@ -0,0 +1,91 @@
|
|
1
|
+
import Plugin from "@ckeditor/ckeditor5-core/src/plugin";
|
2
|
+
import ButtonView from "@ckeditor/ckeditor5-ui/src/button/buttonview";
|
3
|
+
import softHyphenIcon from "../../themes/icons/soft-hyphen.svg";
|
4
|
+
import SoftHyphenCommand from "./softHyphencommand";
|
5
|
+
|
6
|
+
export default class SoftHyphenPlugin extends Plugin {
|
7
|
+
init() {
|
8
|
+
const editor = this.editor;
|
9
|
+
const t = this.editor.locale.t;
|
10
|
+
editor.commands.add('softHyphen', new SoftHyphenCommand(editor));
|
11
|
+
|
12
|
+
// Step 1: Define the 'span' element in the schema
|
13
|
+
editor.model.schema.register('span', {
|
14
|
+
inheritAllFrom: '$inlineObject',
|
15
|
+
allowContentOf: '$block',
|
16
|
+
allowWhere: '$text',
|
17
|
+
allowAttributes: ['class'],
|
18
|
+
isInline: true,
|
19
|
+
isObject: false
|
20
|
+
});
|
21
|
+
|
22
|
+
// Step 2: Handle upcast (when content is loaded into the editor)
|
23
|
+
editor.conversion.for('upcast').elementToElement({
|
24
|
+
view: {
|
25
|
+
name: 'span',
|
26
|
+
classes: 'shy'
|
27
|
+
},
|
28
|
+
model: (viewElement, { writer }) => {
|
29
|
+
return writer.createElement('span', { class: 'shy' });
|
30
|
+
}
|
31
|
+
});
|
32
|
+
// Step 3: Handle downcast (when content is exported from the editor)
|
33
|
+
editor.conversion.for('downcast').elementToElement({
|
34
|
+
model: 'span',
|
35
|
+
view: (modelElement, { writer }) => {
|
36
|
+
return writer.createContainerElement('span', { class: 'shy' });
|
37
|
+
}
|
38
|
+
});
|
39
|
+
|
40
|
+
editor.ui.componentFactory.add("softHyphen", (locale) => {
|
41
|
+
const view = new ButtonView(locale);
|
42
|
+
view.set({
|
43
|
+
label: t('SoftHyphen'),
|
44
|
+
icon: softHyphenIcon,
|
45
|
+
tooltip: true
|
46
|
+
});
|
47
|
+
view.bind('isEnabled').to(editor.commands.get('softHyphen'));
|
48
|
+
|
49
|
+
const viewDocument = editor.editing.view.document;
|
50
|
+
viewDocument.on('keydown', (event, data) => {
|
51
|
+
// Step 4: Insert the 'span' and move cursor after it
|
52
|
+
if (data.ctrlKey && data.shiftKey && data.keyCode === 189) {
|
53
|
+
this.executeEvent(editor);
|
54
|
+
data.preventDefault();
|
55
|
+
event.stop();
|
56
|
+
}
|
57
|
+
if (data.keyCode === 8 || data.keyCode === 46) { // backspace: 8 //delete: 46
|
58
|
+
const selection = editor.model.document.selection;
|
59
|
+
const position = selection.getFirstPosition();
|
60
|
+
const shyElement = data.keyCode === 46
|
61
|
+
? position.nodeAfter
|
62
|
+
: position.nodeBefore;
|
63
|
+
if (shyElement && shyElement.is('element', 'span') && shyElement.getAttribute('class') === 'shy') {
|
64
|
+
data.preventDefault(); // Prevent default delete/backspace action
|
65
|
+
editor.model.change(writer => {
|
66
|
+
writer.remove(shyElement); // Remove the shy span element
|
67
|
+
});
|
68
|
+
}
|
69
|
+
}
|
70
|
+
});
|
71
|
+
view.on("execute", (event, data) => {
|
72
|
+
this.executeEvent(editor);
|
73
|
+
});
|
74
|
+
return view;
|
75
|
+
});
|
76
|
+
}
|
77
|
+
|
78
|
+
executeEvent(editor) {
|
79
|
+
editor.model.change(writer => {
|
80
|
+
const shySpan = writer.createElement('span', { class: 'shy' });
|
81
|
+
const shyText = writer.createText('\u00AD');
|
82
|
+
writer.insert(shyText, shySpan);
|
83
|
+
|
84
|
+
const selectionPosition = editor.model.document.selection.getFirstPosition();
|
85
|
+
writer.insert(shySpan, selectionPosition);
|
86
|
+
|
87
|
+
const positionAfterSpan = writer.createPositionAfter(shySpan);
|
88
|
+
writer.setSelection(positionAfterSpan);
|
89
|
+
});
|
90
|
+
}
|
91
|
+
}
|
@@ -0,0 +1,102 @@
|
|
1
|
+
import Plugin from "@ckeditor/ckeditor5-core/src/plugin";
|
2
|
+
import { createDropdown } from '@ckeditor/ckeditor5-ui/src/dropdown/utils';
|
3
|
+
import ButtonView from "@ckeditor/ckeditor5-ui/src/button/buttonview";
|
4
|
+
import { icons } from 'ckeditor5/src/core';
|
5
|
+
import VerticalAligncommand from "./verticalAligncommand";
|
6
|
+
|
7
|
+
const ALIGNMENT_ICONS = {
|
8
|
+
top: icons.alignTop,
|
9
|
+
middle: icons.alignMiddle,
|
10
|
+
bottom: icons.alignBottom
|
11
|
+
};
|
12
|
+
|
13
|
+
export default class VerticalAlignPlugin extends Plugin {
|
14
|
+
init() {
|
15
|
+
const editor = this.editor;
|
16
|
+
const t = this.editor.locale.t;
|
17
|
+
editor.commands.add('verticalAlign', new VerticalAligncommand(editor));
|
18
|
+
|
19
|
+
editor.model.schema.extend('tableCell', {
|
20
|
+
allowAttributes: 'verticalAlign'
|
21
|
+
});
|
22
|
+
|
23
|
+
editor.conversion.for('downcast').attributeToAttribute({
|
24
|
+
model: 'verticalAlign',
|
25
|
+
view: (alignment) => {
|
26
|
+
return {
|
27
|
+
key: 'style',
|
28
|
+
value: {
|
29
|
+
'vertical-align': alignment
|
30
|
+
}
|
31
|
+
};
|
32
|
+
},
|
33
|
+
converterPriority: 'low'
|
34
|
+
});
|
35
|
+
let items = [
|
36
|
+
{ label: t('Vertical Align Top'), value: 'top', icon: ALIGNMENT_ICONS.top, class: 'qms-verticalAlign-selected' },
|
37
|
+
{ label: t('Vertical Align Middle'), value: 'middle', icon: ALIGNMENT_ICONS.middle, class: 'qms-verticalAlign' },
|
38
|
+
{ label: t('Vertical Align Bottom'), value: 'bottom', icon: ALIGNMENT_ICONS.bottom, class: 'qms-verticalAlign' }
|
39
|
+
];
|
40
|
+
|
41
|
+
editor.ui.componentFactory.add("verticalAlign", (locale) => {
|
42
|
+
const dropdownView = createDropdown(locale);
|
43
|
+
dropdownView.buttonView.set({
|
44
|
+
label: t('Vertical Alignment'),
|
45
|
+
icon: ALIGNMENT_ICONS.top,
|
46
|
+
tooltip: true
|
47
|
+
});
|
48
|
+
dropdownView.bind('isEnabled').to(editor.commands.get('verticalAlign'));
|
49
|
+
|
50
|
+
items.forEach(item => {
|
51
|
+
const buttonView = new ButtonView(locale);
|
52
|
+
buttonView.set({
|
53
|
+
label: item.label,
|
54
|
+
icon: item.icon,
|
55
|
+
tooltip: true,
|
56
|
+
class: item.class,
|
57
|
+
});
|
58
|
+
|
59
|
+
buttonView.on('execute', () => {
|
60
|
+
dropdownView.buttonView.icon = item.icon;
|
61
|
+
dropdownView.panelView.children._items.forEach(btn => {
|
62
|
+
btn.class = 'qms-verticalAlign';
|
63
|
+
});
|
64
|
+
buttonView.class = 'qms-verticalAlign-selected';
|
65
|
+
|
66
|
+
const model = editor.model;
|
67
|
+
const selection = model.document.selection;
|
68
|
+
|
69
|
+
for (const range of selection.getRanges()) {
|
70
|
+
|
71
|
+
// on focus cell <td>
|
72
|
+
let targetElement = range.start.parent;
|
73
|
+
while (targetElement && !targetElement.is('element', 'tableCell')) {
|
74
|
+
targetElement = targetElement.parent;
|
75
|
+
}
|
76
|
+
if (targetElement) {
|
77
|
+
model.change(writer => {
|
78
|
+
writer.setAttribute('verticalAlign', item.value, targetElement);
|
79
|
+
});
|
80
|
+
break;
|
81
|
+
}
|
82
|
+
|
83
|
+
// on select <tr>
|
84
|
+
for (const cell of range.getItems()) {
|
85
|
+
if (cell.is('element', 'tableCell')) {
|
86
|
+
model.change(writer => {
|
87
|
+
writer.setAttribute('verticalAlign', item.value, cell);
|
88
|
+
});
|
89
|
+
}
|
90
|
+
}
|
91
|
+
}
|
92
|
+
|
93
|
+
dropdownView.isOpen = false;
|
94
|
+
});
|
95
|
+
|
96
|
+
dropdownView.panelView.children.add(buttonView);
|
97
|
+
});
|
98
|
+
return dropdownView;
|
99
|
+
});
|
100
|
+
|
101
|
+
}
|
102
|
+
}
|