qms-angular 1.0.27 → 1.0.31

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 (139) hide show
  1. package/bundles/qms-angular.umd.js +888 -240
  2. package/bundles/qms-angular.umd.js.map +1 -1
  3. package/esm2015/lib/common/qms-icon.const.js +6 -0
  4. package/esm2015/lib/components/breadcrumb/breadcrumb-direction-icon.directive.js +20 -0
  5. package/esm2015/lib/components/breadcrumb/breadcrumb-item.directive.js +40 -0
  6. package/esm2015/lib/components/breadcrumb/breadcrumb.js +129 -0
  7. package/esm2015/lib/components/breadcrumb/breadcrumb.module.js +38 -0
  8. package/esm2015/lib/components/breadcrumb/enum/dropdown-node-width.enum.js +6 -0
  9. package/esm2015/lib/components/breadcrumb/model/breadcrumb-node.model.js +3 -0
  10. package/esm2015/lib/components/button/button-toggle.js +1 -1
  11. package/esm2015/lib/components/dialog/constant.js +4 -2
  12. package/esm2015/lib/components/dialog/dialog.js +4 -4
  13. package/esm2015/lib/components/related/common/data-type.enum.js +2 -2
  14. package/esm2015/lib/components/related/common/qms-icon.const.js +21 -1
  15. package/esm2015/lib/components/related/common/tree.function.js +10 -5
  16. package/esm2015/lib/components/related/list-other-related/list-related.component.js +10 -2
  17. package/esm2015/lib/components/related/model/popup-data.model.js +2 -1
  18. package/esm2015/lib/components/related/model/related-data.model.js +1 -1
  19. package/esm2015/lib/components/related/model/tree-config.model.js +1 -1
  20. package/esm2015/lib/components/related/model/tree-node.model.js +1 -1
  21. package/esm2015/lib/components/related/popup/related-popup.component.js +179 -12
  22. package/esm2015/lib/components/related/related.module.js +7 -5
  23. package/esm2015/lib/components/related/risk/analysis/analysis.component.js +1 -1
  24. package/esm2015/lib/components/related/service/related-global.service.js +5 -1
  25. package/esm2015/lib/components/related/tree/tree.component.js +37 -9
  26. package/esm2015/lib/components/table/table-action.js +2 -2
  27. package/esm2015/lib/directives/scrollbar/scrollbar.directive.js +8 -2
  28. package/esm2015/lib/directives/tooltip/tooltip-renderer.directive.js +4 -4
  29. package/esm2015/lib/model/en.js +7 -2
  30. package/esm2015/lib/model/no.js +7 -2
  31. package/esm2015/lib/qms-ckeditor-components/common/constants/ckeditorEvent.constant.js +3 -1
  32. package/esm2015/lib/qms-ckeditor-components/common/models/qms-ckeditor-data.model.js +1 -1
  33. package/esm2015/lib/qms-ckeditor-components/common/models/qms-ckeditor-input.model.js +2 -1
  34. package/esm2015/lib/qms-ckeditor-components/common/module/confirm/qms-ckeditor-confirm.component.js +1 -1
  35. package/esm2015/lib/qms-ckeditor-components/components/qms-ckeditor-link/attachments/link-attachment.component.js +1 -1
  36. package/esm2015/lib/qms-ckeditor-components/components/qms-ckeditor-link/qms-ckeditor-link.component.js +3 -3
  37. package/esm2015/lib/qms-ckeditor-components/components/qms-ckeditor-load-template/qms-ckeditor-load-template.component.js +1 -1
  38. package/esm2015/lib/qms-ckeditor-components/components/qms-ckeditor-relation/qmsckeditor-related.component.js +1 -1
  39. package/esm2015/lib/qms-ckeditor-components/components/qms-ckeditor-template/qms-ckeditor-template.component.js +1 -1
  40. package/esm2015/lib/qms-ckeditor-components/components/qms-ckeditor-tooltip/qms-ckeditor-tooltip.component.js +76 -0
  41. package/esm2015/lib/qms-ckeditor-components/models/qms-ckeditor-tooltip.model.js +7 -0
  42. package/esm2015/lib/qms-ckeditor-components/qms-ckeditor.component.js +51 -2
  43. package/esm2015/lib/qms-ckeditor-components/qms-ckeditor.module.js +4 -2
  44. package/esm2015/public-api.js +7 -1
  45. package/esm2015/qms-angular.js +3 -1
  46. package/fesm2015/qms-angular.js +910 -292
  47. package/fesm2015/qms-angular.js.map +1 -1
  48. package/lib/common/qms-icon.const.d.ts +1 -0
  49. package/lib/components/breadcrumb/breadcrumb-direction-icon.directive.d.ts +6 -0
  50. package/lib/components/breadcrumb/breadcrumb-item.directive.d.ts +12 -0
  51. package/lib/components/breadcrumb/breadcrumb.d.ts +32 -0
  52. package/lib/components/breadcrumb/breadcrumb.module.d.ts +2 -0
  53. package/lib/components/breadcrumb/enum/dropdown-node-width.enum.d.ts +4 -0
  54. package/lib/components/breadcrumb/model/breadcrumb-node.model.d.ts +13 -0
  55. package/lib/components/related/common/data-type.enum.d.ts +1 -1
  56. package/lib/components/related/common/qms-icon.const.d.ts +4 -0
  57. package/lib/components/related/list-other-related/list-related.component.d.ts +3 -0
  58. package/lib/components/related/model/popup-data.model.d.ts +1 -0
  59. package/lib/components/related/model/related-data.model.d.ts +4 -0
  60. package/lib/components/related/model/tree-config.model.d.ts +1 -0
  61. package/lib/components/related/model/tree-node.model.d.ts +1 -0
  62. package/lib/components/related/popup/related-popup.component.d.ts +18 -0
  63. package/lib/components/related/service/related-global.service.d.ts +2 -0
  64. package/lib/components/related/tree/tree.component.d.ts +7 -1
  65. package/lib/directives/scrollbar/scrollbar.directive.d.ts +1 -0
  66. package/lib/model/en.d.ts +6 -1
  67. package/lib/model/no.d.ts +6 -1
  68. package/lib/qms-ckeditor-components/common/constants/ckeditorEvent.constant.d.ts +2 -0
  69. package/lib/qms-ckeditor-components/common/models/qms-ckeditor-data.model.d.ts +1 -0
  70. package/lib/qms-ckeditor-components/common/models/qms-ckeditor-input.model.d.ts +1 -0
  71. package/lib/qms-ckeditor-components/components/qms-ckeditor-tooltip/qms-ckeditor-tooltip.component.d.ts +36 -0
  72. package/lib/qms-ckeditor-components/models/qms-ckeditor-tooltip.model.d.ts +6 -0
  73. package/lib/qms-ckeditor-components/qms-ckeditor.component.d.ts +6 -0
  74. package/package.json +1 -1
  75. package/public-api.d.ts +6 -0
  76. package/qms-angular.d.ts +2 -0
  77. package/qms-angular.metadata.json +1 -1
  78. package/src/assets/qms-ckeditor-plugin/build/ckeditor.js +2 -1
  79. package/src/assets/qms-ckeditor-plugin/build/ckeditor.js.map +1 -1
  80. package/src/assets/qms-ckeditor-plugin/package-lock.json +1224 -2042
  81. package/src/assets/qms-ckeditor-plugin/package.json +26 -19
  82. package/src/assets/qms-ckeditor-plugin/src/ckeditor.js +23 -1
  83. package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-find-and-replace/src/findandreplace.js +132 -0
  84. package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-find-and-replace/src/findandreplaceediting.js +315 -0
  85. package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-find-and-replace/src/findandreplaceui.js +223 -0
  86. package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-find-and-replace/src/findcommand.js +90 -0
  87. package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-find-and-replace/src/findnextcommand.js +62 -0
  88. package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-find-and-replace/src/findpreviouscommand.js +28 -0
  89. package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-find-and-replace/src/index.js +10 -0
  90. package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-find-and-replace/src/replaceallcommand.js +54 -0
  91. package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-find-and-replace/src/replacecommand.js +66 -0
  92. package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-find-and-replace/src/ui/checkboxview.js +212 -0
  93. package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-find-and-replace/src/ui/findandreplaceformview.js +546 -0
  94. package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-find-and-replace/src/utils.js +158 -0
  95. package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-find-and-replace/theme/findandreplace.css +13 -0
  96. package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-find-and-replace/theme/findandreplaceform.css +226 -0
  97. package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-find-and-replace/theme/icons/find-replace.svg +1 -0
  98. package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/index.js +16 -0
  99. package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharacters.js +254 -0
  100. package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharactersarrows.js +60 -0
  101. package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharacterscurrency.js +78 -0
  102. package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharactersessentials.js +43 -0
  103. package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharacterslatin.js +170 -0
  104. package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharactersmathematical.js +86 -0
  105. package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharacterstext.js +69 -0
  106. package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/ui/charactergridview.js +116 -0
  107. package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/ui/characterinfoview.js +111 -0
  108. package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/ui/specialcharactersnavigationview.js +127 -0
  109. package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/theme/charactergrid.css +12 -0
  110. package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/theme/characterinfo.css +9 -0
  111. package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/theme/icons/specialcharacters.svg +1 -0
  112. package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/theme/specialcharacters.css +10 -0
  113. package/src/assets/qms-ckeditor-plugin/src/plugins/common/qmsCKEditorConstant.js +4 -0
  114. package/src/assets/qms-ckeditor-plugin/src/plugins/common/qmsCKEditorService.js +10 -0
  115. package/src/assets/qms-ckeditor-plugin/src/plugins/common/qmsCKEditorUtil.js +63 -0
  116. package/src/assets/qms-ckeditor-plugin/src/plugins/timestamp/timestamp.js +34 -0
  117. package/src/assets/qms-ckeditor-plugin/src/plugins/tooltip/inserttooltipcommand.js +98 -0
  118. package/src/assets/qms-ckeditor-plugin/src/plugins/tooltip/removetooltipcommand.js +41 -0
  119. package/src/assets/qms-ckeditor-plugin/src/plugins/tooltip/tooltip.js +14 -0
  120. package/src/assets/qms-ckeditor-plugin/src/plugins/tooltip/tooltipediting.js +280 -0
  121. package/src/assets/qms-ckeditor-plugin/src/plugins/tooltip/tooltipui.js +203 -0
  122. package/src/assets/qms-ckeditor-plugin/src/plugins/tooltip/ui/actionsview.js +95 -0
  123. package/src/assets/qms-ckeditor-plugin/src/plugins/tooltip/utils.js +70 -0
  124. package/src/assets/qms-ckeditor-plugin/src/themes/icons/information.svg +50 -0
  125. package/src/assets/qms-ckeditor-plugin/src/themes/icons/timestamp.svg +1 -0
  126. package/src/assets/qms-ckeditor-plugin/src/themes/tyles/tooltip.css +74 -0
  127. package/src/lib/components/breadcrumb/breadcrumb.scss +100 -0
  128. package/src/lib/components/button/button-toggle.scss +25 -1
  129. package/src/lib/components/dialog/dialog.scss +9 -0
  130. package/src/lib/components/related/popup/related-popup.component.scss +46 -0
  131. package/src/lib/components/table/table.scss +5 -27
  132. package/src/lib/qms-ckeditor-components/components/qms-ckeditor-tooltip/qms-ckeditor-tooltip.component.scss +11 -0
  133. package/src/lib/qms-ckeditor-components/qms-ckeditor.component.scss +29 -1
  134. package/src/lib/qms-ckeditor-components/styles/_modules.scss +6 -0
  135. package/src/themes/core/_form.scss +4 -0
  136. package/src/themes/core/_input.scss +8 -0
  137. package/src/themes/core/_scrollbar.scss +9 -2
  138. package/src/themes/core/_styles.scss +5 -0
  139. package/src/themes/core/_tab.scss +272 -6
