@atlaskit/editor-plugin-text-color 1.9.0 → 1.10.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 +15 -0
- package/dist/cjs/commands/remove-color.js +37 -29
- package/dist/es2019/commands/remove-color.js +39 -31
- package/dist/esm/commands/remove-color.js +37 -29
- package/package.json +12 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-text-color
|
|
2
2
|
|
|
3
|
+
## 1.10.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#124209](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/124209)
|
|
8
|
+
[`8aa1792f12ed3`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/8aa1792f12ed3) -
|
|
9
|
+
bump @atlaskit/editor-prosemirror to 5.0.0, bump @atlaskit/adf-schema to 40.1.0
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#123786](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/123786)
|
|
14
|
+
[`3ff9313b19349`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/3ff9313b19349) -
|
|
15
|
+
[ux] [ED-23356] Use removeMark in editor-plugin-text-color removeColor logic
|
|
16
|
+
- Updated dependencies
|
|
17
|
+
|
|
3
18
|
## 1.9.0
|
|
4
19
|
|
|
5
20
|
### Minor Changes
|
|
@@ -4,8 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.removeColor = void 0;
|
|
7
|
+
var _mark = require("@atlaskit/editor-common/mark");
|
|
7
8
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
8
9
|
var _cellSelection = require("@atlaskit/editor-tables/cell-selection");
|
|
10
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
9
11
|
var _main = require("../pm-plugins/main");
|
|
10
12
|
// TODO: ED-23356 - Adopt shared logic with `editor-plugin-highlight` which
|
|
11
13
|
// uses the new `removeMark` command from `editor-common/mark`
|
|
@@ -15,37 +17,43 @@ var removeColor = exports.removeColor = function removeColor() {
|
|
|
15
17
|
selection = state.selection;
|
|
16
18
|
var textColor = schema.marks.textColor;
|
|
17
19
|
var tr = state.tr;
|
|
18
|
-
if (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
* The main difference is we can't toggle the default from another (since they are different marks),
|
|
22
|
-
* we want to remove all text color marks on the selection, so we slightly modify the cell selection
|
|
23
|
-
* part here.
|
|
24
|
-
*/
|
|
25
|
-
selection.forEachCell(function (cell, cellPos) {
|
|
26
|
-
var from = cellPos;
|
|
27
|
-
var to = cellPos + cell.nodeSize;
|
|
28
|
-
tr.doc.nodesBetween(tr.mapping.map(from), tr.mapping.map(to), function (node, pos) {
|
|
29
|
-
if (!node.isText) {
|
|
30
|
-
return true;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
// This is an issue when the user selects some text.
|
|
34
|
-
// We need to check if the current node position is less than the range selection from.
|
|
35
|
-
// If it’s true, that means we should apply the mark using the range selection,
|
|
36
|
-
// not the current node position.
|
|
37
|
-
var nodeBetweenFrom = Math.max(pos, tr.mapping.map(from));
|
|
38
|
-
var nodeBetweenTo = Math.min(pos + node.nodeSize, tr.mapping.map(to));
|
|
39
|
-
tr.removeMark(nodeBetweenFrom, nodeBetweenTo, textColor);
|
|
40
|
-
return true;
|
|
41
|
-
});
|
|
20
|
+
if ((0, _platformFeatureFlags.fg)('editor_use_removeMark')) {
|
|
21
|
+
(0, _mark.removeMark)(textColor)({
|
|
22
|
+
tr: tr
|
|
42
23
|
});
|
|
43
|
-
} else if (selection instanceof _state.TextSelection && selection.$cursor) {
|
|
44
|
-
tr = state.tr.removeStoredMark(textColor);
|
|
45
24
|
} else {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
25
|
+
if (selection instanceof _cellSelection.CellSelection) {
|
|
26
|
+
/**
|
|
27
|
+
* This is a slight abstraction from `src/utils/commands.ts`
|
|
28
|
+
* The main difference is we can't toggle the default from another (since they are different marks),
|
|
29
|
+
* we want to remove all text color marks on the selection, so we slightly modify the cell selection
|
|
30
|
+
* part here.
|
|
31
|
+
*/
|
|
32
|
+
selection.forEachCell(function (cell, cellPos) {
|
|
33
|
+
var from = cellPos;
|
|
34
|
+
var to = cellPos + cell.nodeSize;
|
|
35
|
+
tr.doc.nodesBetween(tr.mapping.map(from), tr.mapping.map(to), function (node, pos) {
|
|
36
|
+
if (!node.isText) {
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// This is an issue when the user selects some text.
|
|
41
|
+
// We need to check if the current node position is less than the range selection from.
|
|
42
|
+
// If it’s true, that means we should apply the mark using the range selection,
|
|
43
|
+
// not the current node position.
|
|
44
|
+
var nodeBetweenFrom = Math.max(pos, tr.mapping.map(from));
|
|
45
|
+
var nodeBetweenTo = Math.min(pos + node.nodeSize, tr.mapping.map(to));
|
|
46
|
+
tr.removeMark(nodeBetweenFrom, nodeBetweenTo, textColor);
|
|
47
|
+
return true;
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
} else if (selection instanceof _state.TextSelection && selection.$cursor) {
|
|
51
|
+
tr = state.tr.removeStoredMark(textColor);
|
|
52
|
+
} else {
|
|
53
|
+
var from = selection.from,
|
|
54
|
+
to = selection.to;
|
|
55
|
+
tr = state.tr.removeMark(from, to, textColor);
|
|
56
|
+
}
|
|
49
57
|
}
|
|
50
58
|
if (dispatch) {
|
|
51
59
|
dispatch(tr.setMeta(_main.pluginKey, {
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { removeMark } from '@atlaskit/editor-common/mark';
|
|
1
2
|
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
2
3
|
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
4
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
3
5
|
import { ACTIONS, pluginKey } from '../pm-plugins/main';
|
|
4
6
|
|
|
5
7
|
// TODO: ED-23356 - Adopt shared logic with `editor-plugin-highlight` which
|
|
@@ -13,39 +15,45 @@ export const removeColor = () => (state, dispatch) => {
|
|
|
13
15
|
textColor
|
|
14
16
|
} = schema.marks;
|
|
15
17
|
let tr = state.tr;
|
|
16
|
-
if (
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
* The main difference is we can't toggle the default from another (since they are different marks),
|
|
20
|
-
* we want to remove all text color marks on the selection, so we slightly modify the cell selection
|
|
21
|
-
* part here.
|
|
22
|
-
*/
|
|
23
|
-
selection.forEachCell((cell, cellPos) => {
|
|
24
|
-
const from = cellPos;
|
|
25
|
-
const to = cellPos + cell.nodeSize;
|
|
26
|
-
tr.doc.nodesBetween(tr.mapping.map(from), tr.mapping.map(to), (node, pos) => {
|
|
27
|
-
if (!node.isText) {
|
|
28
|
-
return true;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
// This is an issue when the user selects some text.
|
|
32
|
-
// We need to check if the current node position is less than the range selection from.
|
|
33
|
-
// If it’s true, that means we should apply the mark using the range selection,
|
|
34
|
-
// not the current node position.
|
|
35
|
-
const nodeBetweenFrom = Math.max(pos, tr.mapping.map(from));
|
|
36
|
-
const nodeBetweenTo = Math.min(pos + node.nodeSize, tr.mapping.map(to));
|
|
37
|
-
tr.removeMark(nodeBetweenFrom, nodeBetweenTo, textColor);
|
|
38
|
-
return true;
|
|
39
|
-
});
|
|
18
|
+
if (fg('editor_use_removeMark')) {
|
|
19
|
+
removeMark(textColor)({
|
|
20
|
+
tr
|
|
40
21
|
});
|
|
41
|
-
} else if (selection instanceof TextSelection && selection.$cursor) {
|
|
42
|
-
tr = state.tr.removeStoredMark(textColor);
|
|
43
22
|
} else {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
23
|
+
if (selection instanceof CellSelection) {
|
|
24
|
+
/**
|
|
25
|
+
* This is a slight abstraction from `src/utils/commands.ts`
|
|
26
|
+
* The main difference is we can't toggle the default from another (since they are different marks),
|
|
27
|
+
* we want to remove all text color marks on the selection, so we slightly modify the cell selection
|
|
28
|
+
* part here.
|
|
29
|
+
*/
|
|
30
|
+
selection.forEachCell((cell, cellPos) => {
|
|
31
|
+
const from = cellPos;
|
|
32
|
+
const to = cellPos + cell.nodeSize;
|
|
33
|
+
tr.doc.nodesBetween(tr.mapping.map(from), tr.mapping.map(to), (node, pos) => {
|
|
34
|
+
if (!node.isText) {
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// This is an issue when the user selects some text.
|
|
39
|
+
// We need to check if the current node position is less than the range selection from.
|
|
40
|
+
// If it’s true, that means we should apply the mark using the range selection,
|
|
41
|
+
// not the current node position.
|
|
42
|
+
const nodeBetweenFrom = Math.max(pos, tr.mapping.map(from));
|
|
43
|
+
const nodeBetweenTo = Math.min(pos + node.nodeSize, tr.mapping.map(to));
|
|
44
|
+
tr.removeMark(nodeBetweenFrom, nodeBetweenTo, textColor);
|
|
45
|
+
return true;
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
} else if (selection instanceof TextSelection && selection.$cursor) {
|
|
49
|
+
tr = state.tr.removeStoredMark(textColor);
|
|
50
|
+
} else {
|
|
51
|
+
const {
|
|
52
|
+
from,
|
|
53
|
+
to
|
|
54
|
+
} = selection;
|
|
55
|
+
tr = state.tr.removeMark(from, to, textColor);
|
|
56
|
+
}
|
|
49
57
|
}
|
|
50
58
|
if (dispatch) {
|
|
51
59
|
dispatch(tr.setMeta(pluginKey, {
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { removeMark } from '@atlaskit/editor-common/mark';
|
|
1
2
|
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
2
3
|
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
4
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
3
5
|
import { ACTIONS, pluginKey } from '../pm-plugins/main';
|
|
4
6
|
|
|
5
7
|
// TODO: ED-23356 - Adopt shared logic with `editor-plugin-highlight` which
|
|
@@ -10,37 +12,43 @@ export var removeColor = function removeColor() {
|
|
|
10
12
|
selection = state.selection;
|
|
11
13
|
var textColor = schema.marks.textColor;
|
|
12
14
|
var tr = state.tr;
|
|
13
|
-
if (
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
* The main difference is we can't toggle the default from another (since they are different marks),
|
|
17
|
-
* we want to remove all text color marks on the selection, so we slightly modify the cell selection
|
|
18
|
-
* part here.
|
|
19
|
-
*/
|
|
20
|
-
selection.forEachCell(function (cell, cellPos) {
|
|
21
|
-
var from = cellPos;
|
|
22
|
-
var to = cellPos + cell.nodeSize;
|
|
23
|
-
tr.doc.nodesBetween(tr.mapping.map(from), tr.mapping.map(to), function (node, pos) {
|
|
24
|
-
if (!node.isText) {
|
|
25
|
-
return true;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// This is an issue when the user selects some text.
|
|
29
|
-
// We need to check if the current node position is less than the range selection from.
|
|
30
|
-
// If it’s true, that means we should apply the mark using the range selection,
|
|
31
|
-
// not the current node position.
|
|
32
|
-
var nodeBetweenFrom = Math.max(pos, tr.mapping.map(from));
|
|
33
|
-
var nodeBetweenTo = Math.min(pos + node.nodeSize, tr.mapping.map(to));
|
|
34
|
-
tr.removeMark(nodeBetweenFrom, nodeBetweenTo, textColor);
|
|
35
|
-
return true;
|
|
36
|
-
});
|
|
15
|
+
if (fg('editor_use_removeMark')) {
|
|
16
|
+
removeMark(textColor)({
|
|
17
|
+
tr: tr
|
|
37
18
|
});
|
|
38
|
-
} else if (selection instanceof TextSelection && selection.$cursor) {
|
|
39
|
-
tr = state.tr.removeStoredMark(textColor);
|
|
40
19
|
} else {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
20
|
+
if (selection instanceof CellSelection) {
|
|
21
|
+
/**
|
|
22
|
+
* This is a slight abstraction from `src/utils/commands.ts`
|
|
23
|
+
* The main difference is we can't toggle the default from another (since they are different marks),
|
|
24
|
+
* we want to remove all text color marks on the selection, so we slightly modify the cell selection
|
|
25
|
+
* part here.
|
|
26
|
+
*/
|
|
27
|
+
selection.forEachCell(function (cell, cellPos) {
|
|
28
|
+
var from = cellPos;
|
|
29
|
+
var to = cellPos + cell.nodeSize;
|
|
30
|
+
tr.doc.nodesBetween(tr.mapping.map(from), tr.mapping.map(to), function (node, pos) {
|
|
31
|
+
if (!node.isText) {
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// This is an issue when the user selects some text.
|
|
36
|
+
// We need to check if the current node position is less than the range selection from.
|
|
37
|
+
// If it’s true, that means we should apply the mark using the range selection,
|
|
38
|
+
// not the current node position.
|
|
39
|
+
var nodeBetweenFrom = Math.max(pos, tr.mapping.map(from));
|
|
40
|
+
var nodeBetweenTo = Math.min(pos + node.nodeSize, tr.mapping.map(to));
|
|
41
|
+
tr.removeMark(nodeBetweenFrom, nodeBetweenTo, textColor);
|
|
42
|
+
return true;
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
} else if (selection instanceof TextSelection && selection.$cursor) {
|
|
46
|
+
tr = state.tr.removeStoredMark(textColor);
|
|
47
|
+
} else {
|
|
48
|
+
var from = selection.from,
|
|
49
|
+
to = selection.to;
|
|
50
|
+
tr = state.tr.removeMark(from, to, textColor);
|
|
51
|
+
}
|
|
44
52
|
}
|
|
45
53
|
if (dispatch) {
|
|
46
54
|
dispatch(tr.setMeta(pluginKey, {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-text-color",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.10.0",
|
|
4
4
|
"description": "Text color plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -34,14 +34,15 @@
|
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@atlaskit/adf-schema": "^40.3.0",
|
|
37
|
-
"@atlaskit/editor-common": "^86.
|
|
37
|
+
"@atlaskit/editor-common": "^86.8.0",
|
|
38
38
|
"@atlaskit/editor-palette": "1.6.0",
|
|
39
|
-
"@atlaskit/editor-plugin-analytics": "^1.
|
|
40
|
-
"@atlaskit/editor-plugin-primary-toolbar": "^1.
|
|
41
|
-
"@atlaskit/editor-prosemirror": "
|
|
39
|
+
"@atlaskit/editor-plugin-analytics": "^1.6.0",
|
|
40
|
+
"@atlaskit/editor-plugin-primary-toolbar": "^1.3.0",
|
|
41
|
+
"@atlaskit/editor-prosemirror": "5.0.1",
|
|
42
42
|
"@atlaskit/editor-shared-styles": "^2.13.0",
|
|
43
|
-
"@atlaskit/editor-tables": "^2.
|
|
43
|
+
"@atlaskit/editor-tables": "^2.8.0",
|
|
44
44
|
"@atlaskit/icon": "^22.7.0",
|
|
45
|
+
"@atlaskit/platform-feature-flags": "^0.3.0",
|
|
45
46
|
"@atlaskit/theme": "^12.11.0",
|
|
46
47
|
"@atlaskit/tokens": "^1.56.0",
|
|
47
48
|
"@babel/runtime": "^7.0.0",
|
|
@@ -92,5 +93,10 @@
|
|
|
92
93
|
"import-no-extraneous-disable-for-examples-and-docs"
|
|
93
94
|
]
|
|
94
95
|
}
|
|
96
|
+
},
|
|
97
|
+
"platform-feature-flags": {
|
|
98
|
+
"editor_use_removeMark": {
|
|
99
|
+
"type": "boolean"
|
|
100
|
+
}
|
|
95
101
|
}
|
|
96
102
|
}
|