@atlaskit/editor-plugin-synced-block 5.3.7 → 5.3.9

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.
@@ -1,5 +1,5 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
- import React, { useCallback, useState } from 'react';
2
+ import React, { useCallback, useMemo, useState } from 'react';
3
3
  import { useIntl } from 'react-intl-next';
4
4
  import { syncBlockMessages as messages } from '@atlaskit/editor-common/messages';
5
5
  import { SyncBlockLabelSharedCssClassName } from '@atlaskit/editor-common/sync-block';
@@ -14,7 +14,8 @@ var SyncBlockLabelComponent = function SyncBlockLabelComponent(_ref) {
14
14
  var contentUpdatedAt = _ref.contentUpdatedAt,
15
15
  isSource = _ref.isSource,
16
16
  localId = _ref.localId,
17
- title = _ref.title;
17
+ title = _ref.title,
18
+ isUnsyncedBlock = _ref.isUnsyncedBlock;
18
19
  var intl = useIntl();
19
20
  var formatMessage = intl.formatMessage;
20
21
  var _useState = useState(formatMessage(messages.defaultSyncBlockTooltip)),
@@ -51,6 +52,25 @@ var SyncBlockLabelComponent = function SyncBlockLabelComponent(_ref) {
51
52
  setTooltipContent(tooltipContent);
52
53
  }, [contentUpdatedAt, formatMessage, intl, tooltipMessage]);
53
54
  var ariaDescribedById = "sync-block-label-description-".concat(localId);
55
+ var getLabelContent = useMemo(function () {
56
+ if (isUnsyncedBlock && fg('platform_synced_block_dogfooding')) {
57
+ return /*#__PURE__*/React.createElement(Text, {
58
+ size: "small",
59
+ color: "color.text.subtle"
60
+ }, formatMessage(messages.unsyncedBlockLabel));
61
+ }
62
+ if (isSource || !title) {
63
+ return /*#__PURE__*/React.createElement(Text, {
64
+ size: "small",
65
+ color: "color.text.subtle"
66
+ }, formatMessage(messages.syncedBlockLabel));
67
+ }
68
+ return /*#__PURE__*/React.createElement(Text, {
69
+ maxLines: 1,
70
+ size: "small",
71
+ color: "color.text.subtle"
72
+ }, title);
73
+ }, [formatMessage, isSource, isUnsyncedBlock, title]);
54
74
  var label = /*#__PURE__*/React.createElement("div", {
55
75
  "data-testid": SyncBlockLabelDataId
56
76
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop
@@ -61,15 +81,8 @@ var SyncBlockLabelComponent = function SyncBlockLabelComponent(_ref) {
61
81
  color: "var(--ds-icon-subtle, #505258)",
62
82
  size: "small",
63
83
  label: ""
64
- }), isSource || !title ? /*#__PURE__*/React.createElement(Text, {
65
- size: "small",
66
- color: "color.text.subtle"
67
- }, formatMessage(messages.syncedBlockLabel)) : /*#__PURE__*/React.createElement(Text, {
68
- maxLines: 1,
69
- size: "small",
70
- color: "color.text.subtle"
71
- }, title));
72
- if (isSource && fg('platform_synced_block_dogfooding')) {
84
+ }), getLabelContent);
85
+ if ((isSource || isUnsyncedBlock) && fg('platform_synced_block_dogfooding')) {
73
86
  return label;
74
87
  }
75
88
  return /*#__PURE__*/React.createElement(Tooltip, {
@@ -1,9 +1,10 @@
1
1
  import React from 'react';
2
2
  import { SyncBlockSharedCssClassName } from '@atlaskit/editor-common/sync-block';
3
+ import { SyncBlockError } from '@atlaskit/editor-synced-block-provider';
3
4
  import { SyncBlockLabel } from './SyncBlockLabel';
4
5
  var SyncBlockRendererWrapperDataId = 'sync-block-plugin-renderer-wrapper';
5
6
  var SyncBlockRendererWrapperComponent = function SyncBlockRendererWrapperComponent(_ref) {
6
- var _syncBlockFetchResult;
7
+ var _syncBlockFetchResult, _syncBlockFetchResult2, _syncBlockFetchResult3;
7
8
  var syncedBlockRenderer = _ref.syncedBlockRenderer,
8
9
  useFetchSyncBlockData = _ref.useFetchSyncBlockData,
9
10
  useFetchSyncBlockTitle = _ref.useFetchSyncBlockTitle,
@@ -12,6 +13,8 @@ var SyncBlockRendererWrapperComponent = function SyncBlockRendererWrapperCompone
12
13
  var syncBlockFetchResult = useFetchSyncBlockData();
13
14
  var title = useFetchSyncBlockTitle === null || useFetchSyncBlockTitle === void 0 ? void 0 : useFetchSyncBlockTitle();
14
15
  var contentUpdatedAt = syncBlockFetchResult === null || syncBlockFetchResult === void 0 || (_syncBlockFetchResult = syncBlockFetchResult.syncBlockInstance) === null || _syncBlockFetchResult === void 0 || (_syncBlockFetchResult = _syncBlockFetchResult.data) === null || _syncBlockFetchResult === void 0 ? void 0 : _syncBlockFetchResult.contentUpdatedAt;
16
+ var isUnpublishedBlock = ((_syncBlockFetchResult2 = syncBlockFetchResult.syncBlockInstance) === null || _syncBlockFetchResult2 === void 0 || (_syncBlockFetchResult2 = _syncBlockFetchResult2.data) === null || _syncBlockFetchResult2 === void 0 ? void 0 : _syncBlockFetchResult2.status) === 'unpublished';
17
+ var isUnsyncedBlock = isUnpublishedBlock || (syncBlockFetchResult === null || syncBlockFetchResult === void 0 || (_syncBlockFetchResult3 = syncBlockFetchResult.syncBlockInstance) === null || _syncBlockFetchResult3 === void 0 || (_syncBlockFetchResult3 = _syncBlockFetchResult3.error) === null || _syncBlockFetchResult3 === void 0 ? void 0 : _syncBlockFetchResult3.type) === SyncBlockError.NotFound;
15
18
  return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
16
19
  "data-testid": SyncBlockRendererWrapperDataId
17
20
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop
@@ -24,7 +27,8 @@ var SyncBlockRendererWrapperComponent = function SyncBlockRendererWrapperCompone
24
27
  isSource: false,
25
28
  title: title,
26
29
  contentUpdatedAt: contentUpdatedAt,
27
- localId: localId
30
+ localId: localId,
31
+ isUnsyncedBlock: isUnsyncedBlock
28
32
  }));