@@ -0,0 +1,12 @@
1
+ /*
2
+ * Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+
6
+ .ck.ck-character-grid {
7
+ max-width: 100%;
8
+
9
+ & .ck-character-grid__tiles {
10
+ display: grid;
11
+ }
12
+ }
@@ -0,0 +1,9 @@
1
+ /*
2
+ * Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+
6
+ .ck.ck-character-info {
7
+ display: flex;
8
+ justify-content: space-between;
9
+ }
@@ -0,0 +1 @@
1
+ <svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M10 2.5a7.47 7.47 0 0 1 4.231 1.31 7.268 7.268 0 0 1 2.703 3.454 7.128 7.128 0 0 1 .199 4.353c-.39 1.436-1.475 2.72-2.633 3.677h2.013c0-.226.092-.443.254-.603a.876.876 0 0 1 1.229 0c.163.16.254.377.254.603v.853c0 .209-.078.41-.22.567a.873.873 0 0 1-.547.28l-.101.006h-4.695a.517.517 0 0 1-.516-.518v-1.265c0-.21.128-.398.317-.489a5.601 5.601 0 0 0 2.492-2.371 5.459 5.459 0 0 0 .552-3.693 5.53 5.53 0 0 0-1.955-3.2A5.71 5.71 0 0 0 10 4.206 5.708 5.708 0 0 0 6.419 5.46 5.527 5.527 0 0 0 4.46 8.663a5.457 5.457 0 0 0 .554 3.695 5.6 5.6 0 0 0 2.497 2.37.55.55 0 0 1 .317.49v1.264c0 .286-.23.518-.516.518H2.618a.877.877 0 0 1-.614-.25.845.845 0 0 1-.254-.603v-.853c0-.226.091-.443.254-.603a.876.876 0 0 1 1.228 0c.163.16.255.377.255.603h1.925c-1.158-.958-2.155-2.241-2.545-3.678a7.128 7.128 0 0 1 .199-4.352 7.268 7.268 0 0 1 2.703-3.455A7.475 7.475 0 0 1 10 2.5z"/></svg>
@@ -0,0 +1,10 @@
1
+ /*
2
+ * Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+
6
+ /*
7
+ * Note: This file should contain the wireframe styles only. But since there are no such styles,
8
+ * it acts as a message to the builder telling that it should look for the corresponding styles
9
+ * **in the theme** when compiling the editor.
10
+ */
@@ -9,3 +9,7 @@ export const QMSCK_LINKED = 'LINKED'
9
9
  export const QMSCK_LINK_PLUGIN_MSG = 'QMSCK_LINK_PLUGIN_MSG';
