@atlaskit/editor-plugin-highlight 1.6.0 → 1.7.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/.eslintrc.js +4 -4
- package/CHANGELOG.md +76 -60
- package/LICENSE.md +6 -8
- package/dist/cjs/commands/change-color.js +1 -1
- package/dist/cjs/plugin.js +0 -7
- package/dist/cjs/pm-plugin.js +1 -3
- package/dist/cjs/ui/ToolbarHighlightColor.js +1 -1
- package/dist/cjs/utils/color.js +90 -32
- package/dist/es2019/commands/change-color.js +1 -1
- package/dist/es2019/plugin.js +0 -7
- package/dist/es2019/pm-plugin.js +1 -3
- package/dist/es2019/ui/ToolbarHighlightColor.js +1 -1
- package/dist/es2019/utils/color.js +91 -30
- package/dist/esm/commands/change-color.js +1 -1
- package/dist/esm/plugin.js +0 -7
- package/dist/esm/pm-plugin.js +1 -3
- package/dist/esm/ui/ToolbarHighlightColor.js +1 -1
- package/dist/esm/utils/color.js +89 -32
- package/dist/types/plugin.d.ts +8 -1
- package/dist/types/pm-plugin.d.ts +1 -1
- package/dist/types/ui/EditorHighlightIcon.d.ts +1 -1
- package/dist/types/utils/color.d.ts +2 -2
- package/dist/types-ts4.5/plugin.d.ts +8 -1
- package/dist/types-ts4.5/pm-plugin.d.ts +1 -1
- package/dist/types-ts4.5/ui/EditorHighlightIcon.d.ts +1 -1
- package/dist/types-ts4.5/utils/color.d.ts +2 -2
- package/package.json +4 -5
package/.eslintrc.js
CHANGED
package/CHANGELOG.md
CHANGED
|
@@ -1,149 +1,165 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-highlight
|
|
2
2
|
|
|
3
|
+
## 1.7.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#104539](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/104539)
|
|
8
|
+
[`48044c9de18a`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/48044c9de18a) -
|
|
9
|
+
[ED-23340] Split out the background-color mark to its own plugin so we can toggle off the text
|
|
10
|
+
highlighting experiment without breaking existing pages that have highlights
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- [#104995](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/104995)
|
|
15
|
+
[`f3437f0a487e`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/f3437f0a487e) -
|
|
16
|
+
[ux] [ED-23155] Improve implementation of getActiveColor() to also support cell selections
|
|
17
|
+
- Updated dependencies
|
|
18
|
+
|
|
3
19
|
## 1.6.0
|
|
4
20
|
|
|
5
21
|
### Minor Changes
|
|
6
22
|
|
|
7
|
-
-
|
|
8
|
-
|
|
9
|
-
|
|
23
|
+
- [#104271](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/104271)
|
|
24
|
+
[`5d03a899b0c9`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/5d03a899b0c9) -
|
|
25
|
+
[ux] [ED-23155] Adds plugin state for currently selected color for highlight button
|
|
10
26
|
|
|
11
27
|
### Patch Changes
|
|
12
28
|
|
|
13
|
-
-
|
|
14
|
-
|
|
15
|
-
|
|
29
|
+
- [#103816](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/103816)
|
|
30
|
+
[`3fb50173376f`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/3fb50173376f) -
|
|
31
|
+
[ED-23159] Added blending styling for when highlights overlap inline comments
|
|
16
32
|
|
|
17
33
|
## 1.5.0
|
|
18
34
|
|
|
19
35
|
### Minor Changes
|
|
20
36
|
|
|
21
|
-
-
|
|
22
|
-
|
|
23
|
-
|
|
37
|
+
- [#101406](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/101406)
|
|
38
|
+
[`6daffd65aec4`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/6daffd65aec4) -
|
|
39
|
+
[ED-23298] Extract primary toolbar components to editor plugin to allow for custom ordering
|
|
24
40
|
|
|
25
41
|
### Patch Changes
|
|
26
42
|
|
|
27
|
-
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
-
|
|
43
|
+
- [#102478](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/102478)
|
|
44
|
+
[`3378951608b0`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/3378951608b0) -
|
|
45
|
+
[ED-23332] Update adf-schema package to 36.10.1
|
|
46
|
+
- Updated dependencies
|
|
31
47
|
|
|
32
48
|
## 1.4.2
|
|
33
49
|
|
|
34
50
|
### Patch Changes
|
|
35
51
|
|
|
36
|
-
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
52
|
+
- [#101513](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/101513)
|
|
53
|
+
[`98b5dfc33bed`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/98b5dfc33bed) -
|
|
54
|
+
[ux] [ED-23156] The highlight primary toolbar button is disabled when trying to apply it on nodes
|
|
55
|
+
that don't enable the mark and when in a gap cursor. The text color primary toolbar button is
|
|
56
|
+
disabled when selecting text with a highlight.
|
|
41
57
|
|
|
42
58
|
## 1.4.1
|
|
43
59
|
|
|
44
60
|
### Patch Changes
|
|
45
61
|
|
|
46
|
-
-
|
|
47
|
-
|
|
48
|
-
|
|
62
|
+
- [#101524](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/101524)
|
|
63
|
+
[`4821570088e6`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/4821570088e6) -
|
|
64
|
+
ED-23362 Bump ADF schema to version 36.8.1 and add support for adf validation and transformation
|
|
49
65
|
|
|
50
66
|
## 1.4.0
|
|
51
67
|
|
|
52
68
|
### Minor Changes
|
|
53
69
|
|
|
54
|
-
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
70
|
+
- [#100495](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/100495)
|
|
71
|
+
[`dbb78a011fac`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/dbb78a011fac) -
|
|
72
|
+
[ux] [ED-23150] Added `changeColor` command for editor-plugin-highlight, including new
|
|
73
|
+
`removeMark` command for editor-common. Fixed bug with editor-plugin-text-color which prevented
|
|
74
|
+
color from being removed when user selects all.
|
|
59
75
|
|
|
60
76
|
### Patch Changes
|
|
61
77
|
|
|
62
|
-
-
|
|
78
|
+
- Updated dependencies
|
|
63
79
|
|
|
64
80
|
## 1.3.0
|
|
65
81
|
|
|
66
82
|
### Minor Changes
|
|
67
83
|
|
|
68
|
-
-
|
|
69
|
-
|
|
70
|
-
|
|
84
|
+
- [#100553](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/100553)
|
|
85
|
+
[`e0c2a4b9c8ae`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/e0c2a4b9c8ae) -
|
|
86
|
+
[ED-23157] Clear background color (= highlights) when clearing the formatting on a selection
|
|
71
87
|
|
|
72
88
|
### Patch Changes
|
|
73
89
|
|
|
74
|
-
-
|
|
90
|
+
- Updated dependencies
|
|
75
91
|
|
|
76
92
|
## 1.2.0
|
|
77
93
|
|
|
78
94
|
### Minor Changes
|
|
79
95
|
|
|
80
|
-
-
|
|
81
|
-
|
|
82
|
-
|
|
96
|
+
- [#99579](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/99579)
|
|
97
|
+
[`f222af5687e9`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/f222af5687e9) -
|
|
98
|
+
Bump adf-schema to 36.3.0 and adf-schema-json to 1.14.0
|
|
83
99
|
|
|
84
100
|
### Patch Changes
|
|
85
101
|
|
|
86
|
-
-
|
|
102
|
+
- Updated dependencies
|
|
87
103
|
|
|
88
104
|
## 1.1.1
|
|
89
105
|
|
|
90
106
|
### Patch Changes
|
|
91
107
|
|
|
92
|
-
-
|
|
108
|
+
- Updated dependencies
|
|
93
109
|
|
|
94
110
|
## 1.1.0
|
|
95
111
|
|
|
96
112
|
### Minor Changes
|
|
97
113
|
|
|
98
|
-
-
|
|
99
|
-
|
|
100
|
-
|
|
114
|
+
- [#98130](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/98130)
|
|
115
|
+
[`6a3c0d9d6382`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/6a3c0d9d6382) -
|
|
116
|
+
[ED-23154] Add highlight option to main toolbar in editor
|
|
101
117
|
|
|
102
118
|
### Patch Changes
|
|
103
119
|
|
|
104
|
-
-
|
|
120
|
+
- Updated dependencies
|
|
105
121
|
|
|
106
122
|
## 1.0.5
|
|
107
123
|
|
|
108
124
|
### Patch Changes
|
|
109
125
|
|
|
110
|
-
-
|
|
111
|
-
|
|
112
|
-
|
|
126
|
+
- [#97599](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/97599)
|
|
127
|
+
[`32c3130b08fe`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/32c3130b08fe) -
|
|
128
|
+
[ED-22282] Bump adf-schema to 36.1.0
|
|
113
129
|
|
|
114
130
|
## 1.0.4
|
|
115
131
|
|
|
116
132
|
### Patch Changes
|
|
117
133
|
|
|
118
|
-
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
134
|
+
- [#97698](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/97698)
|
|
135
|
+
[`1c7b378c0d3b`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/1c7b378c0d3b) -
|
|
136
|
+
[HOT-108999] We had an incident where the cursor jumps back a character in table headers for any
|
|
137
|
+
language triggering composition on an empty line.This was fixed in a patch bump of
|
|
138
|
+
prosemirror-view. https://github.com/ProseMirror/prosemirror-view/compare/1.33.4...1.33.5
|
|
123
139
|
|
|
124
140
|
## 1.0.3
|
|
125
141
|
|
|
126
142
|
### Patch Changes
|
|
127
143
|
|
|
128
|
-
-
|
|
144
|
+
- Updated dependencies
|
|
129
145
|
|
|
130
146
|
## 1.0.2
|
|
131
147
|
|
|
132
148
|
### Patch Changes
|
|
133
149
|
|
|
134
|
-
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
150
|
+
- [#96237](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/96237)
|
|
151
|
+
[`0401e7b5a88e`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/0401e7b5a88e) -
|
|
152
|
+
[ED-23102] Bump ADF schema to version 35.12.2
|
|
153
|
+
- [#96613](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/96613)
|
|
154
|
+
[`398961a2b0a1`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/398961a2b0a1) -
|
|
155
|
+
[ux] [ED-23133] Moved stepped rainbow text colour icon styles to editor-common and refactored to
|
|
156
|
+
be reusable
|
|
141
157
|
|
|
142
158
|
## 1.0.1
|
|
143
159
|
|
|
144
160
|
### Patch Changes
|
|
145
161
|
|
|
146
|
-
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
162
|
+
- [#95715](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/95715)
|
|
163
|
+
[`f036f2fd9ccf`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/f036f2fd9ccf) -
|
|
164
|
+
[ED-23102] Added global styles that map the custom CSS variables to background color for
|
|
165
|
+
background color mark
|
package/LICENSE.md
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
Copyright 2023 Atlassian Pty Ltd
|
|
2
2
|
|
|
3
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
|
|
5
|
-
You may obtain a copy of the License at
|
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in
|
|
4
|
+
compliance with the License. You may obtain a copy of the License at
|
|
6
5
|
|
|
7
6
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
8
7
|
|
|
9
|
-
Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
distributed
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
limitations under the License.
|
|
8
|
+
Unless required by applicable law or agreed to in writing, software distributed under the License is
|
|
9
|
+
distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
10
|
+
implied. See the License for the specific language governing permissions and limitations under the
|
|
11
|
+
License.
|
|
@@ -59,7 +59,7 @@ var createAnalyticsEvent = function createAnalyticsEvent(color, tr) {
|
|
|
59
59
|
eventType: _analytics.EVENT_TYPE.TRACK,
|
|
60
60
|
attributes: {
|
|
61
61
|
newColor: newColorLabel.toLowerCase(),
|
|
62
|
-
previousColor: previousColorLabel.toLowerCase()
|
|
62
|
+
previousColor: previousColorLabel ? previousColorLabel.toLowerCase() : ''
|
|
63
63
|
}
|
|
64
64
|
};
|
|
65
65
|
};
|
package/dist/cjs/plugin.js
CHANGED
|
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.highlightPlugin = void 0;
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
|
-
var _adfSchema = require("@atlaskit/adf-schema");
|
|
10
9
|
var _commands = require("./commands");
|
|
11
10
|
var _pmPlugin = require("./pm-plugin");
|
|
12
11
|
var _ToolbarHighlightColor = require("./ui/ToolbarHighlightColor");
|
|
@@ -36,12 +35,6 @@ var highlightPlugin = exports.highlightPlugin = function highlightPlugin(_ref) {
|
|
|
36
35
|
commands: {
|
|
37
36
|
changeColor: (0, _commands.changeColor)(editorAnalyticsAPI)
|
|
38
37
|
},
|
|
39
|
-
marks: function marks() {
|
|
40
|
-
return [{
|
|
41
|
-
name: 'backgroundColor',
|
|
42
|
-
mark: _adfSchema.backgroundColor
|
|
43
|
-
}];
|
|
44
|
-
},
|
|
45
38
|
pmPlugins: function pmPlugins() {
|
|
46
39
|
return [{
|
|
47
40
|
name: 'highlight',
|
package/dist/cjs/pm-plugin.js
CHANGED
|
@@ -32,7 +32,6 @@ var createPlugin = exports.createPlugin = function createPlugin(_ref) {
|
|
|
32
32
|
apply: function apply(tr, pluginState, _oldState, newState) {
|
|
33
33
|
var _tr$getMeta;
|
|
34
34
|
var action = (_tr$getMeta = tr.getMeta(highlightPluginKey)) === null || _tr$getMeta === void 0 ? void 0 : _tr$getMeta.type;
|
|
35
|
-
var nextState;
|
|
36
35
|
switch (action) {
|
|
37
36
|
case HighlightPluginAction.CHANGE_COLOR:
|
|
38
37
|
var _tr$getMeta2 = tr.getMeta(highlightPluginKey),
|
|
@@ -41,11 +40,10 @@ var createPlugin = exports.createPlugin = function createPlugin(_ref) {
|
|
|
41
40
|
activeColor: color
|
|
42
41
|
});
|
|
43
42
|
default:
|
|
44
|
-
|
|
43
|
+
return _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
45
44
|
activeColor: (0, _color.getActiveColor)(tr),
|
|
46
45
|
disabled: (0, _disabled.getDisabledState)(newState)
|
|
47
46
|
});
|
|
48
|
-
return nextState;
|
|
49
47
|
}
|
|
50
48
|
}
|
|
51
49
|
}
|
|
@@ -99,7 +99,7 @@ var ToolbarHighlightColor = function ToolbarHighlightColor(_ref) {
|
|
|
99
99
|
|
|
100
100
|
// Get the design token for the active color (if it exists) to modify the toolbar
|
|
101
101
|
// icon, but show the nice rainbow if none is selected
|
|
102
|
-
var activeColorToken = highlightState.activeColor === _uiColor.REMOVE_HIGHLIGHT_COLOR ? null : (0, _editorPalette.hexToEditorTextBackgroundPaletteColor)(highlightState.activeColor);
|
|
102
|
+
var activeColorToken = highlightState.activeColor === _uiColor.REMOVE_HIGHLIGHT_COLOR || highlightState.activeColor === null ? null : (0, _editorPalette.hexToEditorTextBackgroundPaletteColor)(highlightState.activeColor);
|
|
103
103
|
|
|
104
104
|
// pixels, used to determine where to horizontally position the dropdown when space is limited
|
|
105
105
|
// this should reflect the width of the dropdown when fully populated with colors, including translations due to layering
|
package/dist/cjs/utils/color.js
CHANGED
|
@@ -1,47 +1,105 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
7
|
exports.getActiveColor = void 0;
|
|
8
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
|
+
var _mark = require("@atlaskit/editor-common/mark");
|
|
7
10
|
var _uiColor = require("@atlaskit/editor-common/ui-color");
|
|
8
|
-
var
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
var
|
|
11
|
+
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
12
|
+
var _cellSelection = require("@atlaskit/editor-tables/cell-selection");
|
|
13
|
+
var getAllUniqueBackgroundColorMarksInRange = function getAllUniqueBackgroundColorMarksInRange(from, to, tr) {
|
|
14
|
+
var doc = tr.doc;
|
|
15
|
+
var backgroundColor = doc.type.schema.marks.backgroundColor;
|
|
16
|
+
var colorMarks = [];
|
|
17
|
+
var colorSet = new Set();
|
|
18
|
+
doc.nodesBetween(from, to, function (node) {
|
|
19
|
+
if (node.isLeaf) {
|
|
20
|
+
var mark = backgroundColor.isInSet(node.marks);
|
|
21
|
+
if (mark && !colorSet.has(mark.attrs.color)) {
|
|
22
|
+
colorMarks.push(mark);
|
|
23
|
+
colorSet.add(mark.attrs.color);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
return colorMarks;
|
|
28
|
+
};
|
|
29
|
+
var getAllUniqueBackgroundColorMarksInCellSelection = function getAllUniqueBackgroundColorMarksInCellSelection(selection, tr) {
|
|
30
|
+
var colorMarks = [];
|
|
31
|
+
var colorSet = new Set();
|
|
32
|
+
selection.forEachCell(function (cell, cellPos) {
|
|
33
|
+
var from = cellPos;
|
|
34
|
+
var to = cellPos + cell.nodeSize;
|
|
35
|
+
var marks = getAllUniqueBackgroundColorMarksInRange(from, to, tr);
|
|
36
|
+
marks.forEach(function (mark) {
|
|
37
|
+
if (!colorSet.has(mark.attrs.color)) {
|
|
38
|
+
colorMarks.push(mark);
|
|
39
|
+
colorSet.add(mark.attrs.color);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
return colorMarks;
|
|
44
|
+
};
|
|
14
45
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
46
|
+
// For Cell Selections - find first instance of a backgroundColor mark
|
|
47
|
+
// if all cells entirely contain this mark, set the color.
|
|
48
|
+
// If the selection contains multiple colors, return null
|
|
49
|
+
var getColorFromCellSelection = function getColorFromCellSelection(selection, tr) {
|
|
50
|
+
var marks = getAllUniqueBackgroundColorMarksInCellSelection(selection, tr);
|
|
51
|
+
if (marks.length > 1) {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
var firstColorMark = marks.at(0);
|
|
55
|
+
var foundNonColoredNode = false;
|
|
56
|
+
if (firstColorMark) {
|
|
57
|
+
selection.forEachCell(function (cell, cellPos) {
|
|
58
|
+
if (foundNonColoredNode) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
var from = cellPos;
|
|
62
|
+
var to = cellPos + cell.nodeSize;
|
|
63
|
+
if (!(0, _mark.entireSelectionContainsMark)(firstColorMark, tr.doc, from, to)) {
|
|
64
|
+
foundNonColoredNode = true;
|
|
25
65
|
}
|
|
26
|
-
return true;
|
|
27
66
|
});
|
|
28
67
|
}
|
|
68
|
+
return foundNonColoredNode ? _uiColor.REMOVE_HIGHLIGHT_COLOR : firstColorMark === null || firstColorMark === void 0 ? void 0 : firstColorMark.attrs.color;
|
|
69
|
+
};
|
|
29
70
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
return
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
|
|
71
|
+
// All other selections - find the first instance of a backgroundColor mark
|
|
72
|
+
// if selection entirely contains this mark, set the color.
|
|
73
|
+
// If the selection contains multiple colors, return null
|
|
74
|
+
var getColorFromRange = function getColorFromRange(from, to, tr) {
|
|
75
|
+
var marks = getAllUniqueBackgroundColorMarksInRange(from, to, tr);
|
|
76
|
+
if (marks.length > 1) {
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
var firstColorMark = marks.at(0);
|
|
80
|
+
if (firstColorMark && (0, _mark.entireSelectionContainsMark)(firstColorMark, tr.doc, from, to)) {
|
|
81
|
+
return firstColorMark.attrs.color;
|
|
82
|
+
}
|
|
83
|
+
return _uiColor.REMOVE_HIGHLIGHT_COLOR;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
// For Cursor selections - set color if it is found in the storedMarks or $cursor.marks
|
|
87
|
+
var getColorFromCursor = function getColorFromCursor(selection, tr) {
|
|
88
|
+
if (!selection.$cursor) {
|
|
44
89
|
return _uiColor.REMOVE_HIGHLIGHT_COLOR;
|
|
45
90
|
}
|
|
46
|
-
|
|
91
|
+
var mark = tr.doc.type.schema.marks.backgroundColor.isInSet([].concat((0, _toConsumableArray2.default)(tr.storedMarks ? tr.storedMarks : []), (0, _toConsumableArray2.default)(selection.$cursor.marks())));
|
|
92
|
+
return (mark === null || mark === void 0 ? void 0 : mark.attrs.color) || _uiColor.REMOVE_HIGHLIGHT_COLOR;
|
|
93
|
+
};
|
|
94
|
+
var getActiveColor = exports.getActiveColor = function getActiveColor(tr) {
|
|
95
|
+
var selection = tr.selection;
|
|
96
|
+
var color;
|
|
97
|
+
if (selection instanceof _cellSelection.CellSelection) {
|
|
98
|
+
color = getColorFromCellSelection(selection, tr);
|
|
99
|
+
} else if (selection instanceof _state.TextSelection && selection.$cursor) {
|
|
100
|
+
color = getColorFromCursor(selection, tr);
|
|
101
|
+
} else {
|
|
102
|
+
color = getColorFromRange(selection.from, selection.to, tr);
|
|
103
|
+
}
|
|
104
|
+
return color === undefined ? _uiColor.REMOVE_HIGHLIGHT_COLOR : color;
|
|
47
105
|
};
|
|
@@ -51,7 +51,7 @@ const createAnalyticsEvent = (color, tr) => {
|
|
|
51
51
|
eventType: EVENT_TYPE.TRACK,
|
|
52
52
|
attributes: {
|
|
53
53
|
newColor: newColorLabel.toLowerCase(),
|
|
54
|
-
previousColor: previousColorLabel.toLowerCase()
|
|
54
|
+
previousColor: previousColorLabel ? previousColorLabel.toLowerCase() : ''
|
|
55
55
|
}
|
|
56
56
|
};
|
|
57
57
|
};
|
package/dist/es2019/plugin.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { backgroundColor } from '@atlaskit/adf-schema';
|
|
3
2
|
import { changeColor } from './commands';
|
|
4
3
|
import { createPlugin, highlightPluginKey } from './pm-plugin';
|
|
5
4
|
import { ToolbarHighlightColorWithIntl as ToolbarHighlightColor } from './ui/ToolbarHighlightColor';
|
|
@@ -29,12 +28,6 @@ export const highlightPlugin = ({
|
|
|
29
28
|
commands: {
|
|
30
29
|
changeColor: changeColor(editorAnalyticsAPI)
|
|
31
30
|
},
|
|
32
|
-
marks() {
|
|
33
|
-
return [{
|
|
34
|
-
name: 'backgroundColor',
|
|
35
|
-
mark: backgroundColor
|
|
36
|
-
}];
|
|
37
|
-
},
|
|
38
31
|
pmPlugins: () => [{
|
|
39
32
|
name: 'highlight',
|
|
40
33
|
plugin: () => createPlugin({
|
package/dist/es2019/pm-plugin.js
CHANGED
|
@@ -21,7 +21,6 @@ export const createPlugin = ({
|
|
|
21
21
|
apply: (tr, pluginState, _oldState, newState) => {
|
|
22
22
|
var _tr$getMeta;
|
|
23
23
|
const action = (_tr$getMeta = tr.getMeta(highlightPluginKey)) === null || _tr$getMeta === void 0 ? void 0 : _tr$getMeta.type;
|
|
24
|
-
let nextState;
|
|
25
24
|
switch (action) {
|
|
26
25
|
case HighlightPluginAction.CHANGE_COLOR:
|
|
27
26
|
const {
|
|
@@ -32,12 +31,11 @@ export const createPlugin = ({
|
|
|
32
31
|
activeColor: color
|
|
33
32
|
};
|
|
34
33
|
default:
|
|
35
|
-
|
|
34
|
+
return {
|
|
36
35
|
...pluginState,
|
|
37
36
|
activeColor: getActiveColor(tr),
|
|
38
37
|
disabled: getDisabledState(newState)
|
|
39
38
|
};
|
|
40
|
-
return nextState;
|
|
41
39
|
}
|
|
42
40
|
}
|
|
43
41
|
}
|
|
@@ -83,7 +83,7 @@ const ToolbarHighlightColor = ({
|
|
|
83
83
|
|
|
84
84
|
// Get the design token for the active color (if it exists) to modify the toolbar
|
|
85
85
|
// icon, but show the nice rainbow if none is selected
|
|
86
|
-
const activeColorToken = highlightState.activeColor === REMOVE_HIGHLIGHT_COLOR ? null : hexToEditorTextBackgroundPaletteColor(highlightState.activeColor);
|
|
86
|
+
const activeColorToken = highlightState.activeColor === REMOVE_HIGHLIGHT_COLOR || highlightState.activeColor === null ? null : hexToEditorTextBackgroundPaletteColor(highlightState.activeColor);
|
|
87
87
|
|
|
88
88
|
// pixels, used to determine where to horizontally position the dropdown when space is limited
|
|
89
89
|
// this should reflect the width of the dropdown when fully populated with colors, including translations due to layering
|
|
@@ -1,42 +1,103 @@
|
|
|
1
|
+
import { entireSelectionContainsMark } from '@atlaskit/editor-common/mark';
|
|
1
2
|
import { REMOVE_HIGHLIGHT_COLOR } from '@atlaskit/editor-common/ui-color';
|
|
2
|
-
|
|
3
|
+
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
4
|
+
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
5
|
+
const getAllUniqueBackgroundColorMarksInRange = (from, to, tr) => {
|
|
3
6
|
const {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
$cursor
|
|
7
|
-
} = tr.selection;
|
|
7
|
+
doc
|
|
8
|
+
} = tr;
|
|
8
9
|
const {
|
|
9
10
|
backgroundColor
|
|
10
|
-
} =
|
|
11
|
+
} = doc.type.schema.marks;
|
|
12
|
+
const colorMarks = [];
|
|
13
|
+
const colorSet = new Set();
|
|
14
|
+
doc.nodesBetween(from, to, node => {
|
|
15
|
+
if (node.isLeaf) {
|
|
16
|
+
const mark = backgroundColor.isInSet(node.marks);
|
|
17
|
+
if (mark && !colorSet.has(mark.attrs.color)) {
|
|
18
|
+
colorMarks.push(mark);
|
|
19
|
+
colorSet.add(mark.attrs.color);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
return colorMarks;
|
|
24
|
+
};
|
|
25
|
+
const getAllUniqueBackgroundColorMarksInCellSelection = (selection, tr) => {
|
|
26
|
+
const colorMarks = [];
|
|
27
|
+
const colorSet = new Set();
|
|
28
|
+
selection.forEachCell((cell, cellPos) => {
|
|
29
|
+
const from = cellPos;
|
|
30
|
+
const to = cellPos + cell.nodeSize;
|
|
31
|
+
const marks = getAllUniqueBackgroundColorMarksInRange(from, to, tr);
|
|
32
|
+
marks.forEach(mark => {
|
|
33
|
+
if (!colorSet.has(mark.attrs.color)) {
|
|
34
|
+
colorMarks.push(mark);
|
|
35
|
+
colorSet.add(mark.attrs.color);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
return colorMarks;
|
|
40
|
+
};
|
|
11
41
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
42
|
+
// For Cell Selections - find first instance of a backgroundColor mark
|
|
43
|
+
// if all cells entirely contain this mark, set the color.
|
|
44
|
+
// If the selection contains multiple colors, return null
|
|
45
|
+
const getColorFromCellSelection = (selection, tr) => {
|
|
46
|
+
const marks = getAllUniqueBackgroundColorMarksInCellSelection(selection, tr);
|
|
47
|
+
if (marks.length > 1) {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
const firstColorMark = marks.at(0);
|
|
51
|
+
let foundNonColoredNode = false;
|
|
52
|
+
if (firstColorMark) {
|
|
53
|
+
selection.forEachCell((cell, cellPos) => {
|
|
54
|
+
if (foundNonColoredNode) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
const from = cellPos;
|
|
58
|
+
const to = cellPos + cell.nodeSize;
|
|
59
|
+
if (!entireSelectionContainsMark(firstColorMark, tr.doc, from, to)) {
|
|
60
|
+
foundNonColoredNode = true;
|
|
22
61
|
}
|
|
23
|
-
return true;
|
|
24
62
|
});
|
|
25
63
|
}
|
|
64
|
+
return foundNonColoredNode ? REMOVE_HIGHLIGHT_COLOR : firstColorMark === null || firstColorMark === void 0 ? void 0 : firstColorMark.attrs.color;
|
|
65
|
+
};
|
|
26
66
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
67
|
+
// All other selections - find the first instance of a backgroundColor mark
|
|
68
|
+
// if selection entirely contains this mark, set the color.
|
|
69
|
+
// If the selection contains multiple colors, return null
|
|
70
|
+
const getColorFromRange = (from, to, tr) => {
|
|
71
|
+
const marks = getAllUniqueBackgroundColorMarksInRange(from, to, tr);
|
|
72
|
+
if (marks.length > 1) {
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
const firstColorMark = marks.at(0);
|
|
76
|
+
if (firstColorMark && entireSelectionContainsMark(firstColorMark, tr.doc, from, to)) {
|
|
77
|
+
return firstColorMark.attrs.color;
|
|
78
|
+
}
|
|
79
|
+
return REMOVE_HIGHLIGHT_COLOR;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
// For Cursor selections - set color if it is found in the storedMarks or $cursor.marks
|
|
83
|
+
const getColorFromCursor = (selection, tr) => {
|
|
84
|
+
if (!selection.$cursor) {
|
|
39
85
|
return REMOVE_HIGHLIGHT_COLOR;
|
|
40
86
|
}
|
|
41
|
-
|
|
87
|
+
const mark = tr.doc.type.schema.marks.backgroundColor.isInSet([...(tr.storedMarks ? tr.storedMarks : []), ...selection.$cursor.marks()]);
|
|
88
|
+
return (mark === null || mark === void 0 ? void 0 : mark.attrs.color) || REMOVE_HIGHLIGHT_COLOR;
|
|
89
|
+
};
|
|
90
|
+
export const getActiveColor = tr => {
|
|
91
|
+
const {
|
|
92
|
+
selection
|
|
93
|
+
} = tr;
|
|
94
|
+
let color;
|
|
95
|
+
if (selection instanceof CellSelection) {
|
|
96
|
+
color = getColorFromCellSelection(selection, tr);
|
|
97
|
+
} else if (selection instanceof TextSelection && selection.$cursor) {
|
|
98
|
+
color = getColorFromCursor(selection, tr);
|
|
99
|
+
} else {
|
|
100
|
+
color = getColorFromRange(selection.from, selection.to, tr);
|
|
101
|
+
}
|
|
102
|
+
return color === undefined ? REMOVE_HIGHLIGHT_COLOR : color;
|
|
42
103
|
};
|
|
@@ -53,7 +53,7 @@ var createAnalyticsEvent = function createAnalyticsEvent(color, tr) {
|
|
|
53
53
|
eventType: EVENT_TYPE.TRACK,
|
|
54
54
|
attributes: {
|
|
55
55
|
newColor: newColorLabel.toLowerCase(),
|
|
56
|
-
previousColor: previousColorLabel.toLowerCase()
|
|
56
|
+
previousColor: previousColorLabel ? previousColorLabel.toLowerCase() : ''
|
|
57
57
|
}
|
|
58
58
|
};
|
|
59
59
|
};
|
package/dist/esm/plugin.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { backgroundColor } from '@atlaskit/adf-schema';
|
|
3
2
|
import { changeColor } from './commands';
|
|
4
3
|
import { createPlugin, highlightPluginKey } from './pm-plugin';
|
|
5
4
|
import { ToolbarHighlightColorWithIntl as ToolbarHighlightColor } from './ui/ToolbarHighlightColor';
|
|
@@ -29,12 +28,6 @@ export var highlightPlugin = function highlightPlugin(_ref) {
|
|
|
29
28
|
commands: {
|
|
30
29
|
changeColor: changeColor(editorAnalyticsAPI)
|
|
31
30
|
},
|
|
32
|
-
marks: function marks() {
|
|
33
|
-
return [{
|
|
34
|
-
name: 'backgroundColor',
|
|
35
|
-
mark: backgroundColor
|
|
36
|
-
}];
|
|
37
|
-
},
|
|
38
31
|
pmPlugins: function pmPlugins() {
|
|
39
32
|
return [{
|
|
40
33
|
name: 'highlight',
|
package/dist/esm/pm-plugin.js
CHANGED
|
@@ -25,7 +25,6 @@ export var createPlugin = function createPlugin(_ref) {
|
|
|
25
25
|
apply: function apply(tr, pluginState, _oldState, newState) {
|
|
26
26
|
var _tr$getMeta;
|
|
27
27
|
var action = (_tr$getMeta = tr.getMeta(highlightPluginKey)) === null || _tr$getMeta === void 0 ? void 0 : _tr$getMeta.type;
|
|
28
|
-
var nextState;
|
|
29
28
|
switch (action) {
|
|
30
29
|
case HighlightPluginAction.CHANGE_COLOR:
|
|
31
30
|
var _tr$getMeta2 = tr.getMeta(highlightPluginKey),
|
|
@@ -34,11 +33,10 @@ export var createPlugin = function createPlugin(_ref) {
|
|
|
34
33
|
activeColor: color
|
|
35
34
|
});
|
|
36
35
|
default:
|
|
37
|
-
|
|
36
|
+
return _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
38
37
|
activeColor: getActiveColor(tr),
|
|
39
38
|
disabled: getDisabledState(newState)
|
|
40
39
|
});
|
|
41
|
-
return nextState;
|
|
42
40
|
}
|
|
43
41
|
}
|
|
44
42
|
}
|
|
@@ -88,7 +88,7 @@ var ToolbarHighlightColor = function ToolbarHighlightColor(_ref) {
|
|
|
88
88
|
|
|
89
89
|
// Get the design token for the active color (if it exists) to modify the toolbar
|
|
90
90
|
// icon, but show the nice rainbow if none is selected
|
|
91
|
-
var activeColorToken = highlightState.activeColor === REMOVE_HIGHLIGHT_COLOR ? null : hexToEditorTextBackgroundPaletteColor(highlightState.activeColor);
|
|
91
|
+
var activeColorToken = highlightState.activeColor === REMOVE_HIGHLIGHT_COLOR || highlightState.activeColor === null ? null : hexToEditorTextBackgroundPaletteColor(highlightState.activeColor);
|
|
92
92
|
|
|
93
93
|
// pixels, used to determine where to horizontally position the dropdown when space is limited
|
|
94
94
|
// this should reflect the width of the dropdown when fully populated with colors, including translations due to layering
|
package/dist/esm/utils/color.js
CHANGED
|
@@ -1,41 +1,98 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
|
+
import { entireSelectionContainsMark } from '@atlaskit/editor-common/mark';
|
|
1
3
|
import { REMOVE_HIGHLIGHT_COLOR } from '@atlaskit/editor-common/ui-color';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var
|
|
4
|
+
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
5
|
+
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
6
|
+
var getAllUniqueBackgroundColorMarksInRange = function getAllUniqueBackgroundColorMarksInRange(from, to, tr) {
|
|
7
|
+
var doc = tr.doc;
|
|
8
|
+
var backgroundColor = doc.type.schema.marks.backgroundColor;
|
|
9
|
+
var colorMarks = [];
|
|
10
|
+
var colorSet = new Set();
|
|
11
|
+
doc.nodesBetween(from, to, function (node) {
|
|
12
|
+
if (node.isLeaf) {
|
|
13
|
+
var mark = backgroundColor.isInSet(node.marks);
|
|
14
|
+
if (mark && !colorSet.has(mark.attrs.color)) {
|
|
15
|
+
colorMarks.push(mark);
|
|
16
|
+
colorSet.add(mark.attrs.color);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
return colorMarks;
|
|
21
|
+
};
|
|
22
|
+
var getAllUniqueBackgroundColorMarksInCellSelection = function getAllUniqueBackgroundColorMarksInCellSelection(selection, tr) {
|
|
23
|
+
var colorMarks = [];
|
|
24
|
+
var colorSet = new Set();
|
|
25
|
+
selection.forEachCell(function (cell, cellPos) {
|
|
26
|
+
var from = cellPos;
|
|
27
|
+
var to = cellPos + cell.nodeSize;
|
|
28
|
+
var marks = getAllUniqueBackgroundColorMarksInRange(from, to, tr);
|
|
29
|
+
marks.forEach(function (mark) {
|
|
30
|
+
if (!colorSet.has(mark.attrs.color)) {
|
|
31
|
+
colorMarks.push(mark);
|
|
32
|
+
colorSet.add(mark.attrs.color);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
return colorMarks;
|
|
37
|
+
};
|
|
8
38
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
39
|
+
// For Cell Selections - find first instance of a backgroundColor mark
|
|
40
|
+
// if all cells entirely contain this mark, set the color.
|
|
41
|
+
// If the selection contains multiple colors, return null
|
|
42
|
+
var getColorFromCellSelection = function getColorFromCellSelection(selection, tr) {
|
|
43
|
+
var marks = getAllUniqueBackgroundColorMarksInCellSelection(selection, tr);
|
|
44
|
+
if (marks.length > 1) {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
var firstColorMark = marks.at(0);
|
|
48
|
+
var foundNonColoredNode = false;
|
|
49
|
+
if (firstColorMark) {
|
|
50
|
+
selection.forEachCell(function (cell, cellPos) {
|
|
51
|
+
if (foundNonColoredNode) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
var from = cellPos;
|
|
55
|
+
var to = cellPos + cell.nodeSize;
|
|
56
|
+
if (!entireSelectionContainsMark(firstColorMark, tr.doc, from, to)) {
|
|
57
|
+
foundNonColoredNode = true;
|
|
19
58
|
}
|
|
20
|
-
return true;
|
|
21
59
|
});
|
|
22
60
|
}
|
|
61
|
+
return foundNonColoredNode ? REMOVE_HIGHLIGHT_COLOR : firstColorMark === null || firstColorMark === void 0 ? void 0 : firstColorMark.attrs.color;
|
|
62
|
+
};
|
|
23
63
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
return
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
|
|
64
|
+
// All other selections - find the first instance of a backgroundColor mark
|
|
65
|
+
// if selection entirely contains this mark, set the color.
|
|
66
|
+
// If the selection contains multiple colors, return null
|
|
67
|
+
var getColorFromRange = function getColorFromRange(from, to, tr) {
|
|
68
|
+
var marks = getAllUniqueBackgroundColorMarksInRange(from, to, tr);
|
|
69
|
+
if (marks.length > 1) {
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
var firstColorMark = marks.at(0);
|
|
73
|
+
if (firstColorMark && entireSelectionContainsMark(firstColorMark, tr.doc, from, to)) {
|
|
74
|
+
return firstColorMark.attrs.color;
|
|
75
|
+
}
|
|
76
|
+
return REMOVE_HIGHLIGHT_COLOR;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
// For Cursor selections - set color if it is found in the storedMarks or $cursor.marks
|
|
80
|
+
var getColorFromCursor = function getColorFromCursor(selection, tr) {
|
|
81
|
+
if (!selection.$cursor) {
|
|
38
82
|
return REMOVE_HIGHLIGHT_COLOR;
|
|
39
83
|
}
|
|
40
|
-
|
|
84
|
+
var mark = tr.doc.type.schema.marks.backgroundColor.isInSet([].concat(_toConsumableArray(tr.storedMarks ? tr.storedMarks : []), _toConsumableArray(selection.$cursor.marks())));
|
|
85
|
+
return (mark === null || mark === void 0 ? void 0 : mark.attrs.color) || REMOVE_HIGHLIGHT_COLOR;
|
|
86
|
+
};
|
|
87
|
+
export var getActiveColor = function getActiveColor(tr) {
|
|
88
|
+
var selection = tr.selection;
|
|
89
|
+
var color;
|
|
90
|
+
if (selection instanceof CellSelection) {
|
|
91
|
+
color = getColorFromCellSelection(selection, tr);
|
|
92
|
+
} else if (selection instanceof TextSelection && selection.$cursor) {
|
|
93
|
+
color = getColorFromCursor(selection, tr);
|
|
94
|
+
} else {
|
|
95
|
+
color = getColorFromRange(selection.from, selection.to, tr);
|
|
96
|
+
}
|
|
97
|
+
return color === undefined ? REMOVE_HIGHLIGHT_COLOR : color;
|
|
41
98
|
};
|
package/dist/types/plugin.d.ts
CHANGED
|
@@ -1,14 +1,21 @@
|
|
|
1
|
-
import type { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
|
|
1
|
+
import type { EditorCommand, NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
|
|
2
2
|
import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
3
|
+
import type { BackgroundColorPlugin } from '@atlaskit/editor-plugin-background-color';
|
|
3
4
|
import type { PrimaryToolbarPlugin } from '@atlaskit/editor-plugin-primary-toolbar';
|
|
4
5
|
import type { TextFormattingPlugin } from '@atlaskit/editor-plugin-text-formatting';
|
|
5
6
|
import type { HighlightPluginState } from './pm-plugin';
|
|
6
7
|
export type HighlightPlugin = NextEditorPlugin<'highlight', {
|
|
7
8
|
dependencies: [
|
|
9
|
+
BackgroundColorPlugin,
|
|
8
10
|
OptionalPlugin<AnalyticsPlugin>,
|
|
9
11
|
OptionalPlugin<TextFormattingPlugin>,
|
|
10
12
|
OptionalPlugin<PrimaryToolbarPlugin>
|
|
11
13
|
];
|
|
12
14
|
sharedState: HighlightPluginState | undefined;
|
|
15
|
+
commands: {
|
|
16
|
+
changeColor: ({ color }: {
|
|
17
|
+
color: string;
|
|
18
|
+
}) => EditorCommand;
|
|
19
|
+
};
|
|
13
20
|
}>;
|
|
14
21
|
export declare const highlightPlugin: HighlightPlugin;
|
|
@@ -4,7 +4,7 @@ import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
|
4
4
|
import type { HighlightPlugin } from './plugin';
|
|
5
5
|
export declare const highlightPluginKey: PluginKey<HighlightPluginState>;
|
|
6
6
|
export type HighlightPluginState = {
|
|
7
|
-
activeColor: string;
|
|
7
|
+
activeColor: string | null;
|
|
8
8
|
disabled: boolean;
|
|
9
9
|
};
|
|
10
10
|
export declare enum HighlightPluginAction {
|
|
@@ -3,5 +3,5 @@ type EditorHighlightIconProps = {
|
|
|
3
3
|
disabled: boolean;
|
|
4
4
|
selectedColor?: string | null;
|
|
5
5
|
};
|
|
6
|
-
export declare const EditorHighlightIcon: ({ disabled, selectedColor
|
|
6
|
+
export declare const EditorHighlightIcon: ({ disabled, selectedColor }: EditorHighlightIconProps) => JSX.Element;
|
|
7
7
|
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type
|
|
2
|
-
export declare const getActiveColor: (tr: Transaction | ReadonlyTransaction) => string;
|
|
1
|
+
import { type ReadonlyTransaction, type Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
2
|
+
export declare const getActiveColor: (tr: Transaction | ReadonlyTransaction) => string | null;
|
|
@@ -1,14 +1,21 @@
|
|
|
1
|
-
import type { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
|
|
1
|
+
import type { EditorCommand, NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
|
|
2
2
|
import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
3
|
+
import type { BackgroundColorPlugin } from '@atlaskit/editor-plugin-background-color';
|
|
3
4
|
import type { PrimaryToolbarPlugin } from '@atlaskit/editor-plugin-primary-toolbar';
|
|
4
5
|
import type { TextFormattingPlugin } from '@atlaskit/editor-plugin-text-formatting';
|
|
5
6
|
import type { HighlightPluginState } from './pm-plugin';
|
|
6
7
|
export type HighlightPlugin = NextEditorPlugin<'highlight', {
|
|
7
8
|
dependencies: [
|
|
9
|
+
BackgroundColorPlugin,
|
|
8
10
|
OptionalPlugin<AnalyticsPlugin>,
|
|
9
11
|
OptionalPlugin<TextFormattingPlugin>,
|
|
10
12
|
OptionalPlugin<PrimaryToolbarPlugin>
|
|
11
13
|
];
|
|
12
14
|
sharedState: HighlightPluginState | undefined;
|
|
15
|
+
commands: {
|
|
16
|
+
changeColor: ({ color }: {
|
|
17
|
+
color: string;
|
|
18
|
+
}) => EditorCommand;
|
|
19
|
+
};
|
|
13
20
|
}>;
|
|
14
21
|
export declare const highlightPlugin: HighlightPlugin;
|
|
@@ -4,7 +4,7 @@ import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
|
4
4
|
import type { HighlightPlugin } from './plugin';
|
|
5
5
|
export declare const highlightPluginKey: PluginKey<HighlightPluginState>;
|
|
6
6
|
export type HighlightPluginState = {
|
|
7
|
-
activeColor: string;
|
|
7
|
+
activeColor: string | null;
|
|
8
8
|
disabled: boolean;
|
|
9
9
|
};
|
|
10
10
|
export declare enum HighlightPluginAction {
|
|
@@ -3,5 +3,5 @@ type EditorHighlightIconProps = {
|
|
|
3
3
|
disabled: boolean;
|
|
4
4
|
selectedColor?: string | null;
|
|
5
5
|
};
|
|
6
|
-
export declare const EditorHighlightIcon: ({ disabled, selectedColor
|
|
6
|
+
export declare const EditorHighlightIcon: ({ disabled, selectedColor }: EditorHighlightIconProps) => JSX.Element;
|
|
7
7
|
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type
|
|
2
|
-
export declare const getActiveColor: (tr: Transaction | ReadonlyTransaction) => string;
|
|
1
|
+
import { type ReadonlyTransaction, type Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
2
|
+
export declare const getActiveColor: (tr: Transaction | ReadonlyTransaction) => string | null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-highlight",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
4
4
|
"description": "Highlight plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -38,16 +38,17 @@
|
|
|
38
38
|
".": "./src/index.ts"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@atlaskit/adf-schema": "^36.10.7",
|
|
42
41
|
"@atlaskit/editor-common": "^81.1.0",
|
|
43
42
|
"@atlaskit/editor-palette": "1.6.0",
|
|
44
43
|
"@atlaskit/editor-plugin-analytics": "^1.2.0",
|
|
44
|
+
"@atlaskit/editor-plugin-background-color": "^1.1.0",
|
|
45
45
|
"@atlaskit/editor-plugin-primary-toolbar": "^1.1.0",
|
|
46
46
|
"@atlaskit/editor-plugin-text-formatting": "^1.7.0",
|
|
47
47
|
"@atlaskit/editor-prosemirror": "4.0.1",
|
|
48
48
|
"@atlaskit/editor-shared-styles": "^2.11.0",
|
|
49
|
+
"@atlaskit/editor-tables": "^2.7.4",
|
|
49
50
|
"@atlaskit/icon": "^22.3.0",
|
|
50
|
-
"@atlaskit/primitives": "^6.
|
|
51
|
+
"@atlaskit/primitives": "^6.4.0",
|
|
51
52
|
"@babel/runtime": "^7.0.0",
|
|
52
53
|
"@emotion/react": "^11.7.1"
|
|
53
54
|
},
|
|
@@ -57,7 +58,6 @@
|
|
|
57
58
|
},
|
|
58
59
|
"devDependencies": {
|
|
59
60
|
"@atlaskit/tokens": "^1.49.0",
|
|
60
|
-
"@atlassian/atlassian-frontend-prettier-config-1.0.0": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.0",
|
|
61
61
|
"typescript": "~5.4.2"
|
|
62
62
|
},
|
|
63
63
|
"techstack": {
|
|
@@ -95,7 +95,6 @@
|
|
|
95
95
|
]
|
|
96
96
|
}
|
|
97
97
|
},
|
|
98
|
-
"prettier": "@atlassian/atlassian-frontend-prettier-config-1.0.0",
|
|
99
98
|
"stricter": {
|
|
100
99
|
"no-unused-dependencies": {
|
|
101
100
|
"checkDevDependencies": true,
|