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
@@ -130,31 +130,40 @@ export default class LinkUI extends Plugin {
130
130
  // Execute unlink command after clicking on the "Edit" button.
131
131
  this.listenTo( actionsView, 'edit', () => {
132
132
  //this._addFormView();
133
- let link = QMSCKEditorEnum.hyperLink;
134
- const href = this.actionsView.href;
135
- const hasLink = this.isImageLinked( editor.editing.view.document.selection.getSelectedElement(), editor.plugins.get('Image') );
136
- let parentLink;
137
- if (hasLink) {
138
- parentLink = editor.editing.view.document.selection.getSelectedElement().getChild(0);
139
- }
140
- else {
141
- parentLink = this._getSelectedLinkElement();
142
- }
143
- const linkOption = parentLink.getAttribute('url');
144
- link.typeId = QMSCKEditorUtil.getLinkType(linkOption);
145
- link.targetId = parentLink.getAttribute('target') ? QMSCKEditorEnum.targetEnum[parentLink.getAttribute('target')] : 0;
146
- if (parentLink._children.length > 0) {
147
- link.title = parentLink._children[0]._textData ? parentLink._children[0]._textData.trim() : '';
148
- }
149
- else {
150
- link.title = '';
151
- }
152
- link.protocolId = QMSCKEditorUtil.getProtocolId(linkOption);
153
- link.url = href;
154
- link.edit = true;
155
- window[QMSCKEditorConstant.QMSCK_LINKED] = false;
156
- QMSCKEditorService.linkNotify(link);
157
- this._hideUI();
133
+ let link = QMSCKEditorEnum.hyperLink;
134
+ const href = this.actionsView.href;
135
+ const hasLink = this.isImageLinked( editor.editing.view.document.selection.getSelectedElement(), editor.plugins.get('Image') );
136
+ let parentLink;
137
+ if (hasLink) {
138
+ parentLink = editor.editing.view.document.selection.getSelectedElement().getChild(0);
139
+ }
140
+ else {
141
+ parentLink = this._getSelectedLinkElement();
142
+ }
143
+
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();
158
167
  } );
159
168
 
160
169
  // Execute unlink command after clicking on the "Unlink" button.
@@ -240,7 +249,7 @@ export default class LinkUI extends Plugin {
240
249
  */
241
250
  _createToolbarLinkButton() {
242
251
  const editor = this.editor;
243
- const linkCommand = editor.commands.get( 'link' );
252
+ const linkDialogCommand = editor.commands.get( 'linkdialog' );
244
253
  const t = editor.t;
245
254
 
246
255
  // Handle the `Ctrl+K` keystroke and show the panel.
@@ -248,9 +257,9 @@ export default class LinkUI extends Plugin {
248
257
  // Prevent focusing the search bar in FF, Chrome and Edge. See https://github.com/ckeditor/ckeditor5/issues/4811.
249
258
  cancel();
250
259
 
251
- if ( linkCommand.isEnabled ) {
260
+ if ( linkDialogCommand.isEnabled ) {
252
261
  // this._showUI( true );
253
- this.editor.execute('link');
262
+ this.editor.execute('linkdialog');
254
263
  }
255
264
  } );
256
265
 
@@ -265,14 +274,14 @@ export default class LinkUI extends Plugin {
265
274
  button.isToggleable = true;
266
275
 
267
276
  // Bind button to the command.
268
- const linkCommand = editor.commands.get('link');
269
- button.bind( 'isEnabled' ).to( linkCommand, 'isEnabled' );
270
- button.bind( 'isOn' ).to( linkCommand, 'value', value => !!value );
277
+ const linkDialogCommand = editor.commands.get( 'linkdialog' );
278
+ button.bind( 'isEnabled' ).to( linkDialogCommand, 'isEnabled' );
279
+ button.bind( 'isOn' ).to( linkDialogCommand, 'value', value => !!value );
271
280
 
272
281
  // Show the panel on button click.
273
282
  //this.listenTo( button, 'execute', () => this._showUI( true ) );
274
283
  this.listenTo(button, 'execute', () => {
275
- this.editor.execute('link');
284
+ this.editor.execute('linkdialog');
276
285
  });
277
286
 
278
287
  return button;
@@ -0,0 +1,14 @@
1
+ import { Plugin } from '@ckeditor/ckeditor5-core';
2
+ import TableOfContentsEditing from './tableofcontentsediting';
3
+ import TableOfContentsUI from './tableofcontentsui';
4
+
5
+ export default class TableOfContents extends Plugin {
6
+ static get requires() {
7
+ return [TableOfContentsEditing, TableOfContentsUI];
8
+ }
9
+
10
+ static get pluginName() {
11
+ return 'TableOfContents';
12
+ }
13
+ }
14
+
@@ -0,0 +1,87 @@
1
+ import { Command } from '@ckeditor/ckeditor5-core';
2
+ import { rangeToText, getAttributeValueOn, setAttributeOn, TOC_ELEMENTS, TOC_ATTRIBUTES} from './utils';
3
+ import { findOptimalInsertionPosition } from '@ckeditor/ckeditor5-widget/src/utils';
4
+ import { trimStart } from '../common/qmsCKEditorUtil';
5
+
6
+ export default class TableOfContentsCommand extends Command {
7
+
8
+ execute( options = {} ) {
9
+ const editor = this.editor;
10
+ const model = editor.model;
11
+ model.change(writer => {
12
+ const headingObject = this._findHeadingElements(options.headings);
13
+ if(Object.keys(headingObject).length > 0){
14
+ const tocObject = this._buildTOCElements(headingObject);
15
+ this._setAnchorIdAttribute(headingObject, tocObject, writer);
16
+ this._insertTOCElements(tocObject, writer);
17
+ }
18
+ });
19
+ }
20
+
21
+ _insertTOCElements(tocObject, writer){
22
+ let position;
23
+ Object.keys(tocObject).forEach((key) => {
24
+ const section = tocObject[key];
25
+ const paragraphElement = writer.createElement(TOC_ELEMENTS.PARAGRAPH, { ...section.attributes });
26
+ const textElement = writer.createText(section.text, { [TOC_ATTRIBUTES.LINK_HREF]: '#' + section.id });
27
+ writer.insert(textElement, writer.createPositionAt(paragraphElement, 0));
28
+ if(!position){
29
+ position = findOptimalInsertionPosition(this.editor.model.document.selection, this.editor.model);
30
+ }
31
+ const { end: positionAfter } = this.editor.model.insertContent(paragraphElement, position);
32
+ position = positionAfter;
33
+ });
34
+ }
35
+
36
+ _setAnchorIdAttribute(headingObject, tocObject, writer){
37
+ Object.keys(tocObject).forEach((key) =>{
38
+ const node = headingObject[key];
39
+ const sectionOject = tocObject[key];
40
+ if(!sectionOject.hasAnchorId){
41
+ const range = this.editor.model.createRangeIn(node);
42
+ const attribute = { key: TOC_ATTRIBUTES.ANCHOR_ID, value: sectionOject.id }
43
+ const hasAnchorId = setAttributeOn(range, this.editor.model.schema, writer, attribute);
44
+ if(!hasAnchorId){
45
+ let childNode = writer.createText('\u00A0', { [TOC_ATTRIBUTES.ANCHOR_ID]: sectionOject.id });//insert non-breaking space
46
+ writer.insert(childNode, writer.createPositionAt(node, 0));
47
+ }
48
+ }
49
+ });
50
+ }
51
+
52
+ _buildTOCElements(headingObject){
53
+ const tocObject = {};
54
+ let index = 1;
55
+ Object.keys(headingObject).forEach(key =>{
56
+ const node = headingObject[key];
57
+ const range = this.editor.model.createRangeIn(node);
58
+ const attributes = Object.fromEntries(node.getAttributes());
59
+ const name = node.name.toLowerCase();
60
+ attributes[TOC_ATTRIBUTES.HEADING_CLASS] = name;
61
+ const text = rangeToText(range) || '';
62
+ let id = trimStart(text, '#').replace(/[^a-z0-9\+]/gi, '').toLowerCase() + index;
63
+ let hasAnchorId = false;
64
+ const anchorId = getAttributeValueOn(range, TOC_ATTRIBUTES.ANCHOR_ID);
65
+ if(!!anchorId){
66
+ id = trimStart(anchorId, '#');
67
+ hasAnchorId = true;
68
+ }
69
+ tocObject[key] = { id, name, text, hasAnchorId, attributes };
70
+ index++;
71
+ });
72
+ return tocObject;
73
+ }
74
+
75
+ _findHeadingElements(supportedHeadings){
76
+ const headingObject = {};
77
+ const range = this.editor.model.createRangeIn(this.editor.model.document.getRoot());
78
+ for (const value of range.getWalker()) {
79
+ const node = value.item;
80
+ if (node.is('element') && supportedHeadings.indexOf(node.name) > -1) {
81
+ let path = node.getPath();
82
+ headingObject[path] = node;
83
+ }
84
+ }
85
+ return headingObject;
86
+ }
87
+ }
@@ -0,0 +1,59 @@
1
+ import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
2
+ import { TOC_ATTRIBUTES, TOC_COMMAND, normalizeHeadingOptions } from './utils';
3
+ import TableOfContentsCommand from './tableofcontentscommand';
4
+ import '../../themes/styles/heading.css';
5
+
6
+ export default class TableOfContentsEditing extends Plugin {
7
+ static get pluginName() {
8
+ return 'TableOfContentsEditing';
9
+ }
10
+
11
+ init() {
12
+ const editor = this.editor;
13
+ const model = editor.model;
14
+ const supportedHeadings = normalizeHeadingOptions(editor.config.get('tableOfContents.supportedHeadings'));
15
+ model.schema.extend('$block', { allowAttributes: TOC_ATTRIBUTES.HEADING_CLASS } );
16
+ model.schema.setAttributeProperties(TOC_ATTRIBUTES.HEADING_CLASS, { isFormatting: true } );
17
+ editor.conversion.attributeToAttribute(buildClassDefinition(supportedHeadings));
18
+ editor.commands.add(TOC_COMMAND, new TableOfContentsCommand(editor));
19
+ }
20
+ }
21
+
22
+ function buildClassDefinition( supportedHeadings ) {
23
+ const options = [];
24
+ supportedHeadings.forEach((name) =>{
25
+ try{
26
+ /* Reference to the default config of the heading plugin
27
+ editor.config.define( 'heading', {
28
+ options: [
29
+ { model: 'paragraph', title: 'Paragraph', class: 'ck-heading_paragraph' },
30
+ { model: 'heading1', view: 'h2', title: 'Heading 1', class: 'ck-heading_heading1' },
31
+ { model: 'heading2', view: 'h3', title: 'Heading 2', class: 'ck-heading_heading2' },
32
+ { model: 'heading3', view: 'h4', title: 'Heading 3', class: 'ck-heading_heading3' }
33
+ ]
34
+ }); */
35
+ const level = parseInt(name.replace('heading', '')) + 1;
36
+ const className = 'h' + level;
37
+ options.push({ name, className });
38
+ }
39
+ catch{
40
+
41
+ }
42
+ });
43
+
44
+ const definition = {
45
+ model: {
46
+ key: TOC_ATTRIBUTES.HEADING_CLASS,
47
+ values: options.map(option => option.name)
48
+ },
49
+ view: {}
50
+ };
51
+
52
+ for (const option of options) {
53
+ definition.view[option.name] = {
54
+ key: 'class',
55
+ value: option.className
56
+ };
57
+ }
58
+ return definition;
59
+ }
@@ -0,0 +1,35 @@
1
+ import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
2
+ import ButtonView from '@ckeditor/ckeditor5-ui/src/button/buttonview';
3
+ import tableIcon from '../../themes/icons/table-excel.svg';
4
+ import { TOC_COMMAND, normalizeHeadingOptions } from './utils';
5
+
6
+ export default class TableOfContentsUI extends Plugin {
7
+ static get pluginName() {
8
+ return 'TableOfContentsUI';
9
+ }
10
+
11
+ init() {
12
+ const editor = this.editor;
13
+ const t = editor.t;
14
+ const supportedHeadings = normalizeHeadingOptions(editor.config.get('tableOfContents.supportedHeadings'));
15
+ editor.ui.componentFactory.add('tableOfContents', locale => {
16
+ const buttonView = new ButtonView( locale );
17
+ buttonView.set( {
18
+ label: t('Create Table of Contents'),
19
+ icon: tableIcon,
20
+ withText: false,
21
+ tooltip: true
22
+ } );
23
+
24
+ // Bind button to the command.
25
+ const tocCommand = editor.commands.get(TOC_COMMAND);
26
+ buttonView.bind('isEnabled').to(tocCommand, 'isEnabled' );
27
+ buttonView.bind('isOn').to(tocCommand, 'value', value => !!value );
28
+
29
+ buttonView.on('execute', () => {
30
+ editor.execute(TOC_COMMAND, { headings: supportedHeadings });
31
+ });
32
+ return buttonView;
33
+ });
34
+ }
35
+ }
@@ -0,0 +1,62 @@
1
+
2
+ export const DEFAULT_SUPPORTED_HEADINGS = ['heading1', 'heading2', 'heading3'];//It is already defined by the heading plugin
3
+ export const TOC_CUSTOM_PROPERTY = 'toc';
4
+ export const TOC_COMMAND = 'inserttoc';
5
+ export const TOC_ATTRIBUTES = {
6
+ HEADING_CLASS: 'headingClass',
7
+ ANCHOR_ID: 'anchorId', //It is already defined by the anchor plugin,
8
+ LINK_HREF: 'linkHref'//It is already defined by the link plugin
9
+ }
10
+
11
+ export const TOC_ELEMENTS = {
12
+ TOC: 'toc',
13
+ PARAGRAPH: 'paragraph' //It is already defined by the paragraph plugin
14
+ }
15
+
16
+ export function normalizeHeadingOptions(headingOptions) {
17
+ let headings = headingOptions || [];
18
+ headings = headings.map(value => value.toLowerCase()).filter(value => value.startsWith('heading'));
19
+ if(headings.length == 0){
20
+ headings = DEFAULT_SUPPORTED_HEADINGS;
21
+ }
22
+ return headings;
23
+ }
24
+
25
+ export function rangeToText(range) {
26
+ return Array.from(range.getItems()).reduce((rangeText, node) => {
27
+ if (!(node.is('text') || node.is('textProxy'))) {
28
+ return rangeText;
29
+ }
30
+ return rangeText + node.data;
31
+ }, '');
32
+ }
33
+
34
+ export function getAttributeValueOn(range, attributeName) {
35
+ for (const item of range.getItems()) {
36
+ for (const [ key, value ] of item.getAttributes()) {
37
+ if (key.toLowerCase() == attributeName.toLowerCase()) {
38
+ return value;
39
+ }
40
+ }
41
+ }
42
+ return null;
43
+ }
44
+
45
+ export function setAttributeOn(range, schema, writer, attribute) {
46
+ for (const node of Array.from(range.getItems())) {
47
+ if (schema.checkAttribute(node, attribute.key)) {
48
+ writer.setAttribute(attribute.key, attribute.value, node);
49
+ return true;
50
+ }
51
+ }
52
+ return false;
53
+ }
54
+
55
+ export function getTextNodeOn(range) {
56
+ for (const node of Array.from(range.getItems())) {
57
+ if (node.is('text') || node.is('textProxy')) {
58
+ return node;
59
+ }
60
+ }
61
+ return null;
62
+ }
@@ -0,0 +1,14 @@
1
+ import { Command } from '@ckeditor/ckeditor5-core';
2
+ import * as QMSCKEditorConstant from '../common/qmsCKEditorConstant';
3
+ import * as QMSCKEditorService from '../common/qmsCKEditorService';
4
+
5
+ export default class LoadTemplateDialogCommand extends Command {
6
+
7
+ execute() {
8
+ QMSCKEditorService.loadTemplateNotify(null);
9
+ window.addEventListener(QMSCKEditorConstant.QMSCK_LOAD_TEMPLATE_PLUGIN_RESP, function (evt) {
10
+ editor.setData(evt.detail);
11
+ }, { once: true });
12
+ }
13
+ }
14
+
@@ -1,32 +1,30 @@
1
1
  import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
2
2
  import ButtonView from '@ckeditor/ckeditor5-ui/src/button/buttonview';
3
3
  import TemplateIcon from '../../themes/icons/load_template.svg';
4
- import * as QMSCKEditorConstant from '../common/qmsCKEditorConstant';
5
- import * as QMSCKEditorService from '../common/qmsCKEditorService';
6
-
4
+ import LoadTemplateDialogCommand from './loadtemplatedialogcommand';
7
5
  export default class QMSCKEditorLoadTemplatePlugin extends Plugin {
8
6
  init() {
9
7
  const editor = this.editor;
8
+ const t = editor.t;
10
9
 
11
10
  editor.ui.componentFactory.add('qmsLoadTemplate', locale => {
12
11
  const view = new ButtonView(locale);
13
-
12
+ const command = editor.commands.get('loadtemplateDialog');
14
13
  view.set({
15
- label: 'Templates',
14
+ label: t('Templates'),
16
15
  icon: TemplateIcon,
17
16
  tooltip: true
18
17
  });
19
18
 
20
- view.on('execute', () => {
21
- QMSCKEditorService.loadTemplateNotify(null);
19
+ view.bind('isEnabled').to(command);
22
20
 
23
- window.addEventListener(QMSCKEditorConstant.QMSCK_LOAD_TEMPLATE_PLUGIN_RESP, function (evt) {
24
- editor.setData(evt.detail);
25
- },
26
- { once: true });
21
+ view.on('execute', () => {
22
+ command.execute();
27
23
  });
28
24
 
29
25
  return view;
30
- })
26
+ });
27
+
28
+ editor.commands.add('loadtemplateDialog', new LoadTemplateDialogCommand(editor));
31
29
  }
32
30
  }
@@ -1,26 +1,29 @@
1
1
  import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
2
2
  import ButtonView from '@ckeditor/ckeditor5-ui/src/button/buttonview';
3
3
  import TemplateIcon from '../../themes/icons/template.svg';
4
- import * as QMSCKEditorService from '../common/qmsCKEditorService';
5
-
4
+ import TemplateDialogCommand from './templatedialogcommand';
6
5
  export default class QMSCKEditorTemplatePlugin extends Plugin {
7
6
  init() {
8
7
  const editor = this.editor;
9
-
8
+ const t = editor.t;
10
9
  editor.ui.componentFactory.add('qmsTemplate', locale => {
11
10
  const view = new ButtonView(locale);
12
-
11
+ const command = editor.commands.get('templateDialog');
13
12
  view.set({
14
- label: 'Add Template',
13
+ label: t('Add Template'),
15
14
  icon: TemplateIcon,
16
15
  tooltip: true
17
16
  });
18
17
 
18
+ view.bind('isEnabled').to(command);
19
+
19
20
  view.on('execute', () => {
20
- QMSCKEditorService.templateNotify(null);
21
+ command.execute();
21
22
  });
22
23
 
23
24
  return view;
24
- })
25
+ });
26
+
27
+ editor.commands.add('templateDialog', new TemplateDialogCommand(editor));
25
28
  }
26
29
  }
@@ -0,0 +1,9 @@
1
+ import { Command } from '@ckeditor/ckeditor5-core';
2
+ import * as QMSCKEditorService from '../common/qmsCKEditorService';
3
+
4
+ export default class TemplateDialogCommand extends Command {
5
+ execute() {
6
+ QMSCKEditorService.templateNotify(null);
7
+ }
8
+ }
9
+
@@ -1,8 +1,7 @@
1
1
  import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
2
2
  import ButtonView from '@ckeditor/ckeditor5-ui/src/button/buttonview';
3
3
  import timestampIcon from '../../themes/icons/timestamp.svg';
4
- import { formatDate } from '../common/qmsCKEditorUtil';
5
- import { toMap } from '@ckeditor/ckeditor5-utils';
4
+ import TimestampCommand from './timestampcommand';
6
5
 
7
6
  /**
8
7
  * Users can format the DateTime output based on a DateTime pattern
@@ -10,19 +9,19 @@ import { toMap } from '@ckeditor/ckeditor5-utils';
10
9
  * The default DateTime pattern is dd/MM/yyyy hh:mm:ss aaa
11
10
  *
12
11
  * DateTime Patterns:
13
- *
12
+ *
14
13
  * yy = 2-digit year; yyyy = full year
15
- *
14
+ *
16
15
  * M = digit month; MM = 2-digit month
17
- *
16
+ *
18
17
  * d = digit day; dd = 2-digit day
19
- *
18
+ *
20
19
  * h = hours am/pm; hh = 2-digit hours am/pm; H = hours; HH = 2-digit hours
21
- *
20
+ *
22
21
  * m = minutes; mm = 2-digit minutes; aaa = AM/PM
23
- *
22
+ *
24
23
  * s = seconds; ss = 2-digit seconds
25
- *
24
+ *
26
25
  * S = miliseconds
27
26
  */
28
27
  export default class Timestamp extends Plugin {
@@ -33,23 +32,21 @@ export default class Timestamp extends Plugin {
33
32
 
34
33
  editor.ui.componentFactory.add('timestamp', locale => {
35
34
  const buttonView = new ButtonView( locale );
36
-
35
+ const command = editor.commands.get('timestamp');
37
36
  buttonView.set( {
38
37
  label: t('Timestamp'),
39
38
  icon: timestampIcon,
40
- withText: true,
39
+ withText: false,
41
40
  tooltip: true
42
- } );
41
+ });
42
+ buttonView.bind('isEnabled').to( command);
43
43
 
44
44
  buttonView.on('execute', () => {
45
- editor.model.change( writer => {
46
- const attributes = toMap( editor.model.document.selection.getAttributes() );
47
- const timestamp = writer.createText(formatDate(new Date(), datetimeformat), attributes);
48
- editor.model.insertContent(timestamp, editor.model.document.selection );
49
- } );
45
+ command.execute({ datetimeformat: datetimeformat })
50
46
  } );
51
-
52
47
  return buttonView;
53
48
  } );
49
+
50
+ editor.commands.add('timestamp', new TimestampCommand(editor));
54
51
  }
55
52
  }
