@atlaskit/editor-plugin-highlight 1.11.3 → 1.12.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 +12 -0
- package/dist/cjs/commands/change-color.js +6 -4
- package/dist/cjs/commands/index.js +3 -4
- package/dist/cjs/commands/palette.js +56 -0
- package/dist/cjs/pm-plugins/keymap.js +4 -1
- package/dist/cjs/pm-plugins/main.js +2 -2
- package/dist/cjs/ui/FloatingToolbarHighlightColor.js +21 -4
- package/dist/cjs/ui/PrimaryToolbarHighlightColor.js +11 -4
- package/dist/cjs/ui/ToolbarHighlightColor.js +8 -3
- package/dist/cjs/ui/shared/useDropdownEvents.js +5 -2
- package/dist/es2019/commands/change-color.js +6 -4
- package/dist/es2019/commands/index.js +1 -2
- package/dist/es2019/commands/palette.js +44 -0
- package/dist/es2019/pm-plugins/keymap.js +4 -1
- package/dist/es2019/pm-plugins/main.js +2 -2
- package/dist/es2019/ui/FloatingToolbarHighlightColor.js +20 -3
- package/dist/es2019/ui/PrimaryToolbarHighlightColor.js +11 -4
- package/dist/es2019/ui/ToolbarHighlightColor.js +8 -3
- package/dist/es2019/ui/shared/useDropdownEvents.js +6 -2
- package/dist/esm/commands/change-color.js +6 -4
- package/dist/esm/commands/index.js +1 -2
- package/dist/esm/commands/palette.js +50 -0
- package/dist/esm/pm-plugins/keymap.js +4 -1
- package/dist/esm/pm-plugins/main.js +2 -2
- package/dist/esm/ui/FloatingToolbarHighlightColor.js +21 -4
- package/dist/esm/ui/PrimaryToolbarHighlightColor.js +11 -4
- package/dist/esm/ui/ToolbarHighlightColor.js +8 -3
- package/dist/esm/ui/shared/useDropdownEvents.js +5 -2
- package/dist/types/commands/change-color.d.ts +3 -2
- package/dist/types/commands/index.d.ts +1 -2
- package/dist/types/commands/palette.d.ts +10 -0
- package/dist/types/plugin.d.ts +2 -0
- package/dist/types/pm-plugins/main.d.ts +1 -1
- package/dist/types/ui/FloatingToolbarHighlightColor.d.ts +1 -1
- package/dist/types/ui/ToolbarHighlightColor.d.ts +1 -1
- package/dist/types/ui/shared/useDropdownEvents.d.ts +7 -3
- package/dist/types-ts4.5/commands/change-color.d.ts +3 -2
- package/dist/types-ts4.5/commands/index.d.ts +1 -2
- package/dist/types-ts4.5/commands/palette.d.ts +10 -0
- package/dist/types-ts4.5/plugin.d.ts +2 -0
- package/dist/types-ts4.5/pm-plugins/main.d.ts +1 -1
- package/dist/types-ts4.5/ui/FloatingToolbarHighlightColor.d.ts +1 -1
- package/dist/types-ts4.5/ui/ToolbarHighlightColor.d.ts +1 -1
- package/dist/types-ts4.5/ui/shared/useDropdownEvents.d.ts +7 -3
- package/package.json +2 -2
- package/dist/cjs/commands/set-palette.js +0 -39
- package/dist/cjs/commands/toggle-palette.js +0 -40
- package/dist/es2019/commands/set-palette.js +0 -31
- package/dist/es2019/commands/toggle-palette.js +0 -32
- package/dist/esm/commands/set-palette.js +0 -33
- package/dist/esm/commands/toggle-palette.js +0 -34
- package/dist/types/commands/set-palette.d.ts +0 -3
- package/dist/types/commands/toggle-palette.d.ts +0 -3
- package/dist/types-ts4.5/commands/set-palette.d.ts +0 -3
- package/dist/types-ts4.5/commands/toggle-palette.d.ts +0 -3
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import { HighlightPluginAction, highlightPluginKey } from '../pm-plugins/main';
|
|
3
|
+
export var togglePalette = function togglePalette(api) {
|
|
4
|
+
return function (_ref) {
|
|
5
|
+
var inputMethod = _ref.inputMethod;
|
|
6
|
+
return function (state, dispatch) {
|
|
7
|
+
var _highlightPluginKey$g;
|
|
8
|
+
var isPaletteOpen = (_highlightPluginKey$g = highlightPluginKey.getState(state)) === null || _highlightPluginKey$g === void 0 ? void 0 : _highlightPluginKey$g.isPaletteOpen;
|
|
9
|
+
return setPalette(api)({
|
|
10
|
+
isPaletteOpen: !isPaletteOpen,
|
|
11
|
+
inputMethod: inputMethod
|
|
12
|
+
})(state, dispatch);
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
export var setPalette = function setPalette(api) {
|
|
17
|
+
return function (_ref2) {
|
|
18
|
+
var isPaletteOpen = _ref2.isPaletteOpen,
|
|
19
|
+
inputMethod = _ref2.inputMethod;
|
|
20
|
+
return function (state, dispatch) {
|
|
21
|
+
var _highlightPluginKey$g2;
|
|
22
|
+
var isDisabled = (_highlightPluginKey$g2 = highlightPluginKey.getState(state)) === null || _highlightPluginKey$g2 === void 0 ? void 0 : _highlightPluginKey$g2.disabled;
|
|
23
|
+
if (!isDisabled) {
|
|
24
|
+
var _api$analytics;
|
|
25
|
+
var tr = state.tr;
|
|
26
|
+
tr.setMeta(highlightPluginKey, {
|
|
27
|
+
type: HighlightPluginAction.SET_PALETTE,
|
|
28
|
+
isPaletteOpen: isPaletteOpen
|
|
29
|
+
});
|
|
30
|
+
(_api$analytics = api.analytics) === null || _api$analytics === void 0 || _api$analytics.actions.attachAnalyticsEvent(createAnalyticsEvent(isPaletteOpen, inputMethod))(tr);
|
|
31
|
+
if (dispatch) {
|
|
32
|
+
dispatch(tr);
|
|
33
|
+
}
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
return false;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
var createAnalyticsEvent = function createAnalyticsEvent(isPaletteOpen, inputMethod) {
|
|
41
|
+
return {
|
|
42
|
+
action: isPaletteOpen ? ACTION.OPENED : ACTION.CLOSED,
|
|
43
|
+
actionSubject: ACTION_SUBJECT.TOOLBAR,
|
|
44
|
+
actionSubjectId: ACTION_SUBJECT_ID.FORMAT_BACKGROUND_COLOR,
|
|
45
|
+
eventType: EVENT_TYPE.TRACK,
|
|
46
|
+
attributes: {
|
|
47
|
+
inputMethod: inputMethod
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
};
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
1
2
|
import { bindKeymapWithCommand, keymap, toggleHighlightPalette } from '@atlaskit/editor-common/keymaps';
|
|
2
3
|
import { togglePalette } from '../commands';
|
|
3
4
|
export function keymapPlugin(_ref) {
|
|
4
5
|
var api = _ref.api;
|
|
5
6
|
var list = {};
|
|
6
|
-
bindKeymapWithCommand(toggleHighlightPalette.common, togglePalette(api)
|
|
7
|
+
bindKeymapWithCommand(toggleHighlightPalette.common, togglePalette(api)({
|
|
8
|
+
inputMethod: INPUT_METHOD.SHORTCUT
|
|
9
|
+
}), list);
|
|
7
10
|
return keymap(list);
|
|
8
11
|
}
|
|
@@ -8,7 +8,7 @@ import { getDisabledState } from '../utils/disabled';
|
|
|
8
8
|
export var highlightPluginKey = new PluginKey('highlight');
|
|
9
9
|
export var HighlightPluginAction = /*#__PURE__*/function (HighlightPluginAction) {
|
|
10
10
|
HighlightPluginAction[HighlightPluginAction["CHANGE_COLOR"] = 0] = "CHANGE_COLOR";
|
|
11
|
-
HighlightPluginAction[HighlightPluginAction["
|
|
11
|
+
HighlightPluginAction[HighlightPluginAction["SET_PALETTE"] = 1] = "SET_PALETTE";
|
|
12
12
|
return HighlightPluginAction;
|
|
13
13
|
}({});
|
|
14
14
|
export var createPlugin = function createPlugin(_ref) {
|
|
@@ -33,7 +33,7 @@ export var createPlugin = function createPlugin(_ref) {
|
|
|
33
33
|
return _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
34
34
|
activeColor: color
|
|
35
35
|
});
|
|
36
|
-
case HighlightPluginAction.
|
|
36
|
+
case HighlightPluginAction.SET_PALETTE:
|
|
37
37
|
var _tr$getMeta3 = tr.getMeta(highlightPluginKey),
|
|
38
38
|
isPaletteOpen = _tr$getMeta3.isPaletteOpen;
|
|
39
39
|
return _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
@@ -5,6 +5,7 @@ import { useRef, useState } from 'react';
|
|
|
5
5
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
6
6
|
import { css, jsx } from '@emotion/react';
|
|
7
7
|
import { injectIntl } from 'react-intl-next';
|
|
8
|
+
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
8
9
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
9
10
|
import { highlightMessages as messages } from '@atlaskit/editor-common/messages';
|
|
10
11
|
import { TOOLBAR_BUTTON, ToolbarButton } from '@atlaskit/editor-common/ui-menu';
|
|
@@ -23,15 +24,28 @@ var FloatingToolbarHighlightColor = function FloatingToolbarHighlightColor(_ref)
|
|
|
23
24
|
var pluginInjectionApi = _ref.pluginInjectionApi,
|
|
24
25
|
formatMessage = _ref.intl.formatMessage;
|
|
25
26
|
var toolbarItemRef = useRef(null);
|
|
26
|
-
var _useSharedPluginState = useSharedPluginState(pluginInjectionApi, ['highlight']),
|
|
27
|
-
highlightState = _useSharedPluginState.highlightState;
|
|
28
27
|
var _useState = useState(false),
|
|
29
28
|
_useState2 = _slicedToArray(_useState, 2),
|
|
30
29
|
isDropdownOpen = _useState2[0],
|
|
31
30
|
setIsDropdownOpen = _useState2[1];
|
|
31
|
+
var _useSharedPluginState = useSharedPluginState(pluginInjectionApi, ['highlight']),
|
|
32
|
+
highlightState = _useSharedPluginState.highlightState;
|
|
33
|
+
var setDropdownOpen = function setDropdownOpen(isOpen) {
|
|
34
|
+
var _pluginInjectionApi$a;
|
|
35
|
+
setIsDropdownOpen(isOpen);
|
|
36
|
+
pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 || _pluginInjectionApi$a.actions.fireAnalyticsEvent({
|
|
37
|
+
action: isOpen ? ACTION.OPENED : ACTION.CLOSED,
|
|
38
|
+
actionSubject: ACTION_SUBJECT.TOOLBAR,
|
|
39
|
+
actionSubjectId: ACTION_SUBJECT_ID.FORMAT_BACKGROUND_COLOR,
|
|
40
|
+
eventType: EVENT_TYPE.TRACK,
|
|
41
|
+
attributes: {
|
|
42
|
+
inputMethod: INPUT_METHOD.FLOATING_TB
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
};
|
|
32
46
|
var _useDropdownEvents = useDropdownEvents({
|
|
33
47
|
toolbarItemRef: toolbarItemRef,
|
|
34
|
-
setIsDropdownOpen:
|
|
48
|
+
setIsDropdownOpen: setDropdownOpen,
|
|
35
49
|
isDropdownOpen: isDropdownOpen,
|
|
36
50
|
pluginInjectionApi: pluginInjectionApi
|
|
37
51
|
}),
|
|
@@ -79,7 +93,10 @@ var FloatingToolbarHighlightColor = function FloatingToolbarHighlightColor(_ref)
|
|
|
79
93
|
}))
|
|
80
94
|
}, formatMessage(messages.highlightFloatingToolbar)),
|
|
81
95
|
onColorChange: function onColorChange(color) {
|
|
82
|
-
return handleColorChange(
|
|
96
|
+
return handleColorChange({
|
|
97
|
+
color: color,
|
|
98
|
+
inputMethod: INPUT_METHOD.FLOATING_TB
|
|
99
|
+
});
|
|
83
100
|
},
|
|
84
101
|
isOpenedByKeyboard: isOpenedByKeyboard,
|
|
85
102
|
handleClickOutside: handleClickOutside,
|
|
@@ -4,6 +4,7 @@ import { useRef } from 'react';
|
|
|
4
4
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
5
5
|
import { jsx } from '@emotion/react';
|
|
6
6
|
import { injectIntl } from 'react-intl-next';
|
|
7
|
+
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
7
8
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
8
9
|
import { getAriaKeyshortcuts, toggleHighlightPalette, tooltip } from '@atlaskit/editor-common/keymaps';
|
|
9
10
|
import { highlightMessages as messages } from '@atlaskit/editor-common/messages';
|
|
@@ -28,17 +29,20 @@ var PrimaryToolbarHighlightColor = function PrimaryToolbarHighlightColor(_ref) {
|
|
|
28
29
|
var toolbarItemRef = useRef(null);
|
|
29
30
|
var _useSharedPluginState = useSharedPluginState(pluginInjectionApi, ['highlight']),
|
|
30
31
|
highlightState = _useSharedPluginState.highlightState;
|
|
31
|
-
var
|
|
32
|
+
var setIsDropdownOpen = function setIsDropdownOpen(isOpen) {
|
|
32
33
|
if (!(highlightState !== null && highlightState !== void 0 && highlightState.disabled)) {
|
|
33
34
|
var state = editorView.state,
|
|
34
35
|
dispatch = editorView.dispatch;
|
|
35
|
-
setPalette(pluginInjectionApi
|
|
36
|
+
setPalette(pluginInjectionApi)({
|
|
37
|
+
isPaletteOpen: isOpen,
|
|
38
|
+
inputMethod: INPUT_METHOD.TOOLBAR
|
|
39
|
+
})(state, dispatch);
|
|
36
40
|
}
|
|
37
41
|
};
|
|
38
42
|
var isDropdownOpen = !!(highlightState !== null && highlightState !== void 0 && highlightState.isPaletteOpen);
|
|
39
43
|
var _useDropdownEvents = useDropdownEvents({
|
|
40
44
|
toolbarItemRef: toolbarItemRef,
|
|
41
|
-
setIsDropdownOpen:
|
|
45
|
+
setIsDropdownOpen: setIsDropdownOpen,
|
|
42
46
|
isDropdownOpen: isDropdownOpen,
|
|
43
47
|
pluginInjectionApi: pluginInjectionApi
|
|
44
48
|
}),
|
|
@@ -89,7 +93,10 @@ var PrimaryToolbarHighlightColor = function PrimaryToolbarHighlightColor(_ref) {
|
|
|
89
93
|
})))
|
|
90
94
|
}),
|
|
91
95
|
onColorChange: function onColorChange(color) {
|
|
92
|
-
return handleColorChange(
|
|
96
|
+
return handleColorChange({
|
|
97
|
+
color: color,
|
|
98
|
+
inputMethod: INPUT_METHOD.TOOLBAR
|
|
99
|
+
});
|
|
93
100
|
},
|
|
94
101
|
isOpenedByKeyboard: isOpenedByKeyboard,
|
|
95
102
|
handleClickOutside: handleClickOutside,
|
|
@@ -5,6 +5,7 @@ import React, { useRef, useState } from 'react';
|
|
|
5
5
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
6
6
|
import { jsx } from '@emotion/react';
|
|
7
7
|
import { injectIntl } from 'react-intl-next';
|
|
8
|
+
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
8
9
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
9
10
|
import { getAriaKeyshortcuts, toggleHighlightPalette, tooltip } from '@atlaskit/editor-common/keymaps';
|
|
10
11
|
import { highlightMessages as messages } from '@atlaskit/editor-common/messages';
|
|
@@ -34,14 +35,17 @@ var ToolbarHighlightColor = function ToolbarHighlightColor(_ref) {
|
|
|
34
35
|
setIsOpenedByKeyboard = _useState2[1];
|
|
35
36
|
var _useSharedPluginState = useSharedPluginState(pluginInjectionApi, ['highlight']),
|
|
36
37
|
highlightState = _useSharedPluginState.highlightState;
|
|
37
|
-
var isDropdownOpen = !!(highlightState !== null && highlightState !== void 0 && highlightState.isPaletteOpen);
|
|
38
38
|
var setDropdownOpen = function setDropdownOpen(isOpen) {
|
|
39
39
|
if (!(highlightState !== null && highlightState !== void 0 && highlightState.disabled)) {
|
|
40
40
|
var state = editorView.state,
|
|
41
41
|
dispatch = editorView.dispatch;
|
|
42
|
-
setPalette(pluginInjectionApi
|
|
42
|
+
setPalette(pluginInjectionApi)({
|
|
43
|
+
isPaletteOpen: isOpen,
|
|
44
|
+
inputMethod: INPUT_METHOD.TOOLBAR
|
|
45
|
+
})(state, dispatch);
|
|
43
46
|
}
|
|
44
47
|
};
|
|
48
|
+
var isDropdownOpen = !!(highlightState !== null && highlightState !== void 0 && highlightState.isPaletteOpen);
|
|
45
49
|
var toggleDropdown = function toggleDropdown() {
|
|
46
50
|
return setDropdownOpen(!isDropdownOpen);
|
|
47
51
|
};
|
|
@@ -73,7 +77,8 @@ var ToolbarHighlightColor = function ToolbarHighlightColor(_ref) {
|
|
|
73
77
|
var handleColorChange = function handleColorChange(color) {
|
|
74
78
|
var _pluginInjectionApi$c, _pluginInjectionApi$a;
|
|
75
79
|
pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c = pluginInjectionApi.core) === null || _pluginInjectionApi$c === void 0 || _pluginInjectionApi$c.actions.execute(changeColor(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions)({
|
|
76
|
-
color: color
|
|
80
|
+
color: color,
|
|
81
|
+
inputMethod: INPUT_METHOD.TOOLBAR
|
|
77
82
|
}));
|
|
78
83
|
setDropdownOpen(false);
|
|
79
84
|
};
|
|
@@ -36,10 +36,13 @@ export var useDropdownEvents = function useDropdownEvents(args) {
|
|
|
36
36
|
toolbarItemRef === null || toolbarItemRef === void 0 || (_toolbarItemRef$curre = toolbarItemRef.current) === null || _toolbarItemRef$curre === void 0 || _toolbarItemRef$curre.focus();
|
|
37
37
|
}
|
|
38
38
|
},
|
|
39
|
-
handleColorChange: function handleColorChange(
|
|
39
|
+
handleColorChange: function handleColorChange(_ref) {
|
|
40
40
|
var _pluginInjectionApi$c, _pluginInjectionApi$a;
|
|
41
|
+
var color = _ref.color,
|
|
42
|
+
inputMethod = _ref.inputMethod;
|
|
41
43
|
pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c = pluginInjectionApi.core) === null || _pluginInjectionApi$c === void 0 || _pluginInjectionApi$c.actions.execute(changeColor(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions)({
|
|
42
|
-
color: color
|
|
44
|
+
color: color,
|
|
45
|
+
inputMethod: inputMethod
|
|
43
46
|
}));
|
|
44
47
|
setIsDropdownOpen(false);
|
|
45
48
|
},
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
1
|
+
import type { EditorAnalyticsAPI, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
2
2
|
import type { EditorCommand } from '@atlaskit/editor-common/types';
|
|
3
|
-
export declare const changeColor: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => ({ color }: {
|
|
3
|
+
export declare const changeColor: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => ({ color, inputMethod }: {
|
|
4
4
|
color: string;
|
|
5
|
+
inputMethod: INPUT_METHOD;
|
|
5
6
|
}) => EditorCommand;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import type { Command, ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
3
|
+
import type { HighlightPlugin } from '../plugin';
|
|
4
|
+
export declare const togglePalette: (api: ExtractInjectionAPI<HighlightPlugin>) => ({ inputMethod }: {
|
|
5
|
+
inputMethod: INPUT_METHOD;
|
|
6
|
+
}) => Command;
|
|
7
|
+
export declare const setPalette: (api: ExtractInjectionAPI<HighlightPlugin>) => ({ isPaletteOpen, inputMethod, }: {
|
|
8
|
+
isPaletteOpen: boolean;
|
|
9
|
+
inputMethod: INPUT_METHOD;
|
|
10
|
+
}) => Command;
|
package/dist/types/plugin.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
1
2
|
import type { EditorCommand, NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
|
|
2
3
|
import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
3
4
|
import type { BackgroundColorPlugin } from '@atlaskit/editor-plugin-background-color';
|
|
@@ -19,6 +20,7 @@ export type HighlightPlugin = NextEditorPlugin<'highlight', {
|
|
|
19
20
|
commands: {
|
|
20
21
|
changeColor: ({ color }: {
|
|
21
22
|
color: string;
|
|
23
|
+
inputMethod: INPUT_METHOD;
|
|
22
24
|
}) => EditorCommand;
|
|
23
25
|
};
|
|
24
26
|
}>;
|
|
@@ -10,7 +10,7 @@ export type HighlightPluginState = {
|
|
|
10
10
|
};
|
|
11
11
|
export declare enum HighlightPluginAction {
|
|
12
12
|
CHANGE_COLOR = 0,
|
|
13
|
-
|
|
13
|
+
SET_PALETTE = 1
|
|
14
14
|
}
|
|
15
15
|
export declare const createPlugin: ({ api, }: {
|
|
16
16
|
api: ExtractInjectionAPI<HighlightPlugin> | undefined;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { WrappedComponentProps } from 'react-intl-next';
|
|
3
|
-
import type
|
|
3
|
+
import { type DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
|
|
4
4
|
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
5
5
|
import type { HighlightPlugin } from '../plugin';
|
|
6
6
|
export declare const FloatingToolbarHighlightColorWithIntl: import("react").FC<import("react-intl-next").WithIntlProps<{
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import type { WrappedComponentProps } from 'react-intl-next';
|
|
4
|
-
import type
|
|
4
|
+
import { type DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
|
|
5
5
|
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
6
6
|
import { type EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
7
7
|
import type { HighlightPlugin } from '../plugin';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import type { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
3
|
+
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
4
|
+
import type { ToolbarButtonRef } from '@atlaskit/editor-common/ui-menu';
|
|
4
5
|
import type { HighlightPlugin } from '../../plugin';
|
|
5
6
|
type UseDropdownEventArgs = {
|
|
6
7
|
setIsDropdownOpen: (isOpen: boolean) => void;
|
|
@@ -13,7 +14,10 @@ export declare const useDropdownEvents: (args: UseDropdownEventArgs) => {
|
|
|
13
14
|
handleKeyDown: (event: React.KeyboardEvent) => void;
|
|
14
15
|
handleClickOutside: () => void;
|
|
15
16
|
handleEscapeKeydown: () => void;
|
|
16
|
-
handleColorChange: (color
|
|
17
|
+
handleColorChange: ({ color, inputMethod }: {
|
|
18
|
+
color: string;
|
|
19
|
+
inputMethod: INPUT_METHOD;
|
|
20
|
+
}) => void;
|
|
17
21
|
isOpenedByKeyboard: boolean;
|
|
18
22
|
};
|
|
19
23
|
export {};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
1
|
+
import type { EditorAnalyticsAPI, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
2
2
|
import type { EditorCommand } from '@atlaskit/editor-common/types';
|
|
3
|
-
export declare const changeColor: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => ({ color }: {
|
|
3
|
+
export declare const changeColor: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => ({ color, inputMethod }: {
|
|
4
4
|
color: string;
|
|
5
|
+
inputMethod: INPUT_METHOD;
|
|
5
6
|
}) => EditorCommand;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import type { Command, ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
3
|
+
import type { HighlightPlugin } from '../plugin';
|
|
4
|
+
export declare const togglePalette: (api: ExtractInjectionAPI<HighlightPlugin>) => ({ inputMethod }: {
|
|
5
|
+
inputMethod: INPUT_METHOD;
|
|
6
|
+
}) => Command;
|
|
7
|
+
export declare const setPalette: (api: ExtractInjectionAPI<HighlightPlugin>) => ({ isPaletteOpen, inputMethod, }: {
|
|
8
|
+
isPaletteOpen: boolean;
|
|
9
|
+
inputMethod: INPUT_METHOD;
|
|
10
|
+
}) => Command;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
1
2
|
import type { EditorCommand, NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
|
|
2
3
|
import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
3
4
|
import type { BackgroundColorPlugin } from '@atlaskit/editor-plugin-background-color';
|
|
@@ -19,6 +20,7 @@ export type HighlightPlugin = NextEditorPlugin<'highlight', {
|
|
|
19
20
|
commands: {
|
|
20
21
|
changeColor: ({ color }: {
|
|
21
22
|
color: string;
|
|
23
|
+
inputMethod: INPUT_METHOD;
|
|
22
24
|
}) => EditorCommand;
|
|
23
25
|
};
|
|
24
26
|
}>;
|
|
@@ -10,7 +10,7 @@ export type HighlightPluginState = {
|
|
|
10
10
|
};
|
|
11
11
|
export declare enum HighlightPluginAction {
|
|
12
12
|
CHANGE_COLOR = 0,
|
|
13
|
-
|
|
13
|
+
SET_PALETTE = 1
|
|
14
14
|
}
|
|
15
15
|
export declare const createPlugin: ({ api, }: {
|
|
16
16
|
api: ExtractInjectionAPI<HighlightPlugin> | undefined;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { WrappedComponentProps } from 'react-intl-next';
|
|
3
|
-
import type
|
|
3
|
+
import { type DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
|
|
4
4
|
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
5
5
|
import type { HighlightPlugin } from '../plugin';
|
|
6
6
|
export declare const FloatingToolbarHighlightColorWithIntl: import("react").FC<import("react-intl-next").WithIntlProps<{
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import type { WrappedComponentProps } from 'react-intl-next';
|
|
4
|
-
import type
|
|
4
|
+
import { type DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
|
|
5
5
|
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
6
6
|
import { type EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
7
7
|
import type { HighlightPlugin } from '../plugin';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import type { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
3
|
+
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
4
|
+
import type { ToolbarButtonRef } from '@atlaskit/editor-common/ui-menu';
|
|
4
5
|
import type { HighlightPlugin } from '../../plugin';
|
|
5
6
|
type UseDropdownEventArgs = {
|
|
6
7
|
setIsDropdownOpen: (isOpen: boolean) => void;
|
|
@@ -13,7 +14,10 @@ export declare const useDropdownEvents: (args: UseDropdownEventArgs) => {
|
|
|
13
14
|
handleKeyDown: (event: React.KeyboardEvent) => void;
|
|
14
15
|
handleClickOutside: () => void;
|
|
15
16
|
handleEscapeKeydown: () => void;
|
|
16
|
-
handleColorChange: (color
|
|
17
|
+
handleColorChange: ({ color, inputMethod }: {
|
|
18
|
+
color: string;
|
|
19
|
+
inputMethod: INPUT_METHOD;
|
|
20
|
+
}) => void;
|
|
17
21
|
isOpenedByKeyboard: boolean;
|
|
18
22
|
};
|
|
19
23
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-highlight",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.12.0",
|
|
4
4
|
"description": "Highlight plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
".": "./src/index.ts"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@atlaskit/editor-common": "^83.
|
|
41
|
+
"@atlaskit/editor-common": "^83.6.0",
|
|
42
42
|
"@atlaskit/editor-palette": "1.6.0",
|
|
43
43
|
"@atlaskit/editor-plugin-analytics": "^1.4.0",
|
|
44
44
|
"@atlaskit/editor-plugin-background-color": "^1.3.0",
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.setPalette = void 0;
|
|
7
|
-
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
8
|
-
var _main = require("../pm-plugins/main");
|
|
9
|
-
var setPalette = exports.setPalette = function setPalette(api, isPaletteOpen) {
|
|
10
|
-
return function (state, dispatch) {
|
|
11
|
-
var _highlightPluginKey$g;
|
|
12
|
-
var isDisabled = (_highlightPluginKey$g = _main.highlightPluginKey.getState(state)) === null || _highlightPluginKey$g === void 0 ? void 0 : _highlightPluginKey$g.disabled;
|
|
13
|
-
if (!isDisabled) {
|
|
14
|
-
var _api$analytics;
|
|
15
|
-
var tr = state.tr;
|
|
16
|
-
(_api$analytics = api.analytics) === null || _api$analytics === void 0 || _api$analytics.actions.attachAnalyticsEvent(createAnalyticsEvent(isPaletteOpen))(tr);
|
|
17
|
-
tr.setMeta(_main.highlightPluginKey, {
|
|
18
|
-
type: _main.HighlightPluginAction.TOGGLE_PALETTE,
|
|
19
|
-
isPaletteOpen: isPaletteOpen
|
|
20
|
-
});
|
|
21
|
-
if (dispatch) {
|
|
22
|
-
dispatch(tr);
|
|
23
|
-
}
|
|
24
|
-
return true;
|
|
25
|
-
}
|
|
26
|
-
return false;
|
|
27
|
-
};
|
|
28
|
-
};
|
|
29
|
-
var createAnalyticsEvent = function createAnalyticsEvent(isOpen) {
|
|
30
|
-
return {
|
|
31
|
-
action: isOpen ? _analytics.ACTION.OPENED : _analytics.ACTION.CLOSED,
|
|
32
|
-
actionSubject: _analytics.ACTION_SUBJECT.TOOLBAR,
|
|
33
|
-
actionSubjectId: _analytics.ACTION_SUBJECT_ID.FORMAT_BACKGROUND_COLOR,
|
|
34
|
-
eventType: _analytics.EVENT_TYPE.TRACK,
|
|
35
|
-
attributes: {
|
|
36
|
-
inputMethod: _analytics.INPUT_METHOD.TOOLBAR
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
};
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.togglePalette = void 0;
|
|
7
|
-
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
8
|
-
var _main = require("../pm-plugins/main");
|
|
9
|
-
var togglePalette = exports.togglePalette = function togglePalette(api) {
|
|
10
|
-
return function (state, dispatch) {
|
|
11
|
-
var _highlightPluginKey$g, _highlightPluginKey$g2;
|
|
12
|
-
var isDisabled = (_highlightPluginKey$g = _main.highlightPluginKey.getState(state)) === null || _highlightPluginKey$g === void 0 ? void 0 : _highlightPluginKey$g.disabled;
|
|
13
|
-
var isPaletteOpen = (_highlightPluginKey$g2 = _main.highlightPluginKey.getState(state)) === null || _highlightPluginKey$g2 === void 0 ? void 0 : _highlightPluginKey$g2.isPaletteOpen;
|
|
14
|
-
var tr = state.tr;
|
|
15
|
-
if (!isDisabled) {
|
|
16
|
-
var _api$analytics;
|
|
17
|
-
(_api$analytics = api.analytics) === null || _api$analytics === void 0 || _api$analytics.actions.attachAnalyticsEvent(createAnalyticsEvent(!isPaletteOpen))(tr);
|
|
18
|
-
tr.setMeta(_main.highlightPluginKey, {
|
|
19
|
-
type: _main.HighlightPluginAction.TOGGLE_PALETTE,
|
|
20
|
-
isPaletteOpen: !isPaletteOpen
|
|
21
|
-
});
|
|
22
|
-
if (dispatch) {
|
|
23
|
-
dispatch(tr);
|
|
24
|
-
}
|
|
25
|
-
return true;
|
|
26
|
-
}
|
|
27
|
-
return false;
|
|
28
|
-
};
|
|
29
|
-
};
|
|
30
|
-
var createAnalyticsEvent = function createAnalyticsEvent(isOpen) {
|
|
31
|
-
return {
|
|
32
|
-
action: isOpen ? _analytics.ACTION.OPENED : _analytics.ACTION.CLOSED,
|
|
33
|
-
actionSubject: _analytics.ACTION_SUBJECT.TOOLBAR,
|
|
34
|
-
actionSubjectId: _analytics.ACTION_SUBJECT_ID.FORMAT_BACKGROUND_COLOR,
|
|
35
|
-
eventType: _analytics.EVENT_TYPE.TRACK,
|
|
36
|
-
attributes: {
|
|
37
|
-
inputMethod: _analytics.INPUT_METHOD.SHORTCUT
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
};
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
2
|
-
import { HighlightPluginAction, highlightPluginKey } from '../pm-plugins/main';
|
|
3
|
-
export const setPalette = (api, isPaletteOpen) => (state, dispatch) => {
|
|
4
|
-
var _highlightPluginKey$g;
|
|
5
|
-
const isDisabled = (_highlightPluginKey$g = highlightPluginKey.getState(state)) === null || _highlightPluginKey$g === void 0 ? void 0 : _highlightPluginKey$g.disabled;
|
|
6
|
-
if (!isDisabled) {
|
|
7
|
-
var _api$analytics;
|
|
8
|
-
const tr = state.tr;
|
|
9
|
-
(_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions.attachAnalyticsEvent(createAnalyticsEvent(isPaletteOpen))(tr);
|
|
10
|
-
tr.setMeta(highlightPluginKey, {
|
|
11
|
-
type: HighlightPluginAction.TOGGLE_PALETTE,
|
|
12
|
-
isPaletteOpen
|
|
13
|
-
});
|
|
14
|
-
if (dispatch) {
|
|
15
|
-
dispatch(tr);
|
|
16
|
-
}
|
|
17
|
-
return true;
|
|
18
|
-
}
|
|
19
|
-
return false;
|
|
20
|
-
};
|
|
21
|
-
const createAnalyticsEvent = isOpen => {
|
|
22
|
-
return {
|
|
23
|
-
action: isOpen ? ACTION.OPENED : ACTION.CLOSED,
|
|
24
|
-
actionSubject: ACTION_SUBJECT.TOOLBAR,
|
|
25
|
-
actionSubjectId: ACTION_SUBJECT_ID.FORMAT_BACKGROUND_COLOR,
|
|
26
|
-
eventType: EVENT_TYPE.TRACK,
|
|
27
|
-
attributes: {
|
|
28
|
-
inputMethod: INPUT_METHOD.TOOLBAR
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
};
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
2
|
-
import { HighlightPluginAction, highlightPluginKey } from '../pm-plugins/main';
|
|
3
|
-
export const togglePalette = api => (state, dispatch) => {
|
|
4
|
-
var _highlightPluginKey$g, _highlightPluginKey$g2;
|
|
5
|
-
const isDisabled = (_highlightPluginKey$g = highlightPluginKey.getState(state)) === null || _highlightPluginKey$g === void 0 ? void 0 : _highlightPluginKey$g.disabled;
|
|
6
|
-
const isPaletteOpen = (_highlightPluginKey$g2 = highlightPluginKey.getState(state)) === null || _highlightPluginKey$g2 === void 0 ? void 0 : _highlightPluginKey$g2.isPaletteOpen;
|
|
7
|
-
const tr = state.tr;
|
|
8
|
-
if (!isDisabled) {
|
|
9
|
-
var _api$analytics;
|
|
10
|
-
(_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions.attachAnalyticsEvent(createAnalyticsEvent(!isPaletteOpen))(tr);
|
|
11
|
-
tr.setMeta(highlightPluginKey, {
|
|
12
|
-
type: HighlightPluginAction.TOGGLE_PALETTE,
|
|
13
|
-
isPaletteOpen: !isPaletteOpen
|
|
14
|
-
});
|
|
15
|
-
if (dispatch) {
|
|
16
|
-
dispatch(tr);
|
|
17
|
-
}
|
|
18
|
-
return true;
|
|
19
|
-
}
|
|
20
|
-
return false;
|
|
21
|
-
};
|
|
22
|
-
const createAnalyticsEvent = isOpen => {
|
|
23
|
-
return {
|
|
24
|
-
action: isOpen ? ACTION.OPENED : ACTION.CLOSED,
|
|
25
|
-
actionSubject: ACTION_SUBJECT.TOOLBAR,
|
|
26
|
-
actionSubjectId: ACTION_SUBJECT_ID.FORMAT_BACKGROUND_COLOR,
|
|
27
|
-
eventType: EVENT_TYPE.TRACK,
|
|
28
|
-
attributes: {
|
|
29
|
-
inputMethod: INPUT_METHOD.SHORTCUT
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
};
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
2
|
-
import { HighlightPluginAction, highlightPluginKey } from '../pm-plugins/main';
|
|
3
|
-
export var setPalette = function setPalette(api, isPaletteOpen) {
|
|
4
|
-
return function (state, dispatch) {
|
|
5
|
-
var _highlightPluginKey$g;
|
|
6
|
-
var isDisabled = (_highlightPluginKey$g = highlightPluginKey.getState(state)) === null || _highlightPluginKey$g === void 0 ? void 0 : _highlightPluginKey$g.disabled;
|
|
7
|
-
if (!isDisabled) {
|
|
8
|
-
var _api$analytics;
|
|
9
|
-
var tr = state.tr;
|
|
10
|
-
(_api$analytics = api.analytics) === null || _api$analytics === void 0 || _api$analytics.actions.attachAnalyticsEvent(createAnalyticsEvent(isPaletteOpen))(tr);
|
|
11
|
-
tr.setMeta(highlightPluginKey, {
|
|
12
|
-
type: HighlightPluginAction.TOGGLE_PALETTE,
|
|
13
|
-
isPaletteOpen: isPaletteOpen
|
|
14
|
-
});
|
|
15
|
-
if (dispatch) {
|
|
16
|
-
dispatch(tr);
|
|
17
|
-
}
|
|
18
|
-
return true;
|
|
19
|
-
}
|
|
20
|
-
return false;
|
|
21
|
-
};
|
|
22
|
-
};
|
|
23
|
-
var createAnalyticsEvent = function createAnalyticsEvent(isOpen) {
|
|
24
|
-
return {
|
|
25
|
-
action: isOpen ? ACTION.OPENED : ACTION.CLOSED,
|
|
26
|
-
actionSubject: ACTION_SUBJECT.TOOLBAR,
|
|
27
|
-
actionSubjectId: ACTION_SUBJECT_ID.FORMAT_BACKGROUND_COLOR,
|
|
28
|
-
eventType: EVENT_TYPE.TRACK,
|
|
29
|
-
attributes: {
|
|
30
|
-
inputMethod: INPUT_METHOD.TOOLBAR
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
};
|