@atlaskit/editor-core 185.2.24 → 185.2.25

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 (95) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/cjs/labs/next/presets/universal.js +6 -5
  3. package/dist/cjs/plugins/extension/actions.js +6 -4
  4. package/dist/cjs/plugins/extension/commands.js +19 -16
  5. package/dist/cjs/plugins/extension/context-panel.js +4 -4
  6. package/dist/cjs/plugins/extension/extension-api.js +1 -1
  7. package/dist/cjs/plugins/extension/index.js +11 -4
  8. package/dist/cjs/plugins/extension/pm-plugins/keymap.js +2 -2
  9. package/dist/cjs/plugins/extension/pm-plugins/main.js +10 -5
  10. package/dist/cjs/plugins/extension/toolbar.js +8 -6
  11. package/dist/cjs/plugins/floating-toolbar/ui/ExtensionsPlaceholder.js +11 -6
  12. package/dist/cjs/plugins/floating-toolbar/ui/Toolbar.js +5 -2
  13. package/dist/cjs/plugins/index.js +0 -7
  14. package/dist/cjs/ui/ContextPanel/index.js +9 -2
  15. package/dist/cjs/utils/action.js +1 -1
  16. package/dist/cjs/version-wrapper.js +1 -1
  17. package/dist/cjs/version.json +1 -1
  18. package/dist/es2019/labs/next/presets/universal.js +7 -6
  19. package/dist/es2019/plugins/extension/actions.js +6 -4
  20. package/dist/es2019/plugins/extension/commands.js +6 -7
  21. package/dist/es2019/plugins/extension/context-panel.js +4 -4
  22. package/dist/es2019/plugins/extension/extension-api.js +1 -1
  23. package/dist/es2019/plugins/extension/index.js +11 -4
  24. package/dist/es2019/plugins/extension/pm-plugins/keymap.js +2 -2
  25. package/dist/es2019/plugins/extension/pm-plugins/main.js +10 -5
  26. package/dist/es2019/plugins/extension/toolbar.js +8 -4
  27. package/dist/es2019/plugins/floating-toolbar/ui/ExtensionsPlaceholder.js +11 -6
  28. package/dist/es2019/plugins/floating-toolbar/ui/Toolbar.js +5 -2
  29. package/dist/es2019/plugins/index.js +0 -1
  30. package/dist/es2019/ui/ContextPanel/index.js +8 -1
  31. package/dist/es2019/utils/action.js +1 -1
  32. package/dist/es2019/version-wrapper.js +1 -1
  33. package/dist/es2019/version.json +1 -1
  34. package/dist/esm/labs/next/presets/universal.js +7 -6
  35. package/dist/esm/plugins/extension/actions.js +6 -4
  36. package/dist/esm/plugins/extension/commands.js +18 -15
  37. package/dist/esm/plugins/extension/context-panel.js +4 -4
  38. package/dist/esm/plugins/extension/extension-api.js +1 -1
  39. package/dist/esm/plugins/extension/index.js +11 -4
  40. package/dist/esm/plugins/extension/pm-plugins/keymap.js +2 -2
  41. package/dist/esm/plugins/extension/pm-plugins/main.js +10 -5
  42. package/dist/esm/plugins/extension/toolbar.js +8 -6
  43. package/dist/esm/plugins/floating-toolbar/ui/ExtensionsPlaceholder.js +11 -6
  44. package/dist/esm/plugins/floating-toolbar/ui/Toolbar.js +5 -2
  45. package/dist/esm/plugins/index.js +0 -1
  46. package/dist/esm/ui/ContextPanel/index.js +8 -1
  47. package/dist/esm/utils/action.js +1 -1
  48. package/dist/esm/version-wrapper.js +1 -1
  49. package/dist/esm/version.json +1 -1
  50. package/dist/types/labs/next/presets/cxhtml.d.ts +18 -2
  51. package/dist/types/labs/next/presets/default.d.ts +36 -4
  52. package/dist/types/labs/next/presets/mobile.d.ts +18 -2
  53. package/dist/types/plugins/extension/actions.d.ts +2 -1
  54. package/dist/types/plugins/extension/commands.d.ts +4 -3
  55. package/dist/types/plugins/extension/context-panel.d.ts +2 -1
  56. package/dist/types/plugins/extension/extension-api.d.ts +2 -0
  57. package/dist/types/plugins/extension/index.d.ts +4 -2
  58. package/dist/types/plugins/extension/pm-plugins/keymap.d.ts +2 -1
  59. package/dist/types/plugins/extension/pm-plugins/main.d.ts +3 -1
  60. package/dist/types/plugins/extension/toolbar.d.ts +8 -1
  61. package/dist/types/plugins/extension/types.d.ts +2 -0
  62. package/dist/types/plugins/floating-toolbar/ui/ExtensionsPlaceholder.d.ts +2 -0
  63. package/dist/types/plugins/floating-toolbar/ui/Toolbar.d.ts +7 -3
  64. package/dist/types/plugins/index.d.ts +0 -1
  65. package/dist/types-ts4.5/labs/next/presets/cxhtml.d.ts +20 -2
  66. package/dist/types-ts4.5/labs/next/presets/default.d.ts +40 -4
  67. package/dist/types-ts4.5/labs/next/presets/mobile.d.ts +20 -2
  68. package/dist/types-ts4.5/plugins/extension/actions.d.ts +2 -1
  69. package/dist/types-ts4.5/plugins/extension/commands.d.ts +4 -3
  70. package/dist/types-ts4.5/plugins/extension/context-panel.d.ts +2 -1
  71. package/dist/types-ts4.5/plugins/extension/extension-api.d.ts +2 -0
  72. package/dist/types-ts4.5/plugins/extension/index.d.ts +4 -2
  73. package/dist/types-ts4.5/plugins/extension/pm-plugins/keymap.d.ts +2 -1
  74. package/dist/types-ts4.5/plugins/extension/pm-plugins/main.d.ts +3 -1
  75. package/dist/types-ts4.5/plugins/extension/toolbar.d.ts +8 -1
  76. package/dist/types-ts4.5/plugins/extension/types.d.ts +2 -0
  77. package/dist/types-ts4.5/plugins/floating-toolbar/ui/ExtensionsPlaceholder.d.ts +2 -0
  78. package/dist/types-ts4.5/plugins/floating-toolbar/ui/Toolbar.d.ts +7 -3
  79. package/dist/types-ts4.5/plugins/index.d.ts +0 -1
  80. package/package.json +2 -1
  81. package/dist/cjs/plugins/context-panel/index.js +0 -66
  82. package/dist/cjs/plugins/context-panel/transforms.js +0 -13
  83. package/dist/cjs/plugins/context-panel/types.js +0 -5
  84. package/dist/es2019/plugins/context-panel/index.js +0 -45
  85. package/dist/es2019/plugins/context-panel/transforms.js +0 -4
  86. package/dist/es2019/plugins/context-panel/types.js +0 -1
  87. package/dist/esm/plugins/context-panel/index.js +0 -57
  88. package/dist/esm/plugins/context-panel/transforms.js +0 -6
  89. package/dist/esm/plugins/context-panel/types.js +0 -1
  90. package/dist/types/plugins/context-panel/index.d.ts +0 -11
  91. package/dist/types/plugins/context-panel/transforms.d.ts +0 -2
  92. package/dist/types/plugins/context-panel/types.d.ts +0 -1
  93. package/dist/types-ts4.5/plugins/context-panel/index.d.ts +0 -11
  94. package/dist/types-ts4.5/plugins/context-panel/transforms.d.ts +0 -2
  95. package/dist/types-ts4.5/plugins/context-panel/types.d.ts +0 -1