@@ -0,0 +1,17 @@
1
+ import { Command } from '@ckeditor/ckeditor5-core';
2
+ import { formatDate } from '../common/qmsCKEditorUtil';
3
+ import { toMap } from '@ckeditor/ckeditor5-utils';
4
+
5
+ export default class TimestampCommand extends Command {
6
+
7
+ execute(options) {
8
+ const editor = this.editor;
9
+ const model = editor.model;
10
+ model.change( writer => {
11
+ const attributes = toMap(editor.model.document.selection.getAttributes());
12
+ const timestamp = writer.createText(formatDate(new Date(), options.datetimeformat), attributes);
13
+ model.insertContent(timestamp, editor.model.document.selection );
14
+ });
15
+ }
16
+ }
17
+
@@ -1,31 +1,47 @@
1
- import { Command } from 'ckeditor5/src/core';
2
- import { findAttributeRange } from 'ckeditor5/src/typing';
3
- import { TOOLTIP_ATTRIBUTE } from './utils';
1
+
4
2
 
5
- export default class RemoveTooltipCommand extends Command {
6
- refresh() {
7
- const model = this.editor.model;
8
- this.isEnabled = model.schema.checkAttributeInSelection(model.document.selection, TOOLTIP_ATTRIBUTE);
9
- }
3
+ import { Command } from '@ckeditor/ckeditor5-core';
4
+ import { findAttributeRange } from '@ckeditor/ckeditor5-typing';
5
+ import { first } from '@ckeditor/ckeditor5-utils';
6
+ import { isImageAllowed } from './utils';
7
+ import { TOOLTIP_COMMANDS, HTML_ATTRIBUTE, HTML_CLASS, TOOLTIP_ATTRIBUTE, TOOLTIP_CUSTOM_PROPERTY } from './utils';
10
8
 
11
- execute() {
12
- const editor = this.editor;
13
- const model = editor.model;
14
- const selection = model.document.selection;
9
+ export default class RemoveTooltipCommand extends Command {
10
+
11
+ refresh() {
12
+ const model = this.editor.model;
13
+ const doc = model.document;
14
+ const selectedElement = first(doc.selection.getSelectedBlocks());
15
15
 
16
- model.change(writer => {
17
- const selectedRanges = selection.isCollapsed ?
18
- [findAttributeRange(
19
- selection.getFirstPosition(),
20
- TOOLTIP_ATTRIBUTE,
21
- selection.getAttribute(TOOLTIP_ATTRIBUTE),
22
- model
23
- )] :
24
- model.schema.getValidRanges(selection.getRanges(), TOOLTIP_ATTRIBUTE);
16
+ // A check for the `LinkImage` plugin. If the selection contains an image element, get values from the element.
17
+ // Currently the selection reads attributes from text nodes only. See #7429 and #7465.
18
+ if (isImageAllowed(selectedElement, model.schema)) {
19
+ this.isEnabled = model.schema.checkAttribute(selectedElement, TOOLTIP_ATTRIBUTE);
20
+ } else {
21
+ this.isEnabled = model.schema.checkAttributeInSelection(doc.selection, TOOLTIP_ATTRIBUTE);
22
+ }
23
+ }
24
+
25
+ execute() {
26
+ const editor = this.editor;
27
+ const model = editor.model;
28
+ const selection = model.document.selection;
29
+
30
+ model.change(writer => {
31
+ // Get ranges to unlink.
32
+ const rangesToUnlink = selection.isCollapsed ?
33
+ [findAttributeRange(
34
+ selection.getFirstPosition(),
35
+ TOOLTIP_ATTRIBUTE,
36
+ selection.getAttribute(TOOLTIP_ATTRIBUTE),
37
+ model
38
+ )] :
39
+ model.schema.getValidRanges(selection.getRanges(), TOOLTIP_ATTRIBUTE);
25
40
 
26
- for (const range of selectedRanges) {
27
- writer.removeAttribute(TOOLTIP_ATTRIBUTE, range);
28
- }
29
- });
30
- }
41
+ // Remove `qmsTooltip` attribute from specified ranges.
42
+ for (const range of rangesToUnlink) {
43
+ writer.removeAttribute(TOOLTIP_ATTRIBUTE, range);
44
+ }
45
+ });
46
+ }
31
47
  }
@@ -1,14 +1,14 @@
1
-
2
1
  import { Plugin } from '@ckeditor/ckeditor5-core';
3
2
  import TooltipEditing from './tooltipediting';
4
3
  import TooltipUI from './tooltipui';
5
4
 
6
5
  export default class Tooltip extends Plugin {
6
+
7
7
  static get requires() {
8
- return [TooltipEditing, TooltipUI];
8
+ return [ TooltipEditing, TooltipUI ];
9
9
  }
10
10
 
11
11
  static get pluginName() {
12
12
  return 'Tooltip';
13
13
  }
14
- }
14
+ }