@atlaskit/editor-plugin-text-color 1.3.2 → 1.4.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 +25 -0
- package/dist/cjs/plugin.js +29 -21
- package/dist/cjs/ui/ToolbarTextColor/index.js +2 -3
- package/dist/cjs/utils/disabled.js +24 -2
- package/dist/es2019/plugin.js +28 -20
- package/dist/es2019/ui/ToolbarTextColor/index.js +2 -3
- package/dist/es2019/utils/disabled.js +45 -3
- package/dist/esm/plugin.js +29 -21
- package/dist/esm/ui/ToolbarTextColor/index.js +2 -3
- package/dist/esm/utils/disabled.js +25 -3
- package/dist/types/types.d.ts +2 -2
- package/dist/types-ts4.5/types.d.ts +2 -2
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-text-color
|
|
2
2
|
|
|
3
|
+
## 1.4.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#101406](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/101406)
|
|
8
|
+
[`6daffd65aec4`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/6daffd65aec4) -
|
|
9
|
+
[ED-23298] Extract primary toolbar components to editor plugin to allow for custom ordering
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#102478](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/102478)
|
|
14
|
+
[`3378951608b0`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/3378951608b0) -
|
|
15
|
+
[ED-23332] Update adf-schema package to 36.10.1
|
|
16
|
+
- Updated dependencies
|
|
17
|
+
|
|
18
|
+
## 1.3.3
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- [#101513](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/101513)
|
|
23
|
+
[`98b5dfc33bed`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/98b5dfc33bed) -
|
|
24
|
+
[ux] [ED-23156] The highlight primary toolbar button is disabled when trying to apply it on
|
|
25
|
+
nodes that don't enable the mark and when in a gap cursor. The text color primary toolbar button
|
|
26
|
+
is disabled when selecting text with a highlight.
|
|
27
|
+
|
|
3
28
|
## 1.3.2
|
|
4
29
|
|
|
5
30
|
### Patch Changes
|
package/dist/cjs/plugin.js
CHANGED
|
@@ -25,6 +25,25 @@ var pluginConfig = function pluginConfig(textColorConfig) {
|
|
|
25
25
|
var textColorPlugin = exports.textColorPlugin = function textColorPlugin(_ref) {
|
|
26
26
|
var textColorConfig = _ref.config,
|
|
27
27
|
api = _ref.api;
|
|
28
|
+
var primaryToolbarComponent = function primaryToolbarComponent(_ref2) {
|
|
29
|
+
var editorView = _ref2.editorView,
|
|
30
|
+
popupsMountPoint = _ref2.popupsMountPoint,
|
|
31
|
+
popupsBoundariesElement = _ref2.popupsBoundariesElement,
|
|
32
|
+
popupsScrollableElement = _ref2.popupsScrollableElement,
|
|
33
|
+
isToolbarReducedSpacing = _ref2.isToolbarReducedSpacing,
|
|
34
|
+
dispatchAnalyticsEvent = _ref2.dispatchAnalyticsEvent,
|
|
35
|
+
disabled = _ref2.disabled;
|
|
36
|
+
return /*#__PURE__*/_react.default.createElement(_PrimaryToolbarComponent.PrimaryToolbarComponent, {
|
|
37
|
+
isReducedSpacing: isToolbarReducedSpacing,
|
|
38
|
+
editorView: editorView,
|
|
39
|
+
popupsMountPoint: popupsMountPoint,
|
|
40
|
+
popupsBoundariesElement: popupsBoundariesElement,
|
|
41
|
+
popupsScrollableElement: popupsScrollableElement,
|
|
42
|
+
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
43
|
+
disabled: disabled,
|
|
44
|
+
api: api
|
|
45
|
+
});
|
|
46
|
+
};
|
|
28
47
|
return {
|
|
29
48
|
name: 'textColor',
|
|
30
49
|
marks: function marks() {
|
|
@@ -36,8 +55,8 @@ var textColorPlugin = exports.textColorPlugin = function textColorPlugin(_ref) {
|
|
|
36
55
|
pmPlugins: function pmPlugins() {
|
|
37
56
|
return [{
|
|
38
57
|
name: 'textColor',
|
|
39
|
-
plugin: function plugin(
|
|
40
|
-
var dispatch =
|
|
58
|
+
plugin: function plugin(_ref3) {
|
|
59
|
+
var dispatch = _ref3.dispatch;
|
|
41
60
|
return (0, _main.createPlugin)(dispatch, pluginConfig(textColorConfig));
|
|
42
61
|
}
|
|
43
62
|
}];
|
|
@@ -54,24 +73,13 @@ var textColorPlugin = exports.textColorPlugin = function textColorPlugin(_ref) {
|
|
|
54
73
|
return (0, _changeColor2.changeColor)(color, api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions);
|
|
55
74
|
}
|
|
56
75
|
},
|
|
57
|
-
|
|
58
|
-
var
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
return /*#__PURE__*/_react.default.createElement(_PrimaryToolbarComponent.PrimaryToolbarComponent, {
|
|
66
|
-
isReducedSpacing: isToolbarReducedSpacing,
|
|
67
|
-
editorView: editorView,
|
|
68
|
-
popupsMountPoint: popupsMountPoint,
|
|
69
|
-
popupsBoundariesElement: popupsBoundariesElement,
|
|
70
|
-
popupsScrollableElement: popupsScrollableElement,
|
|
71
|
-
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
72
|
-
disabled: disabled,
|
|
73
|
-
api: api
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
+
usePluginHook: function usePluginHook() {
|
|
77
|
+
var _api$core, _api$primaryToolbar;
|
|
78
|
+
api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(api === null || api === void 0 || (_api$primaryToolbar = api.primaryToolbar) === null || _api$primaryToolbar === void 0 ? void 0 : _api$primaryToolbar.commands.registerComponent({
|
|
79
|
+
name: 'textColor',
|
|
80
|
+
component: primaryToolbarComponent
|
|
81
|
+
}));
|
|
82
|
+
},
|
|
83
|
+
primaryToolbarComponent: !(api !== null && api !== void 0 && api.primaryToolbar) ? primaryToolbarComponent : undefined
|
|
76
84
|
};
|
|
77
85
|
};
|
|
@@ -226,9 +226,8 @@ var ToolbarTextColor = exports.ToolbarTextColor = /*#__PURE__*/function (_React$
|
|
|
226
226
|
hexToPaletteColor: _editorPalette.hexToEditorTextPaletteColor,
|
|
227
227
|
paletteColorTooltipMessages: _uiColor.textPaletteTooltipMessages
|
|
228
228
|
}
|
|
229
|
-
}))),
|
|
230
|
-
|
|
231
|
-
!(pluginInjectionApi !== null && pluginInjectionApi !== void 0 && pluginInjectionApi.highlight) && (0, _react2.jsx)("span", {
|
|
229
|
+
}))), !(pluginInjectionApi !== null && pluginInjectionApi !== void 0 && pluginInjectionApi.primaryToolbar) && /* eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage */
|
|
230
|
+
(0, _react2.jsx)("span", {
|
|
232
231
|
css: _styles.separatorStyles
|
|
233
232
|
}))
|
|
234
233
|
);
|
|
@@ -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())) {
|
package/dist/es2019/plugin.js
CHANGED
|
@@ -13,6 +13,26 @@ export const textColorPlugin = ({
|
|
|
13
13
|
config: textColorConfig,
|
|
14
14
|
api
|
|
15
15
|
}) => {
|
|
16
|
+
const primaryToolbarComponent = ({
|
|
17
|
+
editorView,
|
|
18
|
+
popupsMountPoint,
|
|
19
|
+
popupsBoundariesElement,
|
|
20
|
+
popupsScrollableElement,
|
|
21
|
+
isToolbarReducedSpacing,
|
|
22
|
+
dispatchAnalyticsEvent,
|
|
23
|
+
disabled
|
|
24
|
+
}) => {
|
|
25
|
+
return /*#__PURE__*/React.createElement(PrimaryToolbarComponent, {
|
|
26
|
+
isReducedSpacing: isToolbarReducedSpacing,
|
|
27
|
+
editorView: editorView,
|
|
28
|
+
popupsMountPoint: popupsMountPoint,
|
|
29
|
+
popupsBoundariesElement: popupsBoundariesElement,
|
|
30
|
+
popupsScrollableElement: popupsScrollableElement,
|
|
31
|
+
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
32
|
+
disabled: disabled,
|
|
33
|
+
api: api
|
|
34
|
+
});
|
|
35
|
+
};
|
|
16
36
|
return {
|
|
17
37
|
name: 'textColor',
|
|
18
38
|
marks() {
|
|
@@ -41,26 +61,14 @@ export const textColorPlugin = ({
|
|
|
41
61
|
return changeColor(color, api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions);
|
|
42
62
|
}
|
|
43
63
|
},
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}) {
|
|
53
|
-
return /*#__PURE__*/React.createElement(PrimaryToolbarComponent, {
|
|
54
|
-
isReducedSpacing: isToolbarReducedSpacing,
|
|
55
|
-
editorView: editorView,
|
|
56
|
-
popupsMountPoint: popupsMountPoint,
|
|
57
|
-
popupsBoundariesElement: popupsBoundariesElement,
|
|
58
|
-
popupsScrollableElement: popupsScrollableElement,
|
|
59
|
-
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
60
|
-
disabled: disabled,
|
|
61
|
-
api: api
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
+
usePluginHook: () => {
|
|
65
|
+
var _api$core, _api$primaryToolbar;
|
|
66
|
+
api === null || api === void 0 ? void 0 : (_api$core = api.core) === null || _api$core === void 0 ? void 0 : _api$core.actions.execute(api === null || api === void 0 ? void 0 : (_api$primaryToolbar = api.primaryToolbar) === null || _api$primaryToolbar === void 0 ? void 0 : _api$primaryToolbar.commands.registerComponent({
|
|
67
|
+
name: 'textColor',
|
|
68
|
+
component: primaryToolbarComponent
|
|
69
|
+
}));
|
|
70
|
+
},
|
|
71
|
+
primaryToolbarComponent: !(api !== null && api !== void 0 && api.primaryToolbar) ? primaryToolbarComponent : undefined
|
|
64
72
|
};
|
|
65
73
|
};
|
|
66
74
|
export { textColorPluginKey };
|
|
@@ -205,9 +205,8 @@ export class ToolbarTextColor extends React.Component {
|
|
|
205
205
|
hexToPaletteColor: hexToEditorTextPaletteColor,
|
|
206
206
|
paletteColorTooltipMessages: textPaletteTooltipMessages
|
|
207
207
|
}
|
|
208
|
-
}))),
|
|
209
|
-
|
|
210
|
-
!(pluginInjectionApi !== null && pluginInjectionApi !== void 0 && pluginInjectionApi.highlight) && jsx("span", {
|
|
208
|
+
}))), !(pluginInjectionApi !== null && pluginInjectionApi !== void 0 && pluginInjectionApi.primaryToolbar) && /* eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage */
|
|
209
|
+
jsx("span", {
|
|
211
210
|
css: separatorStyles
|
|
212
211
|
}))
|
|
213
212
|
);
|
|
@@ -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())) {
|
package/dist/esm/plugin.js
CHANGED
|
@@ -12,6 +12,25 @@ var pluginConfig = function pluginConfig(textColorConfig) {
|
|
|
12
12
|
export var textColorPlugin = function textColorPlugin(_ref) {
|
|
13
13
|
var textColorConfig = _ref.config,
|
|
14
14
|
api = _ref.api;
|
|
15
|
+
var primaryToolbarComponent = function primaryToolbarComponent(_ref2) {
|
|
16
|
+
var editorView = _ref2.editorView,
|
|
17
|
+
popupsMountPoint = _ref2.popupsMountPoint,
|
|
18
|
+
popupsBoundariesElement = _ref2.popupsBoundariesElement,
|
|
19
|
+
popupsScrollableElement = _ref2.popupsScrollableElement,
|
|
20
|
+
isToolbarReducedSpacing = _ref2.isToolbarReducedSpacing,
|
|
21
|
+
dispatchAnalyticsEvent = _ref2.dispatchAnalyticsEvent,
|
|
22
|
+
disabled = _ref2.disabled;
|
|
23
|
+
return /*#__PURE__*/React.createElement(PrimaryToolbarComponent, {
|
|
24
|
+
isReducedSpacing: isToolbarReducedSpacing,
|
|
25
|
+
editorView: editorView,
|
|
26
|
+
popupsMountPoint: popupsMountPoint,
|
|
27
|
+
popupsBoundariesElement: popupsBoundariesElement,
|
|
28
|
+
popupsScrollableElement: popupsScrollableElement,
|
|
29
|
+
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
30
|
+
disabled: disabled,
|
|
31
|
+
api: api
|
|
32
|
+
});
|
|
33
|
+
};
|
|
15
34
|
return {
|
|
16
35
|
name: 'textColor',
|
|
17
36
|
marks: function marks() {
|
|
@@ -23,8 +42,8 @@ export var textColorPlugin = function textColorPlugin(_ref) {
|
|
|
23
42
|
pmPlugins: function pmPlugins() {
|
|
24
43
|
return [{
|
|
25
44
|
name: 'textColor',
|
|
26
|
-
plugin: function plugin(
|
|
27
|
-
var dispatch =
|
|
45
|
+
plugin: function plugin(_ref3) {
|
|
46
|
+
var dispatch = _ref3.dispatch;
|
|
28
47
|
return createPlugin(dispatch, pluginConfig(textColorConfig));
|
|
29
48
|
}
|
|
30
49
|
}];
|
|
@@ -41,25 +60,14 @@ export var textColorPlugin = function textColorPlugin(_ref) {
|
|
|
41
60
|
return _changeColor(color, api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions);
|
|
42
61
|
}
|
|
43
62
|
},
|
|
44
|
-
|
|
45
|
-
var
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
return /*#__PURE__*/React.createElement(PrimaryToolbarComponent, {
|
|
53
|
-
isReducedSpacing: isToolbarReducedSpacing,
|
|
54
|
-
editorView: editorView,
|
|
55
|
-
popupsMountPoint: popupsMountPoint,
|
|
56
|
-
popupsBoundariesElement: popupsBoundariesElement,
|
|
57
|
-
popupsScrollableElement: popupsScrollableElement,
|
|
58
|
-
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
59
|
-
disabled: disabled,
|
|
60
|
-
api: api
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
+
usePluginHook: function usePluginHook() {
|
|
64
|
+
var _api$core, _api$primaryToolbar;
|
|
65
|
+
api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(api === null || api === void 0 || (_api$primaryToolbar = api.primaryToolbar) === null || _api$primaryToolbar === void 0 ? void 0 : _api$primaryToolbar.commands.registerComponent({
|
|
66
|
+
name: 'textColor',
|
|
67
|
+
component: primaryToolbarComponent
|
|
68
|
+
}));
|
|
69
|
+
},
|
|
70
|
+
primaryToolbarComponent: !(api !== null && api !== void 0 && api.primaryToolbar) ? primaryToolbarComponent : undefined
|
|
63
71
|
};
|
|
64
72
|
};
|
|
65
73
|
export { textColorPluginKey };
|
|
@@ -220,9 +220,8 @@ export var ToolbarTextColor = /*#__PURE__*/function (_React$Component) {
|
|
|
220
220
|
hexToPaletteColor: hexToEditorTextPaletteColor,
|
|
221
221
|
paletteColorTooltipMessages: textPaletteTooltipMessages
|
|
222
222
|
}
|
|
223
|
-
}))),
|
|
224
|
-
|
|
225
|
-
!(pluginInjectionApi !== null && pluginInjectionApi !== void 0 && pluginInjectionApi.highlight) && jsx("span", {
|
|
223
|
+
}))), !(pluginInjectionApi !== null && pluginInjectionApi !== void 0 && pluginInjectionApi.primaryToolbar) && /* eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage */
|
|
224
|
+
jsx("span", {
|
|
226
225
|
css: separatorStyles
|
|
227
226
|
}))
|
|
228
227
|
);
|
|
@@ -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/dist/types/types.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type { Command, NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
|
|
2
2
|
import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
3
|
-
import type {
|
|
3
|
+
import type { PrimaryToolbarPlugin } from '@atlaskit/editor-plugin-primary-toolbar';
|
|
4
4
|
import type { TextColorPluginConfig, TextColorPluginState } from './pm-plugins/main';
|
|
5
5
|
type Config = TextColorPluginConfig | boolean;
|
|
6
6
|
export type TextColorPlugin = NextEditorPlugin<'textColor', {
|
|
7
7
|
pluginConfiguration: Config | undefined;
|
|
8
8
|
dependencies: [
|
|
9
9
|
OptionalPlugin<AnalyticsPlugin>,
|
|
10
|
-
OptionalPlugin<
|
|
10
|
+
OptionalPlugin<PrimaryToolbarPlugin>
|
|
11
11
|
];
|
|
12
12
|
actions: {
|
|
13
13
|
changeColor: (color: string) => Command;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type { Command, NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
|
|
2
2
|
import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
3
|
-
import type {
|
|
3
|
+
import type { PrimaryToolbarPlugin } from '@atlaskit/editor-plugin-primary-toolbar';
|
|
4
4
|
import type { TextColorPluginConfig, TextColorPluginState } from './pm-plugins/main';
|
|
5
5
|
type Config = TextColorPluginConfig | boolean;
|
|
6
6
|
export type TextColorPlugin = NextEditorPlugin<'textColor', {
|
|
7
7
|
pluginConfiguration: Config | undefined;
|
|
8
8
|
dependencies: [
|
|
9
9
|
OptionalPlugin<AnalyticsPlugin>,
|
|
10
|
-
OptionalPlugin<
|
|
10
|
+
OptionalPlugin<PrimaryToolbarPlugin>
|
|
11
11
|
];
|
|
12
12
|
actions: {
|
|
13
13
|
changeColor: (color: string) => Command;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-text-color",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "Text color plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -33,15 +33,15 @@
|
|
|
33
33
|
".": "./src/index.ts"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@atlaskit/adf-schema": "^36.
|
|
37
|
-
"@atlaskit/editor-common": "^
|
|
36
|
+
"@atlaskit/adf-schema": "^36.10.7",
|
|
37
|
+
"@atlaskit/editor-common": "^81.0.0",
|
|
38
38
|
"@atlaskit/editor-palette": "1.6.0",
|
|
39
39
|
"@atlaskit/editor-plugin-analytics": "^1.2.0",
|
|
40
|
-
"@atlaskit/editor-plugin-
|
|
40
|
+
"@atlaskit/editor-plugin-primary-toolbar": "^1.1.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"
|