@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.
Files changed (88) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/cjs/plugins/index.js +0 -7
  3. package/dist/cjs/plugins/tasks-and-decisions/index.js +15 -5
  4. package/dist/cjs/plugins/tasks-and-decisions/nodeviews/decisionItem.js +16 -5
  5. package/dist/cjs/plugins/tasks-and-decisions/nodeviews/hooks/use-show-placeholder.js +40 -0
  6. package/dist/cjs/plugins/tasks-and-decisions/nodeviews/taskItem.js +31 -31
  7. package/dist/cjs/presets/universal.js +2 -1
  8. package/dist/cjs/version-wrapper.js +1 -1
  9. package/dist/es2019/plugins/index.js +0 -1
  10. package/dist/es2019/plugins/tasks-and-decisions/index.js +11 -1
  11. package/dist/es2019/plugins/tasks-and-decisions/nodeviews/decisionItem.js +16 -6
  12. package/dist/es2019/plugins/tasks-and-decisions/nodeviews/hooks/use-show-placeholder.js +36 -0
  13. package/dist/es2019/plugins/tasks-and-decisions/nodeviews/taskItem.js +29 -30
  14. package/dist/es2019/presets/universal.js +2 -1
  15. package/dist/es2019/version-wrapper.js +1 -1
  16. package/dist/esm/plugins/index.js +0 -1
  17. package/dist/esm/plugins/tasks-and-decisions/index.js +11 -1
  18. package/dist/esm/plugins/tasks-and-decisions/nodeviews/decisionItem.js +16 -5
  19. package/dist/esm/plugins/tasks-and-decisions/nodeviews/hooks/use-show-placeholder.js +34 -0
  20. package/dist/esm/plugins/tasks-and-decisions/nodeviews/taskItem.js +31 -32
  21. package/dist/esm/presets/universal.js +2 -1
  22. package/dist/esm/version-wrapper.js +1 -1
  23. package/dist/types/plugins/index.d.ts +0 -1
  24. package/dist/types/plugins/tasks-and-decisions/nodeviews/hooks/use-show-placeholder.d.ts +11 -0
  25. package/dist/types/plugins/tasks-and-decisions/types.d.ts +4 -0
  26. package/dist/types/types/editor-props.d.ts +1 -1
  27. package/dist/types-ts4.5/plugins/index.d.ts +0 -1
  28. package/dist/types-ts4.5/plugins/tasks-and-decisions/nodeviews/hooks/use-show-placeholder.d.ts +11 -0
  29. package/dist/types-ts4.5/plugins/tasks-and-decisions/types.d.ts +4 -0
  30. package/dist/types-ts4.5/types/editor-props.d.ts +1 -1
  31. package/package.json +3 -2
  32. package/report.api.md +1 -12
  33. package/tmp/api-report-tmp.d.ts +1 -12
  34. package/dist/cjs/plugins/text-color/commands/change-color.js +0 -61
  35. package/dist/cjs/plugins/text-color/commands/remove-color.js +0 -59
  36. package/dist/cjs/plugins/text-color/commands/toggle-color.js +0 -36
  37. package/dist/cjs/plugins/text-color/index.js +0 -75
  38. package/dist/cjs/plugins/text-color/pm-plugins/main.js +0 -88
  39. package/dist/cjs/plugins/text-color/types.js +0 -5
  40. package/dist/cjs/plugins/text-color/ui/ToolbarTextColor/icon.js +0 -29
  41. package/dist/cjs/plugins/text-color/ui/ToolbarTextColor/index.js +0 -285
  42. package/dist/cjs/plugins/text-color/ui/ToolbarTextColor/styles.js +0 -38
  43. package/dist/cjs/plugins/text-color/utils/color.js +0 -54
  44. package/dist/cjs/plugins/text-color/utils/disabled.js +0 -32
  45. package/dist/es2019/plugins/text-color/commands/change-color.js +0 -54
  46. package/dist/es2019/plugins/text-color/commands/remove-color.js +0 -57
  47. package/dist/es2019/plugins/text-color/commands/toggle-color.js +0 -30
  48. package/dist/es2019/plugins/text-color/index.js +0 -63
  49. package/dist/es2019/plugins/text-color/pm-plugins/main.js +0 -75
  50. package/dist/es2019/plugins/text-color/types.js +0 -1
  51. package/dist/es2019/plugins/text-color/ui/ToolbarTextColor/icon.js +0 -20
  52. package/dist/es2019/plugins/text-color/ui/ToolbarTextColor/index.js +0 -265
  53. package/dist/es2019/plugins/text-color/ui/ToolbarTextColor/styles.js +0 -48
  54. package/dist/es2019/plugins/text-color/utils/color.js +0 -48
  55. package/dist/es2019/plugins/text-color/utils/disabled.js +0 -39
  56. package/dist/esm/plugins/text-color/commands/change-color.js +0 -56
  57. package/dist/esm/plugins/text-color/commands/remove-color.js +0 -53
  58. package/dist/esm/plugins/text-color/commands/toggle-color.js +0 -30
  59. package/dist/esm/plugins/text-color/index.js +0 -63
  60. package/dist/esm/plugins/text-color/pm-plugins/main.js +0 -75
  61. package/dist/esm/plugins/text-color/types.js +0 -1
  62. package/dist/esm/plugins/text-color/ui/ToolbarTextColor/icon.js +0 -22
  63. package/dist/esm/plugins/text-color/ui/ToolbarTextColor/index.js +0 -282
  64. package/dist/esm/plugins/text-color/ui/ToolbarTextColor/styles.js +0 -28
  65. package/dist/esm/plugins/text-color/utils/color.js +0 -48
  66. package/dist/esm/plugins/text-color/utils/disabled.js +0 -26
  67. package/dist/types/plugins/text-color/commands/change-color.d.ts +0 -3
  68. package/dist/types/plugins/text-color/commands/remove-color.d.ts +0 -2
  69. package/dist/types/plugins/text-color/commands/toggle-color.d.ts +0 -2
  70. package/dist/types/plugins/text-color/index.d.ts +0 -7
  71. package/dist/types/plugins/text-color/pm-plugins/main.d.ts +0 -25
  72. package/dist/types/plugins/text-color/types.d.ts +0 -10
  73. package/dist/types/plugins/text-color/ui/ToolbarTextColor/icon.d.ts +0 -2
  74. package/dist/types/plugins/text-color/ui/ToolbarTextColor/index.d.ts +0 -53
  75. package/dist/types/plugins/text-color/ui/ToolbarTextColor/styles.d.ts +0 -3
  76. package/dist/types/plugins/text-color/utils/color.d.ts +0 -6
  77. package/dist/types/plugins/text-color/utils/disabled.d.ts +0 -2
  78. package/dist/types-ts4.5/plugins/text-color/commands/change-color.d.ts +0 -3
  79. package/dist/types-ts4.5/plugins/text-color/commands/remove-color.d.ts +0 -2
  80. package/dist/types-ts4.5/plugins/text-color/commands/toggle-color.d.ts +0 -2
  81. package/dist/types-ts4.5/plugins/text-color/index.d.ts +0 -7
  82. package/dist/types-ts4.5/plugins/text-color/pm-plugins/main.d.ts +0 -25
  83. package/dist/types-ts4.5/plugins/text-color/types.d.ts +0 -12
  84. package/dist/types-ts4.5/plugins/text-color/ui/ToolbarTextColor/icon.d.ts +0 -2
  85. package/dist/types-ts4.5/plugins/text-color/ui/ToolbarTextColor/index.d.ts +0 -53
  86. package/dist/types-ts4.5/plugins/text-color/ui/ToolbarTextColor/styles.d.ts +0 -3
  87. package/dist/types-ts4.5/plugins/text-color/utils/color.d.ts +0 -6
  88. 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 { WithPluginState } from '@atlaskit/editor-common/with-plugin-state';
