qms-angular 1.1.26 → 1.1.28

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 (128) hide show
  1. package/bundles/qms-angular.umd.js +645 -544
  2. package/bundles/qms-angular.umd.js.map +1 -1
  3. package/esm2015/lib/common/models/qms-flat-node.model.js +1 -1
  4. package/esm2015/lib/common/models/qms-tree-node.model.js +1 -1
  5. package/esm2015/lib/common/themes.const.js +2 -1
  6. package/esm2015/lib/components/breadcrumb/breadcrumb-item.directive.js +3 -3
  7. package/esm2015/lib/components/breadcrumb/breadcrumb.js +10 -4
  8. package/esm2015/lib/components/comment/comment.js +17 -11
  9. package/esm2015/lib/components/edit-file-name-dialog/edit-file-name-dialog.js +9 -2
  10. package/esm2015/lib/components/qms-nav-drawer/qms-nav-drawer.component.js +3 -3
  11. package/esm2015/lib/components/qms-navigation-drawer/qms-navigation-drawer.component.js +3 -3
  12. package/esm2015/lib/components/qms-paginator/qms-paginator.component.js +9 -2
  13. package/esm2015/lib/components/related/list-other-related/list-related.component.js +9 -2
  14. package/esm2015/lib/components/related/model/popup-data.model.js +2 -1
  15. package/esm2015/lib/components/related/popup/related-popup.component.js +58 -24
  16. package/esm2015/lib/components/related/risk/analysis/analysis.component.js +9 -2
  17. package/esm2015/lib/components/related/risk/list/list.component.js +9 -2
  18. package/esm2015/lib/components/related/risk/result/result.component.js +9 -2
  19. package/esm2015/lib/components/reports/qms-report-content-portrait/qms-report-content-portrait.component.js +9 -2
  20. package/esm2015/lib/components/reports/qms-report-cover-portrait/qms-report-cover-portrait.component.js +8 -3
  21. package/esm2015/lib/components/select-access-dialog/select-access-dialog.component.js +2 -2
  22. package/esm2015/lib/components/select-department/select-department.component.js +6 -38
  23. package/esm2015/lib/components/select-department-tree/model/department-paging.model.js +1 -2
  24. package/esm2015/lib/components/select-department-tree/model/select-department-tree.config.js +2 -5
  25. package/esm2015/lib/components/select-department-tree/select-department-tree.component.js +114 -164
  26. package/esm2015/lib/components/select-department-tree/select-department-tree.module.js +2 -4
  27. package/esm2015/lib/components/select-dialog/select-dialog.js +8 -4
  28. package/esm2015/lib/components/select-include-children/select-include-children.component.js +3 -3
  29. package/esm2015/lib/components/select-one/select-one-next.component.js +3 -3
  30. package/esm2015/lib/components/select-one/select-one.component.js +3 -3
  31. package/esm2015/lib/components/select-process-document/select-process-document.component.js +3 -3
  32. package/esm2015/lib/components/tree/basic-tree.component.js +4 -4
  33. package/esm2015/lib/components/upload-file-error-dialog/upload-file-error-dialog.js +9 -2
  34. package/esm2015/lib/directives/chip-input/chip-input-select-trigger.directive.js +3 -3
  35. package/esm2015/lib/directives/chips/chip.directive.js +2 -2
  36. package/esm2015/lib/directives/dropdown-menu/dropdown-item.directive.js +2 -2
  37. package/esm2015/lib/directives/file-upload/file-upload-display.directive.js +3 -3
  38. package/esm2015/lib/directives/file-upload/file-upload-multiple-display.directive.js +3 -3
  39. package/esm2015/lib/directives/file-upload/file-upload-multiple.directive.js +3 -3
  40. package/esm2015/lib/directives/file-upload/file-upload.directive.js +2 -2
  41. package/esm2015/lib/directives/search-field.directive.js +2 -2
  42. package/esm2015/lib/model/en.js +4 -2
  43. package/esm2015/lib/model/no.js +4 -2
  44. package/esm2015/lib/pipe/dateFormat.pipe.js +9 -2
  45. package/esm2015/lib/qms-angular.component.js +9 -2
  46. package/esm2015/lib/qms-ckeditor-components/common/bpmn/toolbar.function.js +10 -1
  47. package/esm2015/lib/qms-ckeditor-components/common/classes/qmsUploadAdapter.js +21 -15
  48. package/esm2015/lib/qms-ckeditor-components/common/constants/ckeditorImageUploadType.const.js +4 -0
  49. package/esm2015/lib/qms-ckeditor-components/common/enums/ckeditor-bpmn-expand.enum.js +8 -0
  50. package/esm2015/lib/qms-ckeditor-components/common/functions/common.function.js +6 -9
  51. package/esm2015/lib/qms-ckeditor-components/common/models/qms-ckeditor-data.model.js +1 -1
  52. package/esm2015/lib/qms-ckeditor-components/components/qms-ckeditor-bpmn/qms-ckeditor-bpmn.component.js +39 -11
  53. package/esm2015/lib/qms-ckeditor-components/components/qms-ckeditor-imagemap/qms-ckeditor-imagemap.component.js +2 -2
  54. package/esm2015/lib/qms-ckeditor-components/components/qms-ckeditor-link/qms-ckeditor-link.component.js +53 -56
  55. package/esm2015/lib/qms-ckeditor-components/components/qms-ckeditor-load-template/qms-ckeditor-load-template.component.js +9 -4
  56. package/esm2015/lib/qms-ckeditor-components/qms-ckeditor.component.js +28 -11
  57. package/esm2015/lib/qms-ckeditor-components/services/qms-ckeditor-bpmn.service.js +33 -2
  58. package/esm2015/lib/qms-ckeditor-components/services/qms-ckeditor-upload.service.js +6 -2
  59. package/esm2015/qms-angular.js +11 -11
  60. package/fesm2015/qms-angular.js +589 -468
  61. package/fesm2015/qms-angular.js.map +1 -1
  62. package/lib/common/models/qms-flat-node.model.d.ts +0 -1
  63. package/lib/common/models/qms-tree-node.model.d.ts +0 -1
  64. package/lib/common/themes.const.d.ts +1 -0
  65. package/lib/components/breadcrumb/breadcrumb-item.directive.d.ts +2 -2
  66. package/lib/components/breadcrumb/breadcrumb.d.ts +3 -0
  67. package/lib/components/comment/comment.d.ts +3 -0
  68. package/lib/components/edit-file-name-dialog/edit-file-name-dialog.d.ts +3 -0
  69. package/lib/components/qms-paginator/qms-paginator.component.d.ts +3 -0
  70. package/lib/components/related/list-other-related/list-related.component.d.ts +3 -0
  71. package/lib/components/related/model/popup-data.model.d.ts +2 -0
  72. package/lib/components/related/popup/related-popup.component.d.ts +13 -2
  73. package/lib/components/related/risk/analysis/analysis.component.d.ts +3 -0
  74. package/lib/components/related/risk/list/list.component.d.ts +3 -0
  75. package/lib/components/related/risk/result/result.component.d.ts +3 -0
  76. package/lib/components/reports/qms-report-content-portrait/qms-report-content-portrait.component.d.ts +3 -0
  77. package/lib/components/reports/qms-report-cover-portrait/qms-report-cover-portrait.component.d.ts +5 -3
  78. package/lib/components/select-department/select-department.component.d.ts +0 -19
  79. package/lib/components/select-department-tree/model/select-department-tree.config.d.ts +0 -3
  80. package/lib/components/select-department-tree/select-department-tree.component.d.ts +23 -51
  81. package/lib/components/select-dialog/select-dialog.d.ts +2 -1
  82. package/lib/components/upload-file-error-dialog/upload-file-error-dialog.d.ts +3 -0
  83. package/lib/directives/chip-input/chip-input-select-trigger.directive.d.ts +1 -1
  84. package/lib/directives/file-upload/file-upload-display.directive.d.ts +1 -1
  85. package/lib/directives/file-upload/file-upload-multiple-display.directive.d.ts +1 -1
  86. package/lib/directives/file-upload/file-upload-multiple.directive.d.ts +2 -2
  87. package/lib/model/en.d.ts +2 -0
  88. package/lib/model/no.d.ts +2 -0
  89. package/lib/pipe/dateFormat.pipe.d.ts +3 -0
  90. package/lib/qms-angular.component.d.ts +3 -0
  91. package/lib/qms-ckeditor-components/common/classes/qmsUploadAdapter.d.ts +1 -1
  92. package/lib/qms-ckeditor-components/common/constants/ckeditorImageUploadType.const.d.ts +3 -0
  93. package/lib/qms-ckeditor-components/common/enums/ckeditor-bpmn-expand.enum.d.ts +6 -0
  94. package/lib/qms-ckeditor-components/common/functions/common.function.d.ts +2 -4
  95. package/lib/qms-ckeditor-components/common/models/qms-ckeditor-data.model.d.ts +1 -0
  96. package/lib/qms-ckeditor-components/components/qms-ckeditor-bpmn/qms-ckeditor-bpmn.component.d.ts +4 -2
  97. package/lib/qms-ckeditor-components/components/qms-ckeditor-link/qms-ckeditor-link.component.d.ts +3 -1
  98. package/lib/qms-ckeditor-components/components/qms-ckeditor-load-template/qms-ckeditor-load-template.component.d.ts +1 -0
  99. package/lib/qms-ckeditor-components/qms-ckeditor.component.d.ts +1 -0
  100. package/lib/qms-ckeditor-components/services/qms-ckeditor-bpmn.service.d.ts +2 -0
  101. package/lib/qms-ckeditor-components/services/qms-ckeditor-upload.service.d.ts +1 -1
  102. package/package.json +1 -1
  103. package/qms-angular.d.ts +10 -10
  104. package/qms-angular.metadata.json +1 -1
  105. package/src/assets/jointjs/scss/bpmn.scss +22 -1
  106. package/src/assets/qms-ckeditor-plugin/build/ckeditor.js +1 -1
  107. package/src/assets/qms-ckeditor-plugin/build/ckeditor.js.map +1 -1
  108. package/src/assets/qms-ckeditor-plugin/src/plugins/anchor/anchorcommand.js +13 -3
  109. package/src/assets/qms-ckeditor-plugin/src/plugins/anchor/anchorui.js +7 -1
  110. package/src/assets/qms-ckeditor-plugin/src/plugins/bpmn/bpmndialogcommand.js +12 -3
  111. package/src/assets/qms-ckeditor-plugin/src/plugins/link/linkcommand.js +35 -33
  112. package/src/assets/qms-ckeditor-plugin/src/plugins/link/linkdialogcommand.js +9 -6
  113. package/src/assets/qms-ckeditor-plugin/src/plugins/link/linkediting.js +28 -14
  114. package/src/assets/qms-ckeditor-plugin/src/plugins/link/linkimageediting.js +1 -1
  115. package/src/assets/qms-ckeditor-plugin/src/plugins/link/linkimageui.js +97 -92
  116. package/src/assets/qms-ckeditor-plugin/src/plugins/link/linkui.js +40 -28
  117. package/src/assets/qms-ckeditor-plugin/src/plugins/link/ui/linkformview.js +24 -24
  118. package/src/assets/qms-ckeditor-plugin/src/plugins/link/utils.js +8 -1
  119. package/src/assets/qms-ckeditor-plugin/src/plugins/table/converters/downcast.js +2 -2
  120. package/src/assets/qms-ckeditor-plugin/src/plugins/template/loadtemplatedialogcommand.js +20 -1
  121. package/src/assets/qms-ckeditor-plugin/src/plugins/video/theme/video.css +1 -1
  122. package/src/assets/qms-ckeditor-plugin/src/plugins/video/video/videoediting.js +3 -2
  123. package/src/assets/qms-ckeditor-plugin/src/plugins/video/videoupload/uploadvideocommand.js +1 -1
  124. package/src/lib/components/related/popup/related-popup.component.scss +19 -0
  125. package/src/lib/components/select-department/select-department.component.scss +5 -25
  126. package/src/lib/components/select-department-tree/select-department-tree.component.scss +182 -381
  127. package/src/lib/qms-ckeditor-components/components/qms-ckeditor-load-template/qms-ckeditor-load-template.component.scss +4 -0
  128. package/src/lib/qms-ckeditor-components/qms-ckeditor.component.scss +4 -0
