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.
Files changed (134) hide show
  1. package/bundles/qms-angular.umd.js +509 -116
  2. package/bundles/qms-angular.umd.js.map +1 -1
  3. package/esm2015/lib/components/qms-navigation-drawer/qms-navigation-drawer.component.js +2 -2
  4. package/esm2015/lib/components/qms-navigation-drawer/qms-navigation-drawer.module.js +1 -3
  5. package/esm2015/lib/components/select-include-children/select-include-children.component.js +112 -45
  6. package/esm2015/lib/components/tree/tree.component.js +10 -14
  7. package/esm2015/lib/model/en.js +19 -2
  8. package/esm2015/lib/model/no.js +19 -2
  9. package/esm2015/lib/qms-ckeditor-components/common/classes/qmsUploadAdapter.js +89 -0
  10. package/esm2015/lib/qms-ckeditor-components/common/constants/ckeditorEvent.constant.js +3 -1
  11. package/esm2015/lib/qms-ckeditor-components/common/models/qms-ckeditor-data.model.js +1 -1
  12. package/esm2015/lib/qms-ckeditor-components/common/models/qms-ckeditor-video-tree.model.js +4 -0
  13. package/esm2015/lib/qms-ckeditor-components/common/models/wproofreader-config.model.js +6 -0
  14. package/esm2015/lib/qms-ckeditor-components/components/qms-ckeditor-about/qms-ckeditor-about.component.js +38 -0
  15. package/esm2015/lib/qms-ckeditor-components/components/qms-ckeditor-bpmn/qms-ckeditor-bpmn.component.js +22 -3
  16. package/esm2015/lib/qms-ckeditor-components/components/qms-ckeditor-imagemap/qms-ckeditor-imagemap.component.js +9 -8
  17. package/esm2015/lib/qms-ckeditor-components/components/qms-ckeditor-link/qms-ckeditor-link.component.js +4 -1
  18. package/esm2015/lib/qms-ckeditor-components/components/qms-ckeditor-tooltip/qms-ckeditor-tooltip.component.js +3 -4
  19. package/esm2015/lib/qms-ckeditor-components/qms-ckeditor.component.js +160 -10
  20. package/esm2015/lib/qms-ckeditor-components/qms-ckeditor.module.js +7 -3
  21. package/esm2015/lib/qms-ckeditor-components/services/qms-ckeditor-tree.service.js +4 -1
  22. package/esm2015/lib/qms-ckeditor-components/services/qms-ckeditor-upload.service.js +20 -0
  23. package/esm2015/qms-angular.js +6 -4
  24. package/fesm2015/qms-angular.js +475 -95
  25. package/fesm2015/qms-angular.js.map +1 -1
  26. package/lib/components/select-include-children/select-include-children.component.d.ts +2 -1
  27. package/lib/model/en.d.ts +17 -0
  28. package/lib/model/no.d.ts +17 -0
  29. package/lib/qms-ckeditor-components/common/classes/qmsUploadAdapter.d.ts +18 -0
  30. package/lib/qms-ckeditor-components/common/constants/ckeditorEvent.constant.d.ts +2 -0
  31. package/lib/qms-ckeditor-components/common/models/qms-ckeditor-data.model.d.ts +4 -0
  32. package/lib/qms-ckeditor-components/common/models/qms-ckeditor-video-tree.model.d.ts +5 -0
  33. package/lib/qms-ckeditor-components/common/models/wproofreader-config.model.d.ts +25 -0
  34. package/lib/qms-ckeditor-components/components/qms-ckeditor-about/qms-ckeditor-about.component.d.ts +15 -0
  35. package/lib/qms-ckeditor-components/components/qms-ckeditor-bpmn/qms-ckeditor-bpmn.component.d.ts +4 -1
  36. package/lib/qms-ckeditor-components/components/qms-ckeditor-imagemap/qms-ckeditor-imagemap.component.d.ts +2 -1
  37. package/lib/qms-ckeditor-components/qms-ckeditor.component.d.ts +15 -1
  38. package/lib/qms-ckeditor-components/services/qms-ckeditor-tree.service.d.ts +2 -0
  39. package/lib/qms-ckeditor-components/services/qms-ckeditor-upload.service.d.ts +5 -0
  40. package/lib.theme.scss +1 -0
  41. package/package.json +1 -1
  42. package/qms-angular.d.ts +5 -3
  43. package/qms-angular.metadata.json +1 -1
  44. package/src/assets/images/ckeditor5.svg +1 -0
  45. package/src/assets/qms-ckeditor-plugin/build/ckeditor.js +1 -1
  46. package/src/assets/qms-ckeditor-plugin/build/ckeditor.js.map +1 -1
  47. package/src/assets/qms-ckeditor-plugin/build/translations/az.js +1 -1
  48. package/src/assets/qms-ckeditor-plugin/build/translations/cs.js +1 -1
  49. package/src/assets/qms-ckeditor-plugin/build/translations/da.js +1 -1
  50. package/src/assets/qms-ckeditor-plugin/build/translations/de-ch.js +1 -1
  51. package/src/assets/qms-ckeditor-plugin/build/translations/de.js +1 -1
  52. package/src/assets/qms-ckeditor-plugin/build/translations/en-au.js +1 -1
  53. package/src/assets/qms-ckeditor-plugin/build/translations/es.js +1 -1
  54. package/src/assets/qms-ckeditor-plugin/build/translations/et.js +1 -1
  55. package/src/assets/qms-ckeditor-plugin/build/translations/fa.js +1 -1
  56. package/src/assets/qms-ckeditor-plugin/build/translations/fr.js +1 -1
  57. package/src/assets/qms-ckeditor-plugin/build/translations/gl.js +1 -1
  58. package/src/assets/qms-ckeditor-plugin/build/translations/he.js +1 -1
  59. package/src/assets/qms-ckeditor-plugin/build/translations/hi.js +1 -1
  60. package/src/assets/qms-ckeditor-plugin/build/translations/hr.js +1 -1
  61. package/src/assets/qms-ckeditor-plugin/build/translations/hu.js +1 -1
  62. package/src/assets/qms-ckeditor-plugin/build/translations/id.js +1 -1
  63. package/src/assets/qms-ckeditor-plugin/build/translations/it.js +1 -1
  64. package/src/assets/qms-ckeditor-plugin/build/translations/ja.js +1 -1
  65. package/src/assets/qms-ckeditor-plugin/build/translations/ko.js +1 -1
  66. package/src/assets/qms-ckeditor-plugin/build/translations/ku.js +1 -1
  67. package/src/assets/qms-ckeditor-plugin/build/translations/lv.js +1 -1
  68. package/src/assets/qms-ckeditor-plugin/build/translations/nl.js +1 -1
  69. package/src/assets/qms-ckeditor-plugin/build/translations/no.js +1 -1
  70. package/src/assets/qms-ckeditor-plugin/build/translations/pl.js +1 -1
  71. package/src/assets/qms-ckeditor-plugin/build/translations/pt-br.js +1 -1
  72. package/src/assets/qms-ckeditor-plugin/build/translations/ru.js +1 -1
  73. package/src/assets/qms-ckeditor-plugin/build/translations/sk.js +1 -1
  74. package/src/assets/qms-ckeditor-plugin/build/translations/sl.js +1 -1
  75. package/src/assets/qms-ckeditor-plugin/build/translations/sr-latn.js +1 -1
  76. package/src/assets/qms-ckeditor-plugin/build/translations/sr.js +1 -1
  77. package/src/assets/qms-ckeditor-plugin/build/translations/th.js +1 -1
  78. package/src/assets/qms-ckeditor-plugin/build/translations/tk.js +1 -1
  79. package/src/assets/qms-ckeditor-plugin/build/translations/tr.js +1 -1
  80. package/src/assets/qms-ckeditor-plugin/build/translations/uk.js +1 -1
  81. package/src/assets/qms-ckeditor-plugin/build/translations/vi.js +1 -1
  82. package/src/assets/qms-ckeditor-plugin/build/translations/zh-cn.js +1 -1
  83. package/src/assets/qms-ckeditor-plugin/build/translations/zh.js +1 -1
  84. package/src/assets/qms-ckeditor-plugin/package-lock.json +23 -0
  85. package/src/assets/qms-ckeditor-plugin/package.json +2 -0
  86. package/src/assets/qms-ckeditor-plugin/src/ckeditor.js +16 -4
  87. package/src/assets/qms-ckeditor-plugin/src/plugins/aboutckeditor/aboutckeditor.js +28 -0
  88. package/src/assets/qms-ckeditor-plugin/src/plugins/bpmn/bpmndialogcommand.js +74 -0
  89. package/src/assets/qms-ckeditor-plugin/src/plugins/bpmn/qmsCKEditorBpmnPlugin.js +5 -68
  90. package/src/assets/qms-ckeditor-plugin/src/plugins/common/qmsCKEditorConstant.js +4 -0
  91. package/src/assets/qms-ckeditor-plugin/src/plugins/common/qmsCKEditorService.js +21 -0
  92. package/src/assets/qms-ckeditor-plugin/src/plugins/imagemap/imagemapcommand.js +1 -0
  93. package/src/assets/qms-ckeditor-plugin/src/plugins/imagemap/utils.js +1 -1
  94. package/src/assets/qms-ckeditor-plugin/src/plugins/link/linkcommand.js +131 -176
  95. package/src/assets/qms-ckeditor-plugin/src/plugins/link/linkdialogcommand.js +88 -0
  96. package/src/assets/qms-ckeditor-plugin/src/plugins/link/linkediting.js +2 -0
  97. package/src/assets/qms-ckeditor-plugin/src/plugins/link/linkui.js +41 -32
  98. package/src/assets/qms-ckeditor-plugin/src/plugins/tableofcontents/tableofcontents.js +14 -0
  99. package/src/assets/qms-ckeditor-plugin/src/plugins/tableofcontents/tableofcontentscommand.js +87 -0
  100. package/src/assets/qms-ckeditor-plugin/src/plugins/tableofcontents/tableofcontentsediting.js +59 -0
  101. package/src/assets/qms-ckeditor-plugin/src/plugins/tableofcontents/tableofcontentsui.js +35 -0
  102. package/src/assets/qms-ckeditor-plugin/src/plugins/tableofcontents/utils.js +62 -0
  103. package/src/assets/qms-ckeditor-plugin/src/plugins/template/loadtemplatedialogcommand.js +14 -0
  104. package/src/assets/qms-ckeditor-plugin/src/plugins/template/qmsCKEditorLoadTemplatePlugin.js +10 -12
  105. package/src/assets/qms-ckeditor-plugin/src/plugins/template/qmsCKEdtiorTemplatePlugin.js +10 -7
  106. package/src/assets/qms-ckeditor-plugin/src/plugins/template/templatedialogcommand.js +9 -0
  107. package/src/assets/qms-ckeditor-plugin/src/plugins/timestamp/timestamp.js +15 -18
  108. package/src/assets/qms-ckeditor-plugin/src/plugins/timestamp/timestampcommand.js +17 -0
  109. package/src/assets/qms-ckeditor-plugin/src/plugins/tooltip/removetooltipcommand.js +42 -26
  110. package/src/assets/qms-ckeditor-plugin/src/plugins/tooltip/tooltip.js +3 -3
  111. package/src/assets/qms-ckeditor-plugin/src/plugins/tooltip/tooltipcommand.js +75 -0
  112. package/src/assets/qms-ckeditor-plugin/src/plugins/tooltip/tooltipdialogcommand.js +68 -0
  113. package/src/assets/qms-ckeditor-plugin/src/plugins/tooltip/tooltipediting.js +206 -131
  114. package/src/assets/qms-ckeditor-plugin/src/plugins/tooltip/tooltipui.js +424 -136
  115. package/src/assets/qms-ckeditor-plugin/src/plugins/tooltip/ui/actionsview.js +67 -12
  116. package/src/assets/qms-ckeditor-plugin/src/plugins/tooltip/utils.js +17 -55
  117. package/src/assets/qms-ckeditor-plugin/src/plugins/video/autovideo.js +1 -5
  118. package/src/assets/qms-ckeditor-plugin/src/plugins/video/video/videoediting.js +5 -2
  119. package/src/assets/qms-ckeditor-plugin/src/plugins/video/videoupload/browsevideodialogcommand.js +25 -0
  120. package/src/assets/qms-ckeditor-plugin/src/plugins/video/videoupload/uploadvideocommand.js +3 -16
  121. package/src/assets/qms-ckeditor-plugin/src/plugins/video/videoupload/videouploadediting.js +4 -0
  122. package/src/assets/qms-ckeditor-plugin/src/plugins/video/videoupload/videouploadui.js +12 -23
  123. package/src/assets/qms-ckeditor-plugin/src/themes/icons/information.svg +1 -50
  124. package/src/assets/qms-ckeditor-plugin/src/themes/icons/table-excel.svg +44 -0
  125. package/src/assets/qms-ckeditor-plugin/src/themes/icons/timestamp.svg +1 -1
  126. package/src/assets/qms-ckeditor-plugin/src/themes/icons/tooltip.svg +1 -0
  127. package/src/assets/qms-ckeditor-plugin/src/themes/styles/heading.css +54 -0
  128. package/src/assets/qms-ckeditor-plugin/src/themes/styles/tooltip.css +11 -53
  129. package/src/lib/qms-ckeditor-components/components/qms-ckeditor-about/qms-ckeditor-about.component.scss +16 -0
  130. package/src/lib/qms-ckeditor-components/components/qms-ckeditor-imagemap/qms-ckeditor-imagemap.component.scss +26 -23
  131. package/src/themes/core/_range-slider.scss +10 -12
  132. package/esm2015/lib/qms-ckeditor-components/common/classes/uploadAdapter.js +0 -26
  133. package/lib/qms-ckeditor-components/common/classes/uploadAdapter.d.ts +0 -5
  134. 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 * as QMSCKEditorConstant from '../common/qmsCKEditorConstant';
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
- const isBpmn = this.isBpmnImage(editor.editing.view.document.selection.getSelectedElement(), editor.plugins.get('Image'))
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
- const altAtr = element.getChild(0).getAttribute('alt')
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
+ }
@@ -90,3 +90,4 @@ export default class ImageMapCommand extends Command {
90
90
  },{ once: true });
