qms-angular 1.0.30 → 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.
- package/bundles/qms-angular.umd.js +902 -496
- package/bundles/qms-angular.umd.js.map +1 -1
- package/esm2015/lib/components/breadcrumb/breadcrumb.js +39 -41
- package/esm2015/lib/components/breadcrumb/enum/dropdown-node-width.enum.js +6 -0
- package/esm2015/lib/components/button/button-toggle.js +1 -1
- package/esm2015/lib/components/dialog/constant.js +4 -2
- package/esm2015/lib/components/dialog/dialog.js +4 -4
- package/esm2015/lib/components/related/common/data-type.enum.js +2 -2
- package/esm2015/lib/components/related/common/qms-icon.const.js +21 -1
- package/esm2015/lib/components/related/common/tree.function.js +10 -5
- package/esm2015/lib/components/related/list-other-related/list-related.component.js +6 -2
- package/esm2015/lib/components/related/model/popup-data.model.js +2 -1
- package/esm2015/lib/components/related/model/related-data.model.js +1 -1
- package/esm2015/lib/components/related/model/tree-config.model.js +1 -1
- package/esm2015/lib/components/related/model/tree-node.model.js +1 -1
- package/esm2015/lib/components/related/popup/related-popup.component.js +179 -12
- package/esm2015/lib/components/related/related.module.js +7 -5
- package/esm2015/lib/components/related/risk/analysis/analysis.component.js +1 -1
- package/esm2015/lib/components/related/service/related-global.service.js +5 -1
- package/esm2015/lib/components/related/tree/tree.component.js +30 -7
- package/esm2015/lib/components/table/table-action.js +2 -2
- package/esm2015/lib/directives/scrollbar/scrollbar.directive.js +8 -2
- package/esm2015/lib/model/en.js +7 -2
- package/esm2015/lib/model/no.js +7 -2
- package/esm2015/lib/qms-ckeditor-components/common/constants/ckeditorEvent.constant.js +3 -1
- package/esm2015/lib/qms-ckeditor-components/common/models/qms-ckeditor-data.model.js +1 -1
- package/esm2015/lib/qms-ckeditor-components/common/models/qms-ckeditor-input.model.js +2 -1
- package/esm2015/lib/qms-ckeditor-components/common/module/confirm/qms-ckeditor-confirm.component.js +1 -1
- package/esm2015/lib/qms-ckeditor-components/components/qms-ckeditor-link/attachments/link-attachment.component.js +1 -1
- package/esm2015/lib/qms-ckeditor-components/components/qms-ckeditor-link/qms-ckeditor-link.component.js +1 -1
- package/esm2015/lib/qms-ckeditor-components/components/qms-ckeditor-load-template/qms-ckeditor-load-template.component.js +1 -1
- package/esm2015/lib/qms-ckeditor-components/components/qms-ckeditor-relation/qmsckeditor-related.component.js +1 -1
- package/esm2015/lib/qms-ckeditor-components/components/qms-ckeditor-template/qms-ckeditor-template.component.js +1 -1
- package/esm2015/lib/qms-ckeditor-components/components/qms-ckeditor-tooltip/qms-ckeditor-tooltip.component.js +76 -0
- package/esm2015/lib/qms-ckeditor-components/models/qms-ckeditor-tooltip.model.js +7 -0
- package/esm2015/lib/qms-ckeditor-components/qms-ckeditor.component.js +51 -2
- package/esm2015/lib/qms-ckeditor-components/qms-ckeditor.module.js +4 -2
- package/esm2015/qms-angular.js +3 -1
- package/fesm2015/qms-angular.js +864 -476
- package/fesm2015/qms-angular.js.map +1 -1
- package/lib/components/breadcrumb/breadcrumb.d.ts +1 -0
- package/lib/components/breadcrumb/enum/dropdown-node-width.enum.d.ts +4 -0
- package/lib/components/related/common/data-type.enum.d.ts +1 -1
- package/lib/components/related/common/qms-icon.const.d.ts +4 -0
- package/lib/components/related/list-other-related/list-related.component.d.ts +1 -0
- package/lib/components/related/model/popup-data.model.d.ts +1 -0
- package/lib/components/related/model/related-data.model.d.ts +4 -0
- package/lib/components/related/model/tree-config.model.d.ts +1 -0
- package/lib/components/related/model/tree-node.model.d.ts +1 -0
- package/lib/components/related/popup/related-popup.component.d.ts +18 -0
- package/lib/components/related/service/related-global.service.d.ts +2 -0
- package/lib/components/related/tree/tree.component.d.ts +7 -1
- package/lib/directives/scrollbar/scrollbar.directive.d.ts +1 -0
- package/lib/model/en.d.ts +6 -1
- package/lib/model/no.d.ts +6 -1
- package/lib/qms-ckeditor-components/common/constants/ckeditorEvent.constant.d.ts +2 -0
- package/lib/qms-ckeditor-components/common/models/qms-ckeditor-data.model.d.ts +1 -0
- package/lib/qms-ckeditor-components/common/models/qms-ckeditor-input.model.d.ts +1 -0
- package/lib/qms-ckeditor-components/components/qms-ckeditor-tooltip/qms-ckeditor-tooltip.component.d.ts +36 -0
- package/lib/qms-ckeditor-components/models/qms-ckeditor-tooltip.model.d.ts +6 -0
- package/lib/qms-ckeditor-components/qms-ckeditor.component.d.ts +6 -0
- package/package.json +1 -1
- package/qms-angular.d.ts +2 -0
- package/qms-angular.metadata.json +1 -1
- package/src/assets/qms-ckeditor-plugin/build/ckeditor.js +2 -1
- package/src/assets/qms-ckeditor-plugin/build/ckeditor.js.map +1 -1
- package/src/assets/qms-ckeditor-plugin/package-lock.json +852 -2063
- package/src/assets/qms-ckeditor-plugin/package.json +25 -19
- package/src/assets/qms-ckeditor-plugin/src/ckeditor.js +10 -2
- package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-find-and-replace/src/findandreplace.js +132 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-find-and-replace/src/findandreplaceediting.js +315 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-find-and-replace/src/findandreplaceui.js +223 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-find-and-replace/src/findcommand.js +90 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-find-and-replace/src/findnextcommand.js +62 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-find-and-replace/src/findpreviouscommand.js +28 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-find-and-replace/src/index.js +10 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-find-and-replace/src/replaceallcommand.js +54 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-find-and-replace/src/replacecommand.js +66 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-find-and-replace/src/ui/checkboxview.js +212 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-find-and-replace/src/ui/findandreplaceformview.js +546 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-find-and-replace/src/utils.js +158 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-find-and-replace/theme/findandreplace.css +13 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-find-and-replace/theme/findandreplaceform.css +226 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-find-and-replace/theme/icons/find-replace.svg +1 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharacters.js +4 -4
- package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharactersarrows.js +1 -1
- package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharacterscurrency.js +1 -1
- package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharactersessentials.js +1 -1
- package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharacterslatin.js +1 -1
- package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharactersmathematical.js +1 -1
- package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharacterstext.js +1 -1
- package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/ui/charactergridview.js +1 -1
- package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/ui/characterinfoview.js +1 -1
- package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/ui/specialcharactersnavigationview.js +2 -2
- package/src/assets/qms-ckeditor-plugin/src/plugins/common/qmsCKEditorConstant.js +4 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/common/qmsCKEditorService.js +10 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/tooltip/inserttooltipcommand.js +98 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/tooltip/removetooltipcommand.js +41 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/tooltip/tooltip.js +14 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/tooltip/tooltipediting.js +280 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/tooltip/tooltipui.js +203 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/tooltip/ui/actionsview.js +95 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/tooltip/utils.js +70 -0
- package/src/assets/qms-ckeditor-plugin/src/themes/icons/information.svg +50 -0
- package/src/assets/qms-ckeditor-plugin/src/themes/tyles/tooltip.css +74 -0
- package/src/lib/components/breadcrumb/breadcrumb.scss +9 -0
- package/src/lib/components/button/button-toggle.scss +25 -1
- package/src/lib/components/dialog/dialog.scss +9 -0
- package/src/lib/components/related/popup/related-popup.component.scss +46 -0
- package/src/lib/components/table/table.scss +5 -27
- package/src/lib/qms-ckeditor-components/components/qms-ckeditor-tooltip/qms-ckeditor-tooltip.component.scss +11 -0
- package/src/lib/qms-ckeditor-components/qms-ckeditor.component.scss +29 -1
- package/src/lib/qms-ckeditor-components/styles/_modules.scss +6 -0
- package/src/themes/core/_form.scss +4 -0
- package/src/themes/core/_input.scss +8 -0
- package/src/themes/core/_scrollbar.scss +9 -2
- package/src/themes/core/_styles.scss +5 -0
- package/src/themes/core/_tab.scss +272 -6
@@ -7,13 +7,34 @@
|
|
7
7
|
"private": true,
|
8
8
|
"main": "./build/ckeditor.js",
|
9
9
|
"devDependencies": {
|
10
|
+
"css-loader": "^5.2.4",
|
11
|
+
"postcss": "^8.2.10",
|
12
|
+
"postcss-loader": "^4.2.0",
|
13
|
+
"raw-loader": "^4.0.2",
|
14
|
+
"style-loader": "^2.0.0",
|
15
|
+
"terser-webpack-plugin": "^4.2.3",
|
16
|
+
"webpack": "^4.46.0",
|
17
|
+
"webpack-cli": "^4.7.2"
|
18
|
+
},
|
19
|
+
"scripts": {
|
20
|
+
"build-prod": "webpack --mode production",
|
21
|
+
"build": "webpack --mode development",
|
22
|
+
"dev": "webpack --watch --mode development"
|
23
|
+
},
|
24
|
+
"dependencies": {
|
25
|
+
"@ckeditor/ckeditor5-core": "^27.1.0",
|
26
|
+
"@ckeditor/ckeditor5-utils": "^27.1.0",
|
27
|
+
"@ckeditor/ckeditor5-typing": "^27.1.0",
|
28
|
+
"@ckeditor/ckeditor5-dev-utils": "^24.4.2",
|
29
|
+
"@ckeditor/ckeditor5-ui": "^27.1.0",
|
30
|
+
"@ckeditor/ckeditor5-alignment": "^27.1.0",
|
31
|
+
"@ckeditor/ckeditor5-font": "^27.1.0",
|
10
32
|
"@ckeditor/ckeditor5-adapter-ckfinder": "^27.1.0",
|
11
33
|
"@ckeditor/ckeditor5-autoformat": "^27.1.0",
|
12
34
|
"@ckeditor/ckeditor5-basic-styles": "^27.1.0",
|
13
35
|
"@ckeditor/ckeditor5-special-characters": "^29.2.0",
|
14
36
|
"@ckeditor/ckeditor5-block-quote": "^27.1.0",
|
15
37
|
"@ckeditor/ckeditor5-ckfinder": "^27.1.0",
|
16
|
-
"@ckeditor/ckeditor5-dev-utils": "^24.4.2",
|
17
38
|
"@ckeditor/ckeditor5-dev-webpack-plugin": "^24.4.2",
|
18
39
|
"@ckeditor/ckeditor5-editor-classic": "^27.1.0",
|
19
40
|
"@ckeditor/ckeditor5-essentials": "^27.1.0",
|
@@ -28,25 +49,10 @@
|
|
28
49
|
"@ckeditor/ckeditor5-paste-from-office": "^27.1.0",
|
29
50
|
"@ckeditor/ckeditor5-table": "^27.1.0",
|
30
51
|
"@ckeditor/ckeditor5-theme-lark": "^27.1.0",
|
31
|
-
"@ckeditor/ckeditor5-typing": "^27.1.0",
|
32
52
|
"@ckeditor/ckeditor5-word-count": "^27.1.0",
|
33
|
-
"
|
34
|
-
"
|
35
|
-
"
|
36
|
-
"raw-loader": "^4.0.2",
|
37
|
-
"style-loader": "^2.0.0",
|
38
|
-
"terser-webpack-plugin": "^4.2.3",
|
39
|
-
"webpack": "^4.46.0",
|
40
|
-
"webpack-cli": "^4.7.2"
|
41
|
-
},
|
42
|
-
"scripts": {
|
43
|
-
"build-prod": "webpack --mode production",
|
44
|
-
"build": "webpack --mode development",
|
45
|
-
"dev": "webpack --watch --mode development"
|
46
|
-
},
|
47
|
-
"dependencies": {
|
48
|
-
"@ckeditor/ckeditor5-alignment": "^27.1.0",
|
49
|
-
"@ckeditor/ckeditor5-font": "^27.1.0",
|
53
|
+
"@ckeditor/ckeditor5-find-and-replace": "^28.0.1",
|
54
|
+
"@ckeditor/ckeditor5-clipboard": "27.1.0",
|
55
|
+
"@wiris/mathtype-ckeditor5": "^7.27.0",
|
50
56
|
"qms-angular": "^1.0.2"
|
51
57
|
}
|
52
58
|
}
|
@@ -49,6 +49,7 @@ import VideoUpload from './plugins/video/videoupload.js';
|
|
49
49
|
import RemoveFormat from '@ckeditor/ckeditor5-remove-format/src/removeformat.js';
|
50
50
|
import Superscript from '@ckeditor/ckeditor5-basic-styles/src/superscript.js';
|
51
51
|
import Subscript from '@ckeditor/ckeditor5-basic-styles/src/subscript.js';
|
52
|
+
import MathType from '@wiris/mathtype-ckeditor5';
|
52
53
|
import Timestamp from './plugins/timestamp/timestamp.js';
|
53
54
|
import SpecialCharacters from './plugins/ckeditor5-special-characters/src/specialcharacters.js';
|
54
55
|
import SpecialCharactersArrows from './plugins/ckeditor5-special-characters/src/specialcharactersarrows.js';
|
@@ -56,6 +57,9 @@ import specialcharacterscurrency from './plugins/ckeditor5-special-characters/sr
|
|
56
57
|
import SpecialCharactersLatin from './plugins/ckeditor5-special-characters/src/specialcharacterslatin.js';
|
57
58
|
import SpecialCharactersText from './plugins/ckeditor5-special-characters/src/specialcharacterstext.js';
|
58
59
|
import SpecialCharactersMathematical from './plugins/ckeditor5-special-characters/src/specialcharactersmathematical.js';
|
60
|
+
import Clipboard from '@ckeditor/ckeditor5-clipboard/src/clipboard';
|
61
|
+
import FindAndReplace from './plugins/ckeditor5-find-and-replace/src/findandreplace.js';
|
62
|
+
import Tooltip from './plugins/tooltip/tooltip.js';
|
59
63
|
|
60
64
|
class Editor extends ClassicEditor {}
|
61
65
|
|
@@ -88,7 +92,6 @@ Editor.builtinPlugins = [
|
|
88
92
|
MediaResize,
|
89
93
|
MediaStyle,
|
90
94
|
Paragraph,
|
91
|
-
PasteFromOffice,
|
92
95
|
Table,
|
93
96
|
TableToolbar,
|
94
97
|
TextTransformation,
|
@@ -105,13 +108,18 @@ Editor.builtinPlugins = [
|
|
105
108
|
RemoveFormat,
|
106
109
|
Superscript,
|
107
110
|
Subscript,
|
111
|
+
MathType,
|
108
112
|
Timestamp,
|
109
113
|
SpecialCharacters,
|
110
114
|
SpecialCharactersArrows,
|
111
115
|
specialcharacterscurrency,
|
112
116
|
SpecialCharactersLatin,
|
113
117
|
SpecialCharactersText,
|
114
|
-
SpecialCharactersMathematical
|
118
|
+
SpecialCharactersMathematical,
|
119
|
+
Clipboard,
|
120
|
+
PasteFromOffice,
|
121
|
+
Tooltip,
|
122
|
+
FindAndReplace
|
115
123
|
];
|
116
124
|
|
117
125
|
export default Editor;
|
package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-find-and-replace/src/findandreplace.js
ADDED
@@ -0,0 +1,132 @@
|
|
1
|
+
/**
|
2
|
+
* @license 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
|
+
* @module find-and-replace/findandreplace
|
8
|
+
*/
|
9
|
+
|
10
|
+
import { Plugin } from '@ckeditor/ckeditor5-core';
|
11
|
+
import FindAndReplaceUI from './findandreplaceui';
|
12
|
+
import FindAndReplaceEditing from './findandreplaceediting';
|
13
|
+
|
14
|
+
/**
|
15
|
+
* The find and replace plugin.
|
16
|
+
*
|
17
|
+
* For a detailed overview, check the {@glink features/find-and-replace Find and replace feature documentation}.
|
18
|
+
*
|
19
|
+
* This is a "glue" plugin which loads the following plugins:
|
20
|
+
*
|
21
|
+
* * The {@link module:find-and-replace/findandreplaceediting~FindAndReplaceEditing find and replace editing feature},
|
22
|
+
* * The {@link module:find-and-replace/findandreplaceui~FindAndReplaceUI find and replace UI feature}
|
23
|
+
*
|
24
|
+
* @extends module:core/plugin~Plugin
|
25
|
+
*/
|
26
|
+
export default class FindAndReplace extends Plugin {
|
27
|
+
/**
|
28
|
+
* @inheritDoc
|
29
|
+
*/
|
30
|
+
static get requires() {
|
31
|
+
return [ FindAndReplaceEditing, FindAndReplaceUI ];
|
32
|
+
}
|
33
|
+
|
34
|
+
/**
|
35
|
+
* @inheritDoc
|
36
|
+
*/
|
37
|
+
static get pluginName() {
|
38
|
+
return 'FindAndReplace';
|
39
|
+
}
|
40
|
+
|
41
|
+
init() {
|
42
|
+
const ui = this.editor.plugins.get( 'FindAndReplaceUI' );
|
43
|
+
const findAndReplaceEditing = this.editor.plugins.get( 'FindAndReplaceEditing' );
|
44
|
+
|
45
|
+
/**
|
46
|
+
* Delegate find next request.
|
47
|
+
*/
|
48
|
+
ui.on( 'findNext', ( event, data ) => {
|
49
|
+
// Data is contained only for the "find" button.
|
50
|
+
if ( data ) {
|
51
|
+
findAndReplaceEditing.state.searchText = data.searchText;
|
52
|
+
this.editor.execute( 'find', data.searchText, data );
|
53
|
+
} else {
|
54
|
+
// Arrow button press.
|
55
|
+
this.editor.execute( 'findNext' );
|
56
|
+
}
|
57
|
+
} );
|
58
|
+
|
59
|
+
/**
|
60
|
+
* Delegate find previous request
|
61
|
+
*/
|
62
|
+
ui.on( 'findPrevious', ( event, data ) => {
|
63
|
+
if ( data && findAndReplaceEditing.state.searchText !== data.searchText ) {
|
64
|
+
this.editor.execute( 'find', data.searchText );
|
65
|
+
} else {
|
66
|
+
// Subsequent calls.
|
67
|
+
this.editor.execute( 'findPrevious' );
|
68
|
+
}
|
69
|
+
} );
|
70
|
+
|
71
|
+
/**
|
72
|
+
* Delegate replace action.
|
73
|
+
*/
|
74
|
+
ui.on( 'replace', ( event, data ) => {
|
75
|
+
if ( findAndReplaceEditing.state.searchText !== data.searchText ) {
|
76
|
+
this.editor.execute( 'find', data.searchText );
|
77
|
+
}
|
78
|
+
|
79
|
+
const highlightedResult = findAndReplaceEditing.state.highlightedResult;
|
80
|
+
|
81
|
+
if ( highlightedResult ) {
|
82
|
+
this.editor.execute( 'replace', data.replaceText, highlightedResult );
|
83
|
+
}
|
84
|
+
} );
|
85
|
+
|
86
|
+
/**
|
87
|
+
* Delegate replace all action.
|
88
|
+
*/
|
89
|
+
ui.on( 'replaceAll', ( event, data ) => {
|
90
|
+
// The state hadn't been yet built for this search text.
|
91
|
+
if ( findAndReplaceEditing.state.searchText !== data.searchText ) {
|
92
|
+
this.editor.execute( 'find', data.searchText );
|
93
|
+
}
|
94
|
+
|
95
|
+
this.editor.execute( 'replaceAll', data.replaceText, findAndReplaceEditing.state.results );
|
96
|
+
} );
|
97
|
+
|
98
|
+
ui.on( 'dropdown:closed', () => {
|
99
|
+
findAndReplaceEditing.state.clear( this.editor.model );
|
100
|
+
findAndReplaceEditing.stop();
|
101
|
+
} );
|
102
|
+
|
103
|
+
if ( this.editor.ui ) {
|
104
|
+
// We need to wait for the UI to be ready to have the toolbar dropdown available.
|
105
|
+
// Otherwise the findAndReplace component is registered but not yet constructed.
|
106
|
+
this.listenTo( this.editor.ui, 'ready', () => {
|
107
|
+
const formView = ui.formView;
|
108
|
+
// If the editor doesn't contain the findAndReplace button then there's no ui#formView property.
|
109
|
+
if ( formView ) {
|
110
|
+
const commands = this.editor.commands;
|
111
|
+
|
112
|
+
formView.findNextButtonView.bind( 'isEnabled' ).to( commands.get( 'findNext' ), 'isEnabled' );
|
113
|
+
formView.findPrevButtonView.bind( 'isEnabled' ).to( commands.get( 'findPrevious' ), 'isEnabled' );
|
114
|
+
|
115
|
+
formView.replaceButtonView.unbind( 'isEnabled' );
|
116
|
+
formView.replaceButtonView.bind( 'isEnabled' ).to(
|
117
|
+
commands.get( 'replace' ), 'isEnabled', formView, 'isSearching', ( commandEnabled, isSearching ) => {
|
118
|
+
return commandEnabled && isSearching;
|
119
|
+
} );
|
120
|
+
|
121
|
+
formView.replaceAllButtonView.unbind( 'isEnabled' );
|
122
|
+
formView.replaceAllButtonView.bind( 'isEnabled' ).to(
|
123
|
+
commands.get( 'replaceAll' ), 'isEnabled', formView, 'isSearching', ( commandEnabled, isSearching ) => {
|
124
|
+
return commandEnabled && isSearching;
|
125
|
+
} );
|
126
|
+
}
|
127
|
+
} );
|
128
|
+
}
|
129
|
+
|
130
|
+
ui._setState( findAndReplaceEditing.state );
|
131
|
+
}
|
132
|
+
}
|
@@ -0,0 +1,315 @@
|
|
1
|
+
/**
|
2
|
+
* @license 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
|
+
* @module find-and-replace/findandreplaceediting
|
8
|
+
*/
|
9
|
+
|
10
|
+
import { Plugin } from '@ckeditor/ckeditor5-core';
|
11
|
+
import { updateFindResultFromRange } from './utils';
|
12
|
+
import FindCommand from './findcommand';
|
13
|
+
import ReplaceCommand from './replacecommand';
|
14
|
+
import ReplaceAllCommand from './replaceallcommand';
|
15
|
+
import FindNextCommand from './findnextcommand';
|
16
|
+
import FindPreviousCommand from './findpreviouscommand';
|
17
|
+
|
18
|
+
import { ObservableMixin, mix, Collection } from '@ckeditor/ckeditor5-utils';
|
19
|
+
// eslint-disable-next-line ckeditor5-rules/ckeditor-imports
|
20
|
+
import { scrollViewportToShowTarget } from '@ckeditor/ckeditor5-utils/src/dom/scroll';
|
21
|
+
|
22
|
+
import { debounce } from 'lodash-es';
|
23
|
+
|
24
|
+
import '../theme/findandreplace.css';
|
25
|
+
|
26
|
+
/**
|
27
|
+
* The object storing find & replace plugin state in a given editor instance.
|
28
|
+
*
|
29
|
+
*/
|
30
|
+
class FindAndReplaceState {
|
31
|
+
constructor( model ) {
|
32
|
+
this.set( 'results', new Collection() );
|
33
|
+
|
34
|
+
this.set( 'highlightedResult', null );
|
35
|
+
|
36
|
+
this.set( 'searchText', '' );
|
37
|
+
|
38
|
+
this.set( 'replaceText', '' );
|
39
|
+
|
40
|
+
this.set( 'matchCase', false );
|
41
|
+
this.set( 'matchWholeWords', false );
|
42
|
+
|
43
|
+
this.results.on( 'change', ( eventInfo, { removed, index } ) => {
|
44
|
+
removed = Array.from( removed );
|
45
|
+
|
46
|
+
if ( removed.length ) {
|
47
|
+
let highlightedResultRemoved = false;
|
48
|
+
|
49
|
+
model.change( writer => {
|
50
|
+
for ( const removedResult of removed ) {
|
51
|
+
if ( this.highlightedResult === removedResult ) {
|
52
|
+
highlightedResultRemoved = true;
|
53
|
+
}
|
54
|
+
|
55
|
+
if ( model.markers.has( removedResult.marker.name ) ) {
|
56
|
+
writer.removeMarker( removedResult.marker );
|
57
|
+
}
|
58
|
+
}
|
59
|
+
} );
|
60
|
+
|
61
|
+
if ( highlightedResultRemoved ) {
|
62
|
+
const nextHighlightedIndex = index >= this.results.length ? 0 : index;
|
63
|
+
this.highlightedResult = this.results.get( nextHighlightedIndex );
|
64
|
+
}
|
65
|
+
}
|
66
|
+
} );
|
67
|
+
}
|
68
|
+
|
69
|
+
clear( model ) {
|
70
|
+
// @todo: actually this handling might be moved to editing part.
|
71
|
+
// This could be a results#change listener that would ensure that related markers are ALWAYS removed without
|
72
|
+
// having to call state.clear() explicitly.
|
73
|
+
|
74
|
+
this.searchText = '';
|
75
|
+
// this.replaceText = '';
|
76
|
+
|
77
|
+
model.change( writer => {
|
78
|
+
if ( this.highlightedResult ) {
|
79
|
+
const oldMatchId = this.highlightedResult.marker.name.split( ':' )[ 1 ];
|
80
|
+
const oldMarker = model.markers.get( `findResultHighlighted:${ oldMatchId }` );
|
81
|
+
|
82
|
+
if ( oldMarker ) {
|
83
|
+
writer.removeMarker( oldMarker );
|
84
|
+
}
|
85
|
+
}
|
86
|
+
|
87
|
+
[ ...this.results ].forEach( ( { marker } ) => {
|
88
|
+
writer.removeMarker( marker );
|
89
|
+
} );
|
90
|
+
} );
|
91
|
+
|
92
|
+
this.results.clear();
|
93
|
+
}
|
94
|
+
}
|
95
|
+
|
96
|
+
mix( FindAndReplaceState, ObservableMixin );
|
97
|
+
|
98
|
+
const HIGHLIGHT_CLASS = 'ck-find-result_selected';
|
99
|
+
|
100
|
+
// Reacts to document changes in order to update search list.
|
101
|
+
function onDocumentChange( results, model, searchCallback ) {
|
102
|
+
const changedNodes = new Set();
|
103
|
+
const removedMarkers = new Set();
|
104
|
+
|
105
|
+
const changes = model.document.differ.getChanges();
|
106
|
+
|
107
|
+
// Get nodes in which changes happened to re-run a search callback on them.
|
108
|
+
changes.forEach( change => {
|
109
|
+
if ( change.name === '$text' || model.schema.isInline( change.position.nodeAfter ) ) {
|
110
|
+
changedNodes.add( change.position.parent );
|
111
|
+
|
112
|
+
[ ...model.markers.getMarkersAtPosition( change.position ) ].forEach( markerAtChange => {
|
113
|
+
removedMarkers.add( markerAtChange.name );
|
114
|
+
} );
|
115
|
+
} else if ( change.type === 'insert' ) {
|
116
|
+
changedNodes.add( change.position.nodeAfter );
|
117
|
+
}
|
118
|
+
} );
|
119
|
+
|
120
|
+
// Get markers from removed nodes also.
|
121
|
+
model.document.differ.getChangedMarkers().forEach( ( { name, data: { newRange } } ) => {
|
122
|
+
if ( newRange && newRange.start.root.rootName === '$graveyard' ) {
|
123
|
+
removedMarkers.add( name );
|
124
|
+
}
|
125
|
+
} );
|
126
|
+
|
127
|
+
// Get markers from the updated nodes and remove all (search will be re-run on these nodes).
|
128
|
+
changedNodes.forEach( node => {
|
129
|
+
const markersInNode = [ ...model.markers.getMarkersIntersectingRange( model.createRangeIn( node ) ) ];
|
130
|
+
|
131
|
+
markersInNode.forEach( marker => removedMarkers.add( marker.name ) );
|
132
|
+
} );
|
133
|
+
|
134
|
+
// Remove results & markers from the changed part of content.
|
135
|
+
model.change( writer => {
|
136
|
+
removedMarkers.forEach( markerName => {
|
137
|
+
// Remove the result first - in order to prevent rendering a removed marker.
|
138
|
+
if ( results.has( markerName ) ) {
|
139
|
+
results.remove( markerName );
|
140
|
+
}
|
141
|
+
|
142
|
+
writer.removeMarker( markerName );
|
143
|
+
} );
|
144
|
+
} );
|
145
|
+
|
146
|
+
// Run search callback again on updated nodes.
|
147
|
+
changedNodes.forEach( nodeToCheck => {
|
148
|
+
updateFindResultFromRange( model.createRangeOn( nodeToCheck ), model, searchCallback, results );
|
149
|
+
} );
|
150
|
+
}
|
151
|
+
|
152
|
+
/**
|
153
|
+
* Implements the editing part for find and replace plugin. For example conversion, commands etc.
|
154
|
+
*
|
155
|
+
* @extends module:core/plugin~Plugin
|
156
|
+
*/
|
157
|
+
export default class FindAndReplaceEditing extends Plugin {
|
158
|
+
/**
|
159
|
+
* @inheritDoc
|
160
|
+
*/
|
161
|
+
static get pluginName() {
|
162
|
+
return 'FindAndReplaceEditing';
|
163
|
+
}
|
164
|
+
|
165
|
+
/**
|
166
|
+
* @inheritDoc
|
167
|
+
*/
|
168
|
+
init() {
|
169
|
+
this.activeResults = null;
|
170
|
+
|
171
|
+
/**
|
172
|
+
* An object storing the find and replace state within a given editor instance.
|
173
|
+
*
|
174
|
+
* @member {module:find-and-replace/findandreplaceediting~FindAndReplaceState} #state
|
175
|
+
*/
|
176
|
+
this.state = new FindAndReplaceState( this.editor.model );
|
177
|
+
|
178
|
+
this._defineConverters();
|
179
|
+
this._defineCommands();
|
180
|
+
|
181
|
+
this.listenTo( this.state, 'change:highlightedResult', ( eventInfo, name, newValue, oldValue ) => {
|
182
|
+
const { model } = this.editor;
|
183
|
+
|
184
|
+
model.change( writer => {
|
185
|
+
if ( oldValue ) {
|
186
|
+
const oldMatchId = oldValue.marker.name.split( ':' )[ 1 ];
|
187
|
+
const oldMarker = model.markers.get( `findResultHighlighted:${ oldMatchId }` );
|
188
|
+
|
189
|
+
if ( oldMarker ) {
|
190
|
+
writer.removeMarker( oldMarker );
|
191
|
+
}
|
192
|
+
}
|
193
|
+
|
194
|
+
if ( newValue ) {
|
195
|
+
const newMatchId = newValue.marker.name.split( ':' )[ 1 ];
|
196
|
+
writer.addMarker( `findResultHighlighted:${ newMatchId }`, {
|
197
|
+
usingOperation: false,
|
198
|
+
affectsData: false,
|
199
|
+
range: newValue.marker.getRange()
|
200
|
+
} );
|
201
|
+
}
|
202
|
+
} );
|
203
|
+
} );
|
204
|
+
|
205
|
+
const debouncedScrollListener = debounce( scrollToHighlightedResult.bind( this ), 32 );
|
206
|
+
// Debounce scroll as highlight might be changed very frequently, e.g. when there's a replace all command.
|
207
|
+
this.listenTo( this.state, 'change:highlightedResult', debouncedScrollListener, { priority: 'low' } );
|
208
|
+
|
209
|
+
// It's possible that the editor will get destroyed before debounced call kicks in.
|
210
|
+
// This would result with accessing a view three that is no longer in DOM.
|
211
|
+
this.listenTo( this.editor, 'destroy', debouncedScrollListener.cancel );
|
212
|
+
|
213
|
+
function scrollToHighlightedResult( eventInfo, name, newValue ) {
|
214
|
+
if ( newValue ) {
|
215
|
+
const domConverter = this.editor.editing.view.domConverter;
|
216
|
+
const viewRange = this.editor.editing.mapper.toViewRange( newValue.marker.getRange() );
|
217
|
+
|
218
|
+
scrollViewportToShowTarget( {
|
219
|
+
target: domConverter.viewRangeToDom( viewRange ),
|
220
|
+
viewportOffset: 40
|
221
|
+
} );
|
222
|
+
}
|
223
|
+
}
|
224
|
+
}
|
225
|
+
|
226
|
+
/**
|
227
|
+
* Initiate a search.
|
228
|
+
*
|
229
|
+
* @param {Function|String} callbackOrText
|
230
|
+
* @returns {module:utils/collection~Collection}
|
231
|
+
*/
|
232
|
+
find( callbackOrText ) {
|
233
|
+
const { editor } = this;
|
234
|
+
const { model } = editor;
|
235
|
+
|
236
|
+
const { findCallback, results } = editor.execute( 'find', callbackOrText );
|
237
|
+
|
238
|
+
this.activeResults = results;
|
239
|
+
|
240
|
+
// @todo: handle this listener, another copy is in findcommand.js file.
|
241
|
+
this.listenTo( model.document, 'change:data', () => onDocumentChange( this.activeResults, model, findCallback ) );
|
242
|
+
|
243
|
+
return this.activeResults;
|
244
|
+
}
|
245
|
+
|
246
|
+
/**
|
247
|
+
* Stops active results from updating, and clears out the results.
|
248
|
+
*/
|
249
|
+
stop() {
|
250
|
+
if ( !this.activeResults ) {
|
251
|
+
return;
|
252
|
+
}
|
253
|
+
|
254
|
+
this.stopListening( this.editor.model.document );
|
255
|
+
|
256
|
+
this.state.clear( this.editor.model );
|
257
|
+
|
258
|
+
this.activeResults = null;
|
259
|
+
}
|
260
|
+
|
261
|
+
/**
|
262
|
+
* @private
|
263
|
+
*/
|
264
|
+
_defineCommands() {
|
265
|
+
this.editor.commands.add( 'find', new FindCommand( this.editor, this.state ) );
|
266
|
+
this.editor.commands.add( 'findNext', new FindNextCommand( this.editor, this.state ) );
|
267
|
+
this.editor.commands.add( 'findPrevious', new FindPreviousCommand( this.editor, this.state ) );
|
268
|
+
this.editor.commands.add( 'replace', new ReplaceCommand( this.editor, this.state ) );
|
269
|
+
this.editor.commands.add( 'replaceAll', new ReplaceAllCommand( this.editor, this.state ) );
|
270
|
+
}
|
271
|
+
|
272
|
+
/**
|
273
|
+
* @private
|
274
|
+
*/
|
275
|
+
_defineConverters() {
|
276
|
+
const { editor } = this;
|
277
|
+
|
278
|
+
// Setup the marker highlighting conversion.
|
279
|
+
editor.conversion.for( 'editingDowncast' ).markerToHighlight( {
|
280
|
+
model: 'findResult',
|
281
|
+
view: ( { markerName } ) => {
|
282
|
+
const [ , id ] = markerName.split( ':' );
|
283
|
+
|
284
|
+
// Marker removal from the view has a bug: https://github.com/ckeditor/ckeditor5/issues/7499
|
285
|
+
// A minimal option is to return a new object for each converted marker...
|
286
|
+
return {
|
287
|
+
name: 'span',
|
288
|
+
classes: [ 'ck-find-result' ],
|
289
|
+
attributes: {
|
290
|
+
// ...however, adding a unique attribute should be future-proof..
|
291
|
+
'data-find-result': id
|
292
|
+
}
|
293
|
+
};
|
294
|
+
}
|
295
|
+
} );
|
296
|
+
|
297
|
+
editor.conversion.for( 'editingDowncast' ).markerToHighlight( {
|
298
|
+
model: 'findResultHighlighted',
|
299
|
+
view: ( { markerName } ) => {
|
300
|
+
const [ , id ] = markerName.split( ':' );
|
301
|
+
|
302
|
+
// Marker removal from the view has a bug: https://github.com/ckeditor/ckeditor5/issues/7499
|
303
|
+
// A minimal option is to return a new object for each converted marker...
|
304
|
+
return {
|
305
|
+
name: 'span',
|
306
|
+
classes: [ HIGHLIGHT_CLASS ],
|
307
|
+
attributes: {
|
308
|
+
// ...however, adding a unique attribute should be future-proof..
|
309
|
+
'data-find-result': id
|
310
|
+
}
|
311
|
+
};
|
312
|
+
}
|
313
|
+
} );
|
314
|
+
}
|
315
|
+
}
|