19
- import { stateKey as taskPluginKey } from '../pm-plugins/plugin-key';
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
- api = _ref.api;
33
- var _useSharedPluginState = useSharedPluginState(api, ['typeAhead']),
34
- typeAheadState = _useSharedPluginState.typeAheadState;
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: isContentNodeEmpty && !(typeAheadState !== null && typeAheadState !== void 0 && typeAheadState.isOpen),
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(WithPluginState, {
156
- plugins: {
157
- taskDecisionPlugin: taskPluginKey
158
- },
159
- render: function render(_ref2) {
160
- var taskDecisionPlugin = _ref2.taskDecisionPlugin;
161
- return /*#__PURE__*/React.createElement(TaskItemWrapper, {
162
- localId: localId,
163
- forwardRef: forwardRef,
164
- isDone: state === 'DONE',
165
- onChange: _this2.handleOnChange,
166
- isFocused: Boolean((taskDecisionPlugin === null || taskDecisionPlugin === void 0 ? void 0 : taskDecisionPlugin.focusedTaskItemLocalId) === localId),
167
- isContentNodeEmpty: isContentNodeEmpty,
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 _this3 = this;
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
- !_this3.isContentEmpty(newNode) && !!(currentNode.attrs.state === newNode.attrs.state)
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, textColorPlugin, alignmentPlugin, indentationPlugin, customAutoformatPlugin, feedbackDialogPlugin, expandPlugin, isExpandInsertionEnabled, mobileDimensionsPlugin, findReplacePlugin, mobileSelectionPlugin, annotationPlugin, avatarGroupPlugin, viewUpdateSubscriptionPlugin, beforePrimaryToolbarPlugin, codeBidiWarningPlugin } from '../plugins';
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';
@@ -1,5 +1,5 @@
1
1
  export var name = "@atlaskit/editor-core";
2
- export var version = "189.0.9";
2
+ export var version = "189.0.11";
3
3
  export var nextMajorVersion = function nextMajorVersion() {
4
4
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
5
5
  };
@@ -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 '../plugins/text-color/pm-plugins/main';
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';
@@ -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 '../plugins/text-color/pm-plugins/main';
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.9",
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": "^2.0.0",
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
 
@@ -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;