91
91
  }
92
92
  }
93
+
@@ -219,7 +219,7 @@ export function drawMap(imageSrc, imageWidth, imageHeight, areas, callback){
219
219
  }, false);
220
220
  }
221
221
  catch(err){
222
-
222
+ console.log(err);
223
223
  }
224
224
  }
225
225
  }
@@ -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
- let link = QMSCKEditorEnum.hyperLink;
163
- link.typeId = 0;
164
- link.targetId = 0;
165
- link.protocolId = 0;
166
- link.url = '';
167
- link.title = '';
168
- link.editorContent = '';
169
- for (const item of ranges.getItems()) {
170
- if (item.data) {
171
- link.title = item.data;
172
- }
173
- }
174
- QMSCKEditorService.linkNotify(link);
175
- window[QMSCKEditorConstant.QMSCK_LINKED] = false;
176
- window.addEventListener(QMSCKEditorConstant.QMSCK_LINK_PLUGIN_RESP, function(evt) {
177
- if (window[QMSCKEditorConstant.QMSCK_LINKED]){
178
- return;
179
- }
180
- const response = evt.detail;
181
- const target = QMSCKEditorEnum.protocolEnum[response.protocolId];
182
- const url = response.url;
183
- const href = url.substring(2, url.length);
184
- const title = response.title ? response.title : url;
185
-
186
- for(let i= 0; i < linkDecorators.length-2; i++){
187
- manualDecoratorIds['link' + i] = (i === response.targetId)? true : false;
188
- }
189
- // Stores information about manual decorators to turn them on/off when command is applied.
190
- const truthyManualDecorators = [];
191
- const falsyManualDecorators = [];
192
-
193
- for ( const name in manualDecoratorIds ) {
194
- if ( manualDecoratorIds[ name ] ) {
195
- truthyManualDecorators.push( name );
196
- } else {
197
- falsyManualDecorators.push( name );
198
- }
199
- }
200
-
201
- model.change( writer => {
202
- // set link option value
203
- window[QMSCKEditorConstant.QMSCK_LINK_OPTION] = url.substring(0, 2);
204
- // If selection is collapsed then update selected link or insert new one at the place of caret.
205
- if ( selection.isCollapsed ) {
206
- const position = selection.getFirstPosition();
207
-
208
- // When selection is inside text with `linkHref` attribute.
209
- if ( selection.hasAttribute( 'linkHref' ) ) {
210
- // Then update `linkHref` value.
211
- const linkRange = findAttributeRange( position, 'linkHref', selection.getAttribute( 'linkHref' ), model );
212
- if (!selection.hasAttribute(selectedRange)) {
213
- writer.remove(linkRange);
214
- const newPosition = selection.getFirstPosition();
215
- const attributes = toMap( selection.getAttributes() );
216
- attributes.set( 'linkHref', href );
217
- truthyManualDecorators.forEach( item => {
218
- attributes.set( item, true );
219
- } );
220
- const { end: positionAfter } = model.insertContent( writer.createText( title, attributes ), newPosition );
221
- writer.setSelection( positionAfter );
222
- }
223
- else {
224
- writer.setAttribute( 'linkHref', href, linkRange );
225
- truthyManualDecorators.forEach( item => {
226
- writer.setAttribute( item, true, linkRange );
227
- } );
228
- falsyManualDecorators.forEach( item => {
229
- writer.removeAttribute( item, linkRange );
230
- } );
231
- // Put the selection at the end of the updated link.
232
- writer.setSelection( writer.createPositionAfter( linkRange.end.nodeBefore ) );
233
- }
234
- }
235
- // If not then insert text node with `linkHref` attribute in place of caret.
236
- // However, since selection is collapsed, attribute value will be used as data for text node.
237
- // So, if `href` is empty, do not create text node.
238
- else if ( href !== '' ) {
239
- const attributes = toMap( selection.getAttributes() );
240
-
241
- attributes.set( 'linkHref', href );
242
-
243
- truthyManualDecorators.forEach( item => {
244
- attributes.set( item, true );
245
- } );
246
-
247
- const { end: positionAfter } = model.insertContent( writer.createText( title, attributes ), position );
248
-
249
- // Put the selection at the end of the inserted link.
250
- // Using end of range returned from insertContent in case nodes with the same attributes got merged.
251
- writer.setSelection( positionAfter );
252
- }
253
-
254
- // Remove the `linkHref` attribute and all link decorators from the selection.
255
- // It stops adding a new content into the link element.
256
- [ 'linkHref', ...truthyManualDecorators, ...falsyManualDecorators ].forEach( item => {
257
- writer.removeSelectionAttribute( item );
258
- } );
259
- } else {
260
- // If selection has non-collapsed ranges, we change attribute on nodes inside those ranges
261
- // omitting nodes where the `linkHref` attribute is disallowed.
262
- const ranges = model.schema.getValidRanges( selection.getRanges(), 'linkHref' );
263
-
264
- // But for the first, check whether the `linkHref` attribute is allowed on selected blocks (e.g. the "image" element).
265
- const allowedRanges = [];
266
-
267
- for ( const element of selection.getSelectedBlocks() ) {
268
- if ( model.schema.checkAttribute( element, 'linkHref' ) ) {
269
- allowedRanges.push( writer.createRangeOn( element ) );
270
- }
271
- }
272
-
273
- // Ranges that accept the `linkHref` attribute. Since we will iterate over `allowedRanges`, let's clone it.
274
- const rangesToUpdate = allowedRanges.slice();
275
-
276
- // eslint-disable-next-line max-len
277
- // For all selection ranges we want to check whether given range is inside an element that accepts the `linkHref` attribute.
278
- // If so, we don't want to propagate applying the attribute to its children.
279
- // for ( const range of ranges ) {
280
- // if ( this._isRangeToUpdate( range, allowedRanges ) ) {
281
- // rangesToUpdate.push( range );
282
- // }
283
- // }
284
-
285
- for ( const range of ranges ) {
286
- const _isRangeToUpdate = true;
287
- for ( const allowedRange of allowedRanges ) {
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' ) ) );