qms-angular 1.1.76 → 1.1.77
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 +18 -7
- package/bundles/qms-angular.umd.js.map +1 -1
- package/esm2015/lib/model/en.js +6 -2
- package/esm2015/lib/model/no.js +6 -2
- package/esm2015/lib/qms-ckeditor-components/common/functions/resource.function.js +9 -6
- package/fesm2015/qms-angular.js +18 -7
- package/fesm2015/qms-angular.js.map +1 -1
- package/lib/model/en.d.ts +4 -0
- package/lib/model/no.d.ts +4 -0
- package/lib/qms-ckeditor-components/common/functions/resource.function.d.ts +8 -5
- package/package.json +1 -1
- package/qms-angular.metadata.json +1 -1
- package/src/assets/qms-ckeditor-plugin/build/ckeditor.js +2 -2
- package/src/assets/qms-ckeditor-plugin/build/ckeditor.js.map +1 -1
- package/src/assets/qms-ckeditor-plugin/src/ckeditor.js +6 -2
- package/src/assets/qms-ckeditor-plugin/src/plugins/collapsible/collapsible.js +229 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/collapsible/collapsiblecommand.js +13 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/heading/headingediting.js +165 -163
- package/src/assets/qms-ckeditor-plugin/src/plugins/heading/headingui.js +18 -8
- package/src/assets/qms-ckeditor-plugin/src/plugins/heading/ingress/ingress.js +63 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/heading/ingress/ingresscommand.js +33 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/heading/theme/heading.css +44 -35
- package/src/assets/qms-ckeditor-plugin/src/plugins/heading/utils.js +2 -1
- package/src/assets/qms-ckeditor-plugin/src/plugins/table/commands/setheadercolumncommand.js +99 -95
- package/src/assets/qms-ckeditor-plugin/src/plugins/table/commands/setheaderrowcommand.js +110 -105
- package/src/assets/qms-ckeditor-plugin/src/plugins/table/converters/downcast.js +529 -529
- package/src/assets/qms-ckeditor-plugin/src/plugins/table/theme/table.css +67 -67
- package/src/assets/qms-ckeditor-plugin/src/plugins/tooltip/tooltipcommand.js +74 -75
- package/src/assets/qms-ckeditor-plugin/src/themes/icons/angles-up-down.svg +1 -0
@@ -68,6 +68,7 @@ import ToggleToolbar from './plugins/toggletoolbar/toggletoolbar.js';
|
|
68
68
|
import Tooltip from './plugins/tooltip/tooltip.js';
|
69
69
|
//import WProofreader from '@webspellchecker/wproofreader-ckeditor5/src/wproofreader';
|
70
70
|
import SourceEditing from './plugins/ckeditor5-source-editing/src/sourceediting';
|
71
|
+
import Collapsible from './plugins/collapsible/collapsible.js';
|
71
72
|
import SpecialCharactersBlockElements from './plugins/ckeditor5-special-characters/src/specialcharactersblockelements.js';
|
72
73
|
import SpecialCharactersBopomofo from './plugins/ckeditor5-special-characters/src/specialcharactersbopomofo.js';
|
73
74
|
import SpecialCharactersBoxDrawing from './plugins/ckeditor5-special-characters/src/specialcharactersboxdrawing.js';
|
@@ -117,6 +118,7 @@ import SpecialCharactersLatinExtendedAdditional from './plugins/ckeditor5-specia
|
|
117
118
|
import SpecialCharactersGreekExtended from './plugins/ckeditor5-special-characters/src/specialcharactersgreekextended.js';
|
118
119
|
import SpecialCharactersGeneralPunctuation from './plugins/ckeditor5-special-characters/src/specialcharactersgeneralpunctuation.js';
|
119
120
|
import SpecialCharactersSuperscriptsandSubscripts from './plugins/ckeditor5-special-characters/src/specialcharacterssuperscriptsandsubscripts.js';
|
121
|
+
import Ingress from './plugins/heading/ingress/ingress.js';
|
120
122
|
|
121
123
|
class Editor extends ClassicEditor { }
|
122
124
|
|
@@ -185,7 +187,8 @@ Editor.builtinPlugins = [
|
|
185
187
|
ToggleToolbar,
|
186
188
|
TableOfContents,
|
187
189
|
//WProofreader,
|
188
|
-
|
190
|
+
SourceEditing,
|
191
|
+
Collapsible,
|
189
192
|
SoftHyphenPlugin,
|
190
193
|
QMSClipboardPlugin,
|
191
194
|
ShowBlocksnPlugin,
|
@@ -236,7 +239,8 @@ Editor.builtinPlugins = [
|
|
236
239
|
SpecialCharactersHiragana,
|
237
240
|
SpecialCharactersKatakana,
|
238
241
|
SpecialCharactersBopomofo,
|
239
|
-
SpecialCharactersSpecials
|
242
|
+
SpecialCharactersSpecials,
|
243
|
+
Ingress
|
240
244
|
];
|
241
245
|
|
242
246
|
Editor.defaultConfig = {
|
@@ -0,0 +1,229 @@
|
|
1
|
+
import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
|
2
|
+
import ButtonView from '@ckeditor/ckeditor5-ui/src/button/buttonview';
|
3
|
+
import angleUpDownIcon from '../../themes/icons/angles-up-down.svg';
|
4
|
+
import CollapsibleCommand from './collapsiblecommand';
|
5
|
+
export default class Collapsible extends Plugin {
|
6
|
+
init() {
|
7
|
+
const openAttribute = "open";
|
8
|
+
const editor = this.editor;
|
9
|
+
const t = editor.t;
|
10
|
+
editor.commands.add('collapsible', new CollapsibleCommand(editor));
|
11
|
+
|
12
|
+
// DETAILS TAG
|
13
|
+
editor.model.schema.register('Details', {
|
14
|
+
allowWhere: '$block',
|
15
|
+
allowContentOf: '$root',
|
16
|
+
allowAttributes: [openAttribute],
|
17
|
+
});
|
18
|
+
|
19
|
+
editor.conversion.for('downcast').elementToElement({ model: 'Details', view: 'details' });
|
20
|
+
|
21
|
+
editor.conversion.for('downcast').add(dispatcher => {
|
22
|
+
dispatcher.on('insert:Details', (evt, data, conversionApi) => {
|
23
|
+
const viewWriter = conversionApi.writer;
|
24
|
+
|
25
|
+
const openAttributeValue = data.item._attrs.get('open');
|
26
|
+
if (openAttributeValue !== null && openAttributeValue !== undefined) {
|
27
|
+
viewWriter.setAttribute(openAttribute, openAttributeValue, conversionApi.mapper.toViewElement(data.item));
|
28
|
+
}
|
29
|
+
}, { priority: 'low' });
|
30
|
+
});
|
31
|
+
|
32
|
+
editor.conversion.for('upcast').elementToElement({
|
33
|
+
view: 'details',
|
34
|
+
model: (viewElement, { writer }) => {
|
35
|
+
const openAttributeValue = viewElement._attrs.get('open');
|
36
|
+
let attributes = {};
|
37
|
+
if (openAttributeValue !== null && openAttributeValue !== undefined) {
|
38
|
+
attributes = { open: openAttributeValue };
|
39
|
+
}
|
40
|
+
let detailsElement = writer.createElement('Details', attributes);
|
41
|
+
if(!viewElement._children.some(x => x.name.toLowerCase() === "summary"))
|
42
|
+
{
|
43
|
+
const summaryElement = writer.createElement('Summary');
|
44
|
+
const titleSummary = writer.createText(t('Details'));
|
45
|
+
writer.append(titleSummary, summaryElement);
|
46
|
+
writer.append(summaryElement, detailsElement);
|
47
|
+
}
|
48
|
+
return detailsElement;
|
49
|
+
}
|
50
|
+
});
|
51
|
+
|
52
|
+
// SUMMARY TAG
|
53
|
+
editor.model.schema.register('Summary', {
|
54
|
+
allowWhere: '$block',
|
55
|
+
allowContentOf: '$block'
|
56
|
+
});
|
57
|
+
|
58
|
+
editor.conversion.for('downcast').elementToElement({ model: 'Summary', view: 'summary' });
|
59
|
+
|
60
|
+
editor.conversion.for('downcast').add(dispatcher => {
|
61
|
+
dispatcher.on('insert:Summary', (evt, data, conversionApi) => {
|
62
|
+
const viewWriter = conversionApi.writer;
|
63
|
+
|
64
|
+
}, { priority: 'low' });
|
65
|
+
});
|
66
|
+
|
67
|
+
editor.conversion.for('upcast').elementToElement({
|
68
|
+
view: 'summary',
|
69
|
+
model: (viewElement, { writer }) => {
|
70
|
+
return writer.createElement('Summary');
|
71
|
+
}
|
72
|
+
});
|
73
|
+
|
74
|
+
const viewDocument = this.editor.editing.view.document;
|
75
|
+
|
76
|
+
// Handle click on view document and when user click on details section, we must update open attribute
|
77
|
+
this.listenTo(viewDocument, 'click', (event, data) => {
|
78
|
+
const detailsElement = data.target.findAncestor('details');
|
79
|
+
|
80
|
+
if (detailsElement) {
|
81
|
+
editor.model.change(writer => {
|
82
|
+
const modelElement = editor.editing.mapper.toModelElement(detailsElement);
|
83
|
+
if (modelElement.hasAttribute(openAttribute)) {
|
84
|
+
writer.removeAttribute(openAttribute, modelElement);
|
85
|
+
}
|
86
|
+
else {
|
87
|
+
writer.setAttribute(openAttribute, "", modelElement);
|
88
|
+
}
|
89
|
+
});
|
90
|
+
}
|
91
|
+
});
|
92
|
+
|
93
|
+
editor.editing.view.document.on('enter', (evt, data) => {
|
94
|
+
// if soft enter (shift + enter), keep it's default behavior
|
95
|
+
if (data.isSoft)
|
96
|
+
return;
|
97
|
+
const selection = editor.model.document.selection;
|
98
|
+
const firstPosition = selection.getFirstPosition();
|
99
|
+
const summaryElement = firstPosition.parent;
|
100
|
+
|
101
|
+
if (summaryElement.is('element', 'Summary')) {
|
102
|
+
evt.stop();
|
103
|
+
const detailsElement = summaryElement.findAncestor('Details');
|
104
|
+
if (detailsElement) {
|
105
|
+
this.createTempParagraphContent(detailsElement, true);
|
106
|
+
}
|
107
|
+
}
|
108
|
+
});
|
109
|
+
|
110
|
+
this.listenTo(viewDocument, 'arrowKey', (evt, data) => {
|
111
|
+
// Handle arrow down event
|
112
|
+
if (data.keyCode === 40) {
|
113
|
+
const selection = editor.model.document.selection;
|
114
|
+
const firstPosition = selection.getFirstPosition();
|
115
|
+
const element = firstPosition.parent;
|
116
|
+
|
117
|
+
if (element.is('element')) {
|
118
|
+
const detailsElement = element.findAncestor('Details');
|
119
|
+
// check reach last element of details tag
|
120
|
+
if (detailsElement && !element.nextSibling && !detailsElement.nextSibling) {
|
121
|
+
this.createTempParagraphContent(detailsElement);
|
122
|
+
}
|
123
|
+
else if (element.is('element', 'Summary') && detailsElement && !detailsElement.nextSibling && !detailsElement.hasAttribute(openAttribute)) {
|
124
|
+
this.createTempParagraphContent(detailsElement);
|
125
|
+
}
|
126
|
+
}
|
127
|
+
}
|
128
|
+
});
|
129
|
+
|
130
|
+
editor.ui.componentFactory.add('collapsible', locale => {
|
131
|
+
const view = new ButtonView(locale);
|
132
|
+
|
133
|
+
view.set({
|
134
|
+
label: t('Collapsible'),
|
135
|
+
icon: angleUpDownIcon,
|
136
|
+
tooltip: true
|
137
|
+
});
|
138
|
+
|
139
|
+
view.bind('isEnabled').to(editor.commands.get('collapsible'));
|
140
|
+
// const selection = editor.model.document.selection;
|
141
|
+
|
142
|
+
editor.model.document.selection.on('change:range', () => {
|
143
|
+
// Disable plugin when selection not a paragraph.
|
144
|
+
const selectedElements = Array.from(editor.model.document.selection.getSelectedBlocks());
|
145
|
+
|
146
|
+
if (editor.isReadOnly || (selectedElements && (selectedElements.length !== 1 || selectedElements[0].name !== "paragraph"))) {
|
147
|
+
view.isEnabled = false;
|
148
|
+
}
|
149
|
+
else
|
150
|
+
{
|
151
|
+
view.isEnabled = true;
|
152
|
+
}
|
153
|
+
});
|
154
|
+
|
155
|
+
|
156
|
+
view.on('execute', () => {
|
157
|
+
editor.model.change(writer => {
|
158
|
+
// Create a <details> element with an editable <summary> element
|
159
|
+
const detailsElement = writer.createElement('Details');
|
160
|
+
writer.setAttribute(openAttribute, "", detailsElement);
|
161
|
+
|
162
|
+
// Create <summary>
|
163
|
+
const summaryElement = writer.createElement('Summary');
|
164
|
+
const selectedElements = Array.from(editor.model.document.selection.getSelectedBlocks());
|
165
|
+
if (selectedElements && selectedElements.length === 1 && selectedElements[0].name === "paragraph") {
|
166
|
+
|
167
|
+
const selection = editor.model.document.selection;
|
168
|
+
const range = selection.getFirstRange();
|
169
|
+
|
170
|
+
let haveInputDataSummary = 0;
|
171
|
+
|
172
|
+
for (const item of range.getItems()) {
|
173
|
+
var itemText = writer.createText(item.data, item.textNode.getAttributes());
|
174
|
+
writer.append(itemText, summaryElement);
|
175
|
+
haveInputDataSummary = 1;
|
176
|
+
}
|
177
|
+
|
178
|
+
if(haveInputDataSummary === 0)
|
179
|
+
{
|
180
|
+
const titleSummary = writer.createText(t('Collapsible title'), { bold: true });
|
181
|
+
writer.append(titleSummary, summaryElement);
|
182
|
+
}
|
183
|
+
}
|
184
|
+
else
|
185
|
+
{
|
186
|
+
const titleSummary = writer.createText(t('Collapsible title'), { bold: true });
|
187
|
+
writer.append(titleSummary, summaryElement);
|
188
|
+
}
|
189
|
+
|
190
|
+
// Append summary to the details element
|
191
|
+
writer.append(summaryElement, detailsElement);
|
192
|
+
|
193
|
+
|
194
|
+
// Add default endline for collapsible content
|
195
|
+
const paragraphElement = writer.createElement('paragraph');
|
196
|
+
|
197
|
+
const defaultContent = writer.createText(t('Collapsible content'));
|
198
|
+
writer.append(defaultContent, paragraphElement);
|
199
|
+
writer.append(paragraphElement, detailsElement);
|
200
|
+
const endLineElement = writer.createElement('paragraph');
|
201
|
+
|
202
|
+
const endLine = writer.createText('-----------------------------------------------------');
|
203
|
+
writer.append(endLine, endLineElement);
|
204
|
+
writer.append(endLineElement, detailsElement);
|
205
|
+
|
206
|
+
editor.model.insertContent(detailsElement, editor.model.document.selection);
|
207
|
+
});
|
208
|
+
});
|
209
|
+
|
210
|
+
return view;
|
211
|
+
});
|
212
|
+
}
|
213
|
+
|
214
|
+
createTempParagraphContent(detailsElement, addContentBefore) {
|
215
|
+
this.editor.model.change(writer => {
|
216
|
+
let position = writer.createPositionAfter(detailsElement);
|
217
|
+
|
218
|
+
if(addContentBefore)
|
219
|
+
{
|
220
|
+
position = writer.createPositionBefore(detailsElement);
|
221
|
+
}
|
222
|
+
const newParagraph = writer.createElement('paragraph');
|
223
|
+
|
224
|
+
writer.insert(newParagraph, position);
|
225
|
+
|
226
|
+
writer.setSelection(newParagraph, 'in');
|
227
|
+
});
|
228
|
+
}
|
229
|
+
}
|
@@ -1,163 +1,165 @@
|
|
1
|
-
/**
|
2
|
-
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
4
|
-
*/
|
5
|
-
|
6
|
-
/**
|
7
|
-
* @module heading/headingediting
|
8
|
-
*/
|
9
|
-
|
10
|
-
import { Plugin } from 'ckeditor5/src/core';
|
11
|
-
import { Paragraph } from 'ckeditor5/src/paragraph';
|
12
|
-
import { priorities } from 'ckeditor5/src/utils';
|
13
|
-
|
14
|
-
import HeadingCommand from './headingcommand';
|
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
|
-
{ model: '
|
43
|
-
{ model: '
|
44
|
-
{ model: '
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
const
|
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
|
-
const
|
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
|
-
|
125
|
-
|
126
|
-
|
127
|
-
*
|
128
|
-
*
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
viewWriter
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
viewWriter
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
viewWriter
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
}
|
1
|
+
/**
|
2
|
+
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
4
|
+
*/
|
5
|
+
|
6
|
+
/**
|
7
|
+
* @module heading/headingediting
|
8
|
+
*/
|
9
|
+
|
10
|
+
import { Plugin } from 'ckeditor5/src/core';
|
11
|
+
import { Paragraph } from 'ckeditor5/src/paragraph';
|
12
|
+
import { priorities } from 'ckeditor5/src/utils';
|
13
|
+
|
14
|
+
import HeadingCommand from './headingcommand';
|
15
|
+
import Ingress from './ingress/ingress';
|
16
|
+
|
17
|
+
const defaultModelElement = 'paragraph';
|
18
|
+
|
19
|
+
/**
|
20
|
+
* The headings engine feature. It handles switching between block formats – headings and paragraph.
|
21
|
+
* This class represents the engine part of the heading feature. See also {@link module:heading/heading~Heading}.
|
22
|
+
* It introduces `heading1`-`headingN` commands which allow to convert paragraphs into headings.
|
23
|
+
*
|
24
|
+
* @extends module:core/plugin~Plugin
|
25
|
+
*/
|
26
|
+
export default class HeadingEditing extends Plugin {
|
27
|
+
/**
|
28
|
+
* @inheritDoc
|
29
|
+
*/
|
30
|
+
static get pluginName() {
|
31
|
+
return 'HeadingEditing';
|
32
|
+
}
|
33
|
+
|
34
|
+
/**
|
35
|
+
* @inheritDoc
|
36
|
+
*/
|
37
|
+
constructor( editor ) {
|
38
|
+
super( editor );
|
39
|
+
|
40
|
+
editor.config.define( 'heading', {
|
41
|
+
options: [
|
42
|
+
{ model: 'paragraph', title: 'Paragraph', class: 'ck-heading_paragraph' },
|
43
|
+
{ model: 'ingress', title: 'Ingress', class: 'ck-heading_ingress' },
|
44
|
+
{ model: 'heading1', view: 'h1', title: 'Heading 1', class: 'ck-heading_heading1' },
|
45
|
+
{ model: 'heading2', view: 'h2', title: 'Heading 2', class: 'ck-heading_heading2' },
|
46
|
+
{ model: 'heading3', view: 'h3', title: 'Heading 3', class: 'ck-heading_heading3' }
|
47
|
+
]
|
48
|
+
} );
|
49
|
+
}
|
50
|
+
|
51
|
+
/**
|
52
|
+
* @inheritDoc
|
53
|
+
*/
|
54
|
+
static get requires() {
|
55
|
+
return [ Paragraph , Ingress];
|
56
|
+
}
|
57
|
+
|
58
|
+
/**
|
59
|
+
* @inheritDoc
|
60
|
+
*/
|
61
|
+
init() {
|
62
|
+
const editor = this.editor;
|
63
|
+
const options = editor.config.get( 'heading.options' );
|
64
|
+
|
65
|
+
const modelElements = [];
|
66
|
+
|
67
|
+
for ( const option of options ) {
|
68
|
+
// Skip paragraph - it is defined in required Paragraph feature.
|
69
|
+
if ( option.model !== defaultModelElement && option.model !== 'ingress' ) {
|
70
|
+
// Schema.
|
71
|
+
editor.model.schema.register( option.model, {
|
72
|
+
allowIn: '$root',
|
73
|
+
inheritAllFrom: '$block'
|
74
|
+
} );
|
75
|
+
|
76
|
+
editor.conversion.elementToElement( option );
|
77
|
+
|
78
|
+
modelElements.push( option.model );
|
79
|
+
}
|
80
|
+
}
|
81
|
+
|
82
|
+
this._addClassToAllHeading( editor );
|
83
|
+
|
84
|
+
// Register the heading command for this option.
|
85
|
+
editor.commands.add( 'heading', new HeadingCommand( editor, modelElements ) );
|
86
|
+
}
|
87
|
+
|
88
|
+
/**
|
89
|
+
* @inheritDoc
|
90
|
+
*/
|
91
|
+
afterInit() {
|
92
|
+
// If the enter command is added to the editor, alter its behavior.
|
93
|
+
// Enter at the end of a heading element should create a paragraph.
|
94
|
+
const editor = this.editor;
|
95
|
+
const enterCommand = editor.commands.get( 'enter' );
|
96
|
+
const options = editor.config.get( 'heading.options' );
|
97
|
+
|
98
|
+
if ( enterCommand ) {
|
99
|
+
this.listenTo( enterCommand, 'afterExecute', ( evt, data ) => {
|
100
|
+
const positionParent = editor.model.document.selection.getFirstPosition().parent;
|
101
|
+
const isHeading = options.some( option => positionParent.is( 'element', option.model ) );
|
102
|
+
|
103
|
+
if ( isHeading && (!positionParent.is( 'element', defaultModelElement ) && !positionParent.is( 'element', 'ingress' )) && positionParent.childCount === 0 ) {
|
104
|
+
data.writer.rename( positionParent, defaultModelElement );
|
105
|
+
}
|
106
|
+
} );
|
107
|
+
}
|
108
|
+
}
|
109
|
+
|
110
|
+
/**
|
111
|
+
* Adds default conversion for `h1` -> `heading1` with a low priority.
|
112
|
+
*
|
113
|
+
* @private
|
114
|
+
* @param {module:core/editor/editor~Editor} editor Editor instance on which to add the `h1` conversion.
|
115
|
+
*/
|
116
|
+
_addDefaultH1Conversion( editor ) {
|
117
|
+
editor.conversion.for( 'upcast' ).elementToElement( {
|
118
|
+
model: 'heading1',
|
119
|
+
view: 'h1',
|
120
|
+
// With a `low` priority, `paragraph` plugin autoparagraphing mechanism is executed. Make sure
|
121
|
+
// this listener is called before it. If not, `h1` will be transformed into a paragraph.
|
122
|
+
converterPriority: priorities.get( 'low' ) + 1
|
123
|
+
} )
|
124
|
+
}
|
125
|
+
|
126
|
+
/**
|
127
|
+
* This plugin brings customization to the downcast pipeline of the editor.
|
128
|
+
*
|
129
|
+
* @private
|
130
|
+
* @param {module:core/editor/editor~Editor} editor
|
131
|
+
*/
|
132
|
+
_addClassToAllHeading( editor ) {
|
133
|
+
// Both the data and the editing pipelines are affected by this conversion.
|
134
|
+
editor.conversion.for( 'downcast' ).add( dispatcher => {
|
135
|
+
// Headings are represented in the model as a "heading1" element.
|
136
|
+
// Use the "low" listener priority to apply the changes after the headings feature.
|
137
|
+
dispatcher.on( 'insert:heading1', ( evt, data, conversionApi ) => {
|
138
|
+
const viewWriter = conversionApi.writer;
|
139
|
+
|
140
|
+
viewWriter.addClass( 'radEdH1', conversionApi.mapper.toViewElement( data.item ) );
|
141
|
+
}, { priority: 'low' } );
|
142
|
+
} );
|
143
|
+
|
144
|
+
editor.conversion.for( 'downcast' ).add( dispatcher => {
|
145
|
+
// Headings are represented in the model as a "heading2" element.
|
146
|
+
// Use the "low" listener priority to apply the changes after the headings feature.
|
147
|
+
dispatcher.on( 'insert:heading2', ( evt, data, conversionApi ) => {
|
148
|
+
const viewWriter = conversionApi.writer;
|
149
|
+
|
150
|
+
viewWriter.addClass( 'radEdH2', conversionApi.mapper.toViewElement( data.item ) );
|
151
|
+
}, { priority: 'low' } );
|
152
|
+
} );
|
153
|
+
|
154
|
+
editor.conversion.for( 'downcast' ).add( dispatcher => {
|
155
|
+
// Headings are represented in the model as a "heading3" element.
|
156
|
+
// Use the "low" listener priority to apply the changes after the headings feature.
|
157
|
+
dispatcher.on( 'insert:heading3', ( evt, data, conversionApi ) => {
|
158
|
+
const viewWriter = conversionApi.writer;
|
159
|
+
|
160
|
+
viewWriter.addClass( 'radEdH3', conversionApi.mapper.toViewElement( data.item ) );
|
161
|
+
}, { priority: 'low' } );
|
162
|
+
} );
|
163
|
+
}
|
164
|
+
|
165
|
+
}
|