@atlaskit/editor-core 189.0.9 → 189.0.11
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 +13 -0
- package/dist/cjs/plugins/index.js +0 -7
- package/dist/cjs/plugins/tasks-and-decisions/index.js +15 -5
- package/dist/cjs/plugins/tasks-and-decisions/nodeviews/decisionItem.js +16 -5
- package/dist/cjs/plugins/tasks-and-decisions/nodeviews/hooks/use-show-placeholder.js +40 -0
- package/dist/cjs/plugins/tasks-and-decisions/nodeviews/taskItem.js +31 -31
- package/dist/cjs/presets/universal.js +2 -1
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/es2019/plugins/index.js +0 -1
- package/dist/es2019/plugins/tasks-and-decisions/index.js +11 -1
- package/dist/es2019/plugins/tasks-and-decisions/nodeviews/decisionItem.js +16 -6
- package/dist/es2019/plugins/tasks-and-decisions/nodeviews/hooks/use-show-placeholder.js +36 -0
- package/dist/es2019/plugins/tasks-and-decisions/nodeviews/taskItem.js +29 -30
- package/dist/es2019/presets/universal.js +2 -1
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/esm/plugins/index.js +0 -1
- package/dist/esm/plugins/tasks-and-decisions/index.js +11 -1
- package/dist/esm/plugins/tasks-and-decisions/nodeviews/decisionItem.js +16 -5
- package/dist/esm/plugins/tasks-and-decisions/nodeviews/hooks/use-show-placeholder.js +34 -0
- package/dist/esm/plugins/tasks-and-decisions/nodeviews/taskItem.js +31 -32
- package/dist/esm/presets/universal.js +2 -1
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/types/plugins/index.d.ts +0 -1
- package/dist/types/plugins/tasks-and-decisions/nodeviews/hooks/use-show-placeholder.d.ts +11 -0
- package/dist/types/plugins/tasks-and-decisions/types.d.ts +4 -0
- package/dist/types/types/editor-props.d.ts +1 -1
- package/dist/types-ts4.5/plugins/index.d.ts +0 -1
- package/dist/types-ts4.5/plugins/tasks-and-decisions/nodeviews/hooks/use-show-placeholder.d.ts +11 -0
- package/dist/types-ts4.5/plugins/tasks-and-decisions/types.d.ts +4 -0
- package/dist/types-ts4.5/types/editor-props.d.ts +1 -1
- package/package.json +3 -2
- package/report.api.md +1 -12
- package/tmp/api-report-tmp.d.ts +1 -12
- package/dist/cjs/plugins/text-color/commands/change-color.js +0 -61
- package/dist/cjs/plugins/text-color/commands/remove-color.js +0 -59
- package/dist/cjs/plugins/text-color/commands/toggle-color.js +0 -36
- package/dist/cjs/plugins/text-color/index.js +0 -75
- package/dist/cjs/plugins/text-color/pm-plugins/main.js +0 -88
- package/dist/cjs/plugins/text-color/types.js +0 -5
- package/dist/cjs/plugins/text-color/ui/ToolbarTextColor/icon.js +0 -29
- package/dist/cjs/plugins/text-color/ui/ToolbarTextColor/index.js +0 -285
- package/dist/cjs/plugins/text-color/ui/ToolbarTextColor/styles.js +0 -38
- package/dist/cjs/plugins/text-color/utils/color.js +0 -54
- package/dist/cjs/plugins/text-color/utils/disabled.js +0 -32
- package/dist/es2019/plugins/text-color/commands/change-color.js +0 -54
- package/dist/es2019/plugins/text-color/commands/remove-color.js +0 -57
- package/dist/es2019/plugins/text-color/commands/toggle-color.js +0 -30
- package/dist/es2019/plugins/text-color/index.js +0 -63
- package/dist/es2019/plugins/text-color/pm-plugins/main.js +0 -75
- package/dist/es2019/plugins/text-color/types.js +0 -1
- package/dist/es2019/plugins/text-color/ui/ToolbarTextColor/icon.js +0 -20
- package/dist/es2019/plugins/text-color/ui/ToolbarTextColor/index.js +0 -265
- package/dist/es2019/plugins/text-color/ui/ToolbarTextColor/styles.js +0 -48
- package/dist/es2019/plugins/text-color/utils/color.js +0 -48
- package/dist/es2019/plugins/text-color/utils/disabled.js +0 -39
- package/dist/esm/plugins/text-color/commands/change-color.js +0 -56
- package/dist/esm/plugins/text-color/commands/remove-color.js +0 -53
- package/dist/esm/plugins/text-color/commands/toggle-color.js +0 -30
- package/dist/esm/plugins/text-color/index.js +0 -63
- package/dist/esm/plugins/text-color/pm-plugins/main.js +0 -75
- package/dist/esm/plugins/text-color/types.js +0 -1
- package/dist/esm/plugins/text-color/ui/ToolbarTextColor/icon.js +0 -22
- package/dist/esm/plugins/text-color/ui/ToolbarTextColor/index.js +0 -282
- package/dist/esm/plugins/text-color/ui/ToolbarTextColor/styles.js +0 -28
- package/dist/esm/plugins/text-color/utils/color.js +0 -48
- package/dist/esm/plugins/text-color/utils/disabled.js +0 -26
- package/dist/types/plugins/text-color/commands/change-color.d.ts +0 -3
- package/dist/types/plugins/text-color/commands/remove-color.d.ts +0 -2
- package/dist/types/plugins/text-color/commands/toggle-color.d.ts +0 -2
- package/dist/types/plugins/text-color/index.d.ts +0 -7
- package/dist/types/plugins/text-color/pm-plugins/main.d.ts +0 -25
- package/dist/types/plugins/text-color/types.d.ts +0 -10
- package/dist/types/plugins/text-color/ui/ToolbarTextColor/icon.d.ts +0 -2
- package/dist/types/plugins/text-color/ui/ToolbarTextColor/index.d.ts +0 -53
- package/dist/types/plugins/text-color/ui/ToolbarTextColor/styles.d.ts +0 -3
- package/dist/types/plugins/text-color/utils/color.d.ts +0 -6
- package/dist/types/plugins/text-color/utils/disabled.d.ts +0 -2
- package/dist/types-ts4.5/plugins/text-color/commands/change-color.d.ts +0 -3
- package/dist/types-ts4.5/plugins/text-color/commands/remove-color.d.ts +0 -2
- package/dist/types-ts4.5/plugins/text-color/commands/toggle-color.d.ts +0 -2
- package/dist/types-ts4.5/plugins/text-color/index.d.ts +0 -7
- package/dist/types-ts4.5/plugins/text-color/pm-plugins/main.d.ts +0 -25
- package/dist/types-ts4.5/plugins/text-color/types.d.ts +0 -12
- package/dist/types-ts4.5/plugins/text-color/ui/ToolbarTextColor/icon.d.ts +0 -2
- package/dist/types-ts4.5/plugins/text-color/ui/ToolbarTextColor/index.d.ts +0 -53
- package/dist/types-ts4.5/plugins/text-color/ui/ToolbarTextColor/styles.d.ts +0 -3
- package/dist/types-ts4.5/plugins/text-color/utils/color.d.ts +0 -6
- package/dist/types-ts4.5/plugins/text-color/utils/disabled.d.ts +0 -2
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
+
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
4
|
+
export var useShowPlaceholder = function useShowPlaceholder(_ref) {
|
|
5
|
+
var editorView = _ref.editorView,
|
|
6
|
+
api = _ref.api,
|
|
7
|
+
isContentNodeEmpty = _ref.isContentNodeEmpty,
|
|
8
|
+
getPos = _ref.getPos;
|
|
9
|
+
var _useSharedPluginState = useSharedPluginState(api, ['typeAhead']),
|
|
10
|
+
typeAheadState = _useSharedPluginState.typeAheadState;
|
|
11
|
+
var isTypeAheadOpen = Boolean(typeAheadState === null || typeAheadState === void 0 ? void 0 : typeAheadState.isOpen);
|
|
12
|
+
var isTypeAheadOpenedInsideItem = useMemo(function () {
|
|
13
|
+
var _selection$$cursor;
|
|
14
|
+
if (!isTypeAheadOpen) {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
var itemPosition = getPos();
|
|
18
|
+
if (typeof itemPosition !== 'number') {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
var selection = editorView.state.selection;
|
|
22
|
+
if (!(selection instanceof TextSelection)) {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
var maybeItemNode = editorView.state.doc.nodeAt(itemPosition);
|
|
26
|
+
var maybeParentItemNode = (_selection$$cursor = selection.$cursor) === null || _selection$$cursor === void 0 ? void 0 : _selection$$cursor.node();
|
|
27
|
+
if (maybeItemNode && maybeParentItemNode && maybeItemNode.eq(maybeParentItemNode)) {
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
return false;
|
|
31
|
+
}, [isTypeAheadOpen, getPos, editorView]);
|
|
32
|
+
var showPlaceholder = Boolean(!isTypeAheadOpenedInsideItem && isContentNodeEmpty);
|
|
33
|
+
return showPlaceholder;
|
|
34
|
+
};
|
|
@@ -13,32 +13,36 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
|
|
|
13
13
|
import React from 'react';
|
|
14
14
|
import { AnalyticsListener } from '@atlaskit/analytics-next';
|
|
15
15
|
import { SetAttrsStep } from '@atlaskit/adf-schema/steps';
|
|
16
|
-
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
17
16
|
import ReactNodeView from '@atlaskit/editor-common/react-node-view';
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
17
|
+
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
18
|
+
import { useShowPlaceholder } from './hooks/use-show-placeholder';
|
|
20
19
|
import TaskItem from '../ui/Task';
|
|
21
|
-
|
|
22
|
-
//import { isTypeAheadOpen } from '../../type-ahead/utils';
|
|
23
|
-
|
|
24
20
|
var TaskItemWrapper = function TaskItemWrapper(_ref) {
|
|
25
21
|
var localId = _ref.localId,
|
|
26
22
|
forwardRef = _ref.forwardRef,
|
|
27
23
|
isDone = _ref.isDone,
|
|
28
24
|
onChange = _ref.onChange,
|
|
29
|
-
isFocused = _ref.isFocused,
|
|
30
|
-
isContentNodeEmpty = _ref.isContentNodeEmpty,
|
|
31
25
|
providerFactory = _ref.providerFactory,
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
26
|
+
isContentNodeEmpty = _ref.isContentNodeEmpty,
|
|
27
|
+
api = _ref.api,
|
|
28
|
+
getPos = _ref.getPos,
|
|
29
|
+
editorView = _ref.editorView;
|
|
30
|
+
var _useSharedPluginState = useSharedPluginState(api, ['taskDecision']),
|
|
31
|
+
taskDecisionState = _useSharedPluginState.taskDecisionState;
|
|
32
|
+
var isFocused = Boolean((taskDecisionState === null || taskDecisionState === void 0 ? void 0 : taskDecisionState.focusedTaskItemLocalId) === localId);
|
|
33
|
+
var showPlaceholder = useShowPlaceholder({
|
|
34
|
+
editorView: editorView,
|
|
35
|
+
isContentNodeEmpty: isContentNodeEmpty,
|
|
36
|
+
getPos: getPos,
|
|
37
|
+
api: api
|
|
38
|
+
});
|
|
35
39
|
return /*#__PURE__*/React.createElement(TaskItem, {
|
|
36
40
|
taskId: localId,
|
|
37
41
|
contentRef: forwardRef,
|
|
38
42
|
isDone: isDone,
|
|
39
43
|
onChange: onChange,
|
|
40
44
|
isFocused: isFocused,
|
|
41
|
-
showPlaceholder:
|
|
45
|
+
showPlaceholder: showPlaceholder,
|
|
42
46
|
providers: providerFactory
|
|
43
47
|
});
|
|
44
48
|
};
|
|
@@ -144,7 +148,6 @@ var Task = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
144
148
|
}, {
|
|
145
149
|
key: "render",
|
|
146
150
|
value: function render(props, forwardRef) {
|
|
147
|
-
var _this2 = this;
|
|
148
151
|
var _this$node$attrs = this.node.attrs,
|
|
149
152
|
localId = _this$node$attrs.localId,
|
|
150
153
|
state = _this$node$attrs.state;
|
|
@@ -152,23 +155,19 @@ var Task = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
152
155
|
return /*#__PURE__*/React.createElement(AnalyticsListener, {
|
|
153
156
|
channel: "fabric-elements",
|
|
154
157
|
onEvent: this.addListAnalyticsData
|
|
155
|
-
}, /*#__PURE__*/React.createElement(
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
providerFactory: props.providerFactory,
|
|
169
|
-
api: _this2.api
|
|
170
|
-
});
|
|
171
|
-
}
|
|
158
|
+
}, /*#__PURE__*/React.createElement(TaskItemWrapper, {
|
|
159
|
+
localId: localId,
|
|
160
|
+
forwardRef: forwardRef,
|
|
161
|
+
isDone: state === 'DONE',
|
|
162
|
+
onChange: this.handleOnChange,
|
|
163
|
+
isContentNodeEmpty: isContentNodeEmpty,
|
|
164
|
+
providerFactory: props.providerFactory
|
|
165
|
+
// The getPosHandler type is wrong, there is no `boolean` in the real implementation
|
|
166
|
+
// @ts-expect-error 2322: Type 'getPosHandler' is not assignable to type '() => number | undefined'.
|
|
167
|
+
,
|
|
168
|
+
getPos: this.getPos,
|
|
169
|
+
editorView: this.view,
|
|
170
|
+
api: this.api
|
|
172
171
|
}));
|
|
173
172
|
}
|
|
174
173
|
}, {
|
|
@@ -184,11 +183,11 @@ var Task = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
184
183
|
}, {
|
|
185
184
|
key: "update",
|
|
186
185
|
value: function update(node, decorations) {
|
|
187
|
-
var
|
|
186
|
+
var _this2 = this;
|
|
188
187
|
return _get(_getPrototypeOf(Task.prototype), "update", this).call(this, node, decorations, undefined, function (currentNode, newNode) {
|
|
189
188
|
return (
|
|
190
189
|
// Toggle the placeholder based on whether user input exists
|
|
191
|
-
!
|
|
190
|
+
!_this2.isContentEmpty(newNode) && !!(currentNode.attrs.state === newNode.attrs.state)
|
|
192
191
|
);
|
|
193
192
|
});
|
|
194
193
|
}
|
|
@@ -2,7 +2,8 @@ import _typeof from "@babel/runtime/helpers/typeof";
|
|
|
2
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
3
|
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; }
|
|
4
4
|
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; }
|
|
5
|
-
import { breakoutPlugin, collabEditPlugin, dataConsumerMarkPlugin, extensionPlugin, fragmentMarkPlugin, insertBlockPlugin, jiraIssuePlugin, layoutPlugin, toolbarListsIndentationPlugin, macroPlugin, maxContentSizePlugin, panelPlugin, placeholderTextPlugin, tasksAndDecisionsPlugin,
|
|
5
|
+
import { breakoutPlugin, collabEditPlugin, dataConsumerMarkPlugin, extensionPlugin, fragmentMarkPlugin, insertBlockPlugin, jiraIssuePlugin, layoutPlugin, toolbarListsIndentationPlugin, macroPlugin, maxContentSizePlugin, panelPlugin, placeholderTextPlugin, tasksAndDecisionsPlugin, alignmentPlugin, indentationPlugin, customAutoformatPlugin, feedbackDialogPlugin, expandPlugin, isExpandInsertionEnabled, mobileDimensionsPlugin, findReplacePlugin, mobileSelectionPlugin, annotationPlugin, avatarGroupPlugin, viewUpdateSubscriptionPlugin, beforePrimaryToolbarPlugin, codeBidiWarningPlugin } from '../plugins';
|
|
6
|
+
import { textColorPlugin } from '@atlaskit/editor-plugin-text-color';
|
|
6
7
|
import { historyPlugin } from '@atlaskit/editor-plugin-history';
|
|
7
8
|
import { statusPlugin } from '@atlaskit/editor-plugin-status';
|
|
8
9
|
import { datePlugin } from '@atlaskit/editor-plugin-date';
|
|
@@ -13,7 +13,6 @@ export { default as panelPlugin } from './panel';
|
|
|
13
13
|
export { default as pastePlugin } from './paste';
|
|
14
14
|
export { placeholderTextPlugin } from './placeholder-text';
|
|
15
15
|
export { default as tasksAndDecisionsPlugin } from './tasks-and-decisions';
|
|
16
|
-
export { default as textColorPlugin } from './text-color';
|
|
17
16
|
export { default as breakoutPlugin } from './breakout';
|
|
18
17
|
export { default as alignmentPlugin } from './alignment';
|
|
19
18
|
export { default as dataConsumerMarkPlugin } from './data-consumer';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
2
|
+
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
3
|
+
import type { TaskAndDecisionsPlugin } from '../../types';
|
|
4
|
+
type Props2 = {
|
|
5
|
+
editorView: EditorView;
|
|
6
|
+
api: ExtractInjectionAPI<TaskAndDecisionsPlugin> | undefined;
|
|
7
|
+
getPos: () => number | undefined;
|
|
8
|
+
isContentNodeEmpty: boolean;
|
|
9
|
+
};
|
|
10
|
+
export declare const useShowPlaceholder: ({ editorView, api, isContentNodeEmpty, getPos, }: Props2) => boolean;
|
|
11
|
+
export {};
|
|
@@ -26,8 +26,12 @@ export interface TaskDecisionPluginOptions extends LongPressSelectionPluginOptio
|
|
|
26
26
|
allowNestedTasks?: boolean;
|
|
27
27
|
consumeTabs?: boolean;
|
|
28
28
|
}
|
|
29
|
+
export type TaskAndDecisionsSharedState = {
|
|
30
|
+
focusedTaskItemLocalId: string | null;
|
|
31
|
+
};
|
|
29
32
|
export type TaskAndDecisionsPlugin = NextEditorPlugin<'taskDecision', {
|
|
30
33
|
pluginConfiguration: TaskDecisionPluginOptions | undefined;
|
|
34
|
+
sharedState: TaskAndDecisionsSharedState | undefined;
|
|
31
35
|
dependencies: [
|
|
32
36
|
OptionalPlugin<TypeAheadPlugin>,
|
|
33
37
|
OptionalPlugin<AnalyticsPlugin>
|
|
@@ -23,7 +23,7 @@ import type { MediaOptions, MediaState } from '@atlaskit/editor-plugin-media/typ
|
|
|
23
23
|
import type { MentionPluginConfig } from '@atlaskit/editor-plugin-mentions';
|
|
24
24
|
import type { PanelPluginConfig } from '../plugins/panel/types';
|
|
25
25
|
import type { PlaceholderTextOptions } from '../plugins/placeholder-text/types';
|
|
26
|
-
import type { TextColorPluginConfig } from '
|
|
26
|
+
import type { TextColorPluginConfig } from '@atlaskit/editor-plugin-text-color';
|
|
27
27
|
import type { MenuItem } from '@atlaskit/editor-common/ui-menu';
|
|
28
28
|
import type { EditorAppearance } from './editor-appearance';
|
|
29
29
|
import type { EditorOnChangeHandler } from './editor-onchange';
|
|
@@ -13,7 +13,6 @@ export { default as panelPlugin } from './panel';
|
|
|
13
13
|
export { default as pastePlugin } from './paste';
|
|
14
14
|
export { placeholderTextPlugin } from './placeholder-text';
|
|
15
15
|
export { default as tasksAndDecisionsPlugin } from './tasks-and-decisions';
|
|
16
|
-
export { default as textColorPlugin } from './text-color';
|
|
17
16
|
export { default as breakoutPlugin } from './breakout';
|
|
18
17
|
export { default as alignmentPlugin } from './alignment';
|
|
19
18
|
export { default as dataConsumerMarkPlugin } from './data-consumer';
|
package/dist/types-ts4.5/plugins/tasks-and-decisions/nodeviews/hooks/use-show-placeholder.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
2
|
+
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
3
|
+
import type { TaskAndDecisionsPlugin } from '../../types';
|
|
4
|
+
type Props2 = {
|
|
5
|
+
editorView: EditorView;
|
|
6
|
+
api: ExtractInjectionAPI<TaskAndDecisionsPlugin> | undefined;
|
|
7
|
+
getPos: () => number | undefined;
|
|
8
|
+
isContentNodeEmpty: boolean;
|
|
9
|
+
};
|
|
10
|
+
export declare const useShowPlaceholder: ({ editorView, api, isContentNodeEmpty, getPos, }: Props2) => boolean;
|
|
11
|
+
export {};
|
|
@@ -26,8 +26,12 @@ export interface TaskDecisionPluginOptions extends LongPressSelectionPluginOptio
|
|
|
26
26
|
allowNestedTasks?: boolean;
|
|
27
27
|
consumeTabs?: boolean;
|
|
28
28
|
}
|
|
29
|
+
export type TaskAndDecisionsSharedState = {
|
|
30
|
+
focusedTaskItemLocalId: string | null;
|
|
31
|
+
};
|
|
29
32
|
export type TaskAndDecisionsPlugin = NextEditorPlugin<'taskDecision', {
|
|
30
33
|
pluginConfiguration: TaskDecisionPluginOptions | undefined;
|
|
34
|
+
sharedState: TaskAndDecisionsSharedState | undefined;
|
|
31
35
|
dependencies: [
|
|
32
36
|
OptionalPlugin<TypeAheadPlugin>,
|
|
33
37
|
OptionalPlugin<AnalyticsPlugin>
|
|
@@ -23,7 +23,7 @@ import type { MediaOptions, MediaState } from '@atlaskit/editor-plugin-media/typ
|
|
|
23
23
|
import type { MentionPluginConfig } from '@atlaskit/editor-plugin-mentions';
|
|
24
24
|
import type { PanelPluginConfig } from '../plugins/panel/types';
|
|
25
25
|
import type { PlaceholderTextOptions } from '../plugins/placeholder-text/types';
|
|
26
|
-
import type { TextColorPluginConfig } from '
|
|
26
|
+
import type { TextColorPluginConfig } from '@atlaskit/editor-plugin-text-color';
|
|
27
27
|
import type { MenuItem } from '@atlaskit/editor-common/ui-menu';
|
|
28
28
|
import type { EditorAppearance } from './editor-appearance';
|
|
29
29
|
import type { EditorOnChangeHandler } from './editor-onchange';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-core",
|
|
3
|
-
"version": "189.0.
|
|
3
|
+
"version": "189.0.11",
|
|
4
4
|
"description": "A package contains Atlassian editor core functionality",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"@atlaskit/editor-plugin-analytics": "^0.2.0",
|
|
61
61
|
"@atlaskit/editor-plugin-base": "^0.2.0",
|
|
62
62
|
"@atlaskit/editor-plugin-better-type-history": "^0.1.0",
|
|
63
|
-
"@atlaskit/editor-plugin-block-type": "^
|
|
63
|
+
"@atlaskit/editor-plugin-block-type": "^3.0.0",
|
|
64
64
|
"@atlaskit/editor-plugin-border": "^0.1.0",
|
|
65
65
|
"@atlaskit/editor-plugin-caption": "^0.2.0",
|
|
66
66
|
"@atlaskit/editor-plugin-card": "^0.10.0",
|
|
@@ -98,6 +98,7 @@
|
|
|
98
98
|
"@atlaskit/editor-plugin-status": "^0.1.0",
|
|
99
99
|
"@atlaskit/editor-plugin-submit-editor": "^0.1.0",
|
|
100
100
|
"@atlaskit/editor-plugin-table": "^5.3.0",
|
|
101
|
+
"@atlaskit/editor-plugin-text-color": "^0.1.0",
|
|
101
102
|
"@atlaskit/editor-plugin-text-formatting": "^0.4.0",
|
|
102
103
|
"@atlaskit/editor-plugin-type-ahead": "^0.7.0",
|
|
103
104
|
"@atlaskit/editor-plugin-unsupported-content": "^0.2.0",
|
package/report.api.md
CHANGED
|
@@ -82,6 +82,7 @@ import type { SearchProvider } from '@atlaskit/editor-common/provider-factory';
|
|
|
82
82
|
import { setTextSelection } from '@atlaskit/editor-common/utils';
|
|
83
83
|
import type { TaskDecisionProvider } from '@atlaskit/task-decision';
|
|
84
84
|
import { TeamMentionResource } from '@atlaskit/mention/team-resource';
|
|
85
|
+
import type { TextColorPluginConfig } from '@atlaskit/editor-plugin-text-color';
|
|
85
86
|
import type { TextFormattingOptions } from '@atlaskit/editor-common/types';
|
|
86
87
|
import { ToolbarUIComponentFactory } from '@atlaskit/editor-common/types';
|
|
87
88
|
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
@@ -757,18 +758,6 @@ interface State {}
|
|
|
757
758
|
|
|
758
759
|
export { TeamMentionResource };
|
|
759
760
|
|
|
760
|
-
// @public (undocumented)
|
|
761
|
-
type TextColorDefaultColor = {
|
|
762
|
-
color: string;
|
|
763
|
-
label: string;
|
|
764
|
-
};
|
|
765
|
-
|
|
766
|
-
// @public (undocumented)
|
|
767
|
-
interface TextColorPluginConfig {
|
|
768
|
-
// (undocumented)
|
|
769
|
-
defaultColor?: TextColorDefaultColor;
|
|
770
|
-
}
|
|
771
|
-
|
|
772
761
|
// @public (undocumented)
|
|
773
762
|
export function ToolbarFeedback(props: Props_3): jsx.JSX.Element;
|
|
774
763
|
|
package/tmp/api-report-tmp.d.ts
CHANGED
|
@@ -71,6 +71,7 @@ import type { SearchProvider } from '@atlaskit/editor-common/provider-factory';
|
|
|
71
71
|
import { setTextSelection } from '@atlaskit/editor-common/utils';
|
|
72
72
|
import type { TaskDecisionProvider } from '@atlaskit/task-decision';
|
|
73
73
|
import { TeamMentionResource } from '@atlaskit/mention/team-resource';
|
|
74
|
+
import type { TextColorPluginConfig } from '@atlaskit/editor-plugin-text-color';
|
|
74
75
|
import type { TextFormattingOptions } from '@atlaskit/editor-common/types';
|
|
75
76
|
import { ToolbarUIComponentFactory } from '@atlaskit/editor-common/types';
|
|
76
77
|
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
@@ -704,18 +705,6 @@ interface State {
|
|
|
704
705
|
|
|
705
706
|
export { TeamMentionResource }
|
|
706
707
|
|
|
707
|
-
// @public (undocumented)
|
|
708
|
-
type TextColorDefaultColor = {
|
|
709
|
-
color: string;
|
|
710
|
-
label: string;
|
|
711
|
-
};
|
|
712
|
-
|
|
713
|
-
// @public (undocumented)
|
|
714
|
-
interface TextColorPluginConfig {
|
|
715
|
-
// (undocumented)
|
|
716
|
-
defaultColor?: TextColorDefaultColor;
|
|
717
|
-
}
|
|
718
|
-
|
|
719
708
|
// @public (undocumented)
|
|
720
709
|
export function ToolbarFeedback(props: Props_3): jsx.JSX.Element;
|
|
721
710
|
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.changeColor = void 0;
|
|
7
|
-
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
8
|
-
var _editorAnalytics = require("@atlaskit/editor-common/editor-analytics");
|
|
9
|
-
var _main = require("../pm-plugins/main");
|
|
10
|
-
var _color = require("../utils/color");
|
|
11
|
-
var _removeColor = require("./remove-color");
|
|
12
|
-
var _toggleColor = require("./toggle-color");
|
|
13
|
-
/**
|
|
14
|
-
* Helper to create a higher order analytics command
|
|
15
|
-
* @param newColor - Color to be change in hex code
|
|
16
|
-
* @param previousColor - Active color in hex code
|
|
17
|
-
* @param palette - Current palette of colors
|
|
18
|
-
* @return Higher order command with analytics logic inside.
|
|
19
|
-
*/
|
|
20
|
-
function createWithColorAnalytics(newColor, previousColor, palette, editorAnalyticsApi) {
|
|
21
|
-
var newColorFromPalette = palette.find(function (_ref) {
|
|
22
|
-
var value = _ref.value;
|
|
23
|
-
return value === newColor;
|
|
24
|
-
});
|
|
25
|
-
var previousColorFromPalette = palette.find(function (_ref2) {
|
|
26
|
-
var value = _ref2.value;
|
|
27
|
-
return value === previousColor;
|
|
28
|
-
});
|
|
29
|
-
var newColorLabel = newColorFromPalette ? newColorFromPalette.label : newColor;
|
|
30
|
-
var previousColorLabel = previousColorFromPalette ? previousColorFromPalette.label : previousColor || '';
|
|
31
|
-
return (0, _editorAnalytics.withAnalytics)(editorAnalyticsApi, {
|
|
32
|
-
action: _analytics.ACTION.FORMATTED,
|
|
33
|
-
actionSubject: _analytics.ACTION_SUBJECT.TEXT,
|
|
34
|
-
actionSubjectId: _analytics.ACTION_SUBJECT_ID.FORMAT_COLOR,
|
|
35
|
-
eventType: _analytics.EVENT_TYPE.TRACK,
|
|
36
|
-
attributes: {
|
|
37
|
-
newColor: newColorLabel.toLowerCase(),
|
|
38
|
-
previousColor: previousColorLabel.toLowerCase()
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
var changeColor = exports.changeColor = function changeColor(color, editorAnalyticsApi) {
|
|
43
|
-
return function (state, dispatch) {
|
|
44
|
-
var textColor = state.schema.marks.textColor;
|
|
45
|
-
if (textColor) {
|
|
46
|
-
var pluginState = _main.pluginKey.getState(state);
|
|
47
|
-
var activeColor = (0, _color.getActiveColor)(state);
|
|
48
|
-
var withColorAnalytics = createWithColorAnalytics(color, activeColor, (pluginState === null || pluginState === void 0 ? void 0 : pluginState.palette) || [], editorAnalyticsApi);
|
|
49
|
-
if (pluginState !== null && pluginState !== void 0 && pluginState.disabled) {
|
|
50
|
-
return false;
|
|
51
|
-
}
|
|
52
|
-
if (color === (pluginState === null || pluginState === void 0 ? void 0 : pluginState.defaultColor)) {
|
|
53
|
-
withColorAnalytics((0, _removeColor.removeColor)())(state, dispatch);
|
|
54
|
-
return true;
|
|
55
|
-
}
|
|
56
|
-
withColorAnalytics((0, _toggleColor.toggleColor)(color))(state, dispatch);
|
|
57
|
-
return true;
|
|
58
|
-
}
|
|
59
|
-
return false;
|
|
60
|
-
};
|
|
61
|
-
};
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.removeColor = void 0;
|
|
7
|
-
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
8
|
-
var _cellSelection = require("@atlaskit/editor-tables/cell-selection");
|
|
9
|
-
var _main = require("../pm-plugins/main");
|
|
10
|
-
var removeColor = exports.removeColor = function removeColor() {
|
|
11
|
-
return function (state, dispatch) {
|
|
12
|
-
var schema = state.schema,
|
|
13
|
-
selection = state.selection;
|
|
14
|
-
var textColor = schema.marks.textColor;
|
|
15
|
-
var tr = state.tr;
|
|
16
|
-
if (selection instanceof _state.TextSelection) {
|
|
17
|
-
var from = selection.from,
|
|
18
|
-
to = selection.to,
|
|
19
|
-
$cursor = selection.$cursor;
|
|
20
|
-
if ($cursor) {
|
|
21
|
-
tr = state.tr.removeStoredMark(textColor);
|
|
22
|
-
} else {
|
|
23
|
-
tr = state.tr.removeMark(from, to, textColor);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
if (selection instanceof _cellSelection.CellSelection) {
|
|
27
|
-
/**
|
|
28
|
-
* This is a slight abstraction from `src/utils/commands.ts`
|
|
29
|
-
* The main difference is we can't toggle the default from another (since they are different marks),
|
|
30
|
-
* we want to remove all text color marks on the selection, so we slightly modify the cell selection
|
|
31
|
-
* part here.
|
|
32
|
-
*/
|
|
33
|
-
selection.forEachCell(function (cell, cellPos) {
|
|
34
|
-
var from = cellPos;
|
|
35
|
-
var to = cellPos + cell.nodeSize;
|
|
36
|
-
tr.doc.nodesBetween(tr.mapping.map(from), tr.mapping.map(to), function (node, pos) {
|
|
37
|
-
if (!node.isText) {
|
|
38
|
-
return true;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
// This is an issue when the user selects some text.
|
|
42
|
-
// We need to check if the current node position is less than the range selection from.
|
|
43
|
-
// If it’s true, that means we should apply the mark using the range selection,
|
|
44
|
-
// not the current node position.
|
|
45
|
-
var nodeBetweenFrom = Math.max(pos, tr.mapping.map(from));
|
|
46
|
-
var nodeBetweenTo = Math.min(pos + node.nodeSize, tr.mapping.map(to));
|
|
47
|
-
tr.removeMark(nodeBetweenFrom, nodeBetweenTo, textColor);
|
|
48
|
-
return true;
|
|
49
|
-
});
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
if (dispatch) {
|
|
53
|
-
dispatch(tr.setMeta(_main.pluginKey, {
|
|
54
|
-
action: _main.ACTIONS.RESET_COLOR
|
|
55
|
-
}));
|
|
56
|
-
}
|
|
57
|
-
return true;
|
|
58
|
-
};
|
|
59
|
-
};
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.toggleColor = void 0;
|
|
7
|
-
var _mark = require("@atlaskit/editor-common/mark");
|
|
8
|
-
var _preset = require("@atlaskit/editor-common/preset");
|
|
9
|
-
var _main = require("../pm-plugins/main");
|
|
10
|
-
var _disabled = require("../utils/disabled");
|
|
11
|
-
var toggleColor = exports.toggleColor = function toggleColor(color) {
|
|
12
|
-
return function (state, dispatch) {
|
|
13
|
-
var textColor = state.schema.marks.textColor;
|
|
14
|
-
var tr = state.tr;
|
|
15
|
-
var disabledState = (0, _disabled.getDisabledState)(state);
|
|
16
|
-
if (disabledState) {
|
|
17
|
-
if (dispatch) {
|
|
18
|
-
dispatch(tr.setMeta(_main.pluginKey, {
|
|
19
|
-
action: _main.ACTIONS.DISABLE
|
|
20
|
-
}));
|
|
21
|
-
}
|
|
22
|
-
return false;
|
|
23
|
-
}
|
|
24
|
-
if (dispatch) {
|
|
25
|
-
state.tr.setMeta(_main.pluginKey, {
|
|
26
|
-
action: _main.ACTIONS.SET_COLOR,
|
|
27
|
-
color: color
|
|
28
|
-
});
|
|
29
|
-
state.tr.scrollIntoView();
|
|
30
|
-
(0, _preset.editorCommandToPMCommand)((0, _mark.toggleMark)(textColor, {
|
|
31
|
-
color: color
|
|
32
|
-
}))(state, dispatch);
|
|
33
|
-
}
|
|
34
|
-
return true;
|
|
35
|
-
};
|
|
36
|
-
};
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
Object.defineProperty(exports, "textColorPluginKey", {
|
|
9
|
-
enumerable: true,
|
|
10
|
-
get: function get() {
|
|
11
|
-
return _main.pluginKey;
|
|
12
|
-
}
|
|
13
|
-
});
|
|
14
|
-
var _react = _interopRequireDefault(require("react"));
|
|
15
|
-
var _adfSchema = require("@atlaskit/adf-schema");
|
|
16
|
-
var _withPluginState = require("@atlaskit/editor-common/with-plugin-state");
|
|
17
|
-
var _main = require("./pm-plugins/main");
|
|
18
|
-
var _ToolbarTextColor = _interopRequireDefault(require("./ui/ToolbarTextColor"));
|
|
19
|
-
var pluginConfig = function pluginConfig(textColorConfig) {
|
|
20
|
-
if (!textColorConfig || typeof textColorConfig === 'boolean') {
|
|
21
|
-
return undefined;
|
|
22
|
-
}
|
|
23
|
-
return textColorConfig;
|
|
24
|
-
};
|
|
25
|
-
var textColorPlugin = function textColorPlugin(_ref) {
|
|
26
|
-
var textColorConfig = _ref.config,
|
|
27
|
-
api = _ref.api;
|
|
28
|
-
return {
|
|
29
|
-
name: 'textColor',
|
|
30
|
-
marks: function marks() {
|
|
31
|
-
return [{
|
|
32
|
-
name: 'textColor',
|
|
33
|
-
mark: _adfSchema.textColor
|
|
34
|
-
}];
|
|
35
|
-
},
|
|
36
|
-
pmPlugins: function pmPlugins() {
|
|
37
|
-
return [{
|
|
38
|
-
name: 'textColor',
|
|
39
|
-
plugin: function plugin(_ref2) {
|
|
40
|
-
var dispatch = _ref2.dispatch;
|
|
41
|
-
return (0, _main.createPlugin)(dispatch, pluginConfig(textColorConfig));
|
|
42
|
-
}
|
|
43
|
-
}];
|
|
44
|
-
},
|
|
45
|
-
primaryToolbarComponent: function primaryToolbarComponent(_ref3) {
|
|
46
|
-
var editorView = _ref3.editorView,
|
|
47
|
-
popupsMountPoint = _ref3.popupsMountPoint,
|
|
48
|
-
popupsBoundariesElement = _ref3.popupsBoundariesElement,
|
|
49
|
-
popupsScrollableElement = _ref3.popupsScrollableElement,
|
|
50
|
-
isToolbarReducedSpacing = _ref3.isToolbarReducedSpacing,
|
|
51
|
-
dispatchAnalyticsEvent = _ref3.dispatchAnalyticsEvent,
|
|
52
|
-
disabled = _ref3.disabled;
|
|
53
|
-
return /*#__PURE__*/_react.default.createElement(_withPluginState.WithPluginState, {
|
|
54
|
-
plugins: {
|
|
55
|
-
textColor: _main.pluginKey
|
|
56
|
-
},
|
|
57
|
-
render: function render(_ref4) {
|
|
58
|
-
var textColor = _ref4.textColor;
|
|
59
|
-
return /*#__PURE__*/_react.default.createElement(_ToolbarTextColor.default, {
|
|
60
|
-
pluginState: textColor,
|
|
61
|
-
isReducedSpacing: isToolbarReducedSpacing,
|
|
62
|
-
editorView: editorView,
|
|
63
|
-
popupsMountPoint: popupsMountPoint,
|
|
64
|
-
popupsBoundariesElement: popupsBoundariesElement,
|
|
65
|
-
popupsScrollableElement: popupsScrollableElement,
|
|
66
|
-
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
67
|
-
disabled: disabled,
|
|
68
|
-
pluginInjectionApi: api
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
};
|
|
75
|
-
var _default = exports.default = textColorPlugin;
|