qms-angular 1.0.72 → 1.0.73
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 +509 -116
- package/bundles/qms-angular.umd.js.map +1 -1
- package/esm2015/lib/components/qms-navigation-drawer/qms-navigation-drawer.component.js +2 -2
- package/esm2015/lib/components/qms-navigation-drawer/qms-navigation-drawer.module.js +1 -3
- package/esm2015/lib/components/select-include-children/select-include-children.component.js +112 -45
- package/esm2015/lib/components/tree/tree.component.js +10 -14
- package/esm2015/lib/model/en.js +19 -2
- package/esm2015/lib/model/no.js +19 -2
- package/esm2015/lib/qms-ckeditor-components/common/classes/qmsUploadAdapter.js +89 -0
- package/esm2015/lib/qms-ckeditor-components/common/constants/ckeditorEvent.constant.js +3 -1
- package/esm2015/lib/qms-ckeditor-components/common/models/qms-ckeditor-data.model.js +1 -1
- package/esm2015/lib/qms-ckeditor-components/common/models/qms-ckeditor-video-tree.model.js +4 -0
- package/esm2015/lib/qms-ckeditor-components/common/models/wproofreader-config.model.js +6 -0
- package/esm2015/lib/qms-ckeditor-components/components/qms-ckeditor-about/qms-ckeditor-about.component.js +38 -0
- package/esm2015/lib/qms-ckeditor-components/components/qms-ckeditor-bpmn/qms-ckeditor-bpmn.component.js +22 -3
- package/esm2015/lib/qms-ckeditor-components/components/qms-ckeditor-imagemap/qms-ckeditor-imagemap.component.js +9 -8
- package/esm2015/lib/qms-ckeditor-components/components/qms-ckeditor-link/qms-ckeditor-link.component.js +4 -1
- package/esm2015/lib/qms-ckeditor-components/components/qms-ckeditor-tooltip/qms-ckeditor-tooltip.component.js +3 -4
- package/esm2015/lib/qms-ckeditor-components/qms-ckeditor.component.js +160 -10
- package/esm2015/lib/qms-ckeditor-components/qms-ckeditor.module.js +7 -3
- package/esm2015/lib/qms-ckeditor-components/services/qms-ckeditor-tree.service.js +4 -1
- package/esm2015/lib/qms-ckeditor-components/services/qms-ckeditor-upload.service.js +20 -0
- package/esm2015/qms-angular.js +6 -4
- package/fesm2015/qms-angular.js +475 -95
- package/fesm2015/qms-angular.js.map +1 -1
- package/lib/components/select-include-children/select-include-children.component.d.ts +2 -1
- package/lib/model/en.d.ts +17 -0
- package/lib/model/no.d.ts +17 -0
- package/lib/qms-ckeditor-components/common/classes/qmsUploadAdapter.d.ts +18 -0
- package/lib/qms-ckeditor-components/common/constants/ckeditorEvent.constant.d.ts +2 -0
- package/lib/qms-ckeditor-components/common/models/qms-ckeditor-data.model.d.ts +4 -0
- package/lib/qms-ckeditor-components/common/models/qms-ckeditor-video-tree.model.d.ts +5 -0
- package/lib/qms-ckeditor-components/common/models/wproofreader-config.model.d.ts +25 -0
- package/lib/qms-ckeditor-components/components/qms-ckeditor-about/qms-ckeditor-about.component.d.ts +15 -0
- package/lib/qms-ckeditor-components/components/qms-ckeditor-bpmn/qms-ckeditor-bpmn.component.d.ts +4 -1
- package/lib/qms-ckeditor-components/components/qms-ckeditor-imagemap/qms-ckeditor-imagemap.component.d.ts +2 -1
- package/lib/qms-ckeditor-components/qms-ckeditor.component.d.ts +15 -1
- package/lib/qms-ckeditor-components/services/qms-ckeditor-tree.service.d.ts +2 -0
- package/lib/qms-ckeditor-components/services/qms-ckeditor-upload.service.d.ts +5 -0
- package/lib.theme.scss +1 -0
- package/package.json +1 -1
- package/qms-angular.d.ts +5 -3
- package/qms-angular.metadata.json +1 -1
- package/src/assets/images/ckeditor5.svg +1 -0
- package/src/assets/qms-ckeditor-plugin/build/ckeditor.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/ckeditor.js.map +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/az.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/cs.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/da.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/de-ch.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/de.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/en-au.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/es.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/et.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/fa.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/fr.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/gl.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/he.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/hi.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/hr.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/hu.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/id.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/it.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/ja.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/ko.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/ku.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/lv.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/nl.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/no.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/pl.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/pt-br.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/ru.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/sk.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/sl.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/sr-latn.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/sr.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/th.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/tk.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/tr.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/uk.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/vi.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/zh-cn.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/zh.js +1 -1
- package/src/assets/qms-ckeditor-plugin/package-lock.json +23 -0
- package/src/assets/qms-ckeditor-plugin/package.json +2 -0
- package/src/assets/qms-ckeditor-plugin/src/ckeditor.js +16 -4
- package/src/assets/qms-ckeditor-plugin/src/plugins/aboutckeditor/aboutckeditor.js +28 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/bpmn/bpmndialogcommand.js +74 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/bpmn/qmsCKEditorBpmnPlugin.js +5 -68
- package/src/assets/qms-ckeditor-plugin/src/plugins/common/qmsCKEditorConstant.js +4 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/common/qmsCKEditorService.js +21 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/imagemap/imagemapcommand.js +1 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/imagemap/utils.js +1 -1
- package/src/assets/qms-ckeditor-plugin/src/plugins/link/linkcommand.js +131 -176
- package/src/assets/qms-ckeditor-plugin/src/plugins/link/linkdialogcommand.js +88 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/link/linkediting.js +2 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/link/linkui.js +41 -32
- package/src/assets/qms-ckeditor-plugin/src/plugins/tableofcontents/tableofcontents.js +14 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/tableofcontents/tableofcontentscommand.js +87 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/tableofcontents/tableofcontentsediting.js +59 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/tableofcontents/tableofcontentsui.js +35 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/tableofcontents/utils.js +62 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/template/loadtemplatedialogcommand.js +14 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/template/qmsCKEditorLoadTemplatePlugin.js +10 -12
- package/src/assets/qms-ckeditor-plugin/src/plugins/template/qmsCKEdtiorTemplatePlugin.js +10 -7
- package/src/assets/qms-ckeditor-plugin/src/plugins/template/templatedialogcommand.js +9 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/timestamp/timestamp.js +15 -18
- package/src/assets/qms-ckeditor-plugin/src/plugins/timestamp/timestampcommand.js +17 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/tooltip/removetooltipcommand.js +42 -26
- package/src/assets/qms-ckeditor-plugin/src/plugins/tooltip/tooltip.js +3 -3
- package/src/assets/qms-ckeditor-plugin/src/plugins/tooltip/tooltipcommand.js +75 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/tooltip/tooltipdialogcommand.js +68 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/tooltip/tooltipediting.js +206 -131
- package/src/assets/qms-ckeditor-plugin/src/plugins/tooltip/tooltipui.js +424 -136
- package/src/assets/qms-ckeditor-plugin/src/plugins/tooltip/ui/actionsview.js +67 -12
- package/src/assets/qms-ckeditor-plugin/src/plugins/tooltip/utils.js +17 -55
- package/src/assets/qms-ckeditor-plugin/src/plugins/video/autovideo.js +1 -5
- package/src/assets/qms-ckeditor-plugin/src/plugins/video/video/videoediting.js +5 -2
- package/src/assets/qms-ckeditor-plugin/src/plugins/video/videoupload/browsevideodialogcommand.js +25 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/video/videoupload/uploadvideocommand.js +3 -16
- package/src/assets/qms-ckeditor-plugin/src/plugins/video/videoupload/videouploadediting.js +4 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/video/videoupload/videouploadui.js +12 -23
- package/src/assets/qms-ckeditor-plugin/src/themes/icons/information.svg +1 -50
- package/src/assets/qms-ckeditor-plugin/src/themes/icons/table-excel.svg +44 -0
- package/src/assets/qms-ckeditor-plugin/src/themes/icons/timestamp.svg +1 -1
- package/src/assets/qms-ckeditor-plugin/src/themes/icons/tooltip.svg +1 -0
- package/src/assets/qms-ckeditor-plugin/src/themes/styles/heading.css +54 -0
- package/src/assets/qms-ckeditor-plugin/src/themes/styles/tooltip.css +11 -53
- package/src/lib/qms-ckeditor-components/components/qms-ckeditor-about/qms-ckeditor-about.component.scss +16 -0
- package/src/lib/qms-ckeditor-components/components/qms-ckeditor-imagemap/qms-ckeditor-imagemap.component.scss +26 -23
- package/src/themes/core/_range-slider.scss +10 -12
- package/esm2015/lib/qms-ckeditor-components/common/classes/uploadAdapter.js +0 -26
- package/lib/qms-ckeditor-components/common/classes/uploadAdapter.d.ts +0 -5
- package/src/assets/qms-ckeditor-plugin/src/plugins/tooltip/inserttooltipcommand.js +0 -88
@@ -1,89 +1,26 @@
|
|
1
1
|
import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
|
2
2
|
import ButtonView from '@ckeditor/ckeditor5-ui/src/button/buttonview';
|
3
3
|
import BpmnIcon from '../../themes/icons/bpmn.svg';
|
4
|
-
import
|
5
|
-
import * as QMSCKEditorService from '../common/qmsCKEditorService';
|
6
|
-
import { IMAGEMAP_COMMANDS, createInsertedEvent } from '../imagemap/utils';
|
7
|
-
import { debounced } from '../common/qmsCKEditorUtil';
|
8
|
-
|
4
|
+
import BpmnDialogCommand from './bpmndialogcommand';
|
9
5
|
export default class QMSCKEditorBpmnPlugin extends Plugin {
|
10
6
|
init() {
|
11
7
|
const editor = this.editor;
|
12
8
|
const t = editor.t;
|
13
9
|
editor.ui.componentFactory.add('qmsBpmn', locale => {
|
14
10
|
const view = new ButtonView(locale);
|
15
|
-
|
11
|
+
const command = editor.commands.get('bpmnDialog');
|
16
12
|
view.set({
|
17
13
|
label: t('Business Process Model and Notation'),
|
18
14
|
icon: BpmnIcon,
|
19
15
|
tooltip: true
|
20
16
|
});
|
21
|
-
|
17
|
+
view.bind('isEnabled').to(command);
|
22
18
|
view.on('execute', () => {
|
23
|
-
|
24
|
-
if (isBpmn) {
|
25
|
-
const parentElement = editor.editing.view.document.selection.getSelectedElement();
|
26
|
-
const altAtr = parentElement.getChild(0).getAttribute('alt');
|
27
|
-
const arrAtr = altAtr.split("#");
|
28
|
-
const id = arrAtr[1];
|
29
|
-
QMSCKEditorService.bpmnNotify(id);
|
30
|
-
}
|
31
|
-
else {
|
32
|
-
QMSCKEditorService.bpmnNotify('');
|
33
|
-
}
|
34
|
-
window[QMSCKEditorConstant.QMSCK_BPMN_IS_PROCESSING] = false;
|
35
|
-
window.addEventListener(QMSCKEditorConstant.QMSCK_BPMN_PLUGIN_RESP, function (evt) {
|
36
|
-
if (window[QMSCKEditorConstant.QMSCK_BPMN_IS_PROCESSING]) {
|
37
|
-
return;
|
38
|
-
}
|
39
|
-
window[QMSCKEditorConstant.QMSCK_BPMN_IS_PROCESSING] = true;
|
40
|
-
editor.model.change( writer => {
|
41
|
-
const options = evt.detail.imagemap || {};
|
42
|
-
const imageElement = writer.createElement( 'image', {
|
43
|
-
src: evt.detail.values,
|
44
|
-
alt: evt.detail.key
|
45
|
-
});
|
46
|
-
// Insert the image in the current selection location.
|
47
|
-
editor.model.insertContent( imageElement, editor.model.document.selection );
|
48
|
-
if(!!options.areas && options.areas.length > 0){
|
49
|
-
editor.model.createSelection(imageElement, "in");//Set the current selection in the inserted image
|
50
|
-
const imageMapCommand = editor.commands.get(IMAGEMAP_COMMANDS.IMAGEMAP);
|
51
|
-
if(!!imageMapCommand){
|
52
|
-
imageMapCommand.set('isEnabled', true);//force to run the command
|
53
|
-
options.oldName = options.name;//Delete old image map if any
|
54
|
-
imageMapCommand.execute(options);
|
55
|
-
//resize image map when image width is greater than the widget width (600px)
|
56
|
-
if(options.imageWidth > 600){
|
57
|
-
const resizeImageMapCommand = editor.commands.get(IMAGEMAP_COMMANDS.RESIZE_IMAGEMAP);
|
58
|
-
if(!!resizeImageMapCommand){
|
59
|
-
imageMapCommand.once(createInsertedEvent(options.name), debounced(() => {
|
60
|
-
resizeImageMapCommand.set('isEnabled', true);//force to run the command
|
61
|
-
resizeImageMapCommand.execute();
|
62
|
-
}, 500));
|
63
|
-
}
|
64
|
-
}
|
65
|
-
}
|
66
|
-
}
|
67
|
-
});
|
68
|
-
}, { once: true });
|
19
|
+
command.execute();
|
69
20
|
});
|
70
21
|
return view;
|
71
22
|
});
|
72
|
-
}
|
73
|
-
|
74
|
-
isBpmnImage( element, image ) {
|
75
|
-
const isImage = element && image.isImageWidget( element );
|
76
|
-
|
77
|
-
if ( !isImage ) {
|
78
|
-
return false;
|
79
|
-
}
|
80
23
|
|
81
|
-
|
82
|
-
if (altAtr && altAtr.includes(QMSCKEditorConstant.QMSCK_BPMN)) {
|
83
|
-
return true;
|
84
|
-
}
|
85
|
-
else {
|
86
|
-
return false;
|
87
|
-
}
|
24
|
+
editor.commands.add('bpmnDialog', new BpmnDialogCommand(editor));
|
88
25
|
}
|
89
26
|
}
|
@@ -30,3 +30,7 @@ export const QMSCK_FLOWCHART_PLUGIN_RESP = 'QMSCK_FLOWCHART_PLUGIN_RESP';
|
|
30
30
|
export const QMSCK_FLOWCHART = 'flowchart';
|
31
31
|
/* Toolbar Toggle */
|
32
32
|
export const QMSCK_TOGGLE_TOOLBAR_MSG = 'QMSCK_TOGGLE_TOOLBAR_MSG';
|
33
|
+
/* Browse Video */
|
34
|
+
export const QMSCK_BROWSE_VIDEO_MSG = 'QMSCK_BROWSE_VIDEO_MSG';
|
35
|
+
export const QMSCK_BROWSE_VIDEO_RESP = 'QMSCK_BROWSE_VIDEO_RESP';
|
36
|
+
export const QMSCK_BROWSE_VIDEO_IS_PROCESSING = 'QMSCK_BROWSE_VIDEO_IS_PROCESSING';
|
@@ -79,3 +79,24 @@ export function bpmnNotify(value) {
|
|
79
79
|
'*'
|
80
80
|
);
|
81
81
|
}
|
82
|
+
|
83
|
+
|
84
|
+
export function uploadVideoNotify(value) {
|
85
|
+
window.postMessage(
|
86
|
+
{
|
87
|
+
eventName: constant.QMSCK_BROWSE_VIDEO_MSG,
|
88
|
+
value
|
89
|
+
},
|
90
|
+
'*'
|
91
|
+
);
|
92
|
+
}
|
93
|
+
|
94
|
+
export function aboutCKEditorNotify(value) {
|
95
|
+
window.postMessage(
|
96
|
+
{
|
97
|
+
eventName: constant.QMSCK_ABOUT_CKEDITOR_PLUGIN_MSG,
|
98
|
+
value
|
99
|
+
},
|
100
|
+
'*'
|
101
|
+
);
|
102
|
+
}
|
@@ -11,8 +11,6 @@ import { Command } from '@ckeditor/ckeditor5-core';
|
|
11
11
|
import { findAttributeRange } from '@ckeditor/ckeditor5-typing';
|
12
12
|
import { Collection, first, toMap } from '@ckeditor/ckeditor5-utils';
|
13
13
|
import * as QMSCKEditorConstant from '../common/qmsCKEditorConstant';
|
14
|
-
import * as QMSCKEditorEnum from '../common/qmsCKEditorEnum';
|
15
|
-
import * as QMSCKEditorService from '../common/qmsCKEditorService';
|
16
14
|
import { isImageAllowed } from './utils';
|
17
15
|
import AutomaticDecorators from './utils/automaticdecorators';
|
18
16
|
|
@@ -150,168 +148,143 @@ export default class LinkCommand extends Command {
|
|
150
148
|
* @param {String} href Link destination.
|
151
149
|
* @param {Object} [manualDecoratorIds={}] The information about manual decorator attributes to be applied or removed upon execution.
|
152
150
|
*/
|
153
|
-
execute() {
|
154
|
-
|
151
|
+
execute(options) {
|
155
152
|
const model = this.editor.model;
|
156
153
|
const selection = model.document.selection;
|
157
|
-
const ranges = selection.getFirstRange();
|
158
154
|
const manualDecoratorIds = {};
|
159
155
|
const linkDecorators = this.editor.config.get( 'link.decorators' );
|
160
156
|
const selectedRange = 'link'+ linkDecorators.length;
|
157
|
+
|
158
|
+
const url = options.url;
|
159
|
+
const href = url.substring(2, url.length);
|
160
|
+
const title = options.title ? options.title : url;
|
161
161
|
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
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
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
if ( allowedRange.containsRange( range ) ) {
|
289
|
-
_isRangeToUpdate = false;
|
290
|
-
break;
|
291
|
-
}
|
292
|
-
}
|
293
|
-
if (_isRangeToUpdate) {
|
294
|
-
rangesToUpdate.push( range );
|
295
|
-
}
|
296
|
-
}
|
297
|
-
|
298
|
-
for ( const range of rangesToUpdate ) {
|
299
|
-
writer.setAttribute('linkHref', href, range);
|
300
|
-
writer.setAttribute(selectedRange, true, range);
|
301
|
-
|
302
|
-
truthyManualDecorators.forEach( item => {
|
303
|
-
writer.setAttribute( item, true, range );
|
304
|
-
} );
|
305
|
-
|
306
|
-
falsyManualDecorators.forEach( item => {
|
307
|
-
writer.removeAttribute( item, range );
|
308
|
-
} );
|
309
|
-
}
|
310
|
-
}
|
311
|
-
} );
|
312
|
-
window[QMSCKEditorConstant.QMSCK_LINKED] = true;
|
313
|
-
},
|
314
|
-
{ once: true });
|
162
|
+
for(let i= 0; i < linkDecorators.length-2; i++){
|
163
|
+
manualDecoratorIds['link' + i] = (i === options.targetId)? true : false;
|
164
|
+
}
|
165
|
+
// Stores information about manual decorators to turn them on/off when command is applied.
|
166
|
+
const truthyManualDecorators = [];
|
167
|
+
const falsyManualDecorators = [];
|
168
|
+
|
169
|
+
for ( const name in manualDecoratorIds ) {
|
170
|
+
if ( manualDecoratorIds[ name ] ) {
|
171
|
+
truthyManualDecorators.push( name );
|
172
|
+
} else {
|
173
|
+
falsyManualDecorators.push( name );
|
174
|
+
}
|
175
|
+
}
|
176
|
+
|
177
|
+
model.change( writer => {
|
178
|
+
// set link option value
|
179
|
+
window[QMSCKEditorConstant.QMSCK_LINK_OPTION] = url.substring(0, 2);
|
180
|
+
// If selection is collapsed then update selected link or insert new one at the place of caret.
|
181
|
+
if ( selection.isCollapsed ) {
|
182
|
+
const position = selection.getFirstPosition();
|
183
|
+
|
184
|
+
// When selection is inside text with `linkHref` attribute.
|
185
|
+
if ( selection.hasAttribute( 'linkHref' ) ) {
|
186
|
+
// Then update `linkHref` value.
|
187
|
+
const linkRange = findAttributeRange( position, 'linkHref', selection.getAttribute( 'linkHref' ), model );
|
188
|
+
if (!selection.hasAttribute(selectedRange)) {
|
189
|
+
writer.remove(linkRange);
|
190
|
+
const newPosition = selection.getFirstPosition();
|
191
|
+
const attributes = toMap( selection.getAttributes() );
|
192
|
+
attributes.set( 'linkHref', href );
|
193
|
+
truthyManualDecorators.forEach( item => {
|
194
|
+
attributes.set( item, true );
|
195
|
+
} );
|
196
|
+
const { end: positionAfter } = model.insertContent( writer.createText( title, attributes ), newPosition );
|
197
|
+
writer.setSelection( positionAfter );
|
198
|
+
}
|
199
|
+
else {
|
200
|
+
writer.setAttribute( 'linkHref', href, linkRange );
|
201
|
+
truthyManualDecorators.forEach( item => {
|
202
|
+
writer.setAttribute( item, true, linkRange );
|
203
|
+
} );
|
204
|
+
falsyManualDecorators.forEach( item => {
|
205
|
+
writer.removeAttribute( item, linkRange );
|
206
|
+
} );
|
207
|
+
// Put the selection at the end of the updated link.
|
208
|
+
writer.setSelection( writer.createPositionAfter( linkRange.end.nodeBefore ) );
|
209
|
+
}
|
210
|
+
}
|
211
|
+
// If not then insert text node with `linkHref` attribute in place of caret.
|
212
|
+
// However, since selection is collapsed, attribute value will be used as data for text node.
|
213
|
+
// So, if `href` is empty, do not create text node.
|
214
|
+
else if ( href !== '' ) {
|
215
|
+
const attributes = toMap( selection.getAttributes() );
|
216
|
+
|
217
|
+
attributes.set( 'linkHref', href );
|
218
|
+
|
219
|
+
truthyManualDecorators.forEach( item => {
|
220
|
+
attributes.set( item, true );
|
221
|
+
} );
|
222
|
+
|
223
|
+
const { end: positionAfter } = model.insertContent( writer.createText( title, attributes ), position );
|
224
|
+
|
225
|
+
// Put the selection at the end of the inserted link.
|
226
|
+
// Using end of range returned from insertContent in case nodes with the same attributes got merged.
|
227
|
+
writer.setSelection( positionAfter );
|
228
|
+
}
|
229
|
+
|
230
|
+
// Remove the `linkHref` attribute and all link decorators from the selection.
|
231
|
+
// It stops adding a new content into the link element.
|
232
|
+
[ 'linkHref', ...truthyManualDecorators, ...falsyManualDecorators ].forEach( item => {
|
233
|
+
writer.removeSelectionAttribute( item );
|
234
|
+
} );
|
235
|
+
} else {
|
236
|
+
// If selection has non-collapsed ranges, we change attribute on nodes inside those ranges
|
237
|
+
// omitting nodes where the `linkHref` attribute is disallowed.
|
238
|
+
const ranges = model.schema.getValidRanges( selection.getRanges(), 'linkHref' );
|
239
|
+
|
240
|
+
// But for the first, check whether the `linkHref` attribute is allowed on selected blocks (e.g. the "image" element).
|
241
|
+
const allowedRanges = [];
|
242
|
+
|
243
|
+
for ( const element of selection.getSelectedBlocks() ) {
|
244
|
+
if ( model.schema.checkAttribute( element, 'linkHref' ) ) {
|
245
|
+
allowedRanges.push( writer.createRangeOn( element ) );
|
246
|
+
}
|
247
|
+
}
|
248
|
+
|
249
|
+
// Ranges that accept the `linkHref` attribute. Since we will iterate over `allowedRanges`, let's clone it.
|
250
|
+
const rangesToUpdate = allowedRanges.slice();
|
251
|
+
|
252
|
+
// eslint-disable-next-line max-len
|
253
|
+
// For all selection ranges we want to check whether given range is inside an element that accepts the `linkHref` attribute.
|
254
|
+
// If so, we don't want to propagate applying the attribute to its children.
|
255
|
+
// for ( const range of ranges ) {
|
256
|
+
// if ( this._isRangeToUpdate( range, allowedRanges ) ) {
|
257
|
+
// rangesToUpdate.push( range );
|
258
|
+
// }
|
259
|
+
// }
|
260
|
+
|
261
|
+
for ( const range of ranges ) {
|
262
|
+
const _isRangeToUpdate = true;
|
263
|
+
for ( const allowedRange of allowedRanges ) {
|
264
|
+
if ( allowedRange.containsRange( range ) ) {
|
265
|
+
_isRangeToUpdate = false;
|
266
|
+
break;
|
267
|
+
}
|
268
|
+
}
|
269
|
+
if (_isRangeToUpdate) {
|
270
|
+
rangesToUpdate.push( range );
|
271
|
+
}
|
272
|
+
}
|
273
|
+
|
274
|
+
for ( const range of rangesToUpdate ) {
|
275
|
+
writer.setAttribute('linkHref', href, range);
|
276
|
+
writer.setAttribute(selectedRange, true, range);
|
277
|
+
|
278
|
+
truthyManualDecorators.forEach( item => {
|
279
|
+
writer.setAttribute( item, true, range );
|
280
|
+
} );
|
281
|
+
|
282
|
+
falsyManualDecorators.forEach( item => {
|
283
|
+
writer.removeAttribute( item, range );
|
284
|
+
} );
|
285
|
+
}
|
286
|
+
}
|
287
|
+
} );
|
315
288
|
}
|
316
289
|
|
317
290
|
/**
|
@@ -336,22 +309,4 @@ export default class LinkCommand extends Command {
|
|
336
309
|
return doc.selection.getAttribute( decoratorName );
|
337
310
|
}
|
338
311
|
|
339
|
-
/**
|
340
|
-
* Checks whether specified `range` is inside an element that accepts the `linkHref` attribute.
|
341
|
-
*
|
342
|
-
* @private
|
343
|
-
* @param {module:engine/view/range~Range} range A range to check.
|
344
|
-
* @param {Array.<module:engine/view/range~Range>} allowedRanges An array of ranges created on elements where the attribute is accepted.
|
345
|
-
* @returns {Boolean}
|
346
|
-
*/
|
347
|
-
_isRangeToUpdate( range, allowedRanges ) {
|
348
|
-
for ( const allowedRange of allowedRanges ) {
|
349
|
-
// A range is inside an element that will have the `linkHref` attribute. Do not modify its nodes.
|
350
|
-
if ( allowedRange.containsRange( range ) ) {
|
351
|
-
return false;
|
352
|
-
}
|
353
|
-
}
|
354
|
-
|
355
|
-
return true;
|
356
|
-
}
|
357
312
|
}
|
@@ -0,0 +1,88 @@
|
|
1
|
+
|
2
|
+
import { Command } from '@ckeditor/ckeditor5-core';
|
3
|
+
import { Collection, first } from '@ckeditor/ckeditor5-utils';
|
4
|
+
import * as QMSCKEditorConstant from '../common/qmsCKEditorConstant';
|
5
|
+
import * as QMSCKEditorEnum from '../common/qmsCKEditorEnum';
|
6
|
+
import * as QMSCKEditorService from '../common/qmsCKEditorService';
|
7
|
+
import { isImageAllowed } from './utils';
|
8
|
+
import AutomaticDecorators from './utils/automaticdecorators';
|
9
|
+
|
10
|
+
export default class LinkDialogCommand extends Command {
|
11
|
+
constructor( editor ) {
|
12
|
+
super( editor );
|
13
|
+
this.manualDecorators = new Collection();
|
14
|
+
this.automaticDecorators = new AutomaticDecorators();
|
15
|
+
}
|
16
|
+
|
17
|
+
restoreManualDecoratorStates() {
|
18
|
+
for ( const manualDecorator of this.manualDecorators ) {
|
19
|
+
manualDecorator.value = this._getDecoratorStateFromModel( manualDecorator.id );
|
20
|
+
}
|
21
|
+
}
|
22
|
+
|
23
|
+
refresh() {
|
24
|
+
const model = this.editor.model;
|
25
|
+
const doc = model.document;
|
26
|
+
|
27
|
+
const selectedElement = first( doc.selection.getSelectedBlocks() );
|
28
|
+
|
29
|
+
// A check for the `LinkImage` plugin. If the selection contains an element, get values from the element.
|
30
|
+
// Currently the selection reads attributes from text nodes only. See #7429 and #7465.
|
31
|
+
if ( isImageAllowed( selectedElement, model.schema ) ) {
|
32
|
+
this.value = selectedElement.getAttribute( 'linkHref' );
|
33
|
+
this.isEnabled = model.schema.checkAttribute( selectedElement, 'linkHref' );
|
34
|
+
} else {
|
35
|
+
this.value = doc.selection.getAttribute( 'linkHref' );
|
36
|
+
this.isEnabled = model.schema.checkAttributeInSelection( doc.selection, 'linkHref' );
|
37
|
+
}
|
38
|
+
|
39
|
+
for ( const manualDecorator of this.manualDecorators ) {
|
40
|
+
manualDecorator.value = this._getDecoratorStateFromModel( manualDecorator.id );
|
41
|
+
}
|
42
|
+
}
|
43
|
+
|
44
|
+
execute() {
|
45
|
+
const editor = this.editor;
|
46
|
+
const model = editor.model;
|
47
|
+
const selection = model.document.selection;
|
48
|
+
const ranges = selection.getFirstRange();
|
49
|
+
|
50
|
+
let link = QMSCKEditorEnum.hyperLink;
|
51
|
+
link.typeId = 0;
|
52
|
+
link.targetId = 0;
|
53
|
+
link.protocolId = 0;
|
54
|
+
link.url = '';
|
55
|
+
link.title = '';
|
56
|
+
link.editorContent = '';
|
57
|
+
for (const item of ranges.getItems()) {
|
58
|
+
if (item.data) {
|
59
|
+
link.title = item.data;
|
60
|
+
}
|
61
|
+
}
|
62
|
+
QMSCKEditorService.linkNotify(link);
|
63
|
+
window[QMSCKEditorConstant.QMSCK_LINKED] = false;
|
64
|
+
window.addEventListener(QMSCKEditorConstant.QMSCK_LINK_PLUGIN_RESP, function(evt) {
|
65
|
+
if (window[QMSCKEditorConstant.QMSCK_LINKED]){
|
66
|
+
return;
|
67
|
+
}
|
68
|
+
window[QMSCKEditorConstant.QMSCK_LINKED] = true;
|
69
|
+
const options = evt.detail;
|
70
|
+
editor.commands.get('link').execute(options);
|
71
|
+
}, { once: true });
|
72
|
+
}
|
73
|
+
|
74
|
+
_getDecoratorStateFromModel( decoratorName ) {
|
75
|
+
const model = this.editor.model;
|
76
|
+
const doc = model.document;
|
77
|
+
const selectedElement = first( doc.selection.getSelectedBlocks() );
|
78
|
+
|
79
|
+
// A check for the `LinkImage` plugin. If the selection contains an element, get values from the element.
|
80
|
+
// Currently the selection reads attributes from text nodes only. See #7429 and #7465.
|
81
|
+
if ( isImageAllowed( selectedElement, model.schema ) ) {
|
82
|
+
return selectedElement.getAttribute( decoratorName );
|
83
|
+
}
|
84
|
+
|
85
|
+
return doc.selection.getAttribute( decoratorName );
|
86
|
+
}
|
87
|
+
}
|
88
|
+
|
@@ -20,6 +20,7 @@ import { createLinkElement, ensureSafeUrl, getLocalizedDecorators, normalizeDeco
|
|
20
20
|
import * as QMSCKEditorConstant from '../common/qmsCKEditorConstant';
|
21
21
|
import '../../themes/styles/link.css';
|
22
22
|
import { isLinkElement } from './utils';
|
23
|
+
import LinkDialogCommand from './linkdialogcommand';
|
23
24
|
|
24
25
|
const HIGHLIGHT_CLASS = 'ck-link_selected';
|
25
26
|
const DECORATOR_AUTOMATIC = 'automatic';
|
@@ -94,6 +95,7 @@ export default class LinkEditing extends Plugin {
|
|
94
95
|
|
95
96
|
// Create linking commands.
|
96
97
|
editor.commands.add( 'link', new LinkCommand( editor ) );
|
98
|
+
editor.commands.add( 'linkdialog', new LinkDialogCommand( editor ) );
|
97
99
|
editor.commands.add( 'unlink', new UnlinkCommand( editor ) );
|
98
100
|
|
99
101
|
const linkDecorators = getLocalizedDecorators( editor.t, normalizeDecorators( editor.config.get( 'link.decorators' ) ) );
|