@atlaskit/editor-plugin-find-replace 2.2.8 → 2.3.0
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/CHANGELOG.md +13 -0
- package/dist/cjs/findReplacePlugin.js +1 -1
- package/dist/cjs/pm-plugins/utils/index.js +32 -4
- package/dist/es2019/findReplacePlugin.js +1 -1
- package/dist/es2019/pm-plugins/utils/index.js +34 -4
- package/dist/esm/findReplacePlugin.js +1 -1
- package/dist/esm/pm-plugins/utils/index.js +32 -4
- package/package.json +4 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-find-replace
|
|
2
2
|
|
|
3
|
+
## 2.3.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#165698](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/165698)
|
|
8
|
+
[`e97682ca74f19`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/e97682ca74f19) -
|
|
9
|
+
[ux] [ED-27954] this change is extending the Find algorithm to status nodes behind the
|
|
10
|
+
platform_editor_find_and_replace_1 flag
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Updated dependencies
|
|
15
|
+
|
|
3
16
|
## 2.2.8
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
|
@@ -146,7 +146,7 @@ var findReplacePlugin = exports.findReplacePlugin = function findReplacePlugin(_
|
|
|
146
146
|
primaryToolbarComponent: !(api !== null && api !== void 0 && api.primaryToolbar) ? primaryToolbarComponent : undefined,
|
|
147
147
|
contentComponent: (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1', {
|
|
148
148
|
exposure: true
|
|
149
|
-
})
|
|
149
|
+
}) ? function (_ref5) {
|
|
150
150
|
var editorView = _ref5.editorView,
|
|
151
151
|
containerElement = _ref5.containerElement,
|
|
152
152
|
popupsMountPoint = _ref5.popupsMountPoint,
|
|
@@ -41,7 +41,7 @@ function findMatches(content, searchText, shouldMatchCase) {
|
|
|
41
41
|
var matches = [];
|
|
42
42
|
var searchTextLength = searchText.length;
|
|
43
43
|
var textGrouping = null;
|
|
44
|
-
var
|
|
44
|
+
var collectTextMatch = function collectTextMatch(textGrouping) {
|
|
45
45
|
if (!textGrouping) {
|
|
46
46
|
return;
|
|
47
47
|
}
|
|
@@ -67,6 +67,22 @@ function findMatches(content, searchText, shouldMatchCase) {
|
|
|
67
67
|
index = text.indexOf(searchText, end);
|
|
68
68
|
}
|
|
69
69
|
};
|
|
70
|
+
var collectStatusMatch = function collectStatusMatch(textGrouping, nodeSize) {
|
|
71
|
+
if (!textGrouping) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
var text = textGrouping.text,
|
|
75
|
+
pos = textGrouping.pos;
|
|
76
|
+
var index = text.toLowerCase().indexOf(searchText.toLowerCase());
|
|
77
|
+
if (index !== -1) {
|
|
78
|
+
var start = pos;
|
|
79
|
+
matches.push({
|
|
80
|
+
start: start,
|
|
81
|
+
end: start + nodeSize,
|
|
82
|
+
canReplace: false
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
};
|
|
70
86
|
if (searchTextLength > 0) {
|
|
71
87
|
content.descendants(function (node, pos) {
|
|
72
88
|
if (node.isText) {
|
|
@@ -79,13 +95,25 @@ function findMatches(content, searchText, shouldMatchCase) {
|
|
|
79
95
|
textGrouping.text = textGrouping.text + node.text;
|
|
80
96
|
}
|
|
81
97
|
} else {
|
|
82
|
-
|
|
98
|
+
collectTextMatch(textGrouping);
|
|
83
99
|
textGrouping = null;
|
|
100
|
+
if ((0, _platformFeatureFlags.fg)('platform_editor_find_and_replace_1')) {
|
|
101
|
+
switch (node.type.name) {
|
|
102
|
+
case 'status':
|
|
103
|
+
collectStatusMatch({
|
|
104
|
+
text: node.attrs.text,
|
|
105
|
+
pos: pos
|
|
106
|
+
}, node.nodeSize);
|
|
107
|
+
break;
|
|
108
|
+
default:
|
|
109
|
+
break;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
84
112
|
}
|
|
85
113
|
});
|
|
86
|
-
// if there's a dangling text grouping and no non-text node to trigger
|
|
114
|
+
// if there's a dangling text grouping and no non-text node to trigger collectTextMatch, manually collectTextMatch
|
|
87
115
|
if (textGrouping) {
|
|
88
|
-
|
|
116
|
+
collectTextMatch(textGrouping);
|
|
89
117
|
}
|
|
90
118
|
}
|
|
91
119
|
return matches;
|
|
@@ -142,7 +142,7 @@ export const findReplacePlugin = ({
|
|
|
142
142
|
primaryToolbarComponent: !(api !== null && api !== void 0 && api.primaryToolbar) ? primaryToolbarComponent : undefined,
|
|
143
143
|
contentComponent: editorExperiment('platform_editor_controls', 'variant1', {
|
|
144
144
|
exposure: true
|
|
145
|
-
})
|
|
145
|
+
}) ? ({
|
|
146
146
|
editorView,
|
|
147
147
|
containerElement,
|
|
148
148
|
popupsMountPoint,
|
|
@@ -27,7 +27,7 @@ export function findMatches(content, searchText, shouldMatchCase, contentIndex =
|
|
|
27
27
|
const matches = [];
|
|
28
28
|
const searchTextLength = searchText.length;
|
|
29
29
|
let textGrouping = null;
|
|
30
|
-
const
|
|
30
|
+
const collectTextMatch = textGrouping => {
|
|
31
31
|
if (!textGrouping) {
|
|
32
32
|
return;
|
|
33
33
|
}
|
|
@@ -55,6 +55,24 @@ export function findMatches(content, searchText, shouldMatchCase, contentIndex =
|
|
|
55
55
|
index = text.indexOf(searchText, end);
|
|
56
56
|
}
|
|
57
57
|
};
|
|
58
|
+
const collectStatusMatch = (textGrouping, nodeSize) => {
|
|
59
|
+
if (!textGrouping) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
const {
|
|
63
|
+
text,
|
|
64
|
+
pos
|
|
65
|
+
} = textGrouping;
|
|
66
|
+
const index = text.toLowerCase().indexOf(searchText.toLowerCase());
|
|
67
|
+
if (index !== -1) {
|
|
68
|
+
const start = pos;
|
|
69
|
+
matches.push({
|
|
70
|
+
start,
|
|
71
|
+
end: start + nodeSize,
|
|
72
|
+
canReplace: false
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
};
|
|
58
76
|
if (searchTextLength > 0) {
|
|
59
77
|
content.descendants((node, pos) => {
|
|
60
78
|
if (node.isText) {
|
|
@@ -67,13 +85,25 @@ export function findMatches(content, searchText, shouldMatchCase, contentIndex =
|
|
|
67
85
|
textGrouping.text = textGrouping.text + node.text;
|
|
68
86
|
}
|
|
69
87
|
} else {
|
|
70
|
-
|
|
88
|
+
collectTextMatch(textGrouping);
|
|
71
89
|
textGrouping = null;
|
|
90
|
+
if (fg('platform_editor_find_and_replace_1')) {
|
|
91
|
+
switch (node.type.name) {
|
|
92
|
+
case 'status':
|
|
93
|
+
collectStatusMatch({
|
|
94
|
+
text: node.attrs.text,
|
|
95
|
+
pos
|
|
96
|
+
}, node.nodeSize);
|
|
97
|
+
break;
|
|
98
|
+
default:
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
72
102
|
}
|
|
73
103
|
});
|
|
74
|
-
// if there's a dangling text grouping and no non-text node to trigger
|
|
104
|
+
// if there's a dangling text grouping and no non-text node to trigger collectTextMatch, manually collectTextMatch
|
|
75
105
|
if (textGrouping) {
|
|
76
|
-
|
|
106
|
+
collectTextMatch(textGrouping);
|
|
77
107
|
}
|
|
78
108
|
}
|
|
79
109
|
return matches;
|
|
@@ -139,7 +139,7 @@ export var findReplacePlugin = function findReplacePlugin(_ref) {
|
|
|
139
139
|
primaryToolbarComponent: !(api !== null && api !== void 0 && api.primaryToolbar) ? primaryToolbarComponent : undefined,
|
|
140
140
|
contentComponent: editorExperiment('platform_editor_controls', 'variant1', {
|
|
141
141
|
exposure: true
|
|
142
|
-
})
|
|
142
|
+
}) ? function (_ref5) {
|
|
143
143
|
var editorView = _ref5.editorView,
|
|
144
144
|
containerElement = _ref5.containerElement,
|
|
145
145
|
popupsMountPoint = _ref5.popupsMountPoint,
|
|
@@ -31,7 +31,7 @@ export function findMatches(content, searchText, shouldMatchCase) {
|
|
|
31
31
|
var matches = [];
|
|
32
32
|
var searchTextLength = searchText.length;
|
|
33
33
|
var textGrouping = null;
|
|
34
|
-
var
|
|
34
|
+
var collectTextMatch = function collectTextMatch(textGrouping) {
|
|
35
35
|
if (!textGrouping) {
|
|
36
36
|
return;
|
|
37
37
|
}
|
|
@@ -57,6 +57,22 @@ export function findMatches(content, searchText, shouldMatchCase) {
|
|
|
57
57
|
index = text.indexOf(searchText, end);
|
|
58
58
|
}
|
|
59
59
|
};
|
|
60
|
+
var collectStatusMatch = function collectStatusMatch(textGrouping, nodeSize) {
|
|
61
|
+
if (!textGrouping) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
var text = textGrouping.text,
|
|
65
|
+
pos = textGrouping.pos;
|
|
66
|
+
var index = text.toLowerCase().indexOf(searchText.toLowerCase());
|
|
67
|
+
if (index !== -1) {
|
|
68
|
+
var start = pos;
|
|
69
|
+
matches.push({
|
|
70
|
+
start: start,
|
|
71
|
+
end: start + nodeSize,
|
|
72
|
+
canReplace: false
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
};
|
|
60
76
|
if (searchTextLength > 0) {
|
|
61
77
|
content.descendants(function (node, pos) {
|
|
62
78
|
if (node.isText) {
|
|
@@ -69,13 +85,25 @@ export function findMatches(content, searchText, shouldMatchCase) {
|
|
|
69
85
|
textGrouping.text = textGrouping.text + node.text;
|
|
70
86
|
}
|
|
71
87
|
} else {
|
|
72
|
-
|
|
88
|
+
collectTextMatch(textGrouping);
|
|
73
89
|
textGrouping = null;
|
|
90
|
+
if (fg('platform_editor_find_and_replace_1')) {
|
|
91
|
+
switch (node.type.name) {
|
|
92
|
+
case 'status':
|
|
93
|
+
collectStatusMatch({
|
|
94
|
+
text: node.attrs.text,
|
|
95
|
+
pos: pos
|
|
96
|
+
}, node.nodeSize);
|
|
97
|
+
break;
|
|
98
|
+
default:
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
74
102
|
}
|
|
75
103
|
});
|
|
76
|
-
// if there's a dangling text grouping and no non-text node to trigger
|
|
104
|
+
// if there's a dangling text grouping and no non-text node to trigger collectTextMatch, manually collectTextMatch
|
|
77
105
|
if (textGrouping) {
|
|
78
|
-
|
|
106
|
+
collectTextMatch(textGrouping);
|
|
79
107
|
}
|
|
80
108
|
}
|
|
81
109
|
return matches;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-find-replace",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"description": "find replace plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@atlaskit/button": "^23.2.0",
|
|
36
|
-
"@atlaskit/editor-common": "^106.
|
|
36
|
+
"@atlaskit/editor-common": "^106.3.0",
|
|
37
37
|
"@atlaskit/editor-plugin-analytics": "^2.3.0",
|
|
38
38
|
"@atlaskit/editor-plugin-primary-toolbar": "^3.2.0",
|
|
39
39
|
"@atlaskit/editor-prosemirror": "7.0.0",
|
|
@@ -44,8 +44,8 @@
|
|
|
44
44
|
"@atlaskit/primitives": "^14.8.0",
|
|
45
45
|
"@atlaskit/textfield": "^8.0.0",
|
|
46
46
|
"@atlaskit/theme": "^18.0.0",
|
|
47
|
-
"@atlaskit/tmp-editor-statsig": "^5.
|
|
48
|
-
"@atlaskit/tokens": "^5.
|
|
47
|
+
"@atlaskit/tmp-editor-statsig": "^5.13.0",
|
|
48
|
+
"@atlaskit/tokens": "^5.1.0",
|
|
49
49
|
"@atlaskit/tooltip": "^20.3.0",
|
|
50
50
|
"@babel/runtime": "^7.0.0",
|
|
51
51
|
"@emotion/react": "^11.7.1",
|
|
@@ -113,9 +113,6 @@
|
|
|
113
113
|
"platform_editor_toolbar_responsive_fixes": {
|
|
114
114
|
"type": "boolean"
|
|
115
115
|
},
|
|
116
|
-
"platform_editor_controls_move_actions": {
|
|
117
|
-
"type": "boolean"
|
|
118
|
-
},
|
|
119
116
|
"editor_a11y_refactor_find_replace_style": {
|
|
120
117
|
"type": "boolean"
|
|
121
118
|
},
|