@atlaskit/editor-plugin-synced-block 2.0.1 → 2.1.1

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 (49) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/afm-cc/tsconfig.json +3 -0
  3. package/afm-dev-agents/tsconfig.json +3 -0
  4. package/afm-jira/tsconfig.json +3 -0
  5. package/afm-passionfruit/tsconfig.json +3 -0
  6. package/afm-post-office/tsconfig.json +3 -0
  7. package/afm-rovo-extension/tsconfig.json +3 -0
  8. package/afm-townsquare/tsconfig.json +3 -0
  9. package/dist/cjs/nodeviews/syncedBlock.js +118 -75
  10. package/dist/cjs/pm-plugins/actions.js +23 -9
  11. package/dist/cjs/pm-plugins/main.js +4 -3
  12. package/dist/cjs/pm-plugins/utils/utils.js +11 -0
  13. package/dist/cjs/syncedBlockPlugin.js +8 -3
  14. package/dist/cjs/ui/SyncBlockEditorWrapper.js +38 -0
  15. package/dist/cjs/ui/SyncBlockRendererWrapper.js +26 -0
  16. package/dist/cjs/ui/floating-toolbar.js +58 -3
  17. package/dist/es2019/nodeviews/syncedBlock.js +103 -67
  18. package/dist/es2019/pm-plugins/actions.js +23 -8
  19. package/dist/es2019/pm-plugins/main.js +4 -3
  20. package/dist/es2019/pm-plugins/utils/utils.js +7 -0
  21. package/dist/es2019/syncedBlockPlugin.js +38 -33
  22. package/dist/es2019/ui/SyncBlockEditorWrapper.js +28 -0
  23. package/dist/es2019/ui/SyncBlockRendererWrapper.js +20 -0
  24. package/dist/es2019/ui/floating-toolbar.js +56 -2
  25. package/dist/esm/nodeviews/syncedBlock.js +116 -72
  26. package/dist/esm/pm-plugins/actions.js +21 -8
  27. package/dist/esm/pm-plugins/main.js +4 -3
  28. package/dist/esm/pm-plugins/utils/utils.js +5 -0
  29. package/dist/esm/syncedBlockPlugin.js +8 -3
  30. package/dist/esm/ui/SyncBlockEditorWrapper.js +31 -0
  31. package/dist/esm/ui/SyncBlockRendererWrapper.js +19 -0
  32. package/dist/esm/ui/floating-toolbar.js +57 -3
  33. package/dist/types/nodeviews/syncedBlock.d.ts +29 -15
  34. package/dist/types/pm-plugins/actions.d.ts +3 -1
  35. package/dist/types/pm-plugins/main.d.ts +4 -3
  36. package/dist/types/pm-plugins/utils/utils.d.ts +3 -0
  37. package/dist/types/syncedBlockPluginType.d.ts +6 -2
  38. package/dist/types/ui/SyncBlockEditorWrapper.d.ts +16 -0
  39. package/dist/types/ui/SyncBlockRendererWrapper.d.ts +9 -0
  40. package/dist/types/ui/floating-toolbar.d.ts +6 -2
  41. package/dist/types-ts4.5/nodeviews/syncedBlock.d.ts +29 -15
  42. package/dist/types-ts4.5/pm-plugins/actions.d.ts +3 -1
  43. package/dist/types-ts4.5/pm-plugins/main.d.ts +4 -3
  44. package/dist/types-ts4.5/pm-plugins/utils/utils.d.ts +3 -0
  45. package/dist/types-ts4.5/syncedBlockPluginType.d.ts +8 -2
  46. package/dist/types-ts4.5/ui/SyncBlockEditorWrapper.d.ts +16 -0
  47. package/dist/types-ts4.5/ui/SyncBlockRendererWrapper.d.ts +9 -0
  48. package/dist/types-ts4.5/ui/floating-toolbar.d.ts +6 -2
  49. package/package.json +6 -4
@@ -1,28 +1,42 @@
1
1
  import React from 'react';
2
- import type { DocNode } from '@atlaskit/adf-schema';
3
- import ReactNodeView from '@atlaskit/editor-common/react-node-view';
4
- import type { PMPluginFactoryParams } from '@atlaskit/editor-common/types';
2
+ import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
3
+ import type { PortalProviderAPI } from '@atlaskit/editor-common/portal';
4
+ import ReactNodeView, { type getPosHandler } from '@atlaskit/editor-common/react-node-view';
5
+ import type { ReactComponentProps } from '@atlaskit/editor-common/react-node-view';
6
+ import type { ExtractInjectionAPI, PMPluginFactoryParams } from '@atlaskit/editor-common/types';
5
7
  import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