10
10
  export const QMSCK_LINK_PLUGIN_RESP = 'QMSCK_LINK_PLUGIN_RESP';
11
11
  export const QMSCK_LINK_OPTION = 'LINK_OPTION'
12
+ /* Tooltip */
13
+ export const QMSCK_TOOLTIP_PLUGIN_MSG = 'QMSCK_TOOLTIP_PLUGIN_MSG';
14
+ export const QMSCK_TOOLTIP_PLUGIN_RESP = 'QMSCK_TOOLTIP_PLUGIN_RESP';
15
+ export const QMSCK_TOOLTIP_IS_PROCESSING = 'QMSCK_TOOLTIP_IS_PROCESSING';
@@ -39,3 +39,13 @@ export function linkNotify(value){
39
39
  '*'
40
40
  );
41
41
  }
42
+
43
+ export function tooltipNotify(value) {
44
+ window.postMessage(
45
+ {
46
+ eventName: constant.QMSCK_TOOLTIP_PLUGIN_MSG,
47
+ value
48
+ },
49
+ '*'
50
+ );
51
+ }
@@ -25,3 +25,66 @@ export function getUrl(href) {
25
25
  if (!href) return '';
26
26
  return href.substring(2);
27
27
  }
28
+
29
+
30
+ function twoDigitPad(num) {
31
+ return num < 10 ? "0" + num : num;
32
+ }
33
+
34
+ /**
35
+ * Get a formatted date for a date and time pattern
36
+ *
37
+ * Example: MM/dd/yyy HH:mm:ss aaa
38
+ *
39
+ * Date and Time Patterns:
40
+ * yy = 2-digit year; yyyy = full year
41
+ *
42
+ * M = digit month; MM = 2-digit month
43
+ *
44
+ * d = digit day; dd = 2-digit day
45
+ *
46
+ * h = hours am/pm; hh = 2-digit hours am/pm; H = hours; HH = 2-digit hours
47
+ *
48
+ * m = minutes; mm = 2-digit minutes; aaa = AM/PM
49
+ *
50
+ * s = seconds; ss = 2-digit seconds
51
+ *
52
+ * S = miliseconds
53
+ */
54
+ export function formatDate(date, datetimeFormat){
55
+ if (!datetimeFormat) {
56
+ return date.toLocaleDateString() + ' ' + date.toLocaleTimeString();
57
+ }
58
+ var day = date.getDate(),
59
+ month = date.getMonth(),
60
+ year = date.getFullYear(),
61
+ hour = date.getHours(),
62
+ minute = date.getMinutes(),
63
+ second = date.getSeconds(),
64
+ miliseconds = date.getMilliseconds(),
65
+ h = hour % 12,
66
+ hh = twoDigitPad(h),
67
+ HH = twoDigitPad(hour),
68
+ mm = twoDigitPad(minute),
69
+ ss = twoDigitPad(second),
70
+ aaa = hour < 12 ? 'AM' : 'PM',
71
+ dd = twoDigitPad(day),
72
+ M = month + 1,
73
+ MM = twoDigitPad(M),
74
+ yyyy = year + "",
75
+ yy = yyyy.substr(2, 2)
76
+ ;
77
+ // checks to see if month name will be used
78
+ return datetimeFormat
79
+ .replace('hh', hh).replace('h', h)
80
+ .replace('HH', HH).replace('H', hour)
81
+ .replace('mm', mm).replace('m', minute)
82
+ .replace('ss', ss).replace('s', second)
83
+ .replace('S', miliseconds)
84
+ .replace('dd', dd).replace('d', day)
85
+ .replace('yyyy', yyyy)
86
+ .replace('yy', yy)
87
+ .replace('MM', MM)
88
+ .replace('M', M)
89
+ .replace('aaa', aaa);
90
+ }
@@ -0,0 +1,34 @@
1
+ import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
2
+ import ButtonView from '@ckeditor/ckeditor5-ui/src/button/buttonview';
3
+ import timestampIcon from '../../themes/icons/timestamp.svg';
4
+ import { formatDate } from '../common/qmsCKEditorUtil';
5
+ import { toMap } from '@ckeditor/ckeditor5-utils';
6
+
7
+ export default class Timestamp extends Plugin {
8
+ init() {
9
+ const editor = this.editor;
10
+ const t = editor.t;
11
+ const datetimeformat= editor.config.get('timestampConfig.datetimeFormat');
12
+
13
+ editor.ui.componentFactory.add('timestamp', locale => {
14
+ const buttonView = new ButtonView( locale );
15
+
16
+ buttonView.set( {
17
+ label: t('Timestamp'),
18
+ icon: timestampIcon,
19
+ withText: true,
20
+ tooltip: true
21
+ } );
22
+
23
+ buttonView.on('execute', () => {
24
+ editor.model.change( writer => {
25
+ const attributes = toMap( editor.model.document.selection.getAttributes() );
26
+ const timestamp = writer.createText(formatDate(new Date(), datetimeformat), attributes);
27
+ editor.model.insertContent(timestamp, editor.model.document.selection );
28
+ } );
29
+ } );
30
+
31
+ return buttonView;
32
+ } );
33
+ }
34
+ }
@@ -0,0 +1,98 @@
1
+ import { Command } from '@ckeditor/ckeditor5-core';
2
+ import { findAttributeRange } from '@ckeditor/ckeditor5-typing';
3
+ import { first, toMap } from '@ckeditor/ckeditor5-utils';
4
+ import * as QMSCKEditorConstant from '../common/qmsCKEditorConstant';
5
+ import * as QMSCKEditorService from '../common/qmsCKEditorService';
6
+ import { isTooltipAllowed, TOOLTIP_ATTRIBUTE, findTooltipElementAncestor } from './utils';
7
+
8
+ export default class InsertTooltipCommand extends Command {
9
+ refresh() {
10
+ const model = this.editor.model;
11
+ const doc = model.document;
12
+ const selectedElement = first(doc.selection.getSelectedBlocks() );
13
+
14
+ // A check for the `LinkImage` plugin. If the selection contains an element, get values from the element.
15
+ // Currently the selection reads attributes from text nodes only. See #7429 and #7465.
16
+ if (isTooltipAllowed(selectedElement, model.schema ) ) {
17
+ this.value = selectedElement.getAttribute(TOOLTIP_ATTRIBUTE);
18
+ this.isEnabled = model.schema.checkAttribute(selectedElement, TOOLTIP_ATTRIBUTE);
19
+ } else {
20
+ this.value = doc.selection.getAttribute(TOOLTIP_ATTRIBUTE);
21
+ this.isEnabled = model.schema.checkAttributeInSelection(doc.selection, TOOLTIP_ATTRIBUTE);
22
+ }
23
+ }
24
+
25
+ execute() {
26
+ const model = this.editor.model;
27
+ const selection = model.document.selection;
28
+ let text= '';
29
+ let content = '';
30
+ if(selection.isCollapsed){
31
+ if(selection.hasAttribute(TOOLTIP_ATTRIBUTE)){
32
+ const view = this.editor.editing.view;
33
+ const viewSelection = view.document.selection;
34
+ const selectedElement = findTooltipElementAncestor(viewSelection.getFirstPosition());
35
+ if(selectedElement){
36
+ text = selectedElement.getChild(0).data;
37
+ content = selectedElement.getAttribute(TOOLTIP_ATTRIBUTE);
38
+ }
39
+ }
40
+ }
41
+ else
42
+ {
43
+ const ranges = selection.getFirstRange();
44
+ if(ranges)
45
+ {
46
+ for (const item of ranges.getItems()) {
47
+ if (item.data) {
48
+ text = text + item.data;
49
+ }
50
+ }
51
+ }
52
+ }
53
+
54
+ QMSCKEditorService.tooltipNotify({'text': text, 'content': content});
55
+ window[QMSCKEditorConstant.QMSCK_TOOLTIP_IS_PROCESSING] = false;
56
+ window.addEventListener(QMSCKEditorConstant.QMSCK_TOOLTIP_PLUGIN_RESP, function (evt) {
57
+ if (window[QMSCKEditorConstant.QMSCK_TOOLTIP_IS_PROCESSING]) {
58
+ return;
59
+ }
60
+ window[QMSCKEditorConstant.QMSCK_TOOLTIP_IS_PROCESSING] = true;
61
+ console.log(evt.detail);
62
+ model.change(writer => {
63
+ const position = selection.getFirstPosition();
64
+ const attributes = toMap(selection.getAttributes());
65
+ attributes.set(TOOLTIP_ATTRIBUTE, evt.detail.content);
66
+
67
+ if (selection.isCollapsed) {
68
+ // When selection is inside text with `data-tooltip` attribute.
69
+ if (selection.hasAttribute(TOOLTIP_ATTRIBUTE)) {
70
+ // Then update `data-tooltip` value.
71
+ const linkRange = findAttributeRange(position, TOOLTIP_ATTRIBUTE, selection.getAttribute(TOOLTIP_ATTRIBUTE), model);
72
+ writer.remove(linkRange);
73
+ const newPosition = selection.getFirstPosition();
74
+ const { end: positionAfter } = model.insertContent(writer.createText(evt.detail.text, attributes), newPosition);
75
+ writer.setSelection(positionAfter);
76
+ }
77
+ // If not then insert text node with `data-tooltip` attribute in place of caret.
78
+ // However, since selection is collapsed, attribute value will be used as data for text node.
79
+ // So, if `evt.detail.content` is empty, do not create text node.
80
+ else if (!!evt.detail.content && evt.detail.content !== '') {
81
+ const { end: positionAfter } = model.insertContent(writer.createText(evt.detail.text, attributes), position);
82
+ // Put the selection at the end of the inserted link.
83
+ // Using end of range returned from insertContent in case nodes with the same attributes got merged.
84
+ writer.setSelection(positionAfter);
85
+ }
86
+ } else {
87
+
88
+ const { end: positionAfter } = model.insertContent(writer.createText(evt.detail.text, attributes), selection);
89
+ // Put the selection at the end of the inserted link.
90
+ writer.setSelection(positionAfter);
91
+ }
92
+ // Remove the `data-tooltip` attribute from the selection.
93
+ // It stops adding a new content into the link element.
94
+ writer.removeSelectionAttribute(TOOLTIP_ATTRIBUTE);
95
+ });
96
+ });
97
+ }
98
+ }
@@ -0,0 +1,41 @@
1
+ import { Command } from 'ckeditor5/src/core';
2
+ import { findAttributeRange } from 'ckeditor5/src/typing';
3
+ import { first } from 'ckeditor5/src/utils';
4
+ import { isTooltipAllowed, TOOLTIP_ATTRIBUTE } from './utils';
5
+
6
+ export default class RemoveTooltipCommand extends Command {
7
+ refresh() {
8
+ const model = this.editor.model;
9
+ const doc = model.document;
10
+ const selectedElement = first(doc.selection.getSelectedBlocks());
11
+
12
+ // A check for the `LinkImage` plugin. If the selection contains an image element, get values from the element.
13
+ // Currently the selection reads attributes from text nodes only. See #7429 and #7465.
14
+ if (isTooltipAllowed(selectedElement, model.schema)) {
15
+ this.isEnabled = model.schema.checkAttribute(selectedElement, TOOLTIP_ATTRIBUTE);
16
+ } else {
17
+ this.isEnabled = model.schema.checkAttributeInSelection(doc.selection, TOOLTIP_ATTRIBUTE);
18
+ }
19
+ }
20
+
21
+ execute() {
22
+ const editor = this.editor;
23
+ const model = editor.model;
24
+ const selection = model.document.selection;
25
+
26
+ model.change(writer => {
27
+ const selectedRanges = selection.isCollapsed ?
28
+ [findAttributeRange(
29
+ selection.getFirstPosition(),
30
+ TOOLTIP_ATTRIBUTE,
31
+ selection.getAttribute(TOOLTIP_ATTRIBUTE),
32
+ model
33
+ )] :
34
+ model.schema.getValidRanges(selection.getRanges(), TOOLTIP_ATTRIBUTE);
35
+
36
+ for (const range of selectedRanges) {
37
+ writer.removeAttribute(TOOLTIP_ATTRIBUTE, range);
38
+ }
39
+ });
40
+ }
41
+ }
@@ -0,0 +1,14 @@
1
+
2
+ import { Plugin } from '@ckeditor/ckeditor5-core';
3
+ import TooltipEditing from './tooltipediting';
4
+ import TooltipUI from './tooltipui';
5
+
6
+ export default class Tooltip extends Plugin {
7
+ static get requires() {
8
+ return [TooltipEditing, TooltipUI];
9
+ }
10
+
11
+ static get pluginName() {
12
+ return 'Tooltip';
13
+ }
14
+ }
@@ -0,0 +1,280 @@
1
+ import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
2
+ import '../../themes/tyles/tooltip.css';
3
+ import { TOOLTIP_CUSTOM_PROPERTY, TOOLTIP_ATTRIBUTE, INSERT_TOOLTIP_COMMAND, REMOVE_TOOLTIP_COMMAND, isTyping, shouldCopyAttributes} from './utils';
4
+ import InsertTooltipCommand from './inserttooltipcommand';
5
+ import RemoveTooltipCommand from './removetooltipcommand';
6
+ import {MouseObserver} from '@ckeditor/ckeditor5-engine';
7
+ import { keyCodes } from '@ckeditor/ckeditor5-utils';
8
+ import { Input, TwoStepCaretMovement, findAttributeRange } from '@ckeditor/ckeditor5-typing';
9
+ import { ClipboardPipeline } from '@ckeditor/ckeditor5-clipboard';
10
+
11
+ export default class TooltipEditing extends Plugin {
12
+
13
+ static get pluginName() {
14
+ return 'TooltipEditing';
15
+ }
16
+
17
+ static get requires() {
18
+ // Clipboard is required for handling cut and paste events while typing over the tooltip.
19
+ return [ TwoStepCaretMovement, Input, ClipboardPipeline ];
20
+ }
21
+
22
+ init() {
23
+ const editor = this.editor;
24
+
25
+ editor.model.schema.extend('$text', { allowAttributes: TOOLTIP_ATTRIBUTE });
26
+ editor.conversion.for('upcast').elementToAttribute({
27
+ view: {
28
+ name: 'span',
29
+ attributes: {
30
+ tooltip: true
31
+ }
32
+ },
33
+ model: {
34
+ key: TOOLTIP_ATTRIBUTE,
35
+ value: viewElement => viewElement.getAttribute(TOOLTIP_ATTRIBUTE)
36
+ }
37
+ });
38
+
39
+ editor.conversion.for('downcast').attributeToElement({
40
+ model: TOOLTIP_ATTRIBUTE,
41
+ view: (modelAttributeValue, { writer: viewWriter }) =>{
42
+ const attributes = { class: 'np-tooltip'};
43
+ attributes[TOOLTIP_ATTRIBUTE] = modelAttributeValue;
44
+
45
+ const tooltipElement = viewWriter.createAttributeElement('span', attributes);
46
+ viewWriter.setCustomProperty(TOOLTIP_CUSTOM_PROPERTY, true, tooltipElement);
47
+ return tooltipElement;
48
+ }
49
+ });
50
+
51
+ editor.commands.add(INSERT_TOOLTIP_COMMAND, new InsertTooltipCommand(editor));
52
+ editor.commands.add(REMOVE_TOOLTIP_COMMAND, new RemoveTooltipCommand(editor));
53
+
54
+ // Enable two-step caret movement for `data-tooltip` attribute.
55
+ const twoStepCaretMovementPlugin = editor.plugins.get(TwoStepCaretMovement);
56
+ twoStepCaretMovementPlugin.registerAttribute(TOOLTIP_ATTRIBUTE);
57
+
58
+ // Change the attributes of the selection in certain situations after the link was inserted into the document.
59
+ this._enableInsertContentSelectionAttributesFixer();
60
+
61
+ // Handle a click at the beginning/end of a tooltip element.
62
+ this._enableClickingAtBeginingOrEndTooltip();
63
+
64
+ // Handle typing over the tooltip element.
65
+ this._enableTypingOverTooltip();
66
+
67
+ // Handle removing the content after the tooltip element.
68
+ this._handleDeleteContent();
69
+ }
70
+
71
+ _enableInsertContentSelectionAttributesFixer() {
72
+ const editor = this.editor;
73
+ const model = editor.model;
74
+ const selection = model.document.selection;
75
+
76
+ this.listenTo(model, 'insertContent', () => {
77
+ const nodeBefore = selection.anchor.nodeBefore;
78
+ const nodeAfter = selection.anchor.nodeAfter;
79
+
80
+ if (!selection.hasAttribute(TOOLTIP_ATTRIBUTE)) {
81
+ return;
82
+ }
83
+
84
+ if (!nodeBefore) {
85
+ return;
86
+ }
87
+
88
+ if (!nodeBefore.hasAttribute(TOOLTIP_ATTRIBUTE)) {
89
+ return;
90
+ }
91
+
92
+ if (nodeAfter && nodeAfter.hasAttribute(TOOLTIP_ATTRIBUTE)) {
93
+ return;
94
+ }
95
+ //console.log('_enableInsertContentSelectionAttributesFixer==>insertContent==>writer.removeSelectionAttribute(TOOLTIP_ATTRIBUTE)');
96
+
97
+ model.change(writer => {
98
+ writer.removeSelectionAttribute(TOOLTIP_ATTRIBUTE);
99
+ });
100
+ }, { priority: 'low' });
101
+ }
102
+
103
+ _enableTypingOverTooltip() {
104
+ const editor = this.editor;
105
+ const view = editor.editing.view;
106
+
107
+ // Selection attributes when started typing over the tooltip.
108
+ let selectionAttributes;
109
+
110
+ // Whether pressed `Backspace` or `Delete`. If so, attributes should not be preserved.
111
+ let deletedContent;
112
+
113
+ // Detect pressing `Backspace` / `Delete`.
114
+
115
+ this.listenTo(view.document, 'delete', () => {
116
+ deletedContent = true;
117
+ }, { priority: 'high' });
118
+
119
+ // Listening to `model#deleteContent` allows detecting whether selected content was the tooltip.
120
+ // If so, before removing the element, we will copy its attributes.
121
+ this.listenTo(editor.model, 'deleteContent', () => {
122
+ const selection = editor.model.document.selection;
123
+
124
+ // Copy attributes only if anything is selected.
125
+ if (selection.isCollapsed) {
126
+ return;
127
+ }
128
+
129
+ // When the content was deleted, do not preserve attributes.
130
+ if (deletedContent) {
131
+ deletedContent = false;
132
+ return;
133
+ }
134
+
135
+ // Enabled only when typing.
136
+ if (!isTyping(editor)) {
137
+ return;
138
+ }
139
+
140
+ if (shouldCopyAttributes(editor.model)) {
141
+ selectionAttributes = selection.getAttributes();
142
+ }
143
+ }, { priority: 'high' });
144
+
145
+ // Listening to `model#insertContent` allows detecting the content insertion.
146
+ // We want to apply attributes that were removed while typing over the tooltip.
147
+ this.listenTo(editor.model, 'insertContent', (evt, [ element ]) => {
148
+ deletedContent = false;
149
+ //console.log('_enableTypingOverTooltip==>insertContent==>isTyping(editor): ' + isTyping(editor));
150
+
151
+ // Enabled only when typing.
152
+ if (!isTyping(editor)) {
153
+ return;
154
+ }
155
+
156
+ if (!selectionAttributes) {
157
+ return;
158
+ }
159
+ //console.log('_enableTypingOverTooltip==>insertContent==>selectionAttributes: ');
160
+ //console.log(selectionAttributes);
161
+
162
+ editor.model.change(writer => {
163
+ for (const [ attribute, value ] of selectionAttributes) {
164
+ writer.setAttribute(attribute, value, element);
165
+ }
166
+ });
167
+
168
+ selectionAttributes = null;
169
+ }, { priority: 'high' });
170
+ }
171
+
172
+ _enableClickingAtBeginingOrEndTooltip() {
173
+ const editor = this.editor;
174
+ const selection = editor.model.document.selection;
175
+ editor.editing.view.addObserver(MouseObserver);
176
+ let clicked = false;
177
+
178
+ // Detect the click.
179
+ this.listenTo(editor.editing.view.document, 'mousedown', () => {
180
+ clicked = true;
181
+ });
182
+
183
+ // When the selection has changed...
184
+ this.listenTo(editor.editing.view.document, 'selectionChange', () => {
185
+
186
+ if (!clicked) {
187
+ return;
188
+ }
189
+
190
+ // ...and it was caused by the click...
191
+ clicked = false;
192
+
193
+ // ...and no text is selected...
194
+ if (!selection.isCollapsed) {
195
+ return;
196
+ }
197
+
198
+ //console.log('_enableClickingAtBeginingOrEndTooltip==>selectionChange==>selection.hasAttribute(TOOLTIP_ATTRIBUTE): ' + selection.hasAttribute(TOOLTIP_ATTRIBUTE));
199
+ // ...and clicked text is the tooltip...
200
+ if (!selection.hasAttribute(TOOLTIP_ATTRIBUTE)) {
201
+ return;
202
+ }
203
+
204
+ const position = selection.getFirstPosition();
205
+ const selectedRange = findAttributeRange(position, TOOLTIP_ATTRIBUTE, selection.getAttribute(TOOLTIP_ATTRIBUTE), editor.model);
206
+
207
+ // ...check whether clicked start/end boundary of the tooltip.
208
+ // If so, remove the `tooltip` attribute.
209
+ const isTouching = position.isTouching(selectedRange.start) || position.isTouching(selectedRange.end);
210
+ //console.log('_enableClickingAtBeginingOrEndTooltip==>selectionChange==>isTouching: ' + isTouching);
211
+ if (isTouching) {
212
+ editor.model.change(writer => {
213
+ writer.removeSelectionAttribute(TOOLTIP_ATTRIBUTE);
214
+ });
215
+ }
216
+ });
217
+ }
218
+
219
+ _handleDeleteContent() {
220
+ const editor = this.editor;
221
+ const model = editor.model;
222
+ const selection = model.document.selection;
223
+ const view = editor.editing.view;
224
+
225
+ // A flag whether attributes `tooltip` attribute should be preserved.
226
+ let shouldPreserveAttributes = false;
227
+
228
+ // A flag whether the `Backspace` key was pressed.
229
+ let hasBackspacePressed = false;
230
+
231
+ // Detect pressing `Backspace`.
232
+ this.listenTo(view.document, 'delete', (evt, data) => {
233
+ hasBackspacePressed = data.domEvent.keyCode === keyCodes.backspace;
234
+ }, { priority: 'high' });
235
+
236
+ // Before removing the content, check whether the selection is inside a tooltip or at the end of tooltip but with 2-SCM enabled.
237
+ // If so, we want to preserve tooltip attributes.
238
+ this.listenTo(model, 'deleteContent', () => {
239
+ // Reset the state.
240
+ shouldPreserveAttributes = false;
241
+
242
+ const position = selection.getFirstPosition();
243
+ const tooltip = selection.getAttribute(TOOLTIP_ATTRIBUTE);
244
+
245
+ if (!tooltip) {
246
+ return;
247
+ }
248
+
249
+ const selectedRange = findAttributeRange(position, TOOLTIP_ATTRIBUTE, tooltip, model);
250
+
251
+ // Preserve `tooltip` attribute if the selection is in the middle of the tooltip or
252
+ // the selection is at the end of the tooltip and 2-SCM is activated.
253
+ shouldPreserveAttributes = selectedRange.containsPosition(position) || selectedRange.end.isEqual(position);
254
+ }, { priority: 'high' });
255
+
256
+ // After removing the content, check whether the current selection should preserve the `tooltip` attribute.
257
+ this.listenTo(model, 'deleteContent', () => {
258
+ // If didn't press `Backspace`.
259
+ if (!hasBackspacePressed) {
260
+ return;
261
+ }
262
+
263
+ //console.log('_handleDeleteContent==>deleteContent==>shouldPreserveAttributes: ' + shouldPreserveAttributes);
264
+
265
+ hasBackspacePressed = false;
266
+
267
+ // Disable the mechanism if inside a tooltip (`<$text url="foo">F[]oo</$text>` or <$text url="foo">Foo[]</$text>`).
268
+ if (shouldPreserveAttributes) {
269
+ return;
270
+ }
271
+
272
+ // Use `model.enqueueChange()` in order to execute the callback at the end of the changes process.
273
+ editor.model.enqueueChange(writer => {
274
+ writer.removeSelectionAttribute(TOOLTIP_ATTRIBUTE);
275
+ });
276
+ }, { priority: 'low' });
277
+ }
278
+
279
+ }
280
+