@@ -6,6 +6,7 @@ import { MacroProvider } from '@atlaskit/editor-common/provider-factory';
6
6
  export { transformSliceToRemoveOpenBodiedExtension } from '@atlaskit/editor-common/transforms';
7
7
  import { Command, CommandDispatch } from '../../types';
8
8
  import EditorActions from '../../actions';
9
+ import type { ApplyChangeHandler } from '@atlaskit/editor-plugin-context-panel';
9
10
  export declare const buildExtensionNode: <S extends Schema<any, any>>(type: 'inlineExtension' | 'extension' | 'bodiedExtension', schema: S, attrs: object, content?: Fragment, marks?: Mark<S>[] | undefined) => PmNode<Schema<any, any>>;
10
11
  export declare const performNodeUpdate: (type: 'inlineExtension' | 'extension' | 'bodiedExtension', newAttrs: object, content: Fragment<any>, marks: Mark[], shouldScrollIntoView: boolean) => Command;
11
12
  export declare const updateExtensionParams: (updateExtension: UpdateExtension<object>, node: {
@@ -13,4 +14,4 @@ export declare const updateExtensionParams: (updateExtension: UpdateExtension<ob
13
14
  pos: number;
14
15
  }, actions: ExtensionAPI) => (state: EditorState, dispatch?: CommandDispatch, view?: EditorView) => Promise<boolean>;
15
16
  export declare const editSelectedExtension: (editorActions: EditorActions) => boolean;
16
- export declare const editExtension: (macroProvider: MacroProvider | null, updateExtension?: Promise<UpdateExtension<object> | void>) => Command;
17
+ export declare const editExtension: (macroProvider: MacroProvider | null, applyChangeToContextPanel: ApplyChangeHandler | undefined, updateExtension?: Promise<UpdateExtension<object> | void>) => Command;
@@ -2,10 +2,11 @@ import { ExtensionLayout } from '@atlaskit/adf-schema';
2
2
  import { Node as PMNode } from 'prosemirror-model';
3
3
  import { ExtensionState } from './types';
4
4
  import { Parameters, TransformBefore, TransformAfter } from '@atlaskit/editor-common/src/extensions';
5
+ import type { ApplyChangeHandler } from '@atlaskit/editor-plugin-context-panel';
5
6
  export declare function updateState(state: Partial<ExtensionState>): import("@atlaskit/editor-common/types").Command;
6
- export declare function setEditingContextToContextPanel<T extends Parameters = Parameters>(processParametersBefore: TransformBefore<T>, processParametersAfter: TransformAfter<T>): import("@atlaskit/editor-common/types").Command;
7
- export declare const clearEditingContext: import("@atlaskit/editor-common/types").Command;
8
- export declare const forceAutoSave: (resolve: () => void, reject?: ((reason?: any) => void) | undefined) => import("@atlaskit/editor-common/types").Command;
7
+ export declare function setEditingContextToContextPanel<T extends Parameters = Parameters>(processParametersBefore: TransformBefore<T>, processParametersAfter: TransformAfter<T>, applyChangeToContextPanel: ApplyChangeHandler | undefined): import("@atlaskit/editor-common/types").Command;
8
+ export declare const clearEditingContext: (applyChangeToContextPanel: ApplyChangeHandler | undefined) => import("@atlaskit/editor-common/types").Command;
9
+ export declare const forceAutoSave: (applyChangeToContextPanel: ApplyChangeHandler | undefined) => (resolve: () => void, reject?: ((reason?: any) => void) | undefined) => import("@atlaskit/editor-common/types").Command;
9
10
  export declare const updateExtensionLayout: (layout: ExtensionLayout) => import("@atlaskit/editor-common/types").Command;
10
11
  export declare const removeExtension: () => import("@atlaskit/editor-common/types").Command;
11
12
  export declare const removeDescendantNodes: (sourceNode?: PMNode) => import("@atlaskit/editor-common/types").Command;
@@ -3,5 +3,6 @@ import { EditorState } from 'prosemirror-state';
3
3
  import { FeatureFlags } from '@atlaskit/editor-common/types';
4
4
  import type { EditorView } from 'prosemirror-view';
5
5
  import type { ContentNodeWithPos } from 'prosemirror-utils';
6
- export declare const getContextPanel: (allowAutoSave?: boolean, featureFlags?: FeatureFlags) => (state: EditorState) => JSX.Element | undefined;
6
+ import type { ApplyChangeHandler } from '@atlaskit/editor-plugin-context-panel';
7
+ export declare const getContextPanel: (allowAutoSave?: boolean, featureFlags?: FeatureFlags, applyChange?: ApplyChangeHandler) => (state: EditorState) => JSX.Element | undefined;
7
8
  export declare function onChangeAction(editorView: EditorView, updatedParameters: object | undefined, oldParameters: object | undefined, nodeWithPos: ContentNodeWithPos, onSaving?: () => void): Promise<void>;
@@ -1,6 +1,7 @@
1
1
  import { ExtensionAPI } from '@atlaskit/editor-common/extensions';
2
2
  import type { EditorView } from 'prosemirror-view';
3
3
  import { MacroProvider } from '../macro';
4
+ import type { ApplyChangeHandler } from '@atlaskit/editor-plugin-context-panel';
4
5
  interface EditInLegacyMacroBrowserArgs {
5
6
  view: EditorView;
6
7
  macroProvider?: MacroProvider;
@@ -8,6 +9,7 @@ interface EditInLegacyMacroBrowserArgs {
8
9
  export declare const getEditInLegacyMacroBrowser: ({ view, macroProvider, }: EditInLegacyMacroBrowserArgs) => () => void;
9
10
  interface CreateExtensionAPIOptions {
10
11
  editorView: EditorView;
12
+ applyChange: ApplyChangeHandler | undefined;
11
13
  editInLegacyMacroBrowser?: () => void;
12
14
  }
13
15
  export declare const createExtensionAPI: (options: CreateExtensionAPIOptions) => ExtensionAPI;
@@ -1,9 +1,10 @@
1
1
  import { ExtensionHandlers } from '@atlaskit/editor-common/extensions';
2
2
  import type featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
3
- import { NextEditorPlugin, EditorAppearance } from '../../types';
3
+ import { NextEditorPlugin, EditorAppearance, OptionalPlugin } from '@atlaskit/editor-common/types';
4
4
  import { LongPressSelectionPluginOptions } from '../selection/types';
5
5
  import type { widthPlugin } from '@atlaskit/editor-plugin-width';
6
6
  import type { decorationsPlugin } from '@atlaskit/editor-plugin-decorations';
7
+ import type { contextPanelPlugin } from '@atlaskit/editor-plugin-context-panel';
7
8
  interface ExtensionPluginOptions extends LongPressSelectionPluginOptions {
8
9
  allowAutoSave?: boolean;
9
10
  breakoutEnabled?: boolean;
@@ -15,7 +16,8 @@ declare const extensionPlugin: NextEditorPlugin<'extension', {
15
16
  dependencies: [
16
17
  typeof featureFlagsPlugin,
17
18
  typeof widthPlugin,
18
- typeof decorationsPlugin
19
+ typeof decorationsPlugin,
20
+ OptionalPlugin<typeof contextPanelPlugin>
19
21
  ];
20
22
  }>;
21
23
  export default extensionPlugin;
@@ -1,2 +1,3 @@
1
1
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
- export default function keymapPlugin(): SafePlugin;
2
+ import type { ApplyChangeHandler } from '@atlaskit/editor-plugin-context-panel';
3
+ export default function keymapPlugin(applyChange: ApplyChangeHandler | undefined): SafePlugin;
@@ -11,13 +11,15 @@ import { PortalProviderAPI } from '../../../ui/PortalProvider';
11
11
  import { getPluginState, createCommand } from '../plugin-factory';
12
12
  import { pluginKey } from '../plugin-key';
13
13
  import type extensionPlugin from '../index';
14
+ import type { ApplyChangeHandler } from '@atlaskit/editor-plugin-context-panel';
14
15
  export declare const createExtensionProviderHandler: (view: EditorView) => (name: string, provider?: Promise<ExtensionProvider>) => Promise<void>;
15
16
  export declare const createContextIdentifierProviderHandler: (view: EditorView) => (name: string, provider?: Promise<ContextIdentifierProvider>) => Promise<void>;
16
- export declare const handleUpdate: ({ view, prevState, domAtPos, extensionHandlers, }: {
17
+ export declare const handleUpdate: ({ view, prevState, domAtPos, extensionHandlers, applyChange, }: {
17
18
  view: EditorView;
18
19
  prevState: EditorState;
19
20
  domAtPos: EditorView['domAtPos'];
20
21
  extensionHandlers: ExtensionHandlers;
22
+ applyChange: ApplyChangeHandler | undefined;
21
23
  }) => true | undefined;
22
24
  declare const createPlugin: (dispatch: Dispatch, providerFactory: ProviderFactory, extensionHandlers: ExtensionHandlers, portalProviderAPI: PortalProviderAPI, eventDispatcher: EventDispatcher, pluginInjectionApi: ExtractInjectionAPI<typeof extensionPlugin> | undefined, useLongPressSelection?: boolean, options?: {
23
25
  appearance?: EditorAppearance;
@@ -1,5 +1,6 @@
1
1
  import { FloatingToolbarHandler } from '../floating-toolbar/types';
2
2
  import type { HoverDecorationHandler } from '@atlaskit/editor-plugin-decorations';
3
+ import type { ApplyChangeHandler } from '@atlaskit/editor-plugin-context-panel';
3
4
  export declare const messages: {
4
5
  edit: {
5
6
  id: string;
@@ -32,4 +33,10 @@ export declare const messages: {
32
33
  description: string;
33
34
  };
34
35
  };
35
- export declare const getToolbarConfig: (breakoutEnabled: boolean | undefined, hoverDecoration: HoverDecorationHandler | undefined) => FloatingToolbarHandler;
36
+ interface GetToolbarConfigProps {
37
+ breakoutEnabled: boolean | undefined;
38
+ hoverDecoration: HoverDecorationHandler | undefined;
39
+ applyChangeToContextPanel: ApplyChangeHandler | undefined;
40
+ }
41
+ export declare const getToolbarConfig: ({ breakoutEnabled, hoverDecoration, applyChangeToContextPanel, }: GetToolbarConfigProps) => FloatingToolbarHandler;
42
+ export {};
@@ -1,5 +1,6 @@
1
1
  import type { ContextIdentifierProvider } from '@atlaskit/editor-common/provider-factory';
2
2
  import { UpdateExtension, ExtensionProvider, Parameters, TransformBefore, TransformAfter } from '@atlaskit/editor-common/extensions';
3
+ import type { ApplyChangeHandler } from '@atlaskit/editor-plugin-context-panel';
3
4
  export type ExtensionState<T extends Parameters = Parameters> = {
4
5
  localId?: string;
5
6
  autoSaveResolve?: () => void;
@@ -13,6 +14,7 @@ export type ExtensionState<T extends Parameters = Parameters> = {
13
14
  processParametersBefore?: TransformBefore<T>;
14
15
  processParametersAfter?: TransformAfter<T>;
15
16
  positions?: Record<number, number>;
17
+ applyChangeToContextPanel: ApplyChangeHandler | undefined;
16
18
  };
17
19
  export type ExtensionAction<T extends Parameters = Parameters> = {
18
20
  type: 'UPDATE_STATE';
@@ -2,11 +2,13 @@
2
2
  import { Node as PMNode } from 'prosemirror-model';
3
3
  import { EditorView } from 'prosemirror-view';
4
4
  import type { ExtensionProvider } from '@atlaskit/editor-common/extensions';
5
+ import type { ApplyChangeHandler } from '@atlaskit/editor-plugin-context-panel';
5
6
  interface Props {
6
7
  node: PMNode;
7
8
  extensionProvider: ExtensionProvider;
8
9
  editorView: EditorView;
9
10
  separator?: 'start' | 'end' | 'both';
11
+ applyChangeToContextPanel: ApplyChangeHandler | undefined;
10
12
  }
11
13
  export declare const ExtensionsPlaceholder: (props: Props) => JSX.Element | null;
12
14
  export {};
@@ -7,8 +7,9 @@ import { ProviderFactory } from '@atlaskit/editor-common/provider-factory';
7
7
  import type { DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
8
8
  import { FloatingToolbarItem } from '../types';
9
9
  import { WrappedComponentProps } from 'react-intl-next';
10
- import { FeatureFlags, PluginInjectionAPIWithDependency } from '@atlaskit/editor-common/types';
11
- import { decorationsPlugin } from '@atlaskit/editor-plugin-decorations';
10
+ import { FeatureFlags, PluginInjectionAPIWithDependencies, OptionalPlugin } from '@atlaskit/editor-common/types';
11
+ import type { decorationsPlugin } from '@atlaskit/editor-plugin-decorations';
12
+ import type { contextPanelPlugin } from '@atlaskit/editor-plugin-context-panel';
12
13
  export type Item = FloatingToolbarItem<Function>;
13
14
  export interface Props {
14
15
  items: Array<Item>;
@@ -26,7 +27,10 @@ export interface Props {
26
27
  extensionsProvider?: ExtensionProvider;
27
28
  scrollable?: boolean;
28
29
  featureFlags: FeatureFlags;
29
- api: PluginInjectionAPIWithDependency<typeof decorationsPlugin> | undefined;
30
+ api: PluginInjectionAPIWithDependencies<[
31
+ typeof decorationsPlugin,
32
+ OptionalPlugin<typeof contextPanelPlugin>
33
+ ]> | undefined;
30
34
  }
31
35
  export declare const isSameItem: (leftItem: Item, rightItem: Item) => boolean;
32
36
  export declare const areSameItems: (leftArr?: Array<Item>, rightArr?: Array<Item>) => boolean;
@@ -53,7 +53,6 @@ export { default as expandPlugin, isExpandInsertionEnabled } from './expand';
53
53
  export { default as scrollIntoViewPlugin } from './scroll-into-view';
54
54
  export { default as mobileDimensionsPlugin } from './mobile-dimensions';
55
55
  export { default as findReplacePlugin } from './find-replace';
56
- export { default as contextPanelPlugin } from './context-panel';
57
56
  export { default as selectionPlugin } from './selection';
58
57
  export { default as mobileSelectionPlugin } from './mobile-selection';
59
58
  export { default as clipboardPlugin } from './clipboard';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-core",
3
- "version": "185.2.24",
3
+ "version": "185.2.25",
4
4
  "description": "A package contains Atlassian editor core functionality",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -55,6 +55,7 @@
55
55
  "@atlaskit/editor-palette": "1.5.0",
56
56
  "@atlaskit/editor-plugin-analytics": "^0.0.2",
57
57
  "@atlaskit/editor-plugin-content-insertion": "^0.0.2",
58
+ "@atlaskit/editor-plugin-context-panel": "^0.1.0",
58
59
  "@atlaskit/editor-plugin-decorations": "^0.1.0",
59
60
  "@atlaskit/editor-plugin-feature-flags": "^0.1.0",
60
61
  "@atlaskit/editor-plugin-floating-toolbar": "^0.2.0",
@@ -1,66 +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.pluginKey = exports.default = void 0;
8
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
- var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
10
- var _prosemirrorState = require("prosemirror-state");
11
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
12
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
13
- var pluginKey = new _prosemirrorState.PluginKey('contextPanelPluginKey');
14
- exports.pluginKey = pluginKey;
15
- function contextPanelPluginFactory(contextPanels, dispatch) {
16
- return new _safePlugin.SafePlugin({
17
- key: pluginKey,
18
- state: {
19
- init: function init(_config, state) {
20
- return {
21
- handlers: contextPanels,
22
- contents: contextPanels.map(function (panelContent) {
23
- return panelContent(state);
24
- })
25
- };
26
- },
27
- apply: function apply(tr, pluginState, _oldState, newState) {
28
- var newPluginState = pluginState;
29
- var meta = tr.getMeta(pluginKey);
30
- if (tr.docChanged || tr.selectionSet || meta && meta.changed) {
31
- var newContents = pluginState.handlers.map(function (panelContent) {
32
- return panelContent(newState);
33
- });
34
- if (newContents.length !== newPluginState.contents.length || newContents.some(function (node) {
35
- return newPluginState.contents.indexOf(node) < 0;
36
- })) {
37
- newPluginState = _objectSpread(_objectSpread({}, newPluginState), {}, {
38
- contents: newContents
39
- });
40
- }
41
- }
42
- if (newPluginState !== pluginState) {
43
- dispatch(pluginKey, newPluginState);
44
- }
45
- return newPluginState;
46
- }
47
- }
48
- });
49
- }
50
- var contextPanelPlugin = function contextPanelPlugin() {
51
- return {
52
- name: 'contextPanel',
53
- pmPlugins: function pmPlugins() {
54
- var contextPanels = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
55
- return [{
56
- name: 'contextPanel',
57
- plugin: function plugin(_ref) {
58
- var dispatch = _ref.dispatch;
59
- return contextPanelPluginFactory(contextPanels.filter(Boolean), dispatch);
60
- }
61
- }];
62
- }
63
- };
64
- };
65
- var _default = contextPanelPlugin;
66
- exports.default = _default;
@@ -1,13 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.applyChange = void 0;
7
- var _ = require("./");
8
- var applyChange = function applyChange(tr) {
9
- return tr.setMeta(_.pluginKey, {
10
- changed: true
11
- });
12
- };
13
- exports.applyChange = applyChange;
@@ -1,5 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
@@ -1,45 +0,0 @@
1
- import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
- import { PluginKey } from 'prosemirror-state';
3
- export const pluginKey = new PluginKey('contextPanelPluginKey');
4
- function contextPanelPluginFactory(contextPanels, dispatch) {
5
- return new SafePlugin({
6
- key: pluginKey,
7
- state: {
8
- init(_config, state) {
9
- return {
10
- handlers: contextPanels,
11
- contents: contextPanels.map(panelContent => panelContent(state))
12
- };
13
- },
14
- apply(tr, pluginState, _oldState, newState) {
15
- let newPluginState = pluginState;
16
- const meta = tr.getMeta(pluginKey);
17
- if (tr.docChanged || tr.selectionSet || meta && meta.changed) {
18
- const newContents = pluginState.handlers.map(panelContent => panelContent(newState));
19
- if (newContents.length !== newPluginState.contents.length || newContents.some(node => newPluginState.contents.indexOf(node) < 0)) {
20
- newPluginState = {
21
- ...newPluginState,
22
- contents: newContents
23
- };
24
- }
25
- }
26
- if (newPluginState !== pluginState) {
27
- dispatch(pluginKey, newPluginState);
28
- }
29
- return newPluginState;
30
- }
31
- }
32
- });
33
- }
34
- const contextPanelPlugin = () => ({
35
- name: 'contextPanel',
36
- pmPlugins(contextPanels = []) {
37
- return [{
38
- name: 'contextPanel',
39
- plugin: ({
40
- dispatch
41
- }) => contextPanelPluginFactory(contextPanels.filter(Boolean), dispatch)
42
- }];
43
- }
44
- });
45
- export default contextPanelPlugin;
@@ -1,4 +0,0 @@
1
- import { pluginKey } from './';
2
- export const applyChange = tr => tr.setMeta(pluginKey, {
3
- changed: true
4
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,57 +0,0 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
3
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4
- import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
5
- import { PluginKey } from 'prosemirror-state';
6
- export var pluginKey = new PluginKey('contextPanelPluginKey');
7
- function contextPanelPluginFactory(contextPanels, dispatch) {
8
- return new SafePlugin({
9
- key: pluginKey,
10
- state: {
11
- init: function init(_config, state) {
12
- return {
13
- handlers: contextPanels,
14
- contents: contextPanels.map(function (panelContent) {
15
- return panelContent(state);
16
- })
17
- };
18
- },
19
- apply: function apply(tr, pluginState, _oldState, newState) {
20
- var newPluginState = pluginState;
21
- var meta = tr.getMeta(pluginKey);
22
- if (tr.docChanged || tr.selectionSet || meta && meta.changed) {
23
- var newContents = pluginState.handlers.map(function (panelContent) {
24
- return panelContent(newState);
25
- });
26
- if (newContents.length !== newPluginState.contents.length || newContents.some(function (node) {
27
- return newPluginState.contents.indexOf(node) < 0;
28
- })) {
29
- newPluginState = _objectSpread(_objectSpread({}, newPluginState), {}, {
30
- contents: newContents
31
- });
32
- }
33
- }
34
- if (newPluginState !== pluginState) {
35
- dispatch(pluginKey, newPluginState);
36
- }
37
- return newPluginState;
38
- }
39
- }
40
- });
41
- }
42
- var contextPanelPlugin = function contextPanelPlugin() {
43
- return {
44
- name: 'contextPanel',
45
- pmPlugins: function pmPlugins() {
46
- var contextPanels = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
47
- return [{
48
- name: 'contextPanel',
49
- plugin: function plugin(_ref) {
50
- var dispatch = _ref.dispatch;
51
- return contextPanelPluginFactory(contextPanels.filter(Boolean), dispatch);
52
- }
53
- }];
54
- }
55
- };
56
- };
57
- export default contextPanelPlugin;
@@ -1,6 +0,0 @@
1
- import { pluginKey } from './';
2
- export var applyChange = function applyChange(tr) {
3
- return tr.setMeta(pluginKey, {
4
- changed: true
5
- });
6
- };
@@ -1 +0,0 @@
1
- export {};
@@ -1,11 +0,0 @@
1
- import React from 'react';
2
- import { PluginKey } from 'prosemirror-state';
3
- import { NextEditorPlugin } from '@atlaskit/editor-common/types';
4
- import { ContextPanelHandler } from './types';
5
- export declare const pluginKey: PluginKey<ContextPanelPluginState, any>;
6
- type ContextPanelPluginState = {
7
- handlers: ContextPanelHandler[];
8
- contents: React.ReactNode[];
9
- };
10
- declare const contextPanelPlugin: NextEditorPlugin<'contextPanel'>;
11
- export default contextPanelPlugin;
@@ -1,2 +0,0 @@
1
- import { Transaction } from 'prosemirror-state';
2
- export declare const applyChange: (tr: Transaction) => Transaction;
@@ -1 +0,0 @@
1
- export type { ContextPanelHandler } from '@atlaskit/editor-common/types';
@@ -1,11 +0,0 @@
1
- import React from 'react';
2
- import { PluginKey } from 'prosemirror-state';
3
- import { NextEditorPlugin } from '@atlaskit/editor-common/types';
4
- import { ContextPanelHandler } from './types';
5
- export declare const pluginKey: PluginKey<ContextPanelPluginState, any>;
6
- type ContextPanelPluginState = {
7
- handlers: ContextPanelHandler[];
8
- contents: React.ReactNode[];
9
- };
10
- declare const contextPanelPlugin: NextEditorPlugin<'contextPanel'>;
11
- export default contextPanelPlugin;
@@ -1,2 +0,0 @@
1
- import { Transaction } from 'prosemirror-state';
2
- export declare const applyChange: (tr: Transaction) => Transaction;
@@ -1 +0,0 @@
1
- export type { ContextPanelHandler } from '@atlaskit/editor-common/types';