@atlaskit/editor-plugin-highlight 1.4.2 → 1.6.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 +29 -0
- package/dist/cjs/commands/change-color.js +1 -1
- package/dist/cjs/plugin.js +25 -18
- package/dist/cjs/pm-plugin.js +3 -4
- package/dist/cjs/ui/ToolbarHighlightColor.js +1 -3
- package/dist/cjs/utils/color.js +4 -5
- package/dist/es2019/commands/change-color.js +1 -1
- package/dist/es2019/plugin.js +24 -17
- package/dist/es2019/pm-plugin.js +3 -4
- package/dist/es2019/ui/ToolbarHighlightColor.js +2 -4
- package/dist/es2019/utils/color.js +3 -3
- package/dist/esm/commands/change-color.js +1 -1
- package/dist/esm/plugin.js +25 -18
- package/dist/esm/pm-plugin.js +3 -4
- package/dist/esm/ui/ToolbarHighlightColor.js +2 -4
- package/dist/esm/utils/color.js +4 -5
- package/dist/types/plugin.d.ts +3 -1
- package/dist/types/utils/color.d.ts +2 -2
- package/dist/types-ts4.5/plugin.d.ts +3 -1
- package/dist/types-ts4.5/utils/color.d.ts +2 -2
- package/package.json +5 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,34 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-highlight
|
|
2
2
|
|
|
3
|
+
## 1.6.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#104271](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/104271)
|
|
8
|
+
[`5d03a899b0c9`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/5d03a899b0c9) -
|
|
9
|
+
[ux] [ED-23155] Adds plugin state for currently selected color for highlight button
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#103816](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/103816)
|
|
14
|
+
[`3fb50173376f`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/3fb50173376f) -
|
|
15
|
+
[ED-23159] Added blending styling for when highlights overlap inline comments
|
|
16
|
+
|
|
17
|
+
## 1.5.0
|
|
18
|
+
|
|
19
|
+
### Minor Changes
|
|
20
|
+
|
|
21
|
+
- [#101406](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/101406)
|
|
22
|
+
[`6daffd65aec4`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/6daffd65aec4) -
|
|
23
|
+
[ED-23298] Extract primary toolbar components to editor plugin to allow for custom ordering
|
|
24
|
+
|
|
25
|
+
### Patch Changes
|
|
26
|
+
|
|
27
|
+
- [#102478](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/102478)
|
|
28
|
+
[`3378951608b0`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/3378951608b0) -
|
|
29
|
+
[ED-23332] Update adf-schema package to 36.10.1
|
|
30
|
+
- Updated dependencies
|
|
31
|
+
|
|
3
32
|
## 1.4.2
|
|
4
33
|
|
|
5
34
|
### Patch Changes
|
|
@@ -51,7 +51,7 @@ var createAnalyticsEvent = function createAnalyticsEvent(color, tr) {
|
|
|
51
51
|
return value === previousColor;
|
|
52
52
|
});
|
|
53
53
|
var newColorLabel = newColorFromPalette ? newColorFromPalette.label : color;
|
|
54
|
-
var previousColorLabel = previousColorFromPalette ? previousColorFromPalette.label : previousColor
|
|
54
|
+
var previousColorLabel = previousColorFromPalette ? previousColorFromPalette.label : previousColor;
|
|
55
55
|
return {
|
|
56
56
|
action: _analytics.ACTION.FORMATTED,
|
|
57
57
|
actionSubject: _analytics.ACTION_SUBJECT.TEXT,
|
package/dist/cjs/plugin.js
CHANGED
|
@@ -14,6 +14,23 @@ var highlightPlugin = exports.highlightPlugin = function highlightPlugin(_ref) {
|
|
|
14
14
|
var _api$analytics;
|
|
15
15
|
var api = _ref.api;
|
|
16
16
|
var editorAnalyticsAPI = api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions;
|
|
17
|
+
var primaryToolbarComponent = function primaryToolbarComponent(_ref2) {
|
|
18
|
+
var popupsMountPoint = _ref2.popupsMountPoint,
|
|
19
|
+
popupsBoundariesElement = _ref2.popupsBoundariesElement,
|
|
20
|
+
popupsScrollableElement = _ref2.popupsScrollableElement,
|
|
21
|
+
disabled = _ref2.disabled,
|
|
22
|
+
isToolbarReducedSpacing = _ref2.isToolbarReducedSpacing,
|
|
23
|
+
dispatchAnalyticsEvent = _ref2.dispatchAnalyticsEvent;
|
|
24
|
+
return /*#__PURE__*/_react.default.createElement(_ToolbarHighlightColor.ToolbarHighlightColorWithIntl, {
|
|
25
|
+
popupsMountPoint: popupsMountPoint,
|
|
26
|
+
popupsBoundariesElement: popupsBoundariesElement,
|
|
27
|
+
popupsScrollableElement: popupsScrollableElement,
|
|
28
|
+
disabled: disabled,
|
|
29
|
+
isToolbarReducedSpacing: isToolbarReducedSpacing,
|
|
30
|
+
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
31
|
+
pluginInjectionApi: api
|
|
32
|
+
});
|
|
33
|
+
};
|
|
17
34
|
return {
|
|
18
35
|
name: 'highlight',
|
|
19
36
|
commands: {
|
|
@@ -41,23 +58,13 @@ var highlightPlugin = exports.highlightPlugin = function highlightPlugin(_ref) {
|
|
|
41
58
|
}
|
|
42
59
|
return _pmPlugin.highlightPluginKey.getState(editorState);
|
|
43
60
|
},
|
|
44
|
-
|
|
45
|
-
var
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
return /*#__PURE__*/_react.default.createElement(_ToolbarHighlightColor.ToolbarHighlightColorWithIntl, {
|
|
53
|
-
popupsMountPoint: popupsMountPoint,
|
|
54
|
-
popupsBoundariesElement: popupsBoundariesElement,
|
|
55
|
-
popupsScrollableElement: popupsScrollableElement,
|
|
56
|
-
disabled: disabled,
|
|
57
|
-
isToolbarReducedSpacing: isToolbarReducedSpacing,
|
|
58
|
-
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
59
|
-
pluginInjectionApi: api
|
|
60
|
-
});
|
|
61
|
-
}
|
|
61
|
+
usePluginHook: function usePluginHook() {
|
|
62
|
+
var _api$core, _api$primaryToolbar;
|
|
63
|
+
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({
|
|
64
|
+
name: 'highlight',
|
|
65
|
+
component: primaryToolbarComponent
|
|
66
|
+
}));
|
|
67
|
+
},
|
|
68
|
+
primaryToolbarComponent: !(api !== null && api !== void 0 && api.primaryToolbar) ? primaryToolbarComponent : undefined
|
|
62
69
|
};
|
|
63
70
|
};
|
package/dist/cjs/pm-plugin.js
CHANGED
|
@@ -9,6 +9,7 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
|
|
|
9
9
|
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
10
10
|
var _uiColor = require("@atlaskit/editor-common/ui-color");
|
|
11
11
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
12
|
+
var _color = require("./utils/color");
|
|
12
13
|
var _disabled = require("./utils/disabled");
|
|
13
14
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
14
15
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
@@ -41,12 +42,10 @@ var createPlugin = exports.createPlugin = function createPlugin(_ref) {
|
|
|
41
42
|
});
|
|
42
43
|
default:
|
|
43
44
|
nextState = _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
45
|
+
activeColor: (0, _color.getActiveColor)(tr),
|
|
44
46
|
disabled: (0, _disabled.getDisabledState)(newState)
|
|
45
47
|
});
|
|
46
|
-
|
|
47
|
-
return nextState;
|
|
48
|
-
}
|
|
49
|
-
return pluginState;
|
|
48
|
+
return nextState;
|
|
50
49
|
}
|
|
51
50
|
}
|
|
52
51
|
}
|
|
@@ -158,8 +158,6 @@ var ToolbarHighlightColor = function ToolbarHighlightColor(_ref) {
|
|
|
158
158
|
palette: _uiColor.highlightColorPalette,
|
|
159
159
|
hexToPaletteColor: _editorPalette.hexToEditorTextBackgroundPaletteColor
|
|
160
160
|
}
|
|
161
|
-
})))
|
|
162
|
-
css: _styles.separatorStyles
|
|
163
|
-
}));
|
|
161
|
+
}))));
|
|
164
162
|
};
|
|
165
163
|
var ToolbarHighlightColorWithIntl = exports.ToolbarHighlightColorWithIntl = (0, _reactIntlNext.injectIntl)(ToolbarHighlightColor);
|
package/dist/cjs/utils/color.js
CHANGED
|
@@ -10,8 +10,7 @@ var getActiveColor = exports.getActiveColor = function getActiveColor(tr) {
|
|
|
10
10
|
$from = _ref.$from,
|
|
11
11
|
$to = _ref.$to,
|
|
12
12
|
$cursor = _ref.$cursor;
|
|
13
|
-
var
|
|
14
|
-
backgroundColor = _ref2.backgroundColor;
|
|
13
|
+
var backgroundColor = tr.doc.type.schema.marks.backgroundColor;
|
|
15
14
|
|
|
16
15
|
// Filter out other marks
|
|
17
16
|
var marks = [];
|
|
@@ -41,8 +40,8 @@ var getActiveColor = exports.getActiveColor = function getActiveColor(tr) {
|
|
|
41
40
|
return !!mark;
|
|
42
41
|
});
|
|
43
42
|
// When multiple colors are selected revert back to default color
|
|
44
|
-
if (marksWithColor.length > 1 || marksWithColor.length === 1 && marks.length > 1) {
|
|
45
|
-
return
|
|
43
|
+
if (marksWithColor.length > 1 || marksWithColor.length === 1 && marks.length > 1 || marksWithColor.length === 0) {
|
|
44
|
+
return _uiColor.REMOVE_HIGHLIGHT_COLOR;
|
|
46
45
|
}
|
|
47
|
-
return marksWithColor
|
|
46
|
+
return marksWithColor[0].attrs.color;
|
|
48
47
|
};
|
|
@@ -43,7 +43,7 @@ const createAnalyticsEvent = (color, tr) => {
|
|
|
43
43
|
value
|
|
44
44
|
}) => value === previousColor);
|
|
45
45
|
const newColorLabel = newColorFromPalette ? newColorFromPalette.label : color;
|
|
46
|
-
const previousColorLabel = previousColorFromPalette ? previousColorFromPalette.label : previousColor
|
|
46
|
+
const previousColorLabel = previousColorFromPalette ? previousColorFromPalette.label : previousColor;
|
|
47
47
|
return {
|
|
48
48
|
action: ACTION.FORMATTED,
|
|
49
49
|
actionSubject: ACTION_SUBJECT.TEXT,
|
package/dist/es2019/plugin.js
CHANGED
|
@@ -8,6 +8,22 @@ export const highlightPlugin = ({
|
|
|
8
8
|
}) => {
|
|
9
9
|
var _api$analytics;
|
|
10
10
|
const editorAnalyticsAPI = api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions;
|
|
11
|
+
const primaryToolbarComponent = ({
|
|
12
|
+
popupsMountPoint,
|
|
13
|
+
popupsBoundariesElement,
|
|
14
|
+
popupsScrollableElement,
|
|
15
|
+
disabled,
|
|
16
|
+
isToolbarReducedSpacing,
|
|
17
|
+
dispatchAnalyticsEvent
|
|
18
|
+
}) => /*#__PURE__*/React.createElement(ToolbarHighlightColor, {
|
|
19
|
+
popupsMountPoint: popupsMountPoint,
|
|
20
|
+
popupsBoundariesElement: popupsBoundariesElement,
|
|
21
|
+
popupsScrollableElement: popupsScrollableElement,
|
|
22
|
+
disabled: disabled,
|
|
23
|
+
isToolbarReducedSpacing: isToolbarReducedSpacing,
|
|
24
|
+
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
25
|
+
pluginInjectionApi: api
|
|
26
|
+
});
|
|
11
27
|
return {
|
|
12
28
|
name: 'highlight',
|
|
13
29
|
commands: {
|
|
@@ -31,22 +47,13 @@ export const highlightPlugin = ({
|
|
|
31
47
|
}
|
|
32
48
|
return highlightPluginKey.getState(editorState);
|
|
33
49
|
},
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}) => /*#__PURE__*/React.createElement(ToolbarHighlightColor, {
|
|
43
|
-
popupsMountPoint: popupsMountPoint,
|
|
44
|
-
popupsBoundariesElement: popupsBoundariesElement,
|
|
45
|
-
popupsScrollableElement: popupsScrollableElement,
|
|
46
|
-
disabled: disabled,
|
|
47
|
-
isToolbarReducedSpacing: isToolbarReducedSpacing,
|
|
48
|
-
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
49
|
-
pluginInjectionApi: api
|
|
50
|
-
})
|
|
50
|
+
usePluginHook: () => {
|
|
51
|
+
var _api$core, _api$primaryToolbar;
|
|
52
|
+
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({
|
|
53
|
+
name: 'highlight',
|
|
54
|
+
component: primaryToolbarComponent
|
|
55
|
+
}));
|
|
56
|
+
},
|
|
57
|
+
primaryToolbarComponent: !(api !== null && api !== void 0 && api.primaryToolbar) ? primaryToolbarComponent : undefined
|
|
51
58
|
};
|
|
52
59
|
};
|
package/dist/es2019/pm-plugin.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
2
|
import { REMOVE_HIGHLIGHT_COLOR } from '@atlaskit/editor-common/ui-color';
|
|
3
3
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
4
|
+
import { getActiveColor } from './utils/color';
|
|
4
5
|
import { getDisabledState } from './utils/disabled';
|
|
5
6
|
export const highlightPluginKey = new PluginKey('highlight');
|
|
6
7
|
export let HighlightPluginAction = /*#__PURE__*/function (HighlightPluginAction) {
|
|
@@ -33,12 +34,10 @@ export const createPlugin = ({
|
|
|
33
34
|
default:
|
|
34
35
|
nextState = {
|
|
35
36
|
...pluginState,
|
|
37
|
+
activeColor: getActiveColor(tr),
|
|
36
38
|
disabled: getDisabledState(newState)
|
|
37
39
|
};
|
|
38
|
-
|
|
39
|
-
return nextState;
|
|
40
|
-
}
|
|
41
|
-
return pluginState;
|
|
40
|
+
return nextState;
|
|
42
41
|
}
|
|
43
42
|
}
|
|
44
43
|
}
|
|
@@ -5,7 +5,7 @@ import { injectIntl } from 'react-intl-next';
|
|
|
5
5
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
6
6
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
7
7
|
import { highlightMessages as messages } from '@atlaskit/editor-common/messages';
|
|
8
|
-
import { expandIconWrapperStyle
|
|
8
|
+
import { expandIconWrapperStyle } from '@atlaskit/editor-common/styles';
|
|
9
9
|
import { ColorPalette, getSelectedRowAndColumnFromPalette, highlightColorPalette, REMOVE_HIGHLIGHT_COLOR } from '@atlaskit/editor-common/ui-color';
|
|
10
10
|
import { ArrowKeyNavigationType, DropdownContainer as Dropdown, TOOLBAR_BUTTON, ToolbarButton } from '@atlaskit/editor-common/ui-menu';
|
|
11
11
|
import { hexToEditorTextBackgroundPaletteColor } from '@atlaskit/editor-palette';
|
|
@@ -141,8 +141,6 @@ const ToolbarHighlightColor = ({
|
|
|
141
141
|
palette: highlightColorPalette,
|
|
142
142
|
hexToPaletteColor: hexToEditorTextBackgroundPaletteColor
|
|
143
143
|
}
|
|
144
|
-
})))
|
|
145
|
-
css: separatorStyles
|
|
146
|
-
}));
|
|
144
|
+
}))));
|
|
147
145
|
};
|
|
148
146
|
export const ToolbarHighlightColorWithIntl = injectIntl(ToolbarHighlightColor);
|
|
@@ -35,8 +35,8 @@ export const getActiveColor = tr => {
|
|
|
35
35
|
});
|
|
36
36
|
const marksWithColor = marks.filter(mark => !!mark);
|
|
37
37
|
// When multiple colors are selected revert back to default color
|
|
38
|
-
if (marksWithColor.length > 1 || marksWithColor.length === 1 && marks.length > 1) {
|
|
39
|
-
return
|
|
38
|
+
if (marksWithColor.length > 1 || marksWithColor.length === 1 && marks.length > 1 || marksWithColor.length === 0) {
|
|
39
|
+
return REMOVE_HIGHLIGHT_COLOR;
|
|
40
40
|
}
|
|
41
|
-
return marksWithColor
|
|
41
|
+
return marksWithColor[0].attrs.color;
|
|
42
42
|
};
|
|
@@ -45,7 +45,7 @@ var createAnalyticsEvent = function createAnalyticsEvent(color, tr) {
|
|
|
45
45
|
return value === previousColor;
|
|
46
46
|
});
|
|
47
47
|
var newColorLabel = newColorFromPalette ? newColorFromPalette.label : color;
|
|
48
|
-
var previousColorLabel = previousColorFromPalette ? previousColorFromPalette.label : previousColor
|
|
48
|
+
var previousColorLabel = previousColorFromPalette ? previousColorFromPalette.label : previousColor;
|
|
49
49
|
return {
|
|
50
50
|
action: ACTION.FORMATTED,
|
|
51
51
|
actionSubject: ACTION_SUBJECT.TEXT,
|
package/dist/esm/plugin.js
CHANGED
|
@@ -7,6 +7,23 @@ export var highlightPlugin = function highlightPlugin(_ref) {
|
|
|
7
7
|
var _api$analytics;
|
|
8
8
|
var api = _ref.api;
|
|
9
9
|
var editorAnalyticsAPI = api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions;
|
|
10
|
+
var primaryToolbarComponent = function primaryToolbarComponent(_ref2) {
|
|
11
|
+
var popupsMountPoint = _ref2.popupsMountPoint,
|
|
12
|
+
popupsBoundariesElement = _ref2.popupsBoundariesElement,
|
|
13
|
+
popupsScrollableElement = _ref2.popupsScrollableElement,
|
|
14
|
+
disabled = _ref2.disabled,
|
|
15
|
+
isToolbarReducedSpacing = _ref2.isToolbarReducedSpacing,
|
|
16
|
+
dispatchAnalyticsEvent = _ref2.dispatchAnalyticsEvent;
|
|
17
|
+
return /*#__PURE__*/React.createElement(ToolbarHighlightColor, {
|
|
18
|
+
popupsMountPoint: popupsMountPoint,
|
|
19
|
+
popupsBoundariesElement: popupsBoundariesElement,
|
|
20
|
+
popupsScrollableElement: popupsScrollableElement,
|
|
21
|
+
disabled: disabled,
|
|
22
|
+
isToolbarReducedSpacing: isToolbarReducedSpacing,
|
|
23
|
+
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
24
|
+
pluginInjectionApi: api
|
|
25
|
+
});
|
|
26
|
+
};
|
|
10
27
|
return {
|
|
11
28
|
name: 'highlight',
|
|
12
29
|
commands: {
|
|
@@ -34,23 +51,13 @@ export var highlightPlugin = function highlightPlugin(_ref) {
|
|
|
34
51
|
}
|
|
35
52
|
return highlightPluginKey.getState(editorState);
|
|
36
53
|
},
|
|
37
|
-
|
|
38
|
-
var
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
return /*#__PURE__*/React.createElement(ToolbarHighlightColor, {
|
|
46
|
-
popupsMountPoint: popupsMountPoint,
|
|
47
|
-
popupsBoundariesElement: popupsBoundariesElement,
|
|
48
|
-
popupsScrollableElement: popupsScrollableElement,
|
|
49
|
-
disabled: disabled,
|
|
50
|
-
isToolbarReducedSpacing: isToolbarReducedSpacing,
|
|
51
|
-
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
52
|
-
pluginInjectionApi: api
|
|
53
|
-
});
|
|
54
|
-
}
|
|
54
|
+
usePluginHook: function usePluginHook() {
|
|
55
|
+
var _api$core, _api$primaryToolbar;
|
|
56
|
+
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({
|
|
57
|
+
name: 'highlight',
|
|
58
|
+
component: primaryToolbarComponent
|
|
59
|
+
}));
|
|
60
|
+
},
|
|
61
|
+
primaryToolbarComponent: !(api !== null && api !== void 0 && api.primaryToolbar) ? primaryToolbarComponent : undefined
|
|
55
62
|
};
|
|
56
63
|
};
|
package/dist/esm/pm-plugin.js
CHANGED
|
@@ -4,6 +4,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
4
4
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
5
5
|
import { REMOVE_HIGHLIGHT_COLOR } from '@atlaskit/editor-common/ui-color';
|
|
6
6
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
7
|
+
import { getActiveColor } from './utils/color';
|
|
7
8
|
import { getDisabledState } from './utils/disabled';
|
|
8
9
|
export var highlightPluginKey = new PluginKey('highlight');
|
|
9
10
|
export var HighlightPluginAction = /*#__PURE__*/function (HighlightPluginAction) {
|
|
@@ -34,12 +35,10 @@ export var createPlugin = function createPlugin(_ref) {
|
|
|
34
35
|
});
|
|
35
36
|
default:
|
|
36
37
|
nextState = _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
38
|
+
activeColor: getActiveColor(tr),
|
|
37
39
|
disabled: getDisabledState(newState)
|
|
38
40
|
});
|
|
39
|
-
|
|
40
|
-
return nextState;
|
|
41
|
-
}
|
|
42
|
-
return pluginState;
|
|
41
|
+
return nextState;
|
|
43
42
|
}
|
|
44
43
|
}
|
|
45
44
|
}
|
|
@@ -6,7 +6,7 @@ import { injectIntl } from 'react-intl-next';
|
|
|
6
6
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
7
7
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
8
8
|
import { highlightMessages as messages } from '@atlaskit/editor-common/messages';
|
|
9
|
-
import { expandIconWrapperStyle
|
|
9
|
+
import { expandIconWrapperStyle } from '@atlaskit/editor-common/styles';
|
|
10
10
|
import { ColorPalette, getSelectedRowAndColumnFromPalette, highlightColorPalette, REMOVE_HIGHLIGHT_COLOR } from '@atlaskit/editor-common/ui-color';
|
|
11
11
|
import { ArrowKeyNavigationType, DropdownContainer as Dropdown, TOOLBAR_BUTTON, ToolbarButton } from '@atlaskit/editor-common/ui-menu';
|
|
12
12
|
import { hexToEditorTextBackgroundPaletteColor } from '@atlaskit/editor-palette';
|
|
@@ -147,8 +147,6 @@ var ToolbarHighlightColor = function ToolbarHighlightColor(_ref) {
|
|
|
147
147
|
palette: highlightColorPalette,
|
|
148
148
|
hexToPaletteColor: hexToEditorTextBackgroundPaletteColor
|
|
149
149
|
}
|
|
150
|
-
})))
|
|
151
|
-
css: separatorStyles
|
|
152
|
-
}));
|
|
150
|
+
}))));
|
|
153
151
|
};
|
|
154
152
|
export var ToolbarHighlightColorWithIntl = injectIntl(ToolbarHighlightColor);
|
package/dist/esm/utils/color.js
CHANGED
|
@@ -4,8 +4,7 @@ export var getActiveColor = function getActiveColor(tr) {
|
|
|
4
4
|
$from = _ref.$from,
|
|
5
5
|
$to = _ref.$to,
|
|
6
6
|
$cursor = _ref.$cursor;
|
|
7
|
-
var
|
|
8
|
-
backgroundColor = _ref2.backgroundColor;
|
|
7
|
+
var backgroundColor = tr.doc.type.schema.marks.backgroundColor;
|
|
9
8
|
|
|
10
9
|
// Filter out other marks
|
|
11
10
|
var marks = [];
|
|
@@ -35,8 +34,8 @@ export var getActiveColor = function getActiveColor(tr) {
|
|
|
35
34
|
return !!mark;
|
|
36
35
|
});
|
|
37
36
|
// When multiple colors are selected revert back to default color
|
|
38
|
-
if (marksWithColor.length > 1 || marksWithColor.length === 1 && marks.length > 1) {
|
|
39
|
-
return
|
|
37
|
+
if (marksWithColor.length > 1 || marksWithColor.length === 1 && marks.length > 1 || marksWithColor.length === 0) {
|
|
38
|
+
return REMOVE_HIGHLIGHT_COLOR;
|
|
40
39
|
}
|
|
41
|
-
return marksWithColor
|
|
40
|
+
return marksWithColor[0].attrs.color;
|
|
42
41
|
};
|
package/dist/types/plugin.d.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import type { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
|
|
2
2
|
import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
3
|
+
import type { PrimaryToolbarPlugin } from '@atlaskit/editor-plugin-primary-toolbar';
|
|
3
4
|
import type { TextFormattingPlugin } from '@atlaskit/editor-plugin-text-formatting';
|
|
4
5
|
import type { HighlightPluginState } from './pm-plugin';
|
|
5
6
|
export type HighlightPlugin = NextEditorPlugin<'highlight', {
|
|
6
7
|
dependencies: [
|
|
7
8
|
OptionalPlugin<AnalyticsPlugin>,
|
|
8
|
-
OptionalPlugin<TextFormattingPlugin
|
|
9
|
+
OptionalPlugin<TextFormattingPlugin>,
|
|
10
|
+
OptionalPlugin<PrimaryToolbarPlugin>
|
|
9
11
|
];
|
|
10
12
|
sharedState: HighlightPluginState | undefined;
|
|
11
13
|
}>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
2
|
-
export declare const getActiveColor: (tr: Transaction) => string
|
|
1
|
+
import type { ReadonlyTransaction, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
2
|
+
export declare const getActiveColor: (tr: Transaction | ReadonlyTransaction) => string;
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import type { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
|
|
2
2
|
import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
3
|
+
import type { PrimaryToolbarPlugin } from '@atlaskit/editor-plugin-primary-toolbar';
|
|
3
4
|
import type { TextFormattingPlugin } from '@atlaskit/editor-plugin-text-formatting';
|
|
4
5
|
import type { HighlightPluginState } from './pm-plugin';
|
|
5
6
|
export type HighlightPlugin = NextEditorPlugin<'highlight', {
|
|
6
7
|
dependencies: [
|
|
7
8
|
OptionalPlugin<AnalyticsPlugin>,
|
|
8
|
-
OptionalPlugin<TextFormattingPlugin
|
|
9
|
+
OptionalPlugin<TextFormattingPlugin>,
|
|
10
|
+
OptionalPlugin<PrimaryToolbarPlugin>
|
|
9
11
|
];
|
|
10
12
|
sharedState: HighlightPluginState | undefined;
|
|
11
13
|
}>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
2
|
-
export declare const getActiveColor: (tr: Transaction) => string
|
|
1
|
+
import type { ReadonlyTransaction, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
2
|
+
export declare const getActiveColor: (tr: Transaction | ReadonlyTransaction) => string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-highlight",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"description": "Highlight plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -38,11 +38,12 @@
|
|
|
38
38
|
".": "./src/index.ts"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@atlaskit/adf-schema": "^36.
|
|
42
|
-
"@atlaskit/editor-common": "^
|
|
41
|
+
"@atlaskit/adf-schema": "^36.10.7",
|
|
42
|
+
"@atlaskit/editor-common": "^81.1.0",
|
|
43
43
|
"@atlaskit/editor-palette": "1.6.0",
|
|
44
44
|
"@atlaskit/editor-plugin-analytics": "^1.2.0",
|
|
45
|
-
"@atlaskit/editor-plugin-
|
|
45
|
+
"@atlaskit/editor-plugin-primary-toolbar": "^1.1.0",
|
|
46
|
+
"@atlaskit/editor-plugin-text-formatting": "^1.7.0",
|
|
46
47
|
"@atlaskit/editor-prosemirror": "4.0.1",
|
|
47
48
|
"@atlaskit/editor-shared-styles": "^2.11.0",
|
|
48
49
|
"@atlaskit/icon": "^22.3.0",
|