@atlaskit/editor-plugin-synced-block 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/LICENSE.md +11 -0
  3. package/README.md +1 -0
  4. package/SyncedBlock/package.json +15 -0
  5. package/afm-cc/tsconfig.json +44 -0
  6. package/build/tsconfig.json +22 -0
  7. package/dist/cjs/index.js +12 -0
  8. package/dist/cjs/pm-plugins/SyncClient.js +167 -0
  9. package/dist/cjs/pm-plugins/main.js +50 -0
  10. package/dist/cjs/pm-plugins/utils.js +19 -0
  11. package/dist/cjs/syncedBlockPlugin.js +24 -0
  12. package/dist/cjs/syncedBlockPluginType.js +5 -0
  13. package/dist/cjs/types/index.js +1 -0
  14. package/dist/cjs/ui/extensions/synced-block/components/GlobalStyles.js +25 -0
  15. package/dist/cjs/ui/extensions/synced-block/components/SyncedBlockLiveView.js +25 -0
  16. package/dist/cjs/ui/extensions/synced-block/components/SyncedBlockRenderer.js +25 -0
  17. package/dist/cjs/ui/extensions/synced-block/constants.js +32 -0
  18. package/dist/cjs/ui/extensions/synced-block/getSyncedBlockExtensionProvider.js +11 -0
  19. package/dist/cjs/ui/extensions/synced-block/hooks/useLiveSyncedBlockContent.js +29 -0
  20. package/dist/cjs/ui/extensions/synced-block/hooks/usePollContentProperty.js +121 -0
  21. package/dist/cjs/ui/extensions/synced-block/index.js +19 -0
  22. package/dist/cjs/ui/extensions/synced-block/manifest.js +254 -0
  23. package/dist/cjs/ui/extensions/synced-block/utils/ari.js +29 -0
  24. package/dist/cjs/ui/extensions/synced-block/utils/content-property.js +159 -0
  25. package/dist/cjs/ui/extensions/synced-block/utils/synced-block.js +65 -0
  26. package/dist/es2019/index.js +4 -0
  27. package/dist/es2019/pm-plugins/SyncClient.js +102 -0
  28. package/dist/es2019/pm-plugins/main.js +47 -0
  29. package/dist/es2019/pm-plugins/utils.js +13 -0
  30. package/dist/es2019/syncedBlockPlugin.js +17 -0
  31. package/dist/es2019/syncedBlockPluginType.js +1 -0
  32. package/dist/es2019/types/index.js +0 -0
  33. package/dist/es2019/ui/extensions/synced-block/components/GlobalStyles.js +18 -0
  34. package/dist/es2019/ui/extensions/synced-block/components/SyncedBlockLiveView.js +19 -0
  35. package/dist/es2019/ui/extensions/synced-block/components/SyncedBlockRenderer.js +19 -0
  36. package/dist/es2019/ui/extensions/synced-block/constants.js +26 -0
  37. package/dist/es2019/ui/extensions/synced-block/getSyncedBlockExtensionProvider.js +5 -0
  38. package/dist/es2019/ui/extensions/synced-block/hooks/useLiveSyncedBlockContent.js +24 -0
  39. package/dist/es2019/ui/extensions/synced-block/hooks/usePollContentProperty.js +107 -0
  40. package/dist/es2019/ui/extensions/synced-block/index.js +5 -0
  41. package/dist/es2019/ui/extensions/synced-block/manifest.js +147 -0
  42. package/dist/es2019/ui/extensions/synced-block/utils/ari.js +19 -0
  43. package/dist/es2019/ui/extensions/synced-block/utils/content-property.js +108 -0
  44. package/dist/es2019/ui/extensions/synced-block/utils/synced-block.js +57 -0
  45. package/dist/esm/index.js +4 -0
  46. package/dist/esm/pm-plugins/SyncClient.js +160 -0
  47. package/dist/esm/pm-plugins/main.js +44 -0
  48. package/dist/esm/pm-plugins/utils.js +13 -0
  49. package/dist/esm/syncedBlockPlugin.js +17 -0
  50. package/dist/esm/syncedBlockPluginType.js +1 -0
  51. package/dist/esm/types/index.js +0 -0
  52. package/dist/esm/ui/extensions/synced-block/components/GlobalStyles.js +18 -0
  53. package/dist/esm/ui/extensions/synced-block/components/SyncedBlockLiveView.js +18 -0
  54. package/dist/esm/ui/extensions/synced-block/components/SyncedBlockRenderer.js +18 -0
  55. package/dist/esm/ui/extensions/synced-block/constants.js +26 -0
  56. package/dist/esm/ui/extensions/synced-block/getSyncedBlockExtensionProvider.js +5 -0
  57. package/dist/esm/ui/extensions/synced-block/hooks/useLiveSyncedBlockContent.js +23 -0
  58. package/dist/esm/ui/extensions/synced-block/hooks/usePollContentProperty.js +114 -0
  59. package/dist/esm/ui/extensions/synced-block/index.js +5 -0
  60. package/dist/esm/ui/extensions/synced-block/manifest.js +247 -0
  61. package/dist/esm/ui/extensions/synced-block/utils/ari.js +23 -0
  62. package/dist/esm/ui/extensions/synced-block/utils/content-property.js +153 -0
  63. package/dist/esm/ui/extensions/synced-block/utils/synced-block.js +58 -0
  64. package/dist/types/index.d.ts +3 -0
  65. package/dist/types/pm-plugins/SyncClient.d.ts +14 -0
  66. package/dist/types/pm-plugins/main.d.ts +6 -0
  67. package/dist/types/pm-plugins/utils.d.ts +5 -0
  68. package/dist/types/syncedBlockPlugin.d.ts +2 -0
  69. package/dist/types/syncedBlockPluginType.d.ts +2 -0
  70. package/dist/types/types/index.d.ts +3 -0
  71. package/dist/types/ui/extensions/synced-block/components/GlobalStyles.d.ts +6 -0
  72. package/dist/types/ui/extensions/synced-block/components/SyncedBlockLiveView.d.ts +7 -0
  73. package/dist/types/ui/extensions/synced-block/components/SyncedBlockRenderer.d.ts +7 -0
  74. package/dist/types/ui/extensions/synced-block/constants.d.ts +8 -0
  75. package/dist/types/ui/extensions/synced-block/getSyncedBlockExtensionProvider.d.ts +2 -0
  76. package/dist/types/ui/extensions/synced-block/hooks/useLiveSyncedBlockContent.d.ts +6 -0
  77. package/dist/types/ui/extensions/synced-block/hooks/usePollContentProperty.d.ts +7 -0
  78. package/dist/types/ui/extensions/synced-block/index.d.ts +2 -0
  79. package/dist/types/ui/extensions/synced-block/manifest.d.ts +2 -0
  80. package/dist/types/ui/extensions/synced-block/utils/ari.d.ts +4 -0
  81. package/dist/types/ui/extensions/synced-block/utils/content-property.d.ts +33 -0
  82. package/dist/types/ui/extensions/synced-block/utils/synced-block.d.ts +24 -0
  83. package/dist/types-ts4.5/index.d.ts +3 -0
  84. package/dist/types-ts4.5/pm-plugins/SyncClient.d.ts +14 -0
  85. package/dist/types-ts4.5/pm-plugins/main.d.ts +6 -0
  86. package/dist/types-ts4.5/pm-plugins/utils.d.ts +5 -0
  87. package/dist/types-ts4.5/syncedBlockPlugin.d.ts +2 -0
  88. package/dist/types-ts4.5/syncedBlockPluginType.d.ts +2 -0
  89. package/dist/types-ts4.5/types/index.d.ts +3 -0
  90. package/dist/types-ts4.5/ui/extensions/synced-block/components/GlobalStyles.d.ts +6 -0
  91. package/dist/types-ts4.5/ui/extensions/synced-block/components/SyncedBlockLiveView.d.ts +7 -0
  92. package/dist/types-ts4.5/ui/extensions/synced-block/components/SyncedBlockRenderer.d.ts +7 -0
  93. package/dist/types-ts4.5/ui/extensions/synced-block/constants.d.ts +8 -0
  94. package/dist/types-ts4.5/ui/extensions/synced-block/getSyncedBlockExtensionProvider.d.ts +2 -0
  95. package/dist/types-ts4.5/ui/extensions/synced-block/hooks/useLiveSyncedBlockContent.d.ts +6 -0
  96. package/dist/types-ts4.5/ui/extensions/synced-block/hooks/usePollContentProperty.d.ts +7 -0
  97. package/dist/types-ts4.5/ui/extensions/synced-block/index.d.ts +2 -0
  98. package/dist/types-ts4.5/ui/extensions/synced-block/manifest.d.ts +2 -0
  99. package/dist/types-ts4.5/ui/extensions/synced-block/utils/ari.d.ts +4 -0
  100. package/dist/types-ts4.5/ui/extensions/synced-block/utils/content-property.d.ts +33 -0
  101. package/dist/types-ts4.5/ui/extensions/synced-block/utils/synced-block.d.ts +24 -0
  102. package/docs/0-intro.tsx +43 -0
  103. package/package.json +88 -0
  104. package/tsconfig.json +8 -0
