@atlaskit/editor-plugin-text-color 1.3.2 → 1.3.3
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 +10 -0
- package/dist/cjs/utils/disabled.js +24 -2
- package/dist/es2019/utils/disabled.js +45 -3
- package/dist/esm/utils/disabled.js +25 -3
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-text-color
|
|
2
2
|
|
|
3
|
+
## 1.3.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#101513](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/101513)
|
|
8
|
+
[`98b5dfc33bed`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/98b5dfc33bed) -
|
|
9
|
+
[ux] [ED-23156] The highlight primary toolbar button is disabled when trying to apply it on
|
|
10
|
+
nodes that don't enable the mark and when in a gap cursor. The text color primary toolbar button
|
|
11
|
+
is disabled when selecting text with a highlight.
|
|
12
|
+
|
|
3
13
|
## 1.3.2
|
|
4
14
|
|
|
5
15
|
### Patch Changes
|
|
@@ -13,14 +13,36 @@ var hasLinkMark = function hasLinkMark($pos) {
|
|
|
13
13
|
}
|
|
14
14
|
return $pos.doc.rangeHasMark(pos, Math.min(pos + 1, $pos.doc.content.size), linkMarkType);
|
|
15
15
|
};
|
|
16
|
+
var hasHighlightMark = function hasHighlightMark($pos) {
|
|
17
|
+
var highlightMarkType = $pos.doc.type.schema.marks.backgroundColor;
|
|
18
|
+
if (!highlightMarkType) {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
var node = $pos.nodeBefore;
|
|
22
|
+
if (!node) {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
return !!highlightMarkType.isInSet(node.marks);
|
|
26
|
+
};
|
|
27
|
+
var hasHighlightMarkInRange = function hasHighlightMarkInRange($from, $to) {
|
|
28
|
+
var highlightMarkType = $from.doc.type.schema.marks.backgroundColor,
|
|
29
|
+
pos = $from.pos,
|
|
30
|
+
doc = $from.doc;
|
|
31
|
+
if (!highlightMarkType) {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
return (0, _mark.entireSelectionContainsMark)(highlightMarkType, doc, pos, $to.pos);
|
|
35
|
+
};
|
|
16
36
|
var getDisabledState = exports.getDisabledState = function getDisabledState(state) {
|
|
17
37
|
var textColor = state.schema.marks.textColor;
|
|
18
38
|
if (textColor) {
|
|
19
39
|
var _ref = state.selection,
|
|
20
40
|
empty = _ref.empty,
|
|
21
41
|
ranges = _ref.ranges,
|
|
22
|
-
$cursor = _ref.$cursor
|
|
23
|
-
|
|
42
|
+
$cursor = _ref.$cursor,
|
|
43
|
+
$from = _ref.$from,
|
|
44
|
+
$to = _ref.$to;
|
|
45
|
+
if (empty && !$cursor || $cursor && hasLinkMark($cursor) || $cursor && hasHighlightMark($cursor) || !$cursor && $from && $to && hasHighlightMarkInRange($from, $to) || (0, _mark.isMarkAllowedInRange)(state.doc, ranges, textColor) === false) {
|
|
24
46
|
return true;
|
|
25
47
|
}
|
|
26
48
|
if ((0, _mark.isMarkExcluded)(textColor, state.storedMarks || $cursor && $cursor.marks())) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isMarkAllowedInRange, isMarkExcluded } from '@atlaskit/editor-common/mark';
|
|
1
|
+
import { entireSelectionContainsMark, isMarkAllowedInRange, isMarkExcluded } from '@atlaskit/editor-common/mark';
|
|
2
2
|
const hasLinkMark = $pos => {
|
|
3
3
|
const {
|
|
4
4
|
doc: {
|
|
@@ -17,6 +17,46 @@ const hasLinkMark = $pos => {
|
|
|
17
17
|
}
|
|
18
18
|
return $pos.doc.rangeHasMark(pos, Math.min(pos + 1, $pos.doc.content.size), linkMarkType);
|
|
19
19
|
};
|
|
20
|
+
const hasHighlightMark = $pos => {
|
|
21
|
+
const {
|
|
22
|
+
doc: {
|
|
23
|
+
type: {
|
|
24
|
+
schema: {
|
|
25
|
+
marks: {
|
|
26
|
+
backgroundColor: highlightMarkType
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
} = $pos;
|
|
32
|
+
if (!highlightMarkType) {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
const node = $pos.nodeBefore;
|
|
36
|
+
if (!node) {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
return !!highlightMarkType.isInSet(node.marks);
|
|
40
|
+
};
|
|
41
|
+
const hasHighlightMarkInRange = ($from, $to) => {
|
|
42
|
+
const {
|
|
43
|
+
doc: {
|
|
44
|
+
type: {
|
|
45
|
+
schema: {
|
|
46
|
+
marks: {
|
|
47
|
+
backgroundColor: highlightMarkType
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
pos,
|
|
53
|
+
doc
|
|
54
|
+
} = $from;
|
|
55
|
+
if (!highlightMarkType) {
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
return entireSelectionContainsMark(highlightMarkType, doc, pos, $to.pos);
|
|
59
|
+
};
|
|
20
60
|
export const getDisabledState = state => {
|
|
21
61
|
const {
|
|
22
62
|
textColor
|
|
@@ -25,9 +65,11 @@ export const getDisabledState = state => {
|
|
|
25
65
|
const {
|
|
26
66
|
empty,
|
|
27
67
|
ranges,
|
|
28
|
-
$cursor
|
|
68
|
+
$cursor,
|
|
69
|
+
$from,
|
|
70
|
+
$to
|
|
29
71
|
} = state.selection;
|
|
30
|
-
if (empty && !$cursor || $cursor && hasLinkMark($cursor) || isMarkAllowedInRange(state.doc, ranges, textColor) === false) {
|
|
72
|
+
if (empty && !$cursor || $cursor && hasLinkMark($cursor) || $cursor && hasHighlightMark($cursor) || !$cursor && $from && $to && hasHighlightMarkInRange($from, $to) || isMarkAllowedInRange(state.doc, ranges, textColor) === false) {
|
|
31
73
|
return true;
|
|
32
74
|
}
|
|
33
75
|
if (isMarkExcluded(textColor, state.storedMarks || $cursor && $cursor.marks())) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isMarkAllowedInRange, isMarkExcluded } from '@atlaskit/editor-common/mark';
|
|
1
|
+
import { entireSelectionContainsMark, isMarkAllowedInRange, isMarkExcluded } from '@atlaskit/editor-common/mark';
|
|
2
2
|
var hasLinkMark = function hasLinkMark($pos) {
|
|
3
3
|
var linkMarkType = $pos.doc.type.schema.marks.link,
|
|
4
4
|
pos = $pos.pos;
|
|
@@ -7,14 +7,36 @@ var hasLinkMark = function hasLinkMark($pos) {
|
|
|
7
7
|
}
|
|
8
8
|
return $pos.doc.rangeHasMark(pos, Math.min(pos + 1, $pos.doc.content.size), linkMarkType);
|
|
9
9
|
};
|
|
10
|
+
var hasHighlightMark = function hasHighlightMark($pos) {
|
|
11
|
+
var highlightMarkType = $pos.doc.type.schema.marks.backgroundColor;
|
|
12
|
+
if (!highlightMarkType) {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
var node = $pos.nodeBefore;
|
|
16
|
+
if (!node) {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
return !!highlightMarkType.isInSet(node.marks);
|
|
20
|
+
};
|
|
21
|
+
var hasHighlightMarkInRange = function hasHighlightMarkInRange($from, $to) {
|
|
22
|
+
var highlightMarkType = $from.doc.type.schema.marks.backgroundColor,
|
|
23
|
+
pos = $from.pos,
|
|
24
|
+
doc = $from.doc;
|
|
25
|
+
if (!highlightMarkType) {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
return entireSelectionContainsMark(highlightMarkType, doc, pos, $to.pos);
|
|
29
|
+
};
|
|
10
30
|
export var getDisabledState = function getDisabledState(state) {
|
|
11
31
|
var textColor = state.schema.marks.textColor;
|
|
12
32
|
if (textColor) {
|
|
13
33
|
var _ref = state.selection,
|
|
14
34
|
empty = _ref.empty,
|
|
15
35
|
ranges = _ref.ranges,
|
|
16
|
-
$cursor = _ref.$cursor
|
|
17
|
-
|
|
36
|
+
$cursor = _ref.$cursor,
|
|
37
|
+
$from = _ref.$from,
|
|
38
|
+
$to = _ref.$to;
|
|
39
|
+
if (empty && !$cursor || $cursor && hasLinkMark($cursor) || $cursor && hasHighlightMark($cursor) || !$cursor && $from && $to && hasHighlightMarkInRange($from, $to) || isMarkAllowedInRange(state.doc, ranges, textColor) === false) {
|
|
18
40
|
return true;
|
|
19
41
|
}
|
|
20
42
|
if (isMarkExcluded(textColor, state.storedMarks || $cursor && $cursor.marks())) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-text-color",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.3",
|
|
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,14 @@
|
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@atlaskit/adf-schema": "^36.8.0",
|
|
37
|
-
"@atlaskit/editor-common": "^80.
|
|
37
|
+
"@atlaskit/editor-common": "^80.5.0",
|
|
38
38
|
"@atlaskit/editor-palette": "1.6.0",
|
|
39
39
|
"@atlaskit/editor-plugin-analytics": "^1.2.0",
|
|
40
40
|
"@atlaskit/editor-plugin-highlight": "^1.4.0",
|
|
41
41
|
"@atlaskit/editor-prosemirror": "4.0.1",
|
|
42
42
|
"@atlaskit/editor-shared-styles": "^2.11.0",
|
|
43
43
|
"@atlaskit/editor-tables": "^2.7.0",
|
|
44
|
-
"@atlaskit/icon": "^22.
|
|
44
|
+
"@atlaskit/icon": "^22.3.0",
|
|
45
45
|
"@atlaskit/theme": "^12.8.0",
|
|
46
46
|
"@babel/runtime": "^7.0.0",
|
|
47
47
|
"@emotion/react": "^11.7.1"
|