6
8
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
7
- import type { SyncedBlockPluginOptions } from '../syncedBlockPluginType';
8
- export type SyncBlockNodeViewProps = {
9
- config: SyncedBlockPluginOptions | undefined;
10
- };
11
- export declare const defaultSyncBlockDocument: DocNode;
12
- export declare const SyncBlockPluginComponent: ({ config, dom, }: {
13
- config: SyncedBlockPluginOptions | undefined;
14
- dom: HTMLElement;
15
- }) => React.JSX.Element | null;
9
+ import type { SyncedBlockPlugin, SyncedBlockPluginOptions } from '../syncedBlockPluginType';
10
+ export interface SyncBlockNodeViewProps extends ReactComponentProps {
11
+ api?: ExtractInjectionAPI<SyncedBlockPlugin>;
12
+ eventDispatcher: EventDispatcher;
13
+ getPos: getPosHandler;
14
+ isNodeNested?: boolean;
15
+ node: PMNode;
16
+ options: SyncedBlockPluginOptions | undefined;
17
+ portalProviderAPI: PortalProviderAPI;
18
+ view: EditorView;
19
+ }
16
20
  declare class SyncBlock extends ReactNodeView<SyncBlockNodeViewProps> {
21
+ private isSource;
22
+ private options;
23
+ constructor(props: SyncBlockNodeViewProps);
17
24
  unsubscribe: (() => void) | undefined;
18
25
  createDomRef(): HTMLElement;
19
- render(): React.JSX.Element;
26
+ private handleContentChanges;
27
+ private setInnerEditorView;
28
+ private renderEditor;
29
+ private renderRenderer;
30
+ render(): React.JSX.Element | null;
20
31
  stopEvent(event: Event): boolean;
32
+ selectNode(): void;
21
33
  destroy(): void;
34
+ private selectSyncBlockNode;
22
35
  }
23
36
  export interface SyncBlockNodeViewProperties {
24
- config: SyncedBlockPluginOptions | undefined;
37
+ api?: ExtractInjectionAPI<SyncedBlockPlugin>;
38
+ options: SyncedBlockPluginOptions | undefined;
25
39
  pmPluginFactoryParams: PMPluginFactoryParams;
26
40
  }
27
- export declare const syncBlockNodeView: ({ config, pmPluginFactoryParams }: SyncBlockNodeViewProperties) => (node: PMNode, view: EditorView, getPos: () => number | undefined) => SyncBlock;
41
+ export declare const syncBlockNodeView: ({ options, pmPluginFactoryParams, api }: SyncBlockNodeViewProperties) => (node: PMNode, view: EditorView, getPos: () => number | undefined) => SyncBlock;
28
42
  export {};
@@ -1,2 +1,4 @@
1
- import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
1
+ import type { Command } from '@atlaskit/editor-common/types';
2
+ import { type EditorState, type Transaction } from '@atlaskit/editor-prosemirror/state';
2
3
  export declare const createSyncedBlock: (state: EditorState) => Transaction;
4
+ export declare const copySyncedBlockReferenceToClipboard: Command;
@@ -1,8 +1,9 @@
1
1
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
- import type { PMPluginFactoryParams } from '@atlaskit/editor-common/types';
2
+ import type { SyncBlockStoreManager } from '@atlaskit/editor-common/sync-block';
3
+ import type { ExtractInjectionAPI, PMPluginFactoryParams } from '@atlaskit/editor-common/types';
3
4
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
4
- import type { SyncedBlockPluginOptions } from '../syncedBlockPluginType';
5
+ import type { SyncedBlockPlugin, SyncedBlockPluginOptions } from '../syncedBlockPluginType';
5
6
  export declare const syncedBlockPluginKey: PluginKey<any>;
6
7
  type SyncedBlockPluginState = {};
7
- export declare const createPlugin: (config: SyncedBlockPluginOptions | undefined, pmPluginFactoryParams: PMPluginFactoryParams) => SafePlugin<SyncedBlockPluginState>;
8
+ export declare const createPlugin: (options: SyncedBlockPluginOptions | undefined, pmPluginFactoryParams: PMPluginFactoryParams, _syncBlockStore: SyncBlockStoreManager, api?: ExtractInjectionAPI<SyncedBlockPlugin>) => SafePlugin<SyncedBlockPluginState>;
8
9
  export {};
@@ -0,0 +1,3 @@
1
+ import type { EditorState, Selection } from '@atlaskit/editor-prosemirror/state';
2
+ import { findParentNodeOfType, findSelectedNodeOfType } from '@atlaskit/editor-prosemirror/utils';
3
+ export declare const findSyncBlock: (state: EditorState, selection?: Selection | null) => ReturnType<ReturnType<typeof findSelectedNodeOfType>> | ReturnType<ReturnType<typeof findParentNodeOfType>>;
@@ -1,12 +1,12 @@
1
1
  import type { DocNode } from '@atlaskit/adf-schema';
2
2
  import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
3
+ import type { SyncBlockDataProvider } from '@atlaskit/editor-common/sync-block';
3
4
  import type { NextEditorPlugin } from '@atlaskit/editor-common/types';
4
5
  import type { JSONDocNode } from '@atlaskit/editor-json-transformer';
6
+ import type { SelectionPlugin } from '@atlaskit/editor-plugin-selection';
5
7
  import type { EditorView } from '@atlaskit/editor-prosemirror/dist/types/view';