@@ -0,0 +1,14 @@
1
+ import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
2
+ export declare class SyncClient {
3
+ private requestMap;
4
+ constructor();
5
+ private getRequestState;
6
+ private setRequestState;
7
+ private sendRequest;
8
+ syncContent({ sourceDocumentAri, contentAri, contentPropertyKey, node, }: {
9
+ contentAri: string;
10
+ contentPropertyKey: string;
11
+ node: PMNode;
12
+ sourceDocumentAri: string;
13
+ }): void;
14
+ }
@@ -0,0 +1,6 @@
1
+ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
+ import { PluginKey } from '@atlaskit/editor-prosemirror/state';
3
+ export declare const syncedBlockPluginKey: PluginKey<any>;
4
+ type SyncedBlockPluginState = {};
5
+ export declare const createPlugin: () => SafePlugin<SyncedBlockPluginState>;
6
+ export {};
@@ -0,0 +1,5 @@
1
+ import type { ResolvedPos } from '@atlaskit/editor-prosemirror/model';
2
+ export declare const findSyncedBlockParent: ($pos: ResolvedPos) => {
3
+ node: import("prosemirror-model").Node;
4
+ attributes: import("../ui/extensions/synced-block/utils/synced-block").SyncedBlockAttributes;
5
+ } | undefined;
@@ -0,0 +1,2 @@
1
+ import type { SyncedBlockPlugin } from './syncedBlockPluginType';
2
+ export declare const syncedBlockPlugin: SyncedBlockPlugin;
@@ -0,0 +1,2 @@
1
+ import type { NextEditorPlugin } from '@atlaskit/editor-common/types';
2
+ export type SyncedBlockPlugin = NextEditorPlugin<'syncedBlock'>;
@@ -0,0 +1,3 @@
1
+ export type SyncedBlockPluginOptions = {
2
+ clouldId?: string;
3
+ };
@@ -0,0 +1,6 @@
1
+ /**
2
+ * @jsxRuntime classic
3
+ * @jsx jsx
4
+ */
5
+ import { jsx } from '@emotion/react';
6
+ export declare const GlobalStylesWrapper: () => jsx.JSX.Element;
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ type SyncedBlockLiveView = {
3
+ contentAri: string;
4
+ sourceDocumentAri: string;
5
+ };
6
+ declare const SyncedBlockLiveView: ({ sourceDocumentAri, contentAri }: SyncedBlockLiveView) => React.JSX.Element;
7
+ export default SyncedBlockLiveView;
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ import type { SyncedBlockContentPropertyValue } from '../utils/synced-block';
3
+ type SyncedBlockRenderer = {
4
+ syncedBlockContent: SyncedBlockContentPropertyValue;
5
+ };
6
+ declare const SyncedBlockRenderer: ({ syncedBlockContent }: SyncedBlockRenderer) => React.JSX.Element;
7
+ export default SyncedBlockRenderer;
@@ -0,0 +1,8 @@
1
+ export declare const getPageId: () => string;
2
+ /**
3
+ * This by no means is a stable way to get the cloud id, but it works for now.
4
+ * We should switch passing the cloud id from Confluence to a Editor plugin,
5
+ * for instance the user preferences plugin would have a seperate place for user and cloud info
6
+ * @returns the cloud id from the initial state
7
+ */
8
+ export declare const getCloudId: () => string;
@@ -0,0 +1,2 @@
1
+ import { DefaultExtensionProvider } from '@atlaskit/editor-common/extensions';
2
+ export declare const getSyncedBlockExtensionProvider: () => DefaultExtensionProvider<import("@atlaskit/editor-common/extensions").Parameters>;
@@ -0,0 +1,6 @@
1
+ type UseLiveSyncedBlockContentOptions = {
2
+ contentAri: string;
3
+ sourceDocumentAri: string;
4
+ };
5
+ export declare const useLiveSyncedBlockContent: ({ sourceDocumentAri, contentAri, }: UseLiveSyncedBlockContentOptions) => import("../utils/synced-block").SyncedBlockContentPropertyValue | null;
6
+ export {};
@@ -0,0 +1,7 @@
1
+ import type { ContentProperty } from '../utils/content-property';
2
+ type UsePollContentPropertyOptions = {
3
+ contentAri: string;
4
+ sourceDocumentAri: string;
5
+ };
6
+ export declare const usePollContentProperty: ({ sourceDocumentAri, contentAri, }: UsePollContentPropertyOptions) => ContentProperty | undefined;
7
+ export {};
@@ -0,0 +1,2 @@
1
+ export { getSyncedBlockExtensionProvider } from './getSyncedBlockExtensionProvider';
2
+ export { getSyncedBlockManifest } from './manifest';
@@ -0,0 +1,2 @@
1
+ import type { ExtensionManifest } from '@atlaskit/editor-common/extensions';
2
+ export declare const getSyncedBlockManifest: () => ExtensionManifest;
@@ -0,0 +1,4 @@
1
+ export declare const getConfluencePageAri: (pageId: string) => string;
2
+ export declare const getPageIdFromAri: (ari: string) => string;
3
+ export declare const getContentPropertyAri: (contentPropertyId: string) => string;
4
+ export declare const getContentPropertyIdFromAri: (ari: string) => string;
@@ -0,0 +1,33 @@
1
+ export type ContentProperty = {
2
+ id: string;
3
+ key: string;
4
+ value: string;
5
+ version: ContentPropertyVersion;
6
+ };
7
+ type ContentPropertyVersion = {
8
+ authorId: string;
9
+ createdAt: string;
10
+ message: string;
11
+ minorEdit: boolean;
12
+ number: number;
13
+ };
14
+ type CreateContentPropertyOptions = {
15
+ key: string;
16
+ pageId: string;
17
+ value: string;
18
+ };
19
+ export declare const createContentProperty: ({ pageId, key, value, }: CreateContentPropertyOptions) => Promise<ContentProperty>;
20
+ type GetContentPropertyOptions = {
21
+ contentPropertyId: string;
22
+ pageId: string;
23
+ signal?: AbortSignal;
24
+ };
25
+ export declare const getContentProperty: ({ pageId, contentPropertyId, signal, }: GetContentPropertyOptions) => Promise<ContentProperty>;
26
+ type UpdateContentPropertyOptions = {
27
+ key: string;
28
+ pageId: string;
29
+ signal?: AbortSignal;
30
+ value: string;
31
+ };
32
+ export declare const updateContentProperty: ({ pageId, key, value, }: UpdateContentPropertyOptions) => Promise<ContentProperty>;
33
+ export {};
@@ -0,0 +1,24 @@
1
+ import type { ADFEntity } from '@atlaskit/adf-utils/types';
2
+ export declare const SYNCED_BLOCK_EXTENSION_TYPE = "com.atlassian.platform.extensions";
3
+ export declare const SYNCED_BLOCK_EXTENSION_KEY = "synced-block";
4
+ export declare const SYNCED_BLOCK_SOURCE_NODE = "source";
5
+ export declare const SYNCED_BLOCK_SOURCE_KEY = "synced-block:source";
6
+ export declare const SYNCED_BLOCK_REFERENCE_NODE = "reference";
7
+ export declare const SYNCED_BLOCK_REFERENCE_KEY = "synced-block:reference";
8
+ export type SyncedBlockAttributes = {
9
+ extensionKey: typeof SYNCED_BLOCK_SOURCE_KEY | typeof SYNCED_BLOCK_REFERENCE_KEY;
10
+ extensionType: typeof SYNCED_BLOCK_EXTENSION_TYPE;
11
+ localId: string;
12
+ parameters: {
13
+ contentAri: string;
14
+ contentPropertyKey: string;
15
+ sourceDocumentAri: string;
16
+ };
17
+ };
18
+ export declare const isSyncedBlockAttributes: (attributes: unknown) => attributes is SyncedBlockAttributes;
19
+ export type SyncedBlockContentPropertyValue = {
20
+ adf: ADFEntity;
21
+ };
22
+ export declare const getDefaultSyncedBlockContent: () => ADFEntity;
23
+ export declare const parseSyncedBlockContentPropertyValue: (value: string | object) => SyncedBlockContentPropertyValue;
24
+ export declare const stringifySyncedBlockContentPropertyValue: (value: SyncedBlockContentPropertyValue) => string;
@@ -0,0 +1,43 @@
1
+ import React from 'react';
2
+
3
+ import { AtlassianInternalWarning, code, md } from '@atlaskit/docs';
4
+ // eslint-disable-next-line @atlassian/tangerine/import/entry-points
5
+ import { createEditorUseOnlyNotice } from '@atlaskit/editor-common/doc-utils';
6
+ import { token } from '@atlaskit/tokens';
7
+
8
+ export default md`
9
+
10
+ ${createEditorUseOnlyNotice('Editor Plugin Synced Block', [
11
+ { name: 'Editor Core', link: '/packages/editor/editor-core' },
12
+ ])}
13
+
14
+
15
+ ${
16
+ (
17
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
18
+ <div style={{ marginTop: token('space.100', '8px') }}>
19
+ <AtlassianInternalWarning />
20
+ </div>
21
+ )
22
+ }
23
+
24
+ This package includes the synced block plugin used by \`@atlaskit/editor-core\`.
25
+
26
+ ## Usage
27
+ ---
28
+
29
+ The \`dependencies\`, \`configuration\`, \`state\`, \`actions\`, and \`commands\` of the plugin are defined
30
+ below:
31
+
32
+ ${code`
33
+ type SyncedBlockPlugin = NextEditorPlugin<'syncedBlock'>
34
+ `}
35
+
36
+
37
+ ## Support
38
+ ---
39
+ For internal Atlassian, visit the slack channel [#help-editor](https://atlassian.slack.com/archives/CFG3PSQ9E) for support or visit [go/editor-help](https://go/editor-help) to submit a bug.
40
+ ## License
41
+ ---
42
+ Please see [Atlassian Frontend - License](https://hello.atlassian.net/wiki/spaces/AF/pages/2589099144/Documentation#License) for more licensing information.
43
+ `;
package/package.json ADDED
@@ -0,0 +1,88 @@
1
+ {
2
+ "name": "@atlaskit/editor-plugin-synced-block",
3
+ "version": "0.1.0",
4
+ "description": "SyncedBlock plugin for @atlaskit/editor-core",
5
+ "author": "Atlassian Pty Ltd",
6
+ "license": "Apache-2.0",
7
+ "publishConfig": {
8
+ "registry": "https://registry.npmjs.org/"
9
+ },
10
+ "atlassian": {
11
+ "team": "Editor: Lego",
12
+ "releaseModel": "continuous",
13
+ "singleton": true
14
+ },
15
+ "repository": "https://bitbucket.org/atlassian/atlassian-frontend-mirror",
16
+ "main": "dist/cjs/index.js",
17
+ "module": "dist/esm/index.js",
18
+ "module:es2019": "dist/es2019/index.js",
19
+ "types": "dist/types/index.d.ts",
20
+ "typesVersions": {
21
+ ">=4.5 <4.9": {
22
+ "*": [
23
+ "dist/types-ts4.5/*",
24
+ "dist/types-ts4.5/index.d.ts"
25
+ ]
26
+ }
27
+ },
28
+ "sideEffects": false,
29
+ "atlaskit:src": "src/index.ts",
30
+ "af:exports": {
31
+ ".": "./src/index.ts",
32
+ "./SyncedBlock": "./src/ui/extensions/synced-block/index.ts"
33
+ },
34
+ "dependencies": {
35
+ "@atlaskit/adf-schema": "^50.2.2",
36
+ "@atlaskit/adf-utils": "^19.21.0",
37
+ "@atlaskit/editor-json-transformer": "^8.27.0",
38
+ "@atlaskit/editor-prosemirror": "7.0.0",
39
+ "@atlaskit/icon": "^28.0.0",
40
+ "@atlaskit/renderer": "^120.5.0",
41
+ "@atlaskit/tokens": "^6.0.0",
42
+ "@babel/runtime": "^7.0.0",
43
+ "@emotion/react": "^11.7.1"
44
+ },
45
+ "peerDependencies": {
46
+ "@atlaskit/editor-common": "^107.31.0",
47
+ "react": "^18.2.0"
48
+ },
49
+ "devDependencies": {
50
+ "typescript": "5.9.2"
51
+ },
52
+ "techstack": {
53
+ "@atlassian/frontend": {
54
+ "code-structure": [
55
+ "editor-plugin"
56
+ ],
57
+ "import-structure": [
58
+ "atlassian-conventions"
59
+ ],
60
+ "circular-dependencies": [
61
+ "file-and-folder-level"
62
+ ]
63
+ },
64
+ "@repo/internal": {
65
+ "dom-events": "use-bind-event-listener",
66
+ "analytics": [
67
+ "analytics-next"
68
+ ],
69
+ "design-tokens": [
70
+ "color"
71
+ ],
72
+ "theming": [
73
+ "react-context"
74
+ ],
75
+ "ui-components": [
76
+ "lite-mode"
77
+ ],
78
+ "deprecation": "no-deprecated-imports",
79
+ "styling": [
80
+ "emotion",
81
+ "emotion"
82
+ ],
83
+ "imports": [
84
+ "import-no-extraneous-disable-for-examples-and-docs"
85
+ ]
86
+ }
87
+ }
88
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,8 @@
1
+ {
2
+ "extends": "../../../tsconfig.json",
3
+ "include": [
4
+ "src/**/*.ts",
5
+ "src/**/*.tsx"
6
+ ],
7
+ "compilerOptions": {}
8
+ }