@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.
- package/CHANGELOG.md +12 -0
- package/LICENSE.md +11 -0
- package/README.md +1 -0
- package/SyncedBlock/package.json +15 -0
- package/afm-cc/tsconfig.json +44 -0
- package/build/tsconfig.json +22 -0
- package/dist/cjs/index.js +12 -0
- package/dist/cjs/pm-plugins/SyncClient.js +167 -0
- package/dist/cjs/pm-plugins/main.js +50 -0
- package/dist/cjs/pm-plugins/utils.js +19 -0
- package/dist/cjs/syncedBlockPlugin.js +24 -0
- package/dist/cjs/syncedBlockPluginType.js +5 -0
- package/dist/cjs/types/index.js +1 -0
- package/dist/cjs/ui/extensions/synced-block/components/GlobalStyles.js +25 -0
- package/dist/cjs/ui/extensions/synced-block/components/SyncedBlockLiveView.js +25 -0
- package/dist/cjs/ui/extensions/synced-block/components/SyncedBlockRenderer.js +25 -0
- package/dist/cjs/ui/extensions/synced-block/constants.js +32 -0
- package/dist/cjs/ui/extensions/synced-block/getSyncedBlockExtensionProvider.js +11 -0
- package/dist/cjs/ui/extensions/synced-block/hooks/useLiveSyncedBlockContent.js +29 -0
- package/dist/cjs/ui/extensions/synced-block/hooks/usePollContentProperty.js +121 -0
- package/dist/cjs/ui/extensions/synced-block/index.js +19 -0
- package/dist/cjs/ui/extensions/synced-block/manifest.js +254 -0
- package/dist/cjs/ui/extensions/synced-block/utils/ari.js +29 -0
- package/dist/cjs/ui/extensions/synced-block/utils/content-property.js +159 -0
- package/dist/cjs/ui/extensions/synced-block/utils/synced-block.js +65 -0
- package/dist/es2019/index.js +4 -0
- package/dist/es2019/pm-plugins/SyncClient.js +102 -0
- package/dist/es2019/pm-plugins/main.js +47 -0
- package/dist/es2019/pm-plugins/utils.js +13 -0
- package/dist/es2019/syncedBlockPlugin.js +17 -0
- package/dist/es2019/syncedBlockPluginType.js +1 -0
- package/dist/es2019/types/index.js +0 -0
- package/dist/es2019/ui/extensions/synced-block/components/GlobalStyles.js +18 -0
- package/dist/es2019/ui/extensions/synced-block/components/SyncedBlockLiveView.js +19 -0
- package/dist/es2019/ui/extensions/synced-block/components/SyncedBlockRenderer.js +19 -0
- package/dist/es2019/ui/extensions/synced-block/constants.js +26 -0
- package/dist/es2019/ui/extensions/synced-block/getSyncedBlockExtensionProvider.js +5 -0
- package/dist/es2019/ui/extensions/synced-block/hooks/useLiveSyncedBlockContent.js +24 -0
- package/dist/es2019/ui/extensions/synced-block/hooks/usePollContentProperty.js +107 -0
- package/dist/es2019/ui/extensions/synced-block/index.js +5 -0
- package/dist/es2019/ui/extensions/synced-block/manifest.js +147 -0
- package/dist/es2019/ui/extensions/synced-block/utils/ari.js +19 -0
- package/dist/es2019/ui/extensions/synced-block/utils/content-property.js +108 -0
- package/dist/es2019/ui/extensions/synced-block/utils/synced-block.js +57 -0
- package/dist/esm/index.js +4 -0
- package/dist/esm/pm-plugins/SyncClient.js +160 -0
- package/dist/esm/pm-plugins/main.js +44 -0
- package/dist/esm/pm-plugins/utils.js +13 -0
- package/dist/esm/syncedBlockPlugin.js +17 -0
- package/dist/esm/syncedBlockPluginType.js +1 -0
- package/dist/esm/types/index.js +0 -0
- package/dist/esm/ui/extensions/synced-block/components/GlobalStyles.js +18 -0
- package/dist/esm/ui/extensions/synced-block/components/SyncedBlockLiveView.js +18 -0
- package/dist/esm/ui/extensions/synced-block/components/SyncedBlockRenderer.js +18 -0
- package/dist/esm/ui/extensions/synced-block/constants.js +26 -0
- package/dist/esm/ui/extensions/synced-block/getSyncedBlockExtensionProvider.js +5 -0
- package/dist/esm/ui/extensions/synced-block/hooks/useLiveSyncedBlockContent.js +23 -0
- package/dist/esm/ui/extensions/synced-block/hooks/usePollContentProperty.js +114 -0
- package/dist/esm/ui/extensions/synced-block/index.js +5 -0
- package/dist/esm/ui/extensions/synced-block/manifest.js +247 -0
- package/dist/esm/ui/extensions/synced-block/utils/ari.js +23 -0
- package/dist/esm/ui/extensions/synced-block/utils/content-property.js +153 -0
- package/dist/esm/ui/extensions/synced-block/utils/synced-block.js +58 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/pm-plugins/SyncClient.d.ts +14 -0
- package/dist/types/pm-plugins/main.d.ts +6 -0
- package/dist/types/pm-plugins/utils.d.ts +5 -0
- package/dist/types/syncedBlockPlugin.d.ts +2 -0
- package/dist/types/syncedBlockPluginType.d.ts +2 -0
- package/dist/types/types/index.d.ts +3 -0
- package/dist/types/ui/extensions/synced-block/components/GlobalStyles.d.ts +6 -0
- package/dist/types/ui/extensions/synced-block/components/SyncedBlockLiveView.d.ts +7 -0
- package/dist/types/ui/extensions/synced-block/components/SyncedBlockRenderer.d.ts +7 -0
- package/dist/types/ui/extensions/synced-block/constants.d.ts +8 -0
- package/dist/types/ui/extensions/synced-block/getSyncedBlockExtensionProvider.d.ts +2 -0
- package/dist/types/ui/extensions/synced-block/hooks/useLiveSyncedBlockContent.d.ts +6 -0
- package/dist/types/ui/extensions/synced-block/hooks/usePollContentProperty.d.ts +7 -0
- package/dist/types/ui/extensions/synced-block/index.d.ts +2 -0
- package/dist/types/ui/extensions/synced-block/manifest.d.ts +2 -0
- package/dist/types/ui/extensions/synced-block/utils/ari.d.ts +4 -0
- package/dist/types/ui/extensions/synced-block/utils/content-property.d.ts +33 -0
- package/dist/types/ui/extensions/synced-block/utils/synced-block.d.ts +24 -0
- package/dist/types-ts4.5/index.d.ts +3 -0
- package/dist/types-ts4.5/pm-plugins/SyncClient.d.ts +14 -0
- package/dist/types-ts4.5/pm-plugins/main.d.ts +6 -0
- package/dist/types-ts4.5/pm-plugins/utils.d.ts +5 -0
- package/dist/types-ts4.5/syncedBlockPlugin.d.ts +2 -0
- package/dist/types-ts4.5/syncedBlockPluginType.d.ts +2 -0
- package/dist/types-ts4.5/types/index.d.ts +3 -0
- package/dist/types-ts4.5/ui/extensions/synced-block/components/GlobalStyles.d.ts +6 -0
- package/dist/types-ts4.5/ui/extensions/synced-block/components/SyncedBlockLiveView.d.ts +7 -0
- package/dist/types-ts4.5/ui/extensions/synced-block/components/SyncedBlockRenderer.d.ts +7 -0
- package/dist/types-ts4.5/ui/extensions/synced-block/constants.d.ts +8 -0
- package/dist/types-ts4.5/ui/extensions/synced-block/getSyncedBlockExtensionProvider.d.ts +2 -0
- package/dist/types-ts4.5/ui/extensions/synced-block/hooks/useLiveSyncedBlockContent.d.ts +6 -0
- package/dist/types-ts4.5/ui/extensions/synced-block/hooks/usePollContentProperty.d.ts +7 -0
- package/dist/types-ts4.5/ui/extensions/synced-block/index.d.ts +2 -0
- package/dist/types-ts4.5/ui/extensions/synced-block/manifest.d.ts +2 -0
- package/dist/types-ts4.5/ui/extensions/synced-block/utils/ari.d.ts +4 -0
- package/dist/types-ts4.5/ui/extensions/synced-block/utils/content-property.d.ts +33 -0
- package/dist/types-ts4.5/ui/extensions/synced-block/utils/synced-block.d.ts +24 -0
- package/docs/0-intro.tsx +43 -0
- package/package.json +88 -0
- 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,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,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,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;
|
package/docs/0-intro.tsx
ADDED
|
@@ -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
|
+
}
|