@@ -145,8 +145,10 @@ export default class AnchorCommand extends Command {
145
145
  * @fires execute
146
146
  * @param {String} id Anchor destination.
147
147
  * @param {Object} [manualDecoratorIds={}] The information about manual decorator attributes to be applied or removed upon execution.
148
+ * @param {boolean} isEmptyAnchorContent Check anchor content is empty or not empty.
149
+
148
150
  */
149
- execute( id, manualDecoratorIds = {} ) {
151
+ execute( id, manualDecoratorIds = {}, isEmptyAnchorContent) {
150
152
  const model = this.editor.model;
151
153
  const selection = model.document.selection;
152
154
  // Stores information about manual decorators to turn them on/off when command is applied.
@@ -189,14 +191,22 @@ export default class AnchorCommand extends Command {
189
191
  // So, if `id` is empty, do not create text node.
190
192
  else if ( id !== '' ) {
191
193
  const attributes = toMap( selection.getAttributes() );
192
-
193
194
  attributes.set( 'anchorId', id );
194
195
 
195
196
  truthyManualDecorators.forEach( item => {
196
197
  attributes.set( item, true );
197
198
  } );
198
199
 
199
- const { end: positionAfter } = model.insertContent( writer.createText( id, attributes ), position );
200
+ var newAnchorContent = null;
201
+ if(isEmptyAnchorContent) {
202
+ // When anchor content is empty, set anchor content equal  
203
+ newAnchorContent = writer.createText( " ", attributes );
204
+ } else {
205
+ // When anchor content is not empty, set anchor content equal  
206
+ newAnchorContent = writer.createText( id, attributes );
207
+ }
208
+
209
+ const { end: positionAfter } = model.insertContent( newAnchorContent, position );
200
210
 
201
211
  // Put the selection at the end of the inserted anchor.
202
212
  // Using end of range returned from insertContent in case nodes with the same attributes got merged.
@@ -175,7 +175,13 @@ export default class AnchorUI extends Plugin {
175
175
  this.listenTo( formView, 'submit', () => {
176
176
  const { value } = formView.urlInputView.fieldView.element;
177
177
  const parsedUrl = addAnchorProtocolIfApplicable( value, defaultProtocol );
178
- editor.execute( 'anchor', parsedUrl, formView.getDecoratorSwitchesState() );
178
+ if(editor.model.document.selection.anchor.nodeAfter) {
179
+ // Case anchor content is not empty
180
+ editor.execute( 'anchor', parsedUrl, formView.getDecoratorSwitchesState() , false);
181
+ } else {
182
+ // Case anchor content is empty
183
+ editor.execute( 'anchor', parsedUrl, formView.getDecoratorSwitchesState() , true);
184
+ }
179
185
  this._closeFormView();
180
186
  } );
181
187
 
@@ -26,10 +26,19 @@ export default class BpmnDialogCommand extends Command {
26
26
  window[QMSCKEditorConstant.QMSCK_BPMN_IS_PROCESSING] = true;
27
27
  editor.model.change( writer => {
28
28
  const options = evt.detail.imagemap || {};
29
- const imageElement = writer.createElement( 'image', {
30
- src: evt.detail.values,
31
- alt: evt.detail.key
29
+ let imageElement = null;
30
+ if(options.imageWidth > 600) {
31
+ imageElement = writer.createElement( 'image', {
32
+ src: evt.detail.values,
33
+ alt: evt.detail.key
32
34
  });
35
+ } else {
36
+ imageElement = writer.createElement( 'image', {
37
+ src: evt.detail.values,
38
+ alt: evt.detail.key,
39
+ width: options.imageWidth.toString() + "px"
40
+ });
41
+ }
33
42
  // Insert the image in the current selection location.
34
43
  editor.model.insertContent( imageElement, editor.model.document.selection );
35
44
  if(!!options.areas && options.areas.length > 0){
@@ -149,18 +149,19 @@ export default class LinkCommand extends Command {
149
149
  * @param {Object} [manualDecoratorIds={}] The information about manual decorator attributes to be applied or removed upon execution.
150
150
  */
151
151
  execute(options) {
152
- const model = this.editor.model;
153
- const selection = model.document.selection;
154
- const manualDecoratorIds = {};
155
- const linkDecorators = this.editor.config.get( 'link.decorators' );
156
- const selectedRange = 'link'+ linkDecorators.length;
152
+ const model = this.editor.model;
153
+ const selection = model.document.selection;
154
+ const manualDecoratorIds = {};
155
+ const linkDecorators = this.editor.config.get( 'link.decorators' );
156
+ const selectedRange = 'link'+ linkDecorators.length;
157
157
 
158
- const url = options.url;
158
+ const url = options ? options.url : '';
159
159
  const href = url.substring(2, url.length);
160
+ const linkOption = url.substring(0, 2);
160
161
  const title = options.title ? options.title : url;
161
162
 
162
- for(let i= 0; i < linkDecorators.length-2; i++){
163
- manualDecoratorIds['link' + i] = (i === options.targetId)? true : false;
163
+ for(let i = 0; i < linkDecorators.length-1; i++){
164
+ manualDecoratorIds['link' + i] = (i === options.targetId);
164
165
  }
165
166
  // Stores information about manual decorators to turn them on/off when command is applied.
166
167
  const truthyManualDecorators = [];
@@ -185,28 +186,28 @@ export default class LinkCommand extends Command {
185
186
  if ( selection.hasAttribute( 'linkHref' ) ) {
186
187
  // Then update `linkHref` value.
187
188
  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
- }
189
+
190
+ const attributes = toMap( selection.getAttributes() );
191
+
192
+ writer.remove(linkRange);
193
+ const newPosition = linkRange.start;
194
+
195
+ attributes.set('linkHref', href );
196
+ attributes.set('linkOption', linkOption);
197
+
198
+ // set decorators to determine the target of this link
199
+ truthyManualDecorators.forEach( item => {
200
+ attributes.set( item, true );
201
+ } );
202
+
203
+ const createdRange = model.insertContent( writer.createText( title, attributes ), newPosition );
204
+
205
+ // remove old decorators
206
+ falsyManualDecorators.forEach( item => {
207
+ writer.removeAttribute( item, createdRange );
208
+ } );
209
+
210
+ writer.setSelection( createdRange.end );
210
211
  }
211
212
  // If not then insert text node with `linkHref` attribute in place of caret.
212
213
  // However, since selection is collapsed, attribute value will be used as data for text node.
@@ -214,7 +215,8 @@ export default class LinkCommand extends Command {
214
215
  else if ( href !== '' ) {
215
216
  const attributes = toMap( selection.getAttributes() );
216
217
 
217
- attributes.set( 'linkHref', href );
218
+ attributes.set('linkHref', href );
219
+ attributes.set('linkOption', linkOption);
218
220
 
219
221
  truthyManualDecorators.forEach( item => {
220
222
  attributes.set( item, true );
@@ -229,7 +231,7 @@ export default class LinkCommand extends Command {
229
231
 
230
232
  // Remove the `linkHref` attribute and all link decorators from the selection.
231
233
  // It stops adding a new content into the link element.
232
- [ 'linkHref', ...truthyManualDecorators, ...falsyManualDecorators ].forEach( item => {
234
+ [ 'linkHref', 'linkOption', ...truthyManualDecorators, ...falsyManualDecorators ].forEach( item => {
233
235
  writer.removeSelectionAttribute( item );
234
236
  } );
235
237
  } else {
@@ -273,7 +275,7 @@ export default class LinkCommand extends Command {
273
275
 
274
276
  for ( const range of rangesToUpdate ) {
275
277
  writer.setAttribute('linkHref', href, range);
276
- writer.setAttribute(selectedRange, true, range);
278
+ writer.setAttribute('linkOption', linkOption, range);
277
279
 
278
280
  truthyManualDecorators.forEach( item => {
279
281
  writer.setAttribute( item, true, range );
@@ -62,12 +62,15 @@ import AutomaticDecorators from './utils/automaticdecorators';
62
62
  QMSCKEditorService.linkNotify(link);
63
63
  window[QMSCKEditorConstant.QMSCK_LINKED] = false;
64
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);
65
+ if (window[QMSCKEditorConstant.QMSCK_LINKED]){
66
+ return;
67
+ }
68
+ window[QMSCKEditorConstant.QMSCK_LINKED] = true;
69
+ const options = evt.detail;
70
+ // Return options = null when user cancel link dialog instead of not returning anything to avoid redundant event listener
71
+ if (options) {
72
+ editor.commands.get('link').execute(options);
73
+ }
71
74
  }, { once: true });
72
75
  }
73
76
 
@@ -16,7 +16,7 @@ import { keyCodes } from '@ckeditor/ckeditor5-utils';
16
16
  import LinkCommand from './linkcommand';
17
17
  import UnlinkCommand from './unlinkcommand';
18
18
  import ManualDecorator from './utils/manualdecorator';
19
- import { createLinkElement, ensureSafeUrl, getLocalizedDecorators, normalizeDecorators } from './utils';
19
+ import { createLinkElement, ensureSafeUrl, getLocalizedDecorators, normalizeDecorators, createLinkOptionElement } from './utils';
20
20
  import * as QMSCKEditorConstant from '../common/qmsCKEditorConstant';
21
21
  import '../../themes/styles/link.css';
22
22
  import { isLinkElement } from './utils';
@@ -69,7 +69,8 @@ export default class LinkEditing extends Plugin {
69
69
  const editor = this.editor;
70
70
 
71
71
  // Allow link attribute on all inline nodes.
72
- editor.model.schema.extend( '$text', { allowAttributes: 'linkHref' } );
72
+ editor.model.schema.extend( '$text', { allowAttributes: ['linkHref', 'linkOption'] } );
73
+
73
74
 
74
75
  editor.conversion.for( 'dataDowncast' )
75
76
  .attributeToElement( { model: 'linkHref', view: createLinkElement } );
@@ -93,6 +94,28 @@ export default class LinkEditing extends Plugin {
93
94
  }
94
95
  } );
95
96
 
97
+ editor.conversion.for( 'dataDowncast' )
98
+ .attributeToElement( { model: 'linkOption', view: createLinkOptionElement } );
99
+
100
+ editor.conversion.for( 'editingDowncast' )
101
+ .attributeToElement( { model: 'linkOption', view: ( href, conversionApi ) => {
102
+ return createLinkOptionElement(href, conversionApi );
103
+ } } );
104
+
105
+ editor.conversion.for( 'upcast' )
106
+ .elementToAttribute( {
107
+ view: {
108
+ name: 'a',
109
+ attributes: {
110
+ option: true
111
+ }
112
+ },
113
+ model: {
114
+ key: 'linkOption',
115
+ value: viewElement => viewElement.getAttribute( 'option' )
116
+ }
117
+ });
118
+
96
119
  // Create linking commands.
97
120
  editor.commands.add( 'link', new LinkCommand( editor ) );
98
121
  editor.commands.add( 'linkdialog', new LinkDialogCommand( editor ) );
@@ -192,25 +215,15 @@ export default class LinkEditing extends Plugin {
192
215
  editor.conversion.for( 'downcast' ).attributeToElement( {
193
216
  model: decorator.id,
194
217
  view: ( manualDecoratorName, { writer } ) => {
195
- if ( manualDecoratorName) {
218
+ if ( manualDecoratorName ) {
196
219
  const attributes = manualDecorators.get( decorator.id ).attributes;
197
- let linkOption = window[QMSCKEditorConstant.QMSCK_LINK_OPTION]? window[QMSCKEditorConstant.QMSCK_LINK_OPTION] : '00';
198
- let parentLink = this._getSelectedLinkElement();
199
- if (parentLink && window[QMSCKEditorConstant.QMSCK_LINKED]) {
200
- try {
201
- linkOption = parentLink.parent.getChild(0).getAttribute('url');
202
- } catch{
203
- linkOption = parentLink.parent.getChild(1).getAttribute('url');
204
- }
205
- }
206
- attributes.url = linkOption;
207
220
  const element = writer.createAttributeElement( 'a', attributes, { priority: 5 } );
208
221
  writer.setCustomProperty( 'link', true, element );
209
222
 
210
223
  return element;
211
224
  }
212
225
  } } );
213
-
226
+
214
227
  editor.conversion.for( 'upcast' ).elementToAttribute( {
215
228
  view: {
216
229
  name: 'a',
@@ -555,6 +568,7 @@ export default class LinkEditing extends Plugin {
555
568
  // @param {module:utils/collection~Collection} manualDecorators
556
569
  function removeLinkAttributesFromSelection( writer, manualDecorators ) {
557
570
  writer.removeSelectionAttribute( 'linkHref' );
571
+ writer.removeSelectionAttribute( 'linkOption' );
558
572
 
559
573
  for ( const decorator of manualDecorators ) {
560
574
  writer.removeSelectionAttribute( decorator.id );
@@ -185,7 +185,7 @@ function downcastImageLink( options ) {
185
185
  } else {
186
186
  // But if it does not exist. Let's wrap already converted image by newly created link element.
187
187
  // 1. Create an empty link element.
188
- const linkElement = writer.createContainerElement( 'a', { href: data.attributeNewValue } );
188
+ const linkElement = writer.createContainerElement( 'a', { href: data.attributeNewValue, target: '_blank' } );
189
189
 
190
190
  // 2. Insert link inside the associated image.
191
191
  writer.insert( writer.createPositionAt( viewFigure, 0 ), linkElement );
@@ -7,17 +7,17 @@
7
7
  * @module link/linkimageui
8
8
  */
9
9
 
10
- import { ButtonView } from '@ckeditor/ckeditor5-ui';
11
- import { Plugin } from '@ckeditor/ckeditor5-core';
10
+ import { ButtonView } from "@ckeditor/ckeditor5-ui";
11
+ import { Plugin } from "@ckeditor/ckeditor5-core";
12
12
 
13
- import LinkUI from './linkui';
14
- import LinkEditing from './linkediting';
13
+ import LinkUI from "./linkui";
14
+ import LinkEditing from "./linkediting";
15
15
 
16
- import { LINK_KEYSTROKE } from './utils';
16
+ import { LINK_KEYSTROKE } from "./utils";
17
17
 
18
- import linkIcon from '../../themes/icons/link.svg';
19
- import * as QMSCKEditorEnum from '../common/qmsCKEditorEnum';
20
- import * as QMSCKEditorService from '../common/qmsCKEditorService';
18
+ import linkIcon from "../../themes/icons/link.svg";
19
+ import * as QMSCKEditorEnum from "../common/qmsCKEditorEnum";
20
+ import * as QMSCKEditorService from "../common/qmsCKEditorService";
21
21
 
22
22
  /**
23
23
  * The link image UI plugin.
@@ -28,96 +28,101 @@ import * as QMSCKEditorService from '../common/qmsCKEditorService';
28
28
  * @extends module:core/plugin~Plugin
29
29
  */
30
30
  export default class LinkImageUI extends Plugin {
31
- /**
32
- * @inheritDoc
33
- */
34
- static get requires() {
35
- return [ LinkEditing, LinkUI, 'Image' ];
36
- }
37
-
38
- /**
39
- * @inheritDoc
40
- */
41
- static get pluginName() {
42
- return 'LinkImageUI';
43
- }
44
-
45
- /**
46
- * @inheritDoc
47
- */
48
- init() {
49
- const editor = this.editor;
50
- const viewDocument = editor.editing.view.document;
51
-
52
- this.listenTo( viewDocument, 'click', ( evt, data ) => {
53
- const hasLink = isImageLinked( viewDocument.selection.getSelectedElement(), editor.plugins.get( 'Image' ) );
54
-
55
- if ( hasLink ) {
56
- data.preventDefault();
57
- }
58
- } );
59
-
60
- this._createToolbarLinkImageButton();
61
- }
62
-
63
- /**
64
- * Creates a `LinkImageUI` button view.
65
- *
66
- * Clicking this button shows a {@link module:link/linkui~LinkUI#_balloon} attached to the selection.
67
- * When an image is already linked, the view shows {@link module:link/linkui~LinkUI#actionsView} or
68
- * {@link module:link/linkui~LinkUI#formView} if it is not.
69
- *
70
- * @private
71
- */
72
- _createToolbarLinkImageButton() {
73
- const editor = this.editor;
74
- const t = editor.t;
75
-
76
- editor.ui.componentFactory.add( 'linkImage', locale => {
77
- const button = new ButtonView( locale );
78
- const plugin = editor.plugins.get( 'LinkUI' );
79
- const linkCommand = editor.commands.get( 'link' );
80
-
81
- button.set( {
82
- isEnabled: true,
83
- label: t( 'Link image' ),
84
- icon: linkIcon,
85
- keystroke: LINK_KEYSTROKE,
86
- tooltip: true,
87
- isToggleable: true
88
- } );
89
-
90
- // Bind button to the command.
91
- button.bind( 'isEnabled' ).to( linkCommand, 'isEnabled' );
92
- button.bind( 'isOn' ).to( linkCommand, 'value', value => !!value );
93
-
94
- // Show the actionsView or formView (both from LinkUI) on button click depending on whether the image is linked already.
95
- this.listenTo( button, 'execute', () => {
96
- const hasLink = isImageLinked( editor.editing.view.document.selection.getSelectedElement(), editor.plugins.get( 'Image' ) );
97
-
98
- if ( hasLink ) {
99
- plugin._addActionsView();
100
- } else {
101
- // plugin._showUI( true );
102
- this.editor.execute('link');
103
- }
104
- } );
105
-
106
- return button;
107
- } );
108
- }
31
+ /**
32
+ * @inheritDoc
33
+ */
34
+ static get requires() {
35
+ return [LinkEditing, LinkUI, "Image"];
36
+ }
37
+
38
+ /**
39
+ * @inheritDoc
40
+ */
41
+ static get pluginName() {
42
+ return "LinkImageUI";
43
+ }
44
+
45
+ /**
46
+ * @inheritDoc
47
+ */
48
+ init() {
49
+ const editor = this.editor;
50
+ const viewDocument = editor.editing.view.document;
51
+ this.listenTo(viewDocument, "click", (evt, data) => {
52
+ const hasLink = isImageLinked(
53
+ viewDocument.selection.getSelectedElement(),
54
+ editor.plugins.get("Image")
55
+ );
56
+
57
+ if (hasLink) {
58
+ data.preventDefault();
59
+ }
60
+ });
61
+ this._createToolbarLinkImageButton();
62
+ }
63
+
64
+ /**
65
+ * Creates a `LinkImageUI` button view.
66
+ *
67
+ * Clicking this button shows a {@link module:link/linkui~LinkUI#_balloon} attached to the selection.
68
+ * When an image is already linked, the view shows {@link module:link/linkui~LinkUI#actionsView} or
69
+ * {@link module:link/linkui~LinkUI#formView} if it is not.
70
+ *
71
+ * @private
72
+ */
73
+ _createToolbarLinkImageButton() {
74
+ const editor = this.editor;
75
+ const t = editor.t;
76
+ editor.ui.componentFactory.add("linkImage", (locale) => {
77
+ const button = new ButtonView(locale);
78
+ const plugin = editor.plugins.get("LinkUI");
79
+ const linkCommand = editor.commands.get("link");
80
+
81
+ button.set({
82
+ isEnabled: true,
83
+ label: t("Link image"),
84
+ icon: linkIcon,
85
+ keystroke: LINK_KEYSTROKE,
86
+ tooltip: true,
87
+ isToggleable: true,
88
+ });
89
+
90
+ // Bind button to the command.
91
+ button.bind("isEnabled").to(linkCommand, "isEnabled");
92
+ button.bind("isOn").to(linkCommand, "value", (value) => !!value);
93
+
94
+ // Show the actionsView or formView (both from LinkUI) on button click depending on whether the image is linked already.
95
+ this.listenTo(button, "execute", () => {
96
+ const hasLink = isImageLinked(
97
+ editor.editing.view.document.selection.getSelectedElement(),
98
+ editor.plugins.get("Image")
99
+ );
100
+
101
+ if (hasLink) {
102
+ //plugin._showUI( true );
103
+ plugin._addActionsView();
104
+ } else {
105
+ plugin._showUI(true);
106
+ //this.editor.execute('link');
107
+ // plugin._addActionsView();
108
+ }
109
+ });
110
+
111
+ return button;
112
+ });
113
+ }
109
114
  }
110
115
 
111
116
  // A helper function that checks whether the element is a linked image.
112
117
  //
113
118
  // @param {module:engine/model/element~Element} element
114
119
  // @returns {Boolean}
115
- function isImageLinked( element, image ) {
116
- const isImage = element && image.isImageWidget( element );
120
+ function isImageLinked(element, image) {
121
+ const isImage = element && image.isImageWidget(element);
117
122
 
118
- if ( !isImage ) {
119
- return false;
120
- }
123
+ if (!isImage) {
124
+ return false;
125
+ }
121
126
 
122
- return element.getChild( 0 ).is( 'element', 'a' );
127
+ return element.getChild(0).is("element", "a");
123
128
  }
@@ -129,41 +129,47 @@ export default class LinkUI extends Plugin {
129
129
 
130
130
  // Execute unlink command after clicking on the "Edit" button.
131
131
  this.listenTo( actionsView, 'edit', () => {
132
- //this._addFormView();
132
+ //this._addFormView();
133
+ const hasLink = this.isImageLinked( editor.editing.view.document.selection.getSelectedElement(), editor.plugins.get('Image') );
134
+
133
135
  let link = QMSCKEditorEnum.hyperLink;
134
136
  const href = this.actionsView.href;
135
- const hasLink = this.isImageLinked( editor.editing.view.document.selection.getSelectedElement(), editor.plugins.get('Image') );
137
+
136
138
  let parentLink;
137
139
  if (hasLink) {
138
- parentLink = editor.editing.view.document.selection.getSelectedElement().getChild(0);
140
+ parentLink = this._getSelectedLinkElement();
141
+ this._showUI();
139
142
  }
140
143
  else {
144
+
141
145
  parentLink = this._getSelectedLinkElement();
146
+
147
+ const linkOption = parentLink.getAttribute('url');
148
+ link.typeId = QMSCKEditorUtil.getLinkType(linkOption);
149
+ link.targetId = parentLink.getAttribute('target') ? QMSCKEditorEnum.targetEnum[parentLink.getAttribute('target')] : 0;
150
+ if (parentLink._children.length > 0) {
151
+ link.title = parentLink._children[0]._textData ? parentLink._children[0]._textData.trim() : '';
152
+ }
153
+ else {
154
+ link.title = '';
155
+ }
156
+ link.protocolId = QMSCKEditorUtil.getProtocolId(linkOption);
157
+ link.url = href;
158
+ link.edit = true;
159
+ QMSCKEditorService.linkNotify(link);
160
+ window[QMSCKEditorConstant.QMSCK_LINKED] = false;
161
+ window.addEventListener(QMSCKEditorConstant.QMSCK_LINK_PLUGIN_RESP, function(evt) {
162
+ if (window[QMSCKEditorConstant.QMSCK_LINKED]){
163
+ return;
164
+ }
165
+ window[QMSCKEditorConstant.QMSCK_LINKED] = true;
166
+ const options = evt.detail;
167
+ editor.commands.get('link').execute(options);
168
+ }, { once: true });
169
+ this._hideUI();
142
170
  }
143
171
 
144
- const linkOption = parentLink.getAttribute('url');
145
- link.typeId = QMSCKEditorUtil.getLinkType(linkOption);
146
- link.targetId = parentLink.getAttribute('target') ? QMSCKEditorEnum.targetEnum[parentLink.getAttribute('target')] : 0;
147
- if (parentLink._children.length > 0) {
148
- link.title = parentLink._children[0]._textData ? parentLink._children[0]._textData.trim() : '';
149
- }
150
- else {
151
- link.title = '';
152
- }
153
- link.protocolId = QMSCKEditorUtil.getProtocolId(linkOption);
154
- link.url = href;
155
- link.edit = true;
156
- QMSCKEditorService.linkNotify(link);
157
- window[QMSCKEditorConstant.QMSCK_LINKED] = false;
158
- window.addEventListener(QMSCKEditorConstant.QMSCK_LINK_PLUGIN_RESP, function(evt) {
159
- if (window[QMSCKEditorConstant.QMSCK_LINKED]){
160
- return;
161
- }
162
- window[QMSCKEditorConstant.QMSCK_LINKED] = true;
163
- const options = evt.detail;
164
- editor.commands.get('link').execute(options);
165
- }, { once: true });
166
- this._hideUI();
172
+
167
173
  } );
168
174
 
169
175
  // Execute unlink command after clicking on the "Unlink" button.
@@ -223,8 +229,10 @@ export default class LinkUI extends Plugin {
223
229
  this.listenTo( formView, 'submit', () => {
224
230
  const { value } = formView.urlInputView.fieldView.element;
225
231
  const parsedUrl = addLinkProtocolIfApplicable( value, defaultProtocol );
226
- editor.execute( 'link', parsedUrl, formView.getDecoratorSwitchesState() );
227
- this._closeFormView();
232
+ //editor.execute( 'link', parsedUrl, formView.getDecoratorSwitchesState() );
233
+ const options = {url: '00' + parsedUrl};
234
+ editor.execute( 'link', options, formView.getDecoratorSwitchesState() );
235
+ this._closeFormView();
228
236
  } );
229
237
 
230
238
  // Hide the panel after clicking the "Cancel" button.
@@ -367,6 +375,10 @@ export default class LinkUI extends Plugin {
367
375
  const editor = this.editor;
368
376
  const linkCommand = editor.commands.get( 'link' );
369
377
 
378
+ if(!linkCommand.value) {
379
+ linkCommand.value = editor.editing.view.document.selection.getSelectedElement()._children[0]._attrs.get('src');
380
+ }
381
+
370
382
  this.formView.disableCssTransitions();
371
383
 
372
384
  this._balloon.add( {