6
8
  export type SyncedBlockEditorProps = {
7
- boundariesElement: HTMLElement;
8
9
  defaultDocument: JSONDocNode;
9
- mountPoint: HTMLElement;
10
10
  onChange: (editorView: EditorView, meta: {
11
11
  /**
12
12
  * Indicates whether or not the change may be unnecessary to listen to (dirty
@@ -24,14 +24,20 @@ export type SyncedBlockEditorProps = {
24
24
  editorView: EditorView;
25
25
  eventDispatcher: EventDispatcher;
26
26
  }) => void;
27
+ popupsBoundariesElement: HTMLElement;
28
+ popupsMountPoint: HTMLElement;
27
29
  };
28
30
  export type SyncedBlockRendererProps = {
29
31
  docNode: DocNode;
30
32
  };
31
33
  export type SyncedBlockPluginOptions = {
34
+ dataProvider?: SyncBlockDataProvider;
32
35
  getSyncedBlockEditor?: (props: SyncedBlockEditorProps) => React.JSX.Element;
33
36
  getSyncedBlockRenderer?: (props: SyncedBlockRendererProps) => React.JSX.Element;
34
37
  };
35
38
  export type SyncedBlockPlugin = NextEditorPlugin<'syncedBlock', {
39
+ dependencies: [
40
+ SelectionPlugin
41
+ ];
36
42
  pluginConfiguration: SyncedBlockPluginOptions | undefined;
37
43
  }>;
@@ -0,0 +1,16 @@
1
+ import React from 'react';
2
+ import type { JSONDocNode } from '@atlaskit/editor-json-transformer';
3
+ import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
4
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
5
+ import type { SyncedBlockEditorProps } from '../syncedBlockPluginType';
6
+ type Props = {
7
+ defaultDocument: JSONDocNode;
8
+ getSyncedBlockEditor: (props: SyncedBlockEditorProps) => React.JSX.Element;
9
+ handleContentChanges: (updatedDoc: PMNode) => void;
10
+ popupsBoundariesElement: HTMLElement;
11
+ popupsMountPoint: HTMLElement;
12
+ setInnerEditorView: (editorView: EditorView) => void;
13
+ };
14
+ export declare const SyncBlockEditorWrapperDataId = "sync-block-plugin-editor-wrapper";
15
+ export declare const SyncBlockEditorWrapper: React.MemoExoticComponent<({ defaultDocument, getSyncedBlockEditor, popupsBoundariesElement, popupsMountPoint, setInnerEditorView, handleContentChanges, }: Props) => React.JSX.Element>;
16
+ export {};
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ import type { DocNode } from '@atlaskit/adf-schema';
3
+ import type { SyncedBlockRendererProps } from '../syncedBlockPluginType';
4
+ type Props = {
5
+ docNode: DocNode;
6
+ getSyncedBlockRenderer: (props: SyncedBlockRendererProps) => React.JSX.Element;
7
+ };
8
+ export declare const SyncBlockRendererWrapper: React.MemoExoticComponent<({ getSyncedBlockRenderer, docNode }: Props) => React.JSX.Element>;
9
+ export {};
@@ -1,2 +1,6 @@
1
- import type { FloatingToolbarHandler } from '@atlaskit/editor-common/types';
2
- export declare const getToolbarConfig: () => FloatingToolbarHandler;
1
+ import type { IntlShape } from 'react-intl-next';
2
+ import type { ProviderFactory } from '@atlaskit/editor-common/provider-factory';
3
+ import type { FloatingToolbarConfig } from '@atlaskit/editor-common/types';
4
+ import type { EditorState } from '@atlaskit/editor-prosemirror/dist/types/state';
5
+ import type { SyncedBlockPluginOptions } from '../syncedBlockPluginType';
6
+ export declare const getToolbarConfig: (state: EditorState, _intl: IntlShape, _options: SyncedBlockPluginOptions | undefined, _providerFactory: ProviderFactory) => FloatingToolbarConfig | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-synced-block",
3
- "version": "2.0.1",
3
+ "version": "2.1.1",
4
4
  "description": "SyncedBlock plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -29,13 +29,15 @@
29
29
  "atlaskit:src": "src/index.ts",
30
30
  "dependencies": {
31
31
  "@atlaskit/adf-schema": "^51.1.2",
32
+ "@atlaskit/editor-plugin-selection": "^5.0.0",
32
33
  "@atlaskit/editor-prosemirror": "7.0.0",
33
- "@atlaskit/icon": "28.2.0",
34
+ "@atlaskit/icon": "28.2.1",
34
35
  "@babel/runtime": "^7.0.0",
35
- "react-intl-next": "npm:react-intl@^5.18.1"
36
+ "react-intl-next": "npm:react-intl@^5.18.1",
37
+ "uuid": "^3.1.0"
36
38
  },
37
39
  "peerDependencies": {
38
- "@atlaskit/editor-common": "^109.7.0",
40
+ "@atlaskit/editor-common": "^109.10.0",
39
41
  "react": "^18.2.0"
40
42
  },
41
43
  "devDependencies": {