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
@@ -0,0 +1,223 @@
|
|
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/findandreplaceui
|
8
|
+
*/
|
9
|
+
|
10
|
+
import { Plugin } from '@ckeditor/ckeditor5-core';
|
11
|
+
import { createDropdown, SplitButtonView } from '@ckeditor/ckeditor5-ui';
|
12
|
+
import FindAndReplaceFormView from './ui/findandreplaceformview';
|
13
|
+
// See: #8833.
|
14
|
+
// eslint-disable-next-line ckeditor5-rules/ckeditor-imports
|
15
|
+
import '@ckeditor/ckeditor5-ui/theme/components/responsive-form/responsiveform.css';
|
16
|
+
import '../theme/findandreplaceform.css';
|
17
|
+
|
18
|
+
import loupeIcon from '../theme/icons/find-replace.svg';
|
19
|
+
|
20
|
+
/**
|
21
|
+
* The default find and replace UI. It introduces:
|
22
|
+
*
|
23
|
+
* * The `'Find and replace'` dropdown button.
|
24
|
+
*
|
25
|
+
* It registers the `'findAndReplace'` UI button in the editor's {@link module:ui/componentfactory~ComponentFactory component factory}.
|
26
|
+
* that uses the {@link module:find-and-replace/findandreplace~FindAndReplace FindAndReplace} plugin API.
|
27
|
+
*
|
28
|
+
* It emits events depending on user search/replace intents.
|
29
|
+
*
|
30
|
+
* @extends module:core/plugin~Plugin
|
31
|
+
*/
|
32
|
+
export default class FindAndReplaceUI extends Plugin {
|
33
|
+
/**
|
34
|
+
* @inheritDoc
|
35
|
+
*/
|
36
|
+
static get pluginName() {
|
37
|
+
return 'FindAndReplaceUI';
|
38
|
+
}
|
39
|
+
|
40
|
+
constructor( editor ) {
|
41
|
+
super( editor );
|
42
|
+
|
43
|
+
this.set( 'searchText' );
|
44
|
+
this.set( 'replaceText' );
|
45
|
+
|
46
|
+
this.set( 'isSearching', false );
|
47
|
+
|
48
|
+
this.set( 'matchCount', null );
|
49
|
+
this.set( 'highlightOffset', null );
|
50
|
+
|
51
|
+
this.bind( 'isSearching' ).to( this, 'matchCount', count => count > 0 );
|
52
|
+
|
53
|
+
/**
|
54
|
+
* The form view will only be assigned if the find and replace toolbar button was added.
|
55
|
+
*
|
56
|
+
* @member {module:find-and-replace/ui/findandreplaceformview~FindAndReplaceFormView|null} #formView
|
57
|
+
*/
|
58
|
+
this.formView = null;
|
59
|
+
}
|
60
|
+
|
61
|
+
/**
|
62
|
+
* @inheritDoc
|
63
|
+
*/
|
64
|
+
init() {
|
65
|
+
this.findAndReplacePlugin = this.editor.plugins.get( 'FindAndReplace' );
|
66
|
+
|
67
|
+
const editor = this.editor;
|
68
|
+
|
69
|
+
editor.ui.componentFactory.add( 'findAndReplace', locale => {
|
70
|
+
const dropdown = createDropdown( locale, SplitButtonView );
|
71
|
+
|
72
|
+
const formView = new FindAndReplaceFormView( editor.locale );
|
73
|
+
|
74
|
+
formView.delegate( 'findNext' ).to( this );
|
75
|
+
formView.delegate( 'findPrevious' ).to( this );
|
76
|
+
formView.delegate( 'replace' ).to( this );
|
77
|
+
formView.delegate( 'replaceAll' ).to( this );
|
78
|
+
|
79
|
+
formView.bind( 'matchCount' ).to( this );
|
80
|
+
formView.bind( 'highlightOffset' ).to( this );
|
81
|
+
|
82
|
+
formView.bind( 'isSearching' ).to( this );
|
83
|
+
|
84
|
+
this._createToolbarDropdown( dropdown, loupeIcon, formView );
|
85
|
+
|
86
|
+
dropdown.panelView.children.add( formView );
|
87
|
+
|
88
|
+
dropdown.on( 'change:isOpen', ( event, name, value ) => {
|
89
|
+
if ( !value ) {
|
90
|
+
this.fire( 'dropdown:closed' );
|
91
|
+
}
|
92
|
+
} );
|
93
|
+
|
94
|
+
this.formView = formView;
|
95
|
+
|
96
|
+
if ( this._state ) {
|
97
|
+
this.unbind( 'isSearching' );
|
98
|
+
|
99
|
+
const findTextInputView = formView.findInputView.fieldView;
|
100
|
+
|
101
|
+
// Searching should only be active if there's more than 1 result matched and
|
102
|
+
// the user has not changed any search criteria.
|
103
|
+
this.bind( 'isSearching' ).to( this, 'matchCount',
|
104
|
+
findTextInputView, 'value', this._state, 'searchText',
|
105
|
+
formView.matchCaseView, 'isChecked', this._state, 'matchCase',
|
106
|
+
formView.matchWholeWordsView, 'isChecked', this._state, 'matchWholeWords',
|
107
|
+
( count,
|
108
|
+
viewSearchText, modelSearchText,
|
109
|
+
viewMatchCase, modelMatchCase,
|
110
|
+
viewWholeWords, modelWholeWords
|
111
|
+
) => {
|
112
|
+
return count > 0 &&
|
113
|
+
viewSearchText == modelSearchText &&
|
114
|
+
viewMatchCase == modelMatchCase &&
|
115
|
+
viewWholeWords == modelWholeWords;
|
116
|
+
} );
|
117
|
+
}
|
118
|
+
|
119
|
+
editor.keystrokes.set( 'Ctrl+F', ( data, cancelEvent ) => {
|
120
|
+
dropdown.buttonView.actionView.fire( 'execute' );
|
121
|
+
|
122
|
+
cancelEvent();
|
123
|
+
} );
|
124
|
+
|
125
|
+
return dropdown;
|
126
|
+
} );
|
127
|
+
}
|
128
|
+
|
129
|
+
/**
|
130
|
+
* Sets the observed state object. It is used to display search result count etc.
|
131
|
+
*
|
132
|
+
* @protected
|
133
|
+
* @param {module:find-and-replace/findandreplaceediting~FindAndReplaceState} state State object to be tracked.
|
134
|
+
*/
|
135
|
+
_setState( state ) {
|
136
|
+
this._state = state;
|
137
|
+
|
138
|
+
this.listenTo( state.results, 'change', () => {
|
139
|
+
this.set( 'matchCount', state.results.length );
|
140
|
+
} );
|
141
|
+
|
142
|
+
this.bind( 'highlightOffset' ).to( state, 'highlightedResult', highlightedResult => {
|
143
|
+
if ( !highlightedResult ) {
|
144
|
+
return null;
|
145
|
+
}
|
146
|
+
|
147
|
+
const sortedResults = Array.from( state.results ).sort( ( a, b ) => {
|
148
|
+
const mapping = {
|
149
|
+
before: -1,
|
150
|
+
same: 0,
|
151
|
+
after: 1
|
152
|
+
};
|
153
|
+
|
154
|
+
return mapping[ a.marker.getStart().compareWith( b.marker.getStart() ) ];
|
155
|
+
} );
|
156
|
+
|
157
|
+
const index = sortedResults.indexOf( highlightedResult );
|
158
|
+
|
159
|
+
return index === -1 ?
|
160
|
+
null : index + 1;
|
161
|
+
} );
|
162
|
+
}
|
163
|
+
|
164
|
+
/**
|
165
|
+
* @private
|
166
|
+
* @param {module:ui/dropdown/dropdownview~DropdownView} dropdown
|
167
|
+
* @param {String} icon An icon to be assigned to the button.
|
168
|
+
* @param {module:find-and-replace/ui/findandreplaceformview~FindAndReplaceFormView} formView A related form view.
|
169
|
+
*/
|
170
|
+
_createToolbarDropdown( dropdown, icon, formView ) {
|
171
|
+
const t = this.editor.locale.t;
|
172
|
+
const buttonView = dropdown.buttonView;
|
173
|
+
|
174
|
+
// Configure the dropdown's button properties:
|
175
|
+
buttonView.set( {
|
176
|
+
icon,
|
177
|
+
tooltip: t( 'Find and replace' )
|
178
|
+
} );
|
179
|
+
|
180
|
+
// Clicking the main button has the same effect as clicking the dropdown arrow.
|
181
|
+
buttonView.actionView.delegate( 'execute' ).to( buttonView.arrowView );
|
182
|
+
|
183
|
+
// Each time a dropdown is opened, the search text field should get focused.
|
184
|
+
buttonView.on( 'open', () => {
|
185
|
+
formView.findInputView.fieldView.select();
|
186
|
+
formView.focus();
|
187
|
+
}, { priority: 'low' } );
|
188
|
+
}
|
189
|
+
}
|
190
|
+
|
191
|
+
/**
|
192
|
+
* Fired when the find next button is triggered.
|
193
|
+
*
|
194
|
+
* @event findNext
|
195
|
+
* @param {String} searchText Search text.
|
196
|
+
*/
|
197
|
+
|
198
|
+
/**
|
199
|
+
* Fired when the find previous button is triggered.
|
200
|
+
*
|
201
|
+
* @event findPrevious
|
202
|
+
* @param {String} searchText Search text.
|
203
|
+
*/
|
204
|
+
|
205
|
+
/**
|
206
|
+
* Fired when the replace button is triggered.
|
207
|
+
*
|
208
|
+
* @event replace
|
209
|
+
* @param {String} replaceText Replacement text.
|
210
|
+
*/
|
211
|
+
|
212
|
+
/**
|
213
|
+
* Fired when the replaceAll button is triggered.
|
214
|
+
*
|
215
|
+
* @event replaceAll
|
216
|
+
* @param {String} replaceText Replacement text.
|
217
|
+
*/
|
218
|
+
|
219
|
+
/**
|
220
|
+
* Fired when the toolbar dropdown gets closed.
|
221
|
+
*
|
222
|
+
* @event dropdown:closed
|
223
|
+
*/
|
package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-find-and-replace/src/findcommand.js
ADDED
@@ -0,0 +1,90 @@
|
|
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/findcommand
|
8
|
+
*/
|
9
|
+
|
10
|
+
import { Command } from '@ckeditor/ckeditor5-core';
|
11
|
+
import { updateFindResultFromRange, findByTextCallback } from './utils';
|
12
|
+
|
13
|
+
/**
|
14
|
+
* The find command. It is used by the {@link module:find-and-replace/findandreplace~FindAndReplace find and replace feature}.
|
15
|
+
*
|
16
|
+
* @extends module:core/command~Command
|
17
|
+
*/
|
18
|
+
export default class FindCommand extends Command {
|
19
|
+
/**
|
20
|
+
* Creates a new `FindCommand` instance.
|
21
|
+
*
|
22
|
+
* @param {module:core/editor/editor~Editor} editor The editor on which this command will be used.
|
23
|
+
*/
|
24
|
+
constructor( editor, state ) {
|
25
|
+
super( editor );
|
26
|
+
|
27
|
+
// The find command is always enabled.
|
28
|
+
this.isEnabled = true;
|
29
|
+
|
30
|
+
this.state = state;
|
31
|
+
|
32
|
+
// Do not block the command if the editor goes into the read-only mode as it does not impact the data. See #9975.
|
33
|
+
this.listenTo( editor, 'change:isReadOnly', ( evt, name, value ) => {
|
34
|
+
if ( value ) {
|
35
|
+
this.clearForceDisabled( 'readOnlyMode' );
|
36
|
+
}
|
37
|
+
} );
|
38
|
+
}
|
39
|
+
|
40
|
+
/**
|
41
|
+
* Executes the command.
|
42
|
+
*
|
43
|
+
* @param {Function|String} callbackOrText
|
44
|
+
* @param {Object} [options]
|
45
|
+
* @param {Boolean} [options.matchCase=false] If set to `true`, the letter case will be ignored.
|
46
|
+
* @param {Boolean} [options.wholeWords=false] If set to `true`, only whole words that match `callbackOrText` will be matched.
|
47
|
+
* @fires execute
|
48
|
+
*/
|
49
|
+
execute( callbackOrText, { matchCase, wholeWords } = {} ) {
|
50
|
+
const { editor } = this;
|
51
|
+
const { model } = editor;
|
52
|
+
|
53
|
+
let findCallback;
|
54
|
+
|
55
|
+
// Allow to execute `find()` on a plugin with a keyword only.
|
56
|
+
if ( typeof callbackOrText === 'string' ) {
|
57
|
+
findCallback = findByTextCallback( callbackOrText, { matchCase, wholeWords } );
|
58
|
+
|
59
|
+
this.state.searchText = callbackOrText;
|
60
|
+
} else {
|
61
|
+
// @todo: disable callback version
|
62
|
+
findCallback = callbackOrText;
|
63
|
+
}
|
64
|
+
|
65
|
+
// Initial search is done on all nodes inside the content.
|
66
|
+
const range = model.createRangeIn( model.document.getRoot() );
|
67
|
+
|
68
|
+
// @todo: fix me
|
69
|
+
// this.listenTo( model.document, 'change:data', () => onDocumentChange( results, model, findCallback ) );
|
70
|
+
|
71
|
+
const ret = {
|
72
|
+
results: updateFindResultFromRange( range, model, findCallback ),
|
73
|
+
findCallback
|
74
|
+
};
|
75
|
+
|
76
|
+
this.state.clear( model );
|
77
|
+
this.state.results.addMany( Array.from( ret.results ) );
|
78
|
+
this.state.highlightedResult = ret.results.get( 0 );
|
79
|
+
|
80
|
+
if ( typeof callbackOrText === 'string' ) {
|
81
|
+
// @todo: eliminate this code repetition. Done to fix unit tests.
|
82
|
+
this.state.searchText = callbackOrText;
|
83
|
+
}
|
84
|
+
|
85
|
+
this.state.matchCase = !!matchCase;
|
86
|
+
this.state.matchWholeWords = !!wholeWords;
|
87
|
+
|
88
|
+
return ret;
|
89
|
+
}
|
90
|
+
}
|
package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-find-and-replace/src/findnextcommand.js
ADDED
@@ -0,0 +1,62 @@
|
|
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/findnextcommand
|
8
|
+
*/
|
9
|
+
|
10
|
+
import { Command } from '@ckeditor/ckeditor5-core';
|
11
|
+
|
12
|
+
/**
|
13
|
+
* The find next command. Moves the highlight to the next search result.
|
14
|
+
*
|
15
|
+
* It is used by the {@link module:find-and-replace/findandreplace~FindAndReplace find and replace feature}.
|
16
|
+
*
|
17
|
+
* @extends module:core/command~Command
|
18
|
+
*/
|
19
|
+
export default class FindNextCommand extends Command {
|
20
|
+
/**
|
21
|
+
* Creates a new `FindNextCommand` instance.
|
22
|
+
*
|
23
|
+
* @param {module:core/editor/editor~Editor} editor The editor on which this command will be used.
|
24
|
+
*/
|
25
|
+
constructor( editor, state ) {
|
26
|
+
super( editor );
|
27
|
+
|
28
|
+
/**
|
29
|
+
* The find and replace state object used for command operations.
|
30
|
+
*
|
31
|
+
* @private
|
32
|
+
* @member {module:find-and-replace/findandreplaceediting~FindAndReplaceState} #_state
|
33
|
+
*/
|
34
|
+
this._state = state;
|
35
|
+
|
36
|
+
this.isEnabled = false;
|
37
|
+
|
38
|
+
this.listenTo( this._state.results, 'change', () => {
|
39
|
+
this.isEnabled = this._state.results.length > 1;
|
40
|
+
} );
|
41
|
+
|
42
|
+
// Do not block the command if the editor goes into the read-only mode as it does not impact the data. See #9975.
|
43
|
+
this.listenTo( editor, 'change:isReadOnly', ( evt, name, value ) => {
|
44
|
+
if ( value ) {
|
45
|
+
this.clearForceDisabled( 'readOnlyMode' );
|
46
|
+
}
|
47
|
+
} );
|
48
|
+
}
|
49
|
+
|
50
|
+
refresh() {
|
51
|
+
this.isEnabled = this._state.results.length > 1;
|
52
|
+
}
|
53
|
+
|
54
|
+
execute() {
|
55
|
+
const results = this._state.results;
|
56
|
+
const currentIndex = results.getIndex( this._state.highlightedResult );
|
57
|
+
const nextIndex = currentIndex + 1 >= results.length ?
|
58
|
+
0 : currentIndex + 1;
|
59
|
+
|
60
|
+
this._state.highlightedResult = this._state.results.get( nextIndex );
|
61
|
+
}
|
62
|
+
}
|
@@ -0,0 +1,28 @@
|
|
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/findpreviouscommand
|
8
|
+
*/
|
9
|
+
|
10
|
+
import FindNextCommand from './findnextcommand';
|
11
|
+
|
12
|
+
/**
|
13
|
+
* The find next command. Moves the highlight to the next search result.
|
14
|
+
*
|
15
|
+
* It is used by the {@link module:find-and-replace/findandreplace~FindAndReplace find and replace feature}.
|
16
|
+
*
|
17
|
+
* @extends module:find-and-replace/findnextcommand~FindNextCommand
|
18
|
+
*/
|
19
|
+
export default class FindPreviousCommand extends FindNextCommand {
|
20
|
+
execute() {
|
21
|
+
const results = this._state.results;
|
22
|
+
const currentIndex = results.getIndex( this._state.highlightedResult );
|
23
|
+
const previousIndex = currentIndex - 1 < 0 ?
|
24
|
+
this._state.results.length - 1 : currentIndex - 1;
|
25
|
+
|
26
|
+
this._state.highlightedResult = this._state.results.get( previousIndex );
|
27
|
+
}
|
28
|
+
}
|
@@ -0,0 +1,10 @@
|
|
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
|
8
|
+
*/
|
9
|
+
|
10
|
+
export { default as FindAndReplace } from './findandreplace';
|
@@ -0,0 +1,54 @@
|
|
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/replaceallcommand
|
8
|
+
*/
|
9
|
+
|
10
|
+
import { updateFindResultFromRange, findByTextCallback } from './utils';
|
11
|
+
import { Collection } from '@ckeditor/ckeditor5-utils';
|
12
|
+
import ReplaceCommand from './replacecommand';
|
13
|
+
|
14
|
+
/**
|
15
|
+
* The replace all command. It is used by the {@link module:find-and-replace/findandreplace~FindAndReplace find and replace feature}.
|
16
|
+
*
|
17
|
+
* @extends module:core/command~Command
|
18
|
+
*/
|
19
|
+
export default class ReplaceAllCommand extends ReplaceCommand {
|
20
|
+
/**
|
21
|
+
* Replaces all the occurrences of `textToReplace` with a given `newText` string.
|
22
|
+
*
|
23
|
+
* ```js
|
24
|
+
* replaceAllCommand.execute( 'replaceAll', 'new text replacement', 'text to replace' );
|
25
|
+
* ```
|
26
|
+
*
|
27
|
+
* Alternatively you can call it from editor instance:
|
28
|
+
*
|
29
|
+
* ```js
|
30
|
+
* editor.execute( 'replaceAll', 'new text', 'old text' );
|
31
|
+
* ```
|
32
|
+
*
|
33
|
+
* @param {String} newText Text that will be inserted to the editor for each match.
|
34
|
+
* @param {String|module:utils/collection~Collection} textToReplace Text to be replaced or a collection of matches
|
35
|
+
* as returned by the find command.
|
36
|
+
*/
|
37
|
+
execute( newText, textToReplace ) {
|
38
|
+
const { editor } = this;
|
39
|
+
const { model } = editor;
|
40
|
+
const range = model.createRangeIn( model.document.getRoot() );
|
41
|
+
|
42
|
+
const results = textToReplace instanceof Collection ?
|
43
|
+
textToReplace : updateFindResultFromRange( range, model, findByTextCallback( textToReplace, this._state ) );
|
44
|
+
|
45
|
+
if ( results.length ) {
|
46
|
+
this.editor.model.change( () => {
|
47
|
+
[ ...results ].forEach( searchResult => {
|
48
|
+
// Just reuse logic from the replace command to replace a single match.
|
49
|
+
super.execute( newText, searchResult );
|
50
|
+
} );
|
51
|
+
} );
|
52
|
+
}
|
53
|
+
}
|
54
|
+
}
|
package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-find-and-replace/src/replacecommand.js
ADDED
@@ -0,0 +1,66 @@
|
|
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/replacecommand
|
8
|
+
*/
|
9
|
+
|
10
|
+
import { Command } from '@ckeditor/ckeditor5-core';
|
11
|
+
|
12
|
+
/**
|
13
|
+
* The replace command. It is used by the {@link module:find-and-replace/findandreplace~FindAndReplace find and replace feature}.
|
14
|
+
*
|
15
|
+
* @extends module:core/command~Command
|
16
|
+
*/
|
17
|
+
export default class ReplaceCommand extends Command {
|
18
|
+
/**
|
19
|
+
* Creates a new `ReplaceCommand` instance.
|
20
|
+
*
|
21
|
+
* @param {module:core/editor/editor~Editor} editor Editor on which this command will be used.
|
22
|
+
*/
|
23
|
+
constructor( editor, state ) {
|
24
|
+
super( editor );
|
25
|
+
|
26
|
+
// The replace command is always enabled.
|
27
|
+
this.isEnabled = true;
|
28
|
+
|
29
|
+
/**
|
30
|
+
* The find and replace state object used for command operations.
|
31
|
+
*
|
32
|
+
* @private
|
33
|
+
* @member {module:find-and-replace/findandreplaceediting~FindAndReplaceState} #_state
|
34
|
+
*/
|
35
|
+
this._state = state;
|
36
|
+
}
|
37
|
+
|
38
|
+
/**
|
39
|
+
* Replace a given find result by a string or a callback.
|
40
|
+
*
|
41
|
+
* @param {String} replacementText
|
42
|
+
* @param {Object} result A single result from the find command.
|
43
|
+
*/
|
44
|
+
execute( replacementText, result ) {
|
45
|
+
const { model } = this.editor;
|
46
|
+
|
47
|
+
model.change( writer => {
|
48
|
+
const range = result.marker.getRange();
|
49
|
+
|
50
|
+
let textAttributes = {};
|
51
|
+
|
52
|
+
for ( const item of range.getItems() ) {
|
53
|
+
if ( item.is( '$text' ) || item.is( '$textProxy' ) ) {
|
54
|
+
textAttributes = item.getAttributes();
|
55
|
+
break;
|
56
|
+
}
|
57
|
+
}
|
58
|
+
|
59
|
+
model.insertContent( writer.createText( replacementText, textAttributes ), range );
|
60
|
+
|
61
|
+
if ( this._state.results.has( result ) ) {
|
62
|
+
this._state.results.remove( result );
|
63
|
+
}
|
64
|
+
} );
|
65
|
+
}
|
66
|
+
}
|