29
33
  };
30
34
  export var SyncBlockRendererWrapper = /*#__PURE__*/React.memo(SyncBlockRendererWrapperComponent);
@@ -15,6 +15,7 @@ export declare const copySyncedBlockReferenceToClipboardEditorCommand: (syncBloc
15
15
  export declare const copySyncedBlockReferenceToClipboard: (syncBlockStore: SyncBlockStoreManager, api?: ExtractInjectionAPI<SyncedBlockPlugin>) => Command;
16
16
  export declare const editSyncedBlockSource: (syncBlockStore: SyncBlockStoreManager, api?: ExtractInjectionAPI<SyncedBlockPlugin>) => Command;
17
17
  export declare const removeSyncedBlock: (api?: ExtractInjectionAPI<SyncedBlockPlugin>) => Command;
18
+ export declare const removeSyncedBlockAtPos: (api: ExtractInjectionAPI<SyncedBlockPlugin> | undefined, pos: number) => void;
18
19
  /**
19
20
  * Deletes (bodied)SyncBlock node and paste its content to the editor
20
21
  */
@@ -3,7 +3,7 @@ import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
3
3
  import type { PortalProviderAPI } from '@atlaskit/editor-common/portal';
4
4
  import ReactNodeView, { type getPosHandler } from '@atlaskit/editor-common/react-node-view';
5
5
  import type { ReactComponentProps } from '@atlaskit/editor-common/react-node-view';
6
- import type { ExtractInjectionAPI, PMPluginFactoryParams } from '@atlaskit/editor-common/types';
6
+ import type { ExtractInjectionAPI, getPosHandlerNode, PMPluginFactoryParams } from '@atlaskit/editor-common/types';
7
7
  import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
8
8
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
9
9
  import { type SyncBlockStoreManager } from '@atlaskit/editor-synced-block-provider';
@@ -11,7 +11,7 @@ import type { SyncedBlockPlugin, SyncedBlockPluginOptions } from '../syncedBlock
11
11
  export interface SyncBlockNodeViewProps extends ReactComponentProps {
12
12
  api?: ExtractInjectionAPI<SyncedBlockPlugin>;
13
13
  eventDispatcher: EventDispatcher;
14
- getPos: getPosHandler;
14
+ getPos: getPosHandlerNode;
15
15
  isNodeNested?: boolean;
16
16
  node: PMNode;
17
17
  options: SyncedBlockPluginOptions | undefined;
@@ -26,7 +26,7 @@ export declare class SyncBlock extends ReactNodeView<SyncBlockNodeViewProps> {
26
26
  constructor(props: SyncBlockNodeViewProps);
27
27
  unsubscribe: (() => void) | undefined;
28
28
  createDomRef(): HTMLElement;
29
- render(): React.JSX.Element | null;
29
+ render({ getPos }: SyncBlockNodeViewProps): React.JSX.Element | null;
30
30
  destroy(): void;
31
31
  }
32
32
  export interface SyncBlockNodeViewProperties {
@@ -20,4 +20,6 @@ export interface SyncBlockConversionInfo {
20
20
  * or false if conversion is not possible
21
21
  */
22
22
  export declare const canBeConvertedToSyncBlock: (selection: Selection) => SyncBlockConversionInfo | false;
23
+ export declare const canBeConvertedToSyncBlockOld: (selection: Selection) => SyncBlockConversionInfo | false;
24
+ export declare const canBeConvertedToSyncBlockNew: (selection: Selection) => SyncBlockConversionInfo | false;
23
25
  export declare const sliceFullyContainsNode: (slice: Slice, node: PMNode) => boolean;
@@ -2,8 +2,9 @@ import React from 'react';
2
2
  type SyncBlockLabelProps = {
3
3
  contentUpdatedAt?: string;
4
4
  isSource: boolean;
5
+ isUnsyncedBlock?: boolean;
5
6
  localId: string;
6
7
  title?: string;
7
8
  };
8
- export declare const SyncBlockLabel: React.MemoExoticComponent<({ contentUpdatedAt, isSource, localId, title, }: SyncBlockLabelProps) => React.JSX.Element>;
9
+ export declare const SyncBlockLabel: React.MemoExoticComponent<({ contentUpdatedAt, isSource, localId, title, isUnsyncedBlock, }: SyncBlockLabelProps) => React.JSX.Element>;
9
10
  export {};
@@ -15,6 +15,7 @@ export declare const copySyncedBlockReferenceToClipboardEditorCommand: (syncBloc
15
15
  export declare const copySyncedBlockReferenceToClipboard: (syncBlockStore: SyncBlockStoreManager, api?: ExtractInjectionAPI<SyncedBlockPlugin>) => Command;
16
16
  export declare const editSyncedBlockSource: (syncBlockStore: SyncBlockStoreManager, api?: ExtractInjectionAPI<SyncedBlockPlugin>) => Command;
17
17
  export declare const removeSyncedBlock: (api?: ExtractInjectionAPI<SyncedBlockPlugin>) => Command;
18
+ export declare const removeSyncedBlockAtPos: (api: ExtractInjectionAPI<SyncedBlockPlugin> | undefined, pos: number) => void;
18
19
  /**
19
20
  * Deletes (bodied)SyncBlock node and paste its content to the editor
20
21
  */
@@ -3,7 +3,7 @@ import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
3
3
  import type { PortalProviderAPI } from '@atlaskit/editor-common/portal';
4
4
  import ReactNodeView, { type getPosHandler } from '@atlaskit/editor-common/react-node-view';
5
5
  import type { ReactComponentProps } from '@atlaskit/editor-common/react-node-view';
6
- import type { ExtractInjectionAPI, PMPluginFactoryParams } from '@atlaskit/editor-common/types';
6
+ import type { ExtractInjectionAPI, getPosHandlerNode, PMPluginFactoryParams } from '@atlaskit/editor-common/types';
7
7
  import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
8
8
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
9
9
  import { type SyncBlockStoreManager } from '@atlaskit/editor-synced-block-provider';
@@ -11,7 +11,7 @@ import type { SyncedBlockPlugin, SyncedBlockPluginOptions } from '../syncedBlock
11
11
  export interface SyncBlockNodeViewProps extends ReactComponentProps {
12
12
  api?: ExtractInjectionAPI<SyncedBlockPlugin>;
13
13
  eventDispatcher: EventDispatcher;
14
- getPos: getPosHandler;
14
+ getPos: getPosHandlerNode;
15
15
  isNodeNested?: boolean;
16
16
  node: PMNode;
17
17
  options: SyncedBlockPluginOptions | undefined;
@@ -26,7 +26,7 @@ export declare class SyncBlock extends ReactNodeView<SyncBlockNodeViewProps> {
26
26
  constructor(props: SyncBlockNodeViewProps);
27
27
  unsubscribe: (() => void) | undefined;
28
28
  createDomRef(): HTMLElement;
29
- render(): React.JSX.Element | null;
29
+ render({ getPos }: SyncBlockNodeViewProps): React.JSX.Element | null;
30
30
  destroy(): void;
31
31
  }
32
32
  export interface SyncBlockNodeViewProperties {
@@ -20,4 +20,6 @@ export interface SyncBlockConversionInfo {
20
20
  * or false if conversion is not possible
21
21
  */
22
22
  export declare const canBeConvertedToSyncBlock: (selection: Selection) => SyncBlockConversionInfo | false;
23
+ export declare const canBeConvertedToSyncBlockOld: (selection: Selection) => SyncBlockConversionInfo | false;
24
+ export declare const canBeConvertedToSyncBlockNew: (selection: Selection) => SyncBlockConversionInfo | false;
23
25
  export declare const sliceFullyContainsNode: (slice: Slice, node: PMNode) => boolean;
@@ -2,8 +2,9 @@ import React from 'react';
2
2
  type SyncBlockLabelProps = {
3
3
  contentUpdatedAt?: string;
4
4
  isSource: boolean;
5
+ isUnsyncedBlock?: boolean;
5
6
  localId: string;
6
7
  title?: string;
7
8
  };
8
- export declare const SyncBlockLabel: React.MemoExoticComponent<({ contentUpdatedAt, isSource, localId, title, }: SyncBlockLabelProps) => React.JSX.Element>;
9
+ export declare const SyncBlockLabel: React.MemoExoticComponent<({ contentUpdatedAt, isSource, localId, title, isUnsyncedBlock, }: SyncBlockLabelProps) => React.JSX.Element>;
9
10
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-synced-block",
3
- "version": "5.3.7",
3
+ "version": "5.3.9",
4
4
  "description": "SyncedBlock plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",