@atlaskit/editor-plugin-highlight 3.0.8 → 3.0.10
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 +18 -0
- package/dist/cjs/highlightPlugin.js +16 -7
- package/dist/cjs/ui/HighlightColorMenuItem.compiled.css +7 -0
- package/dist/cjs/ui/HighlightColorMenuItem.js +51 -0
- package/dist/cjs/ui/toolbar-component.js +25 -0
- package/dist/es2019/highlightPlugin.js +16 -7
- package/dist/es2019/ui/HighlightColorMenuItem.compiled.css +7 -0
- package/dist/es2019/ui/HighlightColorMenuItem.js +41 -0
- package/dist/es2019/ui/toolbar-component.js +15 -0
- package/dist/esm/highlightPlugin.js +16 -7
- package/dist/esm/ui/HighlightColorMenuItem.compiled.css +7 -0
- package/dist/esm/ui/HighlightColorMenuItem.js +42 -0
- package/dist/esm/ui/toolbar-component.js +18 -0
- package/dist/types/highlightPluginType.d.ts +2 -0
- package/dist/types/ui/HighlightColorMenuItem.d.ts +12 -0
- package/dist/types/ui/toolbar-component.d.ts +4 -0
- package/dist/types-ts4.5/highlightPluginType.d.ts +2 -0
- package/dist/types-ts4.5/ui/HighlightColorMenuItem.d.ts +12 -0
- package/dist/types-ts4.5/ui/toolbar-component.d.ts +4 -0
- package/package.json +12 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-highlight
|
|
2
2
|
|
|
3
|
+
## 3.0.10
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#197017](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/197017)
|
|
8
|
+
[`5ef01d09bada1`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/5ef01d09bada1) -
|
|
9
|
+
[ux] ED-28687 [Register] Text colour + highlight
|
|
10
|
+
- Updated dependencies
|
|
11
|
+
|
|
12
|
+
## 3.0.9
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- [#195649](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/195649)
|
|
17
|
+
[`231bb33e06dfe`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/231bb33e06dfe) -
|
|
18
|
+
EDITOR-1131 Bump adf-schema version to 50.2.0
|
|
19
|
+
- Updated dependencies
|
|
20
|
+
|
|
3
21
|
## 3.0.8
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
|
@@ -8,17 +8,20 @@ exports.highlightPlugin = void 0;
|
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _adfSchema = require("@atlaskit/adf-schema");
|
|
10
10
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
11
|
+
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
11
12
|
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
12
13
|
var _changeColor = require("./editor-commands/change-color");
|
|
13
14
|
var _keymap = require("./pm-plugins/keymap");
|
|
14
15
|
var _main = require("./pm-plugins/main");
|
|
15
16
|
var _FloatingToolbarHighlightColor = require("./ui/FloatingToolbarHighlightColor");
|
|
16
17
|
var _PrimaryToolbarHighlightColor = require("./ui/PrimaryToolbarHighlightColor");
|
|
18
|
+
var _toolbarComponent = require("./ui/toolbar-component");
|
|
17
19
|
var highlightPlugin = exports.highlightPlugin = function highlightPlugin(_ref) {
|
|
18
|
-
var _api$analytics
|
|
20
|
+
var _api$analytics;
|
|
19
21
|
var api = _ref.api,
|
|
20
22
|
options = _ref.config;
|
|
21
23
|
var editorAnalyticsAPI = api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions;
|
|
24
|
+
var isToolbarAifcEnabled = (0, _expValEquals.expValEquals)('platform_editor_toolbar_aifc', 'isEnabled', true);
|
|
22
25
|
var primaryToolbarComponent = function primaryToolbarComponent(_ref2) {
|
|
23
26
|
var popupsMountPoint = _ref2.popupsMountPoint,
|
|
24
27
|
popupsBoundariesElement = _ref2.popupsBoundariesElement,
|
|
@@ -36,10 +39,16 @@ var highlightPlugin = exports.highlightPlugin = function highlightPlugin(_ref) {
|
|
|
36
39
|
editorView: editorView
|
|
37
40
|
});
|
|
38
41
|
};
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
42
|
+
if (!isToolbarAifcEnabled) {
|
|
43
|
+
var _api$primaryToolbar;
|
|
44
|
+
api === null || api === void 0 || (_api$primaryToolbar = api.primaryToolbar) === null || _api$primaryToolbar === void 0 || _api$primaryToolbar.actions.registerComponent({
|
|
45
|
+
name: 'highlight',
|
|
46
|
+
component: primaryToolbarComponent
|
|
47
|
+
});
|
|
48
|
+
} else {
|
|
49
|
+
var _api$toolbar;
|
|
50
|
+
api === null || api === void 0 || (_api$toolbar = api.toolbar) === null || _api$toolbar === void 0 || _api$toolbar.actions.registerComponents((0, _toolbarComponent.getToolbarComponent)(api));
|
|
51
|
+
}
|
|
43
52
|
return {
|
|
44
53
|
name: 'highlight',
|
|
45
54
|
marks: function marks() {
|
|
@@ -74,7 +83,7 @@ var highlightPlugin = exports.highlightPlugin = function highlightPlugin(_ref) {
|
|
|
74
83
|
}
|
|
75
84
|
return _main.highlightPluginKey.getState(editorState);
|
|
76
85
|
},
|
|
77
|
-
pluginsOptions: {
|
|
86
|
+
pluginsOptions: !isToolbarAifcEnabled ? {
|
|
78
87
|
selectionToolbar: function selectionToolbar() {
|
|
79
88
|
var _api$userPreferences, _api$selectionToolbar;
|
|
80
89
|
var toolbarDocking = (0, _platformFeatureFlags.fg)('platform_editor_use_preferences_plugin') ? api === null || api === void 0 || (_api$userPreferences = api.userPreferences) === null || _api$userPreferences === void 0 || (_api$userPreferences = _api$userPreferences.sharedState.currentState()) === null || _api$userPreferences === void 0 || (_api$userPreferences = _api$userPreferences.preferences) === null || _api$userPreferences === void 0 ? void 0 : _api$userPreferences.toolbarDockingPosition : api === null || api === void 0 || (_api$selectionToolbar = api.selectionToolbar) === null || _api$selectionToolbar === void 0 || (_api$selectionToolbar = _api$selectionToolbar.sharedState) === null || _api$selectionToolbar === void 0 || (_api$selectionToolbar = _api$selectionToolbar.currentState()) === null || _api$selectionToolbar === void 0 ? void 0 : _api$selectionToolbar.toolbarDocking;
|
|
@@ -103,7 +112,7 @@ var highlightPlugin = exports.highlightPlugin = function highlightPlugin(_ref) {
|
|
|
103
112
|
return undefined;
|
|
104
113
|
}
|
|
105
114
|
}
|
|
106
|
-
},
|
|
115
|
+
} : {},
|
|
107
116
|
primaryToolbarComponent: !(api !== null && api !== void 0 && api.primaryToolbar) ? primaryToolbarComponent : undefined
|
|
108
117
|
};
|
|
109
118
|
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
|
|
2
|
+
._2rkoglpi{border-radius:var(--ds-border-radius,4px)}
|
|
3
|
+
._zulpu2gc{gap:var(--ds-space-100,8px)}._189ee4h9{border-width:var(--ds-border-width,1px)}
|
|
4
|
+
._1dqonqa1{border-style:solid}
|
|
5
|
+
._1h6dmuej{border-color:var(--ds-border,#091e4224)}
|
|
6
|
+
._18u0x0bf{margin-left:var(--ds-space-negative-100,-8px)}
|
|
7
|
+
._19pkpxbi{margin-top:var(--ds-space-200,1pc)}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/* HighlightColorMenuItem.tsx generated by @compiled/babel-plugin v0.36.1 */
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
5
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
+
Object.defineProperty(exports, "__esModule", {
|
|
7
|
+
value: true
|
|
8
|
+
});
|
|
9
|
+
exports.HighlightColorMenuItem = HighlightColorMenuItem;
|
|
10
|
+
require("./HighlightColorMenuItem.compiled.css");
|
|
11
|
+
var React = _interopRequireWildcard(require("react"));
|
|
12
|
+
var _runtime = require("@compiled/react/runtime");
|
|
13
|
+
var _new = _interopRequireDefault(require("@atlaskit/button/new"));
|
|
14
|
+
var _uiColor = require("@atlaskit/editor-common/ui-color");
|
|
15
|
+
var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-plugin-state-selector");
|
|
16
|
+
var _editorPalette = require("@atlaskit/editor-palette");
|
|
17
|
+
var _editorToolbar = require("@atlaskit/editor-toolbar");
|
|
18
|
+
var _compiled = require("@atlaskit/primitives/compiled");
|
|
19
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
20
|
+
var styles = {
|
|
21
|
+
container: "_zulpu2gc _19pkpxbi",
|
|
22
|
+
colorPalette: "_18u0x0bf",
|
|
23
|
+
removeHighlightButton: "_2rkoglpi _189ee4h9 _1dqonqa1 _1h6dmuej"
|
|
24
|
+
};
|
|
25
|
+
var colorPalette = _uiColor.highlightColorPaletteNext.filter(function (color) {
|
|
26
|
+
return color.label !== 'No color';
|
|
27
|
+
});
|
|
28
|
+
function HighlightColorMenuItem(_ref) {
|
|
29
|
+
var api = _ref.api;
|
|
30
|
+
var activeColor = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'highlight.activeColor');
|
|
31
|
+
return /*#__PURE__*/React.createElement(_editorToolbar.ToolbarDropdownItemSection, null, /*#__PURE__*/React.createElement(_compiled.Stack, {
|
|
32
|
+
xcss: styles.container,
|
|
33
|
+
testId: "highlight-color-menu-item"
|
|
34
|
+
}, /*#__PURE__*/React.createElement(_compiled.Text, {
|
|
35
|
+
weight: "bold"
|
|
36
|
+
}, "Highlight color"), /*#__PURE__*/React.createElement(_compiled.Box, {
|
|
37
|
+
xcss: styles.colorPalette
|
|
38
|
+
}, /*#__PURE__*/React.createElement(_uiColor.ColorPalette, {
|
|
39
|
+
onClick: function onClick() {},
|
|
40
|
+
selectedColor: activeColor || null,
|
|
41
|
+
paletteOptions: {
|
|
42
|
+
palette: colorPalette || [],
|
|
43
|
+
hexToPaletteColor: _editorPalette.hexToEditorTextBackgroundPaletteColor
|
|
44
|
+
}
|
|
45
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
46
|
+
className: (0, _runtime.ax)([styles.removeHighlightButton])
|
|
47
|
+
}, /*#__PURE__*/React.createElement(_new.default, {
|
|
48
|
+
shouldFitContainer: true,
|
|
49
|
+
appearance: "subtle"
|
|
50
|
+
}, "Remove highlight"))));
|
|
51
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.getToolbarComponent = void 0;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
+
var _react = _interopRequireDefault(require("react"));
|
|
10
|
+
var _toolbar = require("@atlaskit/editor-common/toolbar");
|
|
11
|
+
var _HighlightColorMenuItem = require("./HighlightColorMenuItem");
|
|
12
|
+
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; }
|
|
13
|
+
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; }
|
|
14
|
+
var getToolbarComponent = exports.getToolbarComponent = function getToolbarComponent(api) {
|
|
15
|
+
return [_objectSpread(_objectSpread({}, _toolbar.HIGHLIGHT_MENU_ITEM), {}, {
|
|
16
|
+
parents: [_objectSpread(_objectSpread({}, _toolbar.TEXT_COLOR_HIGHLIGHT_MENU_SECTION), {}, {
|
|
17
|
+
rank: _toolbar.TEXT_COLOR_HIGHLIGHT_MENU_SECTION_RANK[_toolbar.HIGHLIGHT_MENU_ITEM.key]
|
|
18
|
+
})],
|
|
19
|
+
component: function component() {
|
|
20
|
+
return /*#__PURE__*/_react.default.createElement(_HighlightColorMenuItem.HighlightColorMenuItem, {
|
|
21
|
+
api: api
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
})];
|
|
25
|
+
};
|
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { backgroundColor } from '@atlaskit/adf-schema';
|
|
3
3
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
4
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
4
5
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
5
6
|
import { changeColor } from './editor-commands/change-color';
|
|
6
7
|
import { keymapPlugin } from './pm-plugins/keymap';
|
|
7
8
|
import { createPlugin, highlightPluginKey } from './pm-plugins/main';
|
|
8
9
|
import { FloatingToolbarHighlightColorWithIntl as FloatingToolbarHighlightColor } from './ui/FloatingToolbarHighlightColor';
|
|
9
10
|
import { PrimaryToolbarHighlightColorWithIntl as PrimaryToolbarHighlightColor } from './ui/PrimaryToolbarHighlightColor';
|
|
11
|
+
import { getToolbarComponent } from './ui/toolbar-component';
|
|
10
12
|
export const highlightPlugin = ({
|
|
11
13
|
api,
|
|
12
14
|
config: options
|
|
13
15
|
}) => {
|
|
14
|
-
var _api$analytics
|
|
16
|
+
var _api$analytics;
|
|
15
17
|
const editorAnalyticsAPI = api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions;
|
|
18
|
+
const isToolbarAifcEnabled = expValEquals('platform_editor_toolbar_aifc', 'isEnabled', true);
|
|
16
19
|
const primaryToolbarComponent = ({
|
|
17
20
|
popupsMountPoint,
|
|
18
21
|
popupsBoundariesElement,
|
|
@@ -31,10 +34,16 @@ export const highlightPlugin = ({
|
|
|
31
34
|
editorView: editorView
|
|
32
35
|
});
|
|
33
36
|
};
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
37
|
+
if (!isToolbarAifcEnabled) {
|
|
38
|
+
var _api$primaryToolbar;
|
|
39
|
+
api === null || api === void 0 ? void 0 : (_api$primaryToolbar = api.primaryToolbar) === null || _api$primaryToolbar === void 0 ? void 0 : _api$primaryToolbar.actions.registerComponent({
|
|
40
|
+
name: 'highlight',
|
|
41
|
+
component: primaryToolbarComponent
|
|
42
|
+
});
|
|
43
|
+
} else {
|
|
44
|
+
var _api$toolbar;
|
|
45
|
+
api === null || api === void 0 ? void 0 : (_api$toolbar = api.toolbar) === null || _api$toolbar === void 0 ? void 0 : _api$toolbar.actions.registerComponents(getToolbarComponent(api));
|
|
46
|
+
}
|
|
38
47
|
return {
|
|
39
48
|
name: 'highlight',
|
|
40
49
|
marks() {
|
|
@@ -63,7 +72,7 @@ export const highlightPlugin = ({
|
|
|
63
72
|
}
|
|
64
73
|
return highlightPluginKey.getState(editorState);
|
|
65
74
|
},
|
|
66
|
-
pluginsOptions: {
|
|
75
|
+
pluginsOptions: !isToolbarAifcEnabled ? {
|
|
67
76
|
selectionToolbar() {
|
|
68
77
|
var _api$userPreferences, _api$userPreferences$, _api$userPreferences$2, _api$selectionToolbar, _api$selectionToolbar2, _api$selectionToolbar3;
|
|
69
78
|
const toolbarDocking = fg('platform_editor_use_preferences_plugin') ? api === null || api === void 0 ? void 0 : (_api$userPreferences = api.userPreferences) === null || _api$userPreferences === void 0 ? void 0 : (_api$userPreferences$ = _api$userPreferences.sharedState.currentState()) === null || _api$userPreferences$ === void 0 ? void 0 : (_api$userPreferences$2 = _api$userPreferences$.preferences) === null || _api$userPreferences$2 === void 0 ? void 0 : _api$userPreferences$2.toolbarDockingPosition : api === null || api === void 0 ? void 0 : (_api$selectionToolbar = api.selectionToolbar) === null || _api$selectionToolbar === void 0 ? void 0 : (_api$selectionToolbar2 = _api$selectionToolbar.sharedState) === null || _api$selectionToolbar2 === void 0 ? void 0 : (_api$selectionToolbar3 = _api$selectionToolbar2.currentState()) === null || _api$selectionToolbar3 === void 0 ? void 0 : _api$selectionToolbar3.toolbarDocking;
|
|
@@ -90,7 +99,7 @@ export const highlightPlugin = ({
|
|
|
90
99
|
return undefined;
|
|
91
100
|
}
|
|
92
101
|
}
|
|
93
|
-
},
|
|
102
|
+
} : {},
|
|
94
103
|
primaryToolbarComponent: !(api !== null && api !== void 0 && api.primaryToolbar) ? primaryToolbarComponent : undefined
|
|
95
104
|
};
|
|
96
105
|
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
|
|
2
|
+
._2rkoglpi{border-radius:var(--ds-border-radius,4px)}
|
|
3
|
+
._zulpu2gc{gap:var(--ds-space-100,8px)}._189ee4h9{border-width:var(--ds-border-width,1px)}
|
|
4
|
+
._1dqonqa1{border-style:solid}
|
|
5
|
+
._1h6dmuej{border-color:var(--ds-border,#091e4224)}
|
|
6
|
+
._18u0x0bf{margin-left:var(--ds-space-negative-100,-8px)}
|
|
7
|
+
._19pkpxbi{margin-top:var(--ds-space-200,1pc)}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/* HighlightColorMenuItem.tsx generated by @compiled/babel-plugin v0.36.1 */
|
|
2
|
+
import "./HighlightColorMenuItem.compiled.css";
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { ax, ix } from "@compiled/react/runtime";
|
|
5
|
+
import Button from '@atlaskit/button/new';
|
|
6
|
+
import { ColorPalette, highlightColorPaletteNext } from '@atlaskit/editor-common/ui-color';
|
|
7
|
+
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
8
|
+
import { hexToEditorTextBackgroundPaletteColor } from '@atlaskit/editor-palette';
|
|
9
|
+
import { ToolbarDropdownItemSection } from '@atlaskit/editor-toolbar';
|
|
10
|
+
import { Stack, Box, Text } from '@atlaskit/primitives/compiled';
|
|
11
|
+
const styles = {
|
|
12
|
+
container: "_zulpu2gc _19pkpxbi",
|
|
13
|
+
colorPalette: "_18u0x0bf",
|
|
14
|
+
removeHighlightButton: "_2rkoglpi _189ee4h9 _1dqonqa1 _1h6dmuej"
|
|
15
|
+
};
|
|
16
|
+
const colorPalette = highlightColorPaletteNext.filter(color => color.label !== 'No color');
|
|
17
|
+
export function HighlightColorMenuItem({
|
|
18
|
+
api
|
|
19
|
+
}) {
|
|
20
|
+
const activeColor = useSharedPluginStateSelector(api, 'highlight.activeColor');
|
|
21
|
+
return /*#__PURE__*/React.createElement(ToolbarDropdownItemSection, null, /*#__PURE__*/React.createElement(Stack, {
|
|
22
|
+
xcss: styles.container,
|
|
23
|
+
testId: "highlight-color-menu-item"
|
|
24
|
+
}, /*#__PURE__*/React.createElement(Text, {
|
|
25
|
+
weight: "bold"
|
|
26
|
+
}, "Highlight color"), /*#__PURE__*/React.createElement(Box, {
|
|
27
|
+
xcss: styles.colorPalette
|
|
28
|
+
}, /*#__PURE__*/React.createElement(ColorPalette, {
|
|
29
|
+
onClick: () => {},
|
|
30
|
+
selectedColor: activeColor || null,
|
|
31
|
+
paletteOptions: {
|
|
32
|
+
palette: colorPalette || [],
|
|
33
|
+
hexToPaletteColor: hexToEditorTextBackgroundPaletteColor
|
|
34
|
+
}
|
|
35
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
36
|
+
className: ax([styles.removeHighlightButton])
|
|
37
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
38
|
+
shouldFitContainer: true,
|
|
39
|
+
appearance: "subtle"
|
|
40
|
+
}, "Remove highlight"))));
|
|
41
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { HIGHLIGHT_MENU_ITEM, TEXT_COLOR_HIGHLIGHT_MENU_SECTION, TEXT_COLOR_HIGHLIGHT_MENU_SECTION_RANK } from '@atlaskit/editor-common/toolbar';
|
|
3
|
+
import { HighlightColorMenuItem } from './HighlightColorMenuItem';
|
|
4
|
+
export const getToolbarComponent = api => {
|
|
5
|
+
return [{
|
|
6
|
+
...HIGHLIGHT_MENU_ITEM,
|
|
7
|
+
parents: [{
|
|
8
|
+
...TEXT_COLOR_HIGHLIGHT_MENU_SECTION,
|
|
9
|
+
rank: TEXT_COLOR_HIGHLIGHT_MENU_SECTION_RANK[HIGHLIGHT_MENU_ITEM.key]
|
|
10
|
+
}],
|
|
11
|
+
component: () => /*#__PURE__*/React.createElement(HighlightColorMenuItem, {
|
|
12
|
+
api: api
|
|
13
|
+
})
|
|
14
|
+
}];
|
|
15
|
+
};
|
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { backgroundColor } from '@atlaskit/adf-schema';
|
|
3
3
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
4
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
4
5
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
5
6
|
import { changeColor } from './editor-commands/change-color';
|
|
6
7
|
import { keymapPlugin } from './pm-plugins/keymap';
|
|
7
8
|
import { createPlugin, highlightPluginKey } from './pm-plugins/main';
|
|
8
9
|
import { FloatingToolbarHighlightColorWithIntl as FloatingToolbarHighlightColor } from './ui/FloatingToolbarHighlightColor';
|
|
9
10
|
import { PrimaryToolbarHighlightColorWithIntl as PrimaryToolbarHighlightColor } from './ui/PrimaryToolbarHighlightColor';
|
|
11
|
+
import { getToolbarComponent } from './ui/toolbar-component';
|
|
10
12
|
export var highlightPlugin = function highlightPlugin(_ref) {
|
|
11
|
-
var _api$analytics
|
|
13
|
+
var _api$analytics;
|
|
12
14
|
var api = _ref.api,
|
|
13
15
|
options = _ref.config;
|
|
14
16
|
var editorAnalyticsAPI = api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions;
|
|
17
|
+
var isToolbarAifcEnabled = expValEquals('platform_editor_toolbar_aifc', 'isEnabled', true);
|
|
15
18
|
var primaryToolbarComponent = function primaryToolbarComponent(_ref2) {
|
|
16
19
|
var popupsMountPoint = _ref2.popupsMountPoint,
|
|
17
20
|
popupsBoundariesElement = _ref2.popupsBoundariesElement,
|
|
@@ -29,10 +32,16 @@ export var highlightPlugin = function highlightPlugin(_ref) {
|
|
|
29
32
|
editorView: editorView
|
|
30
33
|
});
|
|
31
34
|
};
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
35
|
+
if (!isToolbarAifcEnabled) {
|
|
36
|
+
var _api$primaryToolbar;
|
|
37
|
+
api === null || api === void 0 || (_api$primaryToolbar = api.primaryToolbar) === null || _api$primaryToolbar === void 0 || _api$primaryToolbar.actions.registerComponent({
|
|
38
|
+
name: 'highlight',
|
|
39
|
+
component: primaryToolbarComponent
|
|
40
|
+
});
|
|
41
|
+
} else {
|
|
42
|
+
var _api$toolbar;
|
|
43
|
+
api === null || api === void 0 || (_api$toolbar = api.toolbar) === null || _api$toolbar === void 0 || _api$toolbar.actions.registerComponents(getToolbarComponent(api));
|
|
44
|
+
}
|
|
36
45
|
return {
|
|
37
46
|
name: 'highlight',
|
|
38
47
|
marks: function marks() {
|
|
@@ -67,7 +76,7 @@ export var highlightPlugin = function highlightPlugin(_ref) {
|
|
|
67
76
|
}
|
|
68
77
|
return highlightPluginKey.getState(editorState);
|
|
69
78
|
},
|
|
70
|
-
pluginsOptions: {
|
|
79
|
+
pluginsOptions: !isToolbarAifcEnabled ? {
|
|
71
80
|
selectionToolbar: function selectionToolbar() {
|
|
72
81
|
var _api$userPreferences, _api$selectionToolbar;
|
|
73
82
|
var toolbarDocking = fg('platform_editor_use_preferences_plugin') ? api === null || api === void 0 || (_api$userPreferences = api.userPreferences) === null || _api$userPreferences === void 0 || (_api$userPreferences = _api$userPreferences.sharedState.currentState()) === null || _api$userPreferences === void 0 || (_api$userPreferences = _api$userPreferences.preferences) === null || _api$userPreferences === void 0 ? void 0 : _api$userPreferences.toolbarDockingPosition : api === null || api === void 0 || (_api$selectionToolbar = api.selectionToolbar) === null || _api$selectionToolbar === void 0 || (_api$selectionToolbar = _api$selectionToolbar.sharedState) === null || _api$selectionToolbar === void 0 || (_api$selectionToolbar = _api$selectionToolbar.currentState()) === null || _api$selectionToolbar === void 0 ? void 0 : _api$selectionToolbar.toolbarDocking;
|
|
@@ -96,7 +105,7 @@ export var highlightPlugin = function highlightPlugin(_ref) {
|
|
|
96
105
|
return undefined;
|
|
97
106
|
}
|
|
98
107
|
}
|
|
99
|
-
},
|
|
108
|
+
} : {},
|
|
100
109
|
primaryToolbarComponent: !(api !== null && api !== void 0 && api.primaryToolbar) ? primaryToolbarComponent : undefined
|
|
101
110
|
};
|
|
102
111
|
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
|
|
2
|
+
._2rkoglpi{border-radius:var(--ds-border-radius,4px)}
|
|
3
|
+
._zulpu2gc{gap:var(--ds-space-100,8px)}._189ee4h9{border-width:var(--ds-border-width,1px)}
|
|
4
|
+
._1dqonqa1{border-style:solid}
|
|
5
|
+
._1h6dmuej{border-color:var(--ds-border,#091e4224)}
|
|
6
|
+
._18u0x0bf{margin-left:var(--ds-space-negative-100,-8px)}
|
|
7
|
+
._19pkpxbi{margin-top:var(--ds-space-200,1pc)}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/* HighlightColorMenuItem.tsx generated by @compiled/babel-plugin v0.36.1 */
|
|
2
|
+
import "./HighlightColorMenuItem.compiled.css";
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { ax, ix } from "@compiled/react/runtime";
|
|
5
|
+
import Button from '@atlaskit/button/new';
|
|
6
|
+
import { ColorPalette, highlightColorPaletteNext } from '@atlaskit/editor-common/ui-color';
|
|
7
|
+
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
8
|
+
import { hexToEditorTextBackgroundPaletteColor } from '@atlaskit/editor-palette';
|
|
9
|
+
import { ToolbarDropdownItemSection } from '@atlaskit/editor-toolbar';
|
|
10
|
+
import { Stack, Box, Text } from '@atlaskit/primitives/compiled';
|
|
11
|
+
var styles = {
|
|
12
|
+
container: "_zulpu2gc _19pkpxbi",
|
|
13
|
+
colorPalette: "_18u0x0bf",
|
|
14
|
+
removeHighlightButton: "_2rkoglpi _189ee4h9 _1dqonqa1 _1h6dmuej"
|
|
15
|
+
};
|
|
16
|
+
var colorPalette = highlightColorPaletteNext.filter(function (color) {
|
|
17
|
+
return color.label !== 'No color';
|
|
18
|
+
});
|
|
19
|
+
export function HighlightColorMenuItem(_ref) {
|
|
20
|
+
var api = _ref.api;
|
|
21
|
+
var activeColor = useSharedPluginStateSelector(api, 'highlight.activeColor');
|
|
22
|
+
return /*#__PURE__*/React.createElement(ToolbarDropdownItemSection, null, /*#__PURE__*/React.createElement(Stack, {
|
|
23
|
+
xcss: styles.container,
|
|
24
|
+
testId: "highlight-color-menu-item"
|
|
25
|
+
}, /*#__PURE__*/React.createElement(Text, {
|
|
26
|
+
weight: "bold"
|
|
27
|
+
}, "Highlight color"), /*#__PURE__*/React.createElement(Box, {
|
|
28
|
+
xcss: styles.colorPalette
|
|
29
|
+
}, /*#__PURE__*/React.createElement(ColorPalette, {
|
|
30
|
+
onClick: function onClick() {},
|
|
31
|
+
selectedColor: activeColor || null,
|
|
32
|
+
paletteOptions: {
|
|
33
|
+
palette: colorPalette || [],
|
|
34
|
+
hexToPaletteColor: hexToEditorTextBackgroundPaletteColor
|
|
35
|
+
}
|
|
36
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
37
|
+
className: ax([styles.removeHighlightButton])
|
|
38
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
39
|
+
shouldFitContainer: true,
|
|
40
|
+
appearance: "subtle"
|
|
41
|
+
}, "Remove highlight"))));
|
|
42
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
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; }
|
|
3
|
+
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) { _defineProperty(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; }
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import { HIGHLIGHT_MENU_ITEM, TEXT_COLOR_HIGHLIGHT_MENU_SECTION, TEXT_COLOR_HIGHLIGHT_MENU_SECTION_RANK } from '@atlaskit/editor-common/toolbar';
|
|
6
|
+
import { HighlightColorMenuItem } from './HighlightColorMenuItem';
|
|
7
|
+
export var getToolbarComponent = function getToolbarComponent(api) {
|
|
8
|
+
return [_objectSpread(_objectSpread({}, HIGHLIGHT_MENU_ITEM), {}, {
|
|
9
|
+
parents: [_objectSpread(_objectSpread({}, TEXT_COLOR_HIGHLIGHT_MENU_SECTION), {}, {
|
|
10
|
+
rank: TEXT_COLOR_HIGHLIGHT_MENU_SECTION_RANK[HIGHLIGHT_MENU_ITEM.key]
|
|
11
|
+
})],
|
|
12
|
+
component: function component() {
|
|
13
|
+
return /*#__PURE__*/React.createElement(HighlightColorMenuItem, {
|
|
14
|
+
api: api
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
})];
|
|
18
|
+
};
|
|
@@ -4,6 +4,7 @@ import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
|
4
4
|
import type { PrimaryToolbarPlugin } from '@atlaskit/editor-plugin-primary-toolbar';
|
|
5
5
|
import type { SelectionToolbarPlugin } from '@atlaskit/editor-plugin-selection-toolbar';
|
|
6
6
|
import type { TextFormattingPlugin } from '@atlaskit/editor-plugin-text-formatting';
|
|
7
|
+
import type { ToolbarPlugin } from '@atlaskit/editor-plugin-toolbar';
|
|
7
8
|
import type { UserPreferencesPlugin } from '@atlaskit/editor-plugin-user-preferences';
|
|
8
9
|
import type { HighlightPluginState } from './pm-plugins/main';
|
|
9
10
|
export type HighlightPlugin = NextEditorPlugin<'highlight', {
|
|
@@ -11,6 +12,7 @@ export type HighlightPlugin = NextEditorPlugin<'highlight', {
|
|
|
11
12
|
OptionalPlugin<AnalyticsPlugin>,
|
|
12
13
|
OptionalPlugin<TextFormattingPlugin>,
|
|
13
14
|
OptionalPlugin<PrimaryToolbarPlugin>,
|
|
15
|
+
OptionalPlugin<ToolbarPlugin>,
|
|
14
16
|
OptionalPlugin<SelectionToolbarPlugin>,
|
|
15
17
|
OptionalPlugin<UserPreferencesPlugin>
|
|
16
18
|
];
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jsxRuntime classic
|
|
3
|
+
* @jsx jsx
|
|
4
|
+
*/
|
|
5
|
+
/// <reference types="react" />
|
|
6
|
+
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
7
|
+
import type { HighlightPlugin } from '../highlightPluginType';
|
|
8
|
+
interface HighlightMenuItemProps {
|
|
9
|
+
api: ExtractInjectionAPI<HighlightPlugin> | undefined;
|
|
10
|
+
}
|
|
11
|
+
export declare function HighlightColorMenuItem({ api }: HighlightMenuItemProps): JSX.Element;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
2
|
+
import type { RegisterComponent } from '@atlaskit/editor-toolbar-model';
|
|
3
|
+
import type { HighlightPlugin } from '../highlightPluginType';
|
|
4
|
+
export declare const getToolbarComponent: (api: ExtractInjectionAPI<HighlightPlugin> | undefined) => RegisterComponent[];
|
|
@@ -4,6 +4,7 @@ import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
|
4
4
|
import type { PrimaryToolbarPlugin } from '@atlaskit/editor-plugin-primary-toolbar';
|
|
5
5
|
import type { SelectionToolbarPlugin } from '@atlaskit/editor-plugin-selection-toolbar';
|
|
6
6
|
import type { TextFormattingPlugin } from '@atlaskit/editor-plugin-text-formatting';
|
|
7
|
+
import type { ToolbarPlugin } from '@atlaskit/editor-plugin-toolbar';
|
|
7
8
|
import type { UserPreferencesPlugin } from '@atlaskit/editor-plugin-user-preferences';
|
|
8
9
|
import type { HighlightPluginState } from './pm-plugins/main';
|
|
9
10
|
export type HighlightPlugin = NextEditorPlugin<'highlight', {
|
|
@@ -11,6 +12,7 @@ export type HighlightPlugin = NextEditorPlugin<'highlight', {
|
|
|
11
12
|
OptionalPlugin<AnalyticsPlugin>,
|
|
12
13
|
OptionalPlugin<TextFormattingPlugin>,
|
|
13
14
|
OptionalPlugin<PrimaryToolbarPlugin>,
|
|
15
|
+
OptionalPlugin<ToolbarPlugin>,
|
|
14
16
|
OptionalPlugin<SelectionToolbarPlugin>,
|
|
15
17
|
OptionalPlugin<UserPreferencesPlugin>
|
|
16
18
|
];
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
/**
|
|
3
|
+
* @jsxRuntime classic
|
|
4
|
+
* @jsx jsx
|
|
5
|
+
*/
|
|
6
|
+
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
7
|
+
import type { HighlightPlugin } from '../highlightPluginType';
|
|
8
|
+
interface HighlightMenuItemProps {
|
|
9
|
+
api: ExtractInjectionAPI<HighlightPlugin> | undefined;
|
|
10
|
+
}
|
|
11
|
+
export declare function HighlightColorMenuItem({ api }: HighlightMenuItemProps): JSX.Element;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
2
|
+
import type { RegisterComponent } from '@atlaskit/editor-toolbar-model';
|
|
3
|
+
import type { HighlightPlugin } from '../highlightPluginType';
|
|
4
|
+
export declare const getToolbarComponent: (api: ExtractInjectionAPI<HighlightPlugin> | undefined) => RegisterComponent[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-highlight",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.10",
|
|
4
4
|
"description": "Highlight plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -35,31 +35,33 @@
|
|
|
35
35
|
".": "./src/index.ts"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@atlaskit/adf-schema": "^50.0
|
|
38
|
+
"@atlaskit/adf-schema": "^50.2.0",
|
|
39
|
+
"@atlaskit/button": "^23.3.0",
|
|
40
|
+
"@atlaskit/css": "^0.12.0",
|
|
39
41
|
"@atlaskit/editor-palette": "^2.1.0",
|
|
40
42
|
"@atlaskit/editor-plugin-analytics": "^3.0.0",
|
|
41
43
|
"@atlaskit/editor-plugin-primary-toolbar": "^4.1.0",
|
|
42
|
-
"@atlaskit/editor-plugin-selection-toolbar": "^4.
|
|
44
|
+
"@atlaskit/editor-plugin-selection-toolbar": "^4.3.0",
|
|
43
45
|
"@atlaskit/editor-plugin-text-formatting": "^3.0.0",
|
|
46
|
+
"@atlaskit/editor-plugin-toolbar": "^0.1.0",
|
|
44
47
|
"@atlaskit/editor-prosemirror": "7.0.0",
|
|
45
|
-
"@atlaskit/editor-shared-styles": "^3.
|
|
48
|
+
"@atlaskit/editor-shared-styles": "^3.6.0",
|
|
46
49
|
"@atlaskit/editor-tables": "^2.9.0",
|
|
47
|
-
"@atlaskit/
|
|
50
|
+
"@atlaskit/editor-toolbar": "^0.1.0",
|
|
51
|
+
"@atlaskit/editor-toolbar-model": "^0.0.4",
|
|
52
|
+
"@atlaskit/icon": "^27.10.0",
|
|
48
53
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
49
54
|
"@atlaskit/primitives": "^14.11.0",
|
|
50
|
-
"@atlaskit/tmp-editor-statsig": "^9.
|
|
55
|
+
"@atlaskit/tmp-editor-statsig": "^9.25.0",
|
|
51
56
|
"@atlaskit/tokens": "^6.0.0",
|
|
52
57
|
"@babel/runtime": "^7.0.0",
|
|
53
58
|
"@emotion/react": "^11.7.1"
|
|
54
59
|
},
|
|
55
60
|
"peerDependencies": {
|
|
56
|
-
"@atlaskit/editor-common": "^107.
|
|
61
|
+
"@atlaskit/editor-common": "^107.19.0",
|
|
57
62
|
"react": "^18.2.0",
|
|
58
63
|
"react-intl-next": "npm:react-intl@^5.18.1"
|
|
59
64
|
},
|
|
60
|
-
"devDependencies": {
|
|
61
|
-
"typescript": "~5.4.2"
|
|
62
|
-
},
|
|
63
65
|
"techstack": {
|
|
64
66
|
"@atlassian/frontend": {
|
|
65
67
|
"import-structure": [
|