@atlaskit/editor-plugin-synced-block 3.8.1 → 3.9.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 +20 -0
- package/dist/cjs/editor-actions/index.js +9 -0
- package/dist/cjs/{pm-plugins/actions.js → editor-commands/index.js} +17 -11
- package/dist/cjs/nodeviews/syncedBlock.js +2 -13
- package/dist/cjs/pm-plugins/main.js +0 -15
- package/dist/cjs/syncedBlockPlugin.js +9 -3
- package/dist/cjs/ui/SyncBlockRendererWrapper.js +2 -2
- package/dist/cjs/ui/floating-toolbar.js +4 -4
- package/dist/es2019/editor-actions/index.js +3 -0
- package/dist/es2019/{pm-plugins/actions.js → editor-commands/index.js} +17 -7
- package/dist/es2019/nodeviews/syncedBlock.js +2 -13
- package/dist/es2019/pm-plugins/main.js +0 -15
- package/dist/es2019/syncedBlockPlugin.js +7 -1
- package/dist/es2019/ui/SyncBlockRendererWrapper.js +2 -2
- package/dist/es2019/ui/floating-toolbar.js +1 -1
- package/dist/esm/editor-actions/index.js +3 -0
- package/dist/esm/{pm-plugins/actions.js → editor-commands/index.js} +13 -7
- package/dist/esm/nodeviews/syncedBlock.js +3 -14
- package/dist/esm/pm-plugins/main.js +0 -15
- package/dist/esm/syncedBlockPlugin.js +7 -1
- package/dist/esm/ui/SyncBlockRendererWrapper.js +2 -2
- package/dist/esm/ui/floating-toolbar.js +1 -1
- package/dist/types/editor-actions/index.d.ts +2 -0
- package/dist/types/syncedBlockPluginType.d.ts +12 -3
- package/dist/types/ui/SyncBlockRendererWrapper.d.ts +3 -3
- package/dist/types-ts4.5/editor-actions/index.d.ts +2 -0
- package/dist/types-ts4.5/syncedBlockPluginType.d.ts +12 -3
- package/dist/types-ts4.5/ui/SyncBlockRendererWrapper.d.ts +3 -3
- package/package.json +3 -3
- package/afm-dev-agents/tsconfig.json +0 -68
- package/afm-passionfruit/tsconfig.json +0 -68
- package/afm-rovo-extension/tsconfig.json +0 -68
- /package/dist/types/{pm-plugins/actions.d.ts → editor-commands/index.d.ts} +0 -0
- /package/dist/types-ts4.5/{pm-plugins/actions.d.ts → editor-commands/index.d.ts} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-synced-block
|
|
2
2
|
|
|
3
|
+
## 3.9.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`49860e3111ce8`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/49860e3111ce8) -
|
|
8
|
+
[ux] [EDITOR-2481] Implement plugin action flushBodiedSyncBlocks so that bodied sync block content
|
|
9
|
+
is only updated when required
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies
|
|
14
|
+
|
|
15
|
+
## 3.8.2
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- [`62d0954696c7e`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/62d0954696c7e) -
|
|
20
|
+
[ux] EDITOR-1648 handle permission denied, not found and any generic error for sync block
|
|
21
|
+
- Updated dependencies
|
|
22
|
+
|
|
3
23
|
## 3.8.1
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.flushBodiedSyncBlocks = void 0;
|
|
7
|
+
var flushBodiedSyncBlocks = exports.flushBodiedSyncBlocks = function flushBodiedSyncBlocks(syncBlockStore) {
|
|
8
|
+
return syncBlockStore.flushBodiedSyncBlocks();
|
|
9
|
+
};
|
|
@@ -8,7 +8,8 @@ exports.removeSyncedBlock = exports.editSyncedBlockSource = exports.createSynced
|
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
9
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
10
10
|
var _copyButton = require("@atlaskit/editor-common/copy-button");
|
|
11
|
-
var _utils = require("
|
|
11
|
+
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
12
|
+
var _utils2 = require("../pm-plugins/utils/utils");
|
|
12
13
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
13
14
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
14
15
|
var createSyncedBlock = exports.createSyncedBlock = function createSyncedBlock(_ref) {
|
|
@@ -33,7 +34,7 @@ var createSyncedBlock = exports.createSyncedBlock = function createSyncedBlock(_
|
|
|
33
34
|
tr = tr.replaceSelectionWith(newBodiedSyncBlockNode).scrollIntoView();
|
|
34
35
|
}
|
|
35
36
|
} else {
|
|
36
|
-
var conversionInfo = (0,
|
|
37
|
+
var conversionInfo = (0, _utils2.canBeConvertedToSyncBlock)(tr.selection);
|
|
37
38
|
if (!conversionInfo) {
|
|
38
39
|
// TODO: EDITOR-1665 - Raise an error analytics event
|
|
39
40
|
return false;
|
|
@@ -53,11 +54,11 @@ var copySyncedBlockReferenceToClipboard = exports.copySyncedBlockReferenceToClip
|
|
|
53
54
|
if (!(api !== null && api !== void 0 && api.floatingToolbar)) {
|
|
54
55
|
return false;
|
|
55
56
|
}
|
|
56
|
-
var syncBlockFindResult = (0,
|
|
57
|
+
var syncBlockFindResult = (0, _utils2.findSyncBlockOrBodiedSyncBlock)(state);
|
|
57
58
|
if (!syncBlockFindResult) {
|
|
58
59
|
return false;
|
|
59
60
|
}
|
|
60
|
-
var isBodiedSyncBlock = (0,
|
|
61
|
+
var isBodiedSyncBlock = (0, _utils2.isBodiedSyncBlockNode)(syncBlockFindResult.node, state.schema.nodes.bodiedSyncBlock);
|
|
61
62
|
var referenceSyncBlockNode = null;
|
|
62
63
|
if (isBodiedSyncBlock) {
|
|
63
64
|
var syncBlock = state.tr.doc.type.schema.nodes.syncBlock;
|
|
@@ -83,7 +84,7 @@ var copySyncedBlockReferenceToClipboard = exports.copySyncedBlockReferenceToClip
|
|
|
83
84
|
var editSyncedBlockSource = exports.editSyncedBlockSource = function editSyncedBlockSource(syncBlockStore, api) {
|
|
84
85
|
return function (state, dispatch, _view) {
|
|
85
86
|
var _syncBlock$node;
|
|
86
|
-
var syncBlock = (0,
|
|
87
|
+
var syncBlock = (0, _utils2.findSyncBlock)(state);
|
|
87
88
|
var localId = syncBlock === null || syncBlock === void 0 || (_syncBlock$node = syncBlock.node) === null || _syncBlock$node === void 0 || (_syncBlock$node = _syncBlock$node.attrs) === null || _syncBlock$node === void 0 ? void 0 : _syncBlock$node.localId;
|
|
88
89
|
if (!localId) {
|
|
89
90
|
return false;
|
|
@@ -110,16 +111,21 @@ var editSyncedBlockSource = exports.editSyncedBlockSource = function editSyncedB
|
|
|
110
111
|
};
|
|
111
112
|
var removeSyncedBlock = exports.removeSyncedBlock = function removeSyncedBlock(api) {
|
|
112
113
|
return function (state, dispatch, _view) {
|
|
113
|
-
var
|
|
114
|
-
|
|
115
|
-
if (!
|
|
114
|
+
var nodes = state.schema.nodes,
|
|
115
|
+
tr = state.tr;
|
|
116
|
+
if (!dispatch) {
|
|
116
117
|
return false;
|
|
117
118
|
}
|
|
118
|
-
var
|
|
119
|
-
if (
|
|
119
|
+
var removeTr = tr;
|
|
120
|
+
if ((0, _utils.findSelectedNodeOfType)(nodes.syncBlock)(tr.selection) || (0, _utils.findSelectedNodeOfType)(nodes.bodiedSyncBlock)(tr.selection)) {
|
|
121
|
+
removeTr = (0, _utils.removeSelectedNode)(tr);
|
|
122
|
+
} else {
|
|
123
|
+
removeTr = (0, _utils.removeParentNodeOfType)(nodes.bodiedSyncBlock)(tr);
|
|
124
|
+
}
|
|
125
|
+
if (!removeTr) {
|
|
120
126
|
return false;
|
|
121
127
|
}
|
|
122
|
-
dispatch
|
|
128
|
+
dispatch(removeTr);
|
|
123
129
|
api === null || api === void 0 || api.core.actions.focus();
|
|
124
130
|
return true;
|
|
125
131
|
};
|
|
@@ -19,17 +19,6 @@ var _SyncBlockRendererWrapper = require("../ui/SyncBlockRendererWrapper");
|
|
|
19
19
|
function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
|
|
20
20
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
21
21
|
function _superPropGet(t, o, e, r) { var p = (0, _get2.default)((0, _getPrototypeOf2.default)(1 & r ? t.prototype : t), o, e); return 2 & r && "function" == typeof p ? function (t) { return p.apply(e, t); } : p; }
|
|
22
|
-
var defaultSyncBlockRendererDocument = {
|
|
23
|
-
version: 1,
|
|
24
|
-
type: 'doc',
|
|
25
|
-
content: [{
|
|
26
|
-
type: 'paragraph',
|
|
27
|
-
content: [{
|
|
28
|
-
type: 'text',
|
|
29
|
-
text: 'This is a reference sync block. Stay tuned for updates...'
|
|
30
|
-
}]
|
|
31
|
-
}]
|
|
32
|
-
};
|
|
33
22
|
var SyncBlock = /*#__PURE__*/function (_ReactNodeView) {
|
|
34
23
|
function SyncBlock(props) {
|
|
35
24
|
var _this;
|
|
@@ -60,8 +49,8 @@ var SyncBlock = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
60
49
|
// get document node from data provider
|
|
61
50
|
|
|
62
51
|
return /*#__PURE__*/_react.default.createElement(_SyncBlockRendererWrapper.SyncBlockRendererWrapper, {
|
|
63
|
-
|
|
64
|
-
return (0, _editorSyncedBlockProvider.
|
|
52
|
+
useFetchSyncBlockData: function useFetchSyncBlockData() {
|
|
53
|
+
return (0, _editorSyncedBlockProvider.useFetchSyncBlockData)(_this2.syncBlockStore, _this2.node);
|
|
65
54
|
},
|
|
66
55
|
getSyncedBlockRenderer: (_this$options2 = this.options) === null || _this$options2 === void 0 ? void 0 : _this$options2.getSyncedBlockRenderer
|
|
67
56
|
});
|
|
@@ -9,14 +9,10 @@ var _state = require("@atlaskit/editor-prosemirror/state");
|
|
|
9
9
|
var _bodiedLazySyncedBlock = require("../nodeviews/bodiedLazySyncedBlock");
|
|
10
10
|
var _lazySyncedBlock = require("../nodeviews/lazySyncedBlock");
|
|
11
11
|
var _trackSyncBlocks2 = require("./utils/track-sync-blocks");
|
|
12
|
-
var _utils = require("./utils/utils");
|
|
13
12
|
var syncedBlockPluginKey = exports.syncedBlockPluginKey = new _state.PluginKey('syncedBlockPlugin');
|
|
14
13
|
|
|
15
14
|
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
16
15
|
|
|
17
|
-
function isInsideBodiedSyncBlock(state, selection) {
|
|
18
|
-
return (0, _utils.findBodiedSyncBlock)(state, selection) !== undefined;
|
|
19
|
-
}
|
|
20
16
|
var createPlugin = exports.createPlugin = function createPlugin(options, pmPluginFactoryParams, syncBlockStore, api) {
|
|
21
17
|
return new _safePlugin.SafePlugin({
|
|
22
18
|
key: syncedBlockPluginKey,
|
|
@@ -46,17 +42,6 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
|
|
|
46
42
|
api: api,
|
|
47
43
|
syncBlockStore: syncBlockStore
|
|
48
44
|
})
|
|
49
|
-
},
|
|
50
|
-
handleKeyDown: function handleKeyDown(view, event) {
|
|
51
|
-
if (event.key === 'Enter' && isInsideBodiedSyncBlock(view.state, view.state.selection)) {
|
|
52
|
-
event.preventDefault();
|
|
53
|
-
// Insert a new paragraph instead of letting browser handle it
|
|
54
|
-
var tr = view.state.tr;
|
|
55
|
-
tr.split(view.state.selection.from);
|
|
56
|
-
view.dispatch(tr);
|
|
57
|
-
return true;
|
|
58
|
-
}
|
|
59
|
-
return false;
|
|
60
45
|
}
|
|
61
46
|
},
|
|
62
47
|
view: function view(editorView) {
|
|
@@ -10,7 +10,8 @@ var _adfSchema = require("@atlaskit/adf-schema");
|
|
|
10
10
|
var _messages = require("@atlaskit/editor-common/messages");
|
|
11
11
|
var _quickInsert = require("@atlaskit/editor-common/quick-insert");
|
|
12
12
|
var _editorSyncedBlockProvider = require("@atlaskit/editor-synced-block-provider");
|
|
13
|
-
var
|
|
13
|
+
var _editorActions = require("./editor-actions");
|
|
14
|
+
var _editorCommands = require("./editor-commands");
|
|
14
15
|
var _main = require("./pm-plugins/main");
|
|
15
16
|
var _blockMenuComponents = require("./ui/block-menu-components");
|
|
16
17
|
var _ContentComponent = require("./ui/ContentComponent");
|
|
@@ -44,13 +45,18 @@ var syncedBlockPlugin = exports.syncedBlockPlugin = function syncedBlockPlugin(_
|
|
|
44
45
|
insertSyncedBlock: function insertSyncedBlock() {
|
|
45
46
|
return function (_ref2) {
|
|
46
47
|
var tr = _ref2.tr;
|
|
47
|
-
return (0,
|
|
48
|
+
return (0, _editorCommands.createSyncedBlock)({
|
|
48
49
|
tr: tr,
|
|
49
50
|
syncBlockStore: syncBlockStore
|
|
50
51
|
}) || null;
|
|
51
52
|
};
|
|
52
53
|
}
|
|
53
54
|
},
|
|
55
|
+
actions: {
|
|
56
|
+
flushBodiedSyncBlocks: function flushBodiedSyncBlocks() {
|
|
57
|
+
return (0, _editorActions.flushBodiedSyncBlocks)(syncBlockStore);
|
|
58
|
+
}
|
|
59
|
+
},
|
|
54
60
|
pluginsOptions: {
|
|
55
61
|
quickInsert: function quickInsert(_ref3) {
|
|
56
62
|
var formatMessage = _ref3.formatMessage;
|
|
@@ -67,7 +73,7 @@ var syncedBlockPlugin = exports.syncedBlockPlugin = function syncedBlockPlugin(_
|
|
|
67
73
|
});
|
|
68
74
|
},
|
|
69
75
|
action: function action(insert, state) {
|
|
70
|
-
return (0,
|
|
76
|
+
return (0, _editorCommands.createSyncedBlock)({
|
|
71
77
|
tr: state.tr,
|
|
72
78
|
syncBlockStore: syncBlockStore,
|
|
73
79
|
typeAheadInsert: insert
|
|
@@ -11,14 +11,14 @@ var _SyncBlockLabel = require("./SyncBlockLabel");
|
|
|
11
11
|
var SyncBlockRendererWrapperDataId = 'sync-block-plugin-renderer-wrapper';
|
|
12
12
|
var SyncBlockRendererWrapperComponent = function SyncBlockRendererWrapperComponent(_ref) {
|
|
13
13
|
var getSyncedBlockRenderer = _ref.getSyncedBlockRenderer,
|
|
14
|
-
|
|
14
|
+
useFetchSyncBlockData = _ref.useFetchSyncBlockData;
|
|
15
15
|
return /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(_SyncBlockLabel.SyncBlockLabel, null), /*#__PURE__*/_react.default.createElement("div", {
|
|
16
16
|
"data-testid": SyncBlockRendererWrapperDataId
|
|
17
17
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop
|
|
18
18
|
,
|
|
19
19
|
className: _syncBlock.SyncBlockSharedCssClassName.renderer
|
|
20
20
|
}, getSyncedBlockRenderer({
|
|
21
|
-
|
|
21
|
+
useFetchSyncBlockData: useFetchSyncBlockData
|
|
22
22
|
})));
|
|
23
23
|
};
|
|
24
24
|
var SyncBlockRendererWrapper = exports.SyncBlockRendererWrapper = /*#__PURE__*/_react.default.memo(SyncBlockRendererWrapperComponent);
|
|
@@ -14,7 +14,7 @@ var _consts = require("@atlaskit/editor-shared-styles/consts");
|
|
|
14
14
|
var _copy = _interopRequireDefault(require("@atlaskit/icon/core/copy"));
|
|
15
15
|
var _delete = _interopRequireDefault(require("@atlaskit/icon/core/delete"));
|
|
16
16
|
var _linkExternal = _interopRequireDefault(require("@atlaskit/icon/core/link-external"));
|
|
17
|
-
var
|
|
17
|
+
var _editorCommands = require("../editor-commands");
|
|
18
18
|
var _utils2 = require("../pm-plugins/utils/utils");
|
|
19
19
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
20
20
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
@@ -51,7 +51,7 @@ var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig(stat
|
|
|
51
51
|
title: formatMessage(_messages.syncBlockMessages.copySyncBlockLabel),
|
|
52
52
|
showTitle: true,
|
|
53
53
|
tooltipContent: formatMessage(_messages.syncBlockMessages.copySyncBlockTooltip),
|
|
54
|
-
onClick: (0,
|
|
54
|
+
onClick: (0, _editorCommands.copySyncedBlockReferenceToClipboard)(api)
|
|
55
55
|
}, hoverDecorationProps(nodeType, _consts.akEditorSelectedNodeClassName));
|
|
56
56
|
items.push(copyButton);
|
|
57
57
|
var disabled = !syncBlockStore.getSyncBlockURL(syncBlockObject.node.attrs.localId);
|
|
@@ -65,7 +65,7 @@ var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig(stat
|
|
|
65
65
|
title: formatMessage(_messages.syncBlockMessages.editSourceLabel),
|
|
66
66
|
showTitle: true,
|
|
67
67
|
tooltipContent: disabled ? formatMessage(_messages.syncBlockMessages.editSourceTooltipDisabled) : formatMessage(_messages.syncBlockMessages.editSourceTooltip),
|
|
68
|
-
onClick: (0,
|
|
68
|
+
onClick: (0, _editorCommands.editSyncedBlockSource)(syncBlockStore, api)
|
|
69
69
|
}, hoverDecorationProps(nodeType, _consts.akEditorSelectedNodeClassName));
|
|
70
70
|
items.push(editSourceButton);
|
|
71
71
|
}
|
|
@@ -81,7 +81,7 @@ var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig(stat
|
|
|
81
81
|
testId: testId,
|
|
82
82
|
options: [_objectSpread({
|
|
83
83
|
title: formatMessage(_messages.default.delete),
|
|
84
|
-
onClick: (0,
|
|
84
|
+
onClick: (0, _editorCommands.removeSyncedBlock)(api),
|
|
85
85
|
icon: /*#__PURE__*/_react.default.createElement(_delete.default, {
|
|
86
86
|
label: ""
|
|
87
87
|
})
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
2
2
|
import { copyDomNode, toDOM } from '@atlaskit/editor-common/copy-button';
|
|
3
|
-
import {
|
|
3
|
+
import { findSelectedNodeOfType, removeParentNodeOfType, removeSelectedNode } from '@atlaskit/editor-prosemirror/utils';
|
|
4
|
+
import { canBeConvertedToSyncBlock, findSyncBlock, findSyncBlockOrBodiedSyncBlock, isBodiedSyncBlockNode } from '../pm-plugins/utils/utils';
|
|
4
5
|
export const createSyncedBlock = ({
|
|
5
6
|
tr,
|
|
6
7
|
syncBlockStore,
|
|
@@ -111,16 +112,25 @@ export const editSyncedBlockSource = (syncBlockStore, api) => (state, dispatch,
|
|
|
111
112
|
return true;
|
|
112
113
|
};
|
|
113
114
|
export const removeSyncedBlock = api => (state, dispatch, _view) => {
|
|
114
|
-
const
|
|
115
|
-
|
|
116
|
-
|
|
115
|
+
const {
|
|
116
|
+
schema: {
|
|
117
|
+
nodes
|
|
118
|
+
},
|
|
119
|
+
tr
|
|
120
|
+
} = state;
|
|
121
|
+
if (!dispatch) {
|
|
117
122
|
return false;
|
|
118
123
|
}
|
|
119
|
-
|
|
120
|
-
if (
|
|
124
|
+
let removeTr = tr;
|
|
125
|
+
if (findSelectedNodeOfType(nodes.syncBlock)(tr.selection) || findSelectedNodeOfType(nodes.bodiedSyncBlock)(tr.selection)) {
|
|
126
|
+
removeTr = removeSelectedNode(tr);
|
|
127
|
+
} else {
|
|
128
|
+
removeTr = removeParentNodeOfType(nodes.bodiedSyncBlock)(tr);
|
|
129
|
+
}
|
|
130
|
+
if (!removeTr) {
|
|
121
131
|
return false;
|
|
122
132
|
}
|
|
123
|
-
dispatch
|
|
133
|
+
dispatch(removeTr);
|
|
124
134
|
api === null || api === void 0 ? void 0 : api.core.actions.focus();
|
|
125
135
|
return true;
|
|
126
136
|
};
|
|
@@ -1,19 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import ReactNodeView from '@atlaskit/editor-common/react-node-view';
|
|
3
3
|
import { SyncBlockSharedCssClassName } from '@atlaskit/editor-common/sync-block';
|
|
4
|
-
import {
|
|
4
|
+
import { useFetchSyncBlockData } from '@atlaskit/editor-synced-block-provider';
|
|
5
5
|
import { SyncBlockRendererWrapper } from '../ui/SyncBlockRendererWrapper';
|
|
6
|
-
const defaultSyncBlockRendererDocument = {
|
|
7
|
-
version: 1,
|
|
8
|
-
type: 'doc',
|
|
9
|
-
content: [{
|
|
10
|
-
type: 'paragraph',
|
|
11
|
-
content: [{
|
|
12
|
-
type: 'text',
|
|
13
|
-
text: 'This is a reference sync block. Stay tuned for updates...'
|
|
14
|
-
}]
|
|
15
|
-
}]
|
|
16
|
-
};
|
|
17
6
|
class SyncBlock extends ReactNodeView {
|
|
18
7
|
constructor(props) {
|
|
19
8
|
super(props.node, props.view, props.getPos, props.portalProviderAPI, props.eventDispatcher, props);
|
|
@@ -34,7 +23,7 @@ class SyncBlock extends ReactNodeView {
|
|
|
34
23
|
// get document node from data provider
|
|
35
24
|
|
|
36
25
|
return /*#__PURE__*/React.createElement(SyncBlockRendererWrapper, {
|
|
37
|
-
|
|
26
|
+
useFetchSyncBlockData: () => useFetchSyncBlockData(this.syncBlockStore, this.node),
|
|
38
27
|
getSyncedBlockRenderer: (_this$options2 = this.options) === null || _this$options2 === void 0 ? void 0 : _this$options2.getSyncedBlockRenderer
|
|
39
28
|
});
|
|
40
29
|
}
|
|
@@ -3,14 +3,10 @@ import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
|
3
3
|
import { lazyBodiedSyncBlockView } from '../nodeviews/bodiedLazySyncedBlock';
|
|
4
4
|
import { lazySyncBlockView } from '../nodeviews/lazySyncedBlock';
|
|
5
5
|
import { trackSyncBlocks } from './utils/track-sync-blocks';
|
|
6
|
-
import { findBodiedSyncBlock } from './utils/utils';
|
|
7
6
|
export const syncedBlockPluginKey = new PluginKey('syncedBlockPlugin');
|
|
8
7
|
|
|
9
8
|
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
10
9
|
|
|
11
|
-
function isInsideBodiedSyncBlock(state, selection) {
|
|
12
|
-
return findBodiedSyncBlock(state, selection) !== undefined;
|
|
13
|
-
}
|
|
14
10
|
export const createPlugin = (options, pmPluginFactoryParams, syncBlockStore, api) => {
|
|
15
11
|
return new SafePlugin({
|
|
16
12
|
key: syncedBlockPluginKey,
|
|
@@ -40,17 +36,6 @@ export const createPlugin = (options, pmPluginFactoryParams, syncBlockStore, api
|
|
|
40
36
|
api,
|
|
41
37
|
syncBlockStore
|
|
42
38
|
})
|
|
43
|
-
},
|
|
44
|
-
handleKeyDown: (view, event) => {
|
|
45
|
-
if (event.key === 'Enter' && isInsideBodiedSyncBlock(view.state, view.state.selection)) {
|
|
46
|
-
event.preventDefault();
|
|
47
|
-
// Insert a new paragraph instead of letting browser handle it
|
|
48
|
-
const tr = view.state.tr;
|
|
49
|
-
tr.split(view.state.selection.from);
|
|
50
|
-
view.dispatch(tr);
|
|
51
|
-
return true;
|
|
52
|
-
}
|
|
53
|
-
return false;
|
|
54
39
|
}
|
|
55
40
|
},
|
|
56
41
|
view: editorView => {
|
|
@@ -3,7 +3,8 @@ import { bodiedSyncBlock, syncBlock } from '@atlaskit/adf-schema';
|
|
|
3
3
|
import { blockTypeMessages } from '@atlaskit/editor-common/messages';
|
|
4
4
|
import { IconSyncBlock } from '@atlaskit/editor-common/quick-insert';
|
|
5
5
|
import { SyncBlockStoreManager } from '@atlaskit/editor-synced-block-provider';
|
|
6
|
-
import {
|
|
6
|
+
import { flushBodiedSyncBlocks } from './editor-actions';
|
|
7
|
+
import { createSyncedBlock } from './editor-commands';
|
|
7
8
|
import { createPlugin } from './pm-plugins/main';
|
|
8
9
|
import { getBlockMenuComponents } from './ui/block-menu-components';
|
|
9
10
|
import { ContentComponent } from './ui/ContentComponent';
|
|
@@ -40,6 +41,11 @@ export const syncedBlockPlugin = ({
|
|
|
40
41
|
syncBlockStore
|
|
41
42
|
}) || null
|
|
42
43
|
},
|
|
44
|
+
actions: {
|
|
45
|
+
flushBodiedSyncBlocks: () => {
|
|
46
|
+
return flushBodiedSyncBlocks(syncBlockStore);
|
|
47
|
+
}
|
|
48
|
+
},
|
|
43
49
|
pluginsOptions: {
|
|
44
50
|
quickInsert: ({
|
|
45
51
|
formatMessage
|
|
@@ -4,7 +4,7 @@ import { SyncBlockLabel } from './SyncBlockLabel';
|
|
|
4
4
|
const SyncBlockRendererWrapperDataId = 'sync-block-plugin-renderer-wrapper';
|
|
5
5
|
const SyncBlockRendererWrapperComponent = ({
|
|
6
6
|
getSyncedBlockRenderer,
|
|
7
|
-
|
|
7
|
+
useFetchSyncBlockData
|
|
8
8
|
}) => {
|
|
9
9
|
return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(SyncBlockLabel, null), /*#__PURE__*/React.createElement("div", {
|
|
10
10
|
"data-testid": SyncBlockRendererWrapperDataId
|
|
@@ -12,7 +12,7 @@ const SyncBlockRendererWrapperComponent = ({
|
|
|
12
12
|
,
|
|
13
13
|
className: SyncBlockSharedCssClassName.renderer
|
|
14
14
|
}, getSyncedBlockRenderer({
|
|
15
|
-
|
|
15
|
+
useFetchSyncBlockData
|
|
16
16
|
})));
|
|
17
17
|
};
|
|
18
18
|
export const SyncBlockRendererWrapper = /*#__PURE__*/React.memo(SyncBlockRendererWrapperComponent);
|
|
@@ -5,7 +5,7 @@ import { akEditorSelectedNodeClassName } from '@atlaskit/editor-shared-styles/co
|
|
|
5
5
|
import CopyIcon from '@atlaskit/icon/core/copy';
|
|
6
6
|
import DeleteIcon from '@atlaskit/icon/core/delete';
|
|
7
7
|
import LinkExternalIcon from '@atlaskit/icon/core/link-external';
|
|
8
|
-
import { copySyncedBlockReferenceToClipboard, editSyncedBlockSource, removeSyncedBlock } from '../
|
|
8
|
+
import { copySyncedBlockReferenceToClipboard, editSyncedBlockSource, removeSyncedBlock } from '../editor-commands';
|
|
9
9
|
import { findSyncBlockOrBodiedSyncBlock, isBodiedSyncBlockNode } from '../pm-plugins/utils/utils';
|
|
10
10
|
export const getToolbarConfig = (state, intl, _options = {}, _providerFactory, api, syncBlockStore) => {
|
|
11
11
|
var _api$decorations;
|
|
@@ -3,7 +3,8 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
|
|
|
3
3
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
4
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
5
5
|
import { copyDomNode, toDOM } from '@atlaskit/editor-common/copy-button';
|
|
6
|
-
import {
|
|
6
|
+
import { findSelectedNodeOfType, removeParentNodeOfType, removeSelectedNode } from '@atlaskit/editor-prosemirror/utils';
|
|
7
|
+
import { canBeConvertedToSyncBlock, findSyncBlock, findSyncBlockOrBodiedSyncBlock, isBodiedSyncBlockNode } from '../pm-plugins/utils/utils';
|
|
7
8
|
export var createSyncedBlock = function createSyncedBlock(_ref) {
|
|
8
9
|
var tr = _ref.tr,
|
|
9
10
|
syncBlockStore = _ref.syncBlockStore,
|
|
@@ -103,16 +104,21 @@ export var editSyncedBlockSource = function editSyncedBlockSource(syncBlockStore
|
|
|
103
104
|
};
|
|
104
105
|
export var removeSyncedBlock = function removeSyncedBlock(api) {
|
|
105
106
|
return function (state, dispatch, _view) {
|
|
106
|
-
var
|
|
107
|
-
|
|
108
|
-
if (!
|
|
107
|
+
var nodes = state.schema.nodes,
|
|
108
|
+
tr = state.tr;
|
|
109
|
+
if (!dispatch) {
|
|
109
110
|
return false;
|
|
110
111
|
}
|
|
111
|
-
var
|
|
112
|
-
if (
|
|
112
|
+
var removeTr = tr;
|
|
113
|
+
if (findSelectedNodeOfType(nodes.syncBlock)(tr.selection) || findSelectedNodeOfType(nodes.bodiedSyncBlock)(tr.selection)) {
|
|
114
|
+
removeTr = removeSelectedNode(tr);
|
|
115
|
+
} else {
|
|
116
|
+
removeTr = removeParentNodeOfType(nodes.bodiedSyncBlock)(tr);
|
|
117
|
+
}
|
|
118
|
+
if (!removeTr) {
|
|
113
119
|
return false;
|
|
114
120
|
}
|
|
115
|
-
dispatch
|
|
121
|
+
dispatch(removeTr);
|
|
116
122
|
api === null || api === void 0 || api.core.actions.focus();
|
|
117
123
|
return true;
|
|
118
124
|
};
|
|
@@ -10,19 +10,8 @@ function _superPropGet(t, o, e, r) { var p = _get(_getPrototypeOf(1 & r ? t.prot
|
|
|
10
10
|
import React from 'react';
|
|
11
11
|
import ReactNodeView from '@atlaskit/editor-common/react-node-view';
|
|
12
12
|
import { SyncBlockSharedCssClassName } from '@atlaskit/editor-common/sync-block';
|
|
13
|
-
import {
|
|
13
|
+
import { useFetchSyncBlockData as _useFetchSyncBlockData } from '@atlaskit/editor-synced-block-provider';
|
|
14
14
|
import { SyncBlockRendererWrapper } from '../ui/SyncBlockRendererWrapper';
|
|
15
|
-
var defaultSyncBlockRendererDocument = {
|
|
16
|
-
version: 1,
|
|
17
|
-
type: 'doc',
|
|
18
|
-
content: [{
|
|
19
|
-
type: 'paragraph',
|
|
20
|
-
content: [{
|
|
21
|
-
type: 'text',
|
|
22
|
-
text: 'This is a reference sync block. Stay tuned for updates...'
|
|
23
|
-
}]
|
|
24
|
-
}]
|
|
25
|
-
};
|
|
26
15
|
var SyncBlock = /*#__PURE__*/function (_ReactNodeView) {
|
|
27
16
|
function SyncBlock(props) {
|
|
28
17
|
var _this;
|
|
@@ -53,8 +42,8 @@ var SyncBlock = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
53
42
|
// get document node from data provider
|
|
54
43
|
|
|
55
44
|
return /*#__PURE__*/React.createElement(SyncBlockRendererWrapper, {
|
|
56
|
-
|
|
57
|
-
return
|
|
45
|
+
useFetchSyncBlockData: function useFetchSyncBlockData() {
|
|
46
|
+
return _useFetchSyncBlockData(_this2.syncBlockStore, _this2.node);
|
|
58
47
|
},
|
|
59
48
|
getSyncedBlockRenderer: (_this$options2 = this.options) === null || _this$options2 === void 0 ? void 0 : _this$options2.getSyncedBlockRenderer
|
|
60
49
|
});
|
|
@@ -3,14 +3,10 @@ import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
|
3
3
|
import { lazyBodiedSyncBlockView } from '../nodeviews/bodiedLazySyncedBlock';
|
|
4
4
|
import { lazySyncBlockView } from '../nodeviews/lazySyncedBlock';
|
|
5
5
|
import { trackSyncBlocks } from './utils/track-sync-blocks';
|
|
6
|
-
import { findBodiedSyncBlock } from './utils/utils';
|
|
7
6
|
export var syncedBlockPluginKey = new PluginKey('syncedBlockPlugin');
|
|
8
7
|
|
|
9
8
|
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
10
9
|
|
|
11
|
-
function isInsideBodiedSyncBlock(state, selection) {
|
|
12
|
-
return findBodiedSyncBlock(state, selection) !== undefined;
|
|
13
|
-
}
|
|
14
10
|
export var createPlugin = function createPlugin(options, pmPluginFactoryParams, syncBlockStore, api) {
|
|
15
11
|
return new SafePlugin({
|
|
16
12
|
key: syncedBlockPluginKey,
|
|
@@ -40,17 +36,6 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
|
|
|
40
36
|
api: api,
|
|
41
37
|
syncBlockStore: syncBlockStore
|
|
42
38
|
})
|
|
43
|
-
},
|
|
44
|
-
handleKeyDown: function handleKeyDown(view, event) {
|
|
45
|
-
if (event.key === 'Enter' && isInsideBodiedSyncBlock(view.state, view.state.selection)) {
|
|
46
|
-
event.preventDefault();
|
|
47
|
-
// Insert a new paragraph instead of letting browser handle it
|
|
48
|
-
var tr = view.state.tr;
|
|
49
|
-
tr.split(view.state.selection.from);
|
|
50
|
-
view.dispatch(tr);
|
|
51
|
-
return true;
|
|
52
|
-
}
|
|
53
|
-
return false;
|
|
54
39
|
}
|
|
55
40
|
},
|
|
56
41
|
view: function view(editorView) {
|
|
@@ -3,7 +3,8 @@ import { bodiedSyncBlock, syncBlock } from '@atlaskit/adf-schema';
|
|
|
3
3
|
import { blockTypeMessages } from '@atlaskit/editor-common/messages';
|
|
4
4
|
import { IconSyncBlock } from '@atlaskit/editor-common/quick-insert';
|
|
5
5
|
import { SyncBlockStoreManager } from '@atlaskit/editor-synced-block-provider';
|
|
6
|
-
import {
|
|
6
|
+
import { flushBodiedSyncBlocks as _flushBodiedSyncBlocks } from './editor-actions';
|
|
7
|
+
import { createSyncedBlock } from './editor-commands';
|
|
7
8
|
import { createPlugin } from './pm-plugins/main';
|
|
8
9
|
import { getBlockMenuComponents } from './ui/block-menu-components';
|
|
9
10
|
import { ContentComponent } from './ui/ContentComponent';
|
|
@@ -44,6 +45,11 @@ export var syncedBlockPlugin = function syncedBlockPlugin(_ref) {
|
|
|
44
45
|
};
|
|
45
46
|
}
|
|
46
47
|
},
|
|
48
|
+
actions: {
|
|
49
|
+
flushBodiedSyncBlocks: function flushBodiedSyncBlocks() {
|
|
50
|
+
return _flushBodiedSyncBlocks(syncBlockStore);
|
|
51
|
+
}
|
|
52
|
+
},
|
|
47
53
|
pluginsOptions: {
|
|
48
54
|
quickInsert: function quickInsert(_ref3) {
|
|
49
55
|
var formatMessage = _ref3.formatMessage;
|
|
@@ -4,14 +4,14 @@ import { SyncBlockLabel } from './SyncBlockLabel';
|
|
|
4
4
|
var SyncBlockRendererWrapperDataId = 'sync-block-plugin-renderer-wrapper';
|
|
5
5
|
var SyncBlockRendererWrapperComponent = function SyncBlockRendererWrapperComponent(_ref) {
|
|
6
6
|
var getSyncedBlockRenderer = _ref.getSyncedBlockRenderer,
|
|
7
|
-
|
|
7
|
+
useFetchSyncBlockData = _ref.useFetchSyncBlockData;
|
|
8
8
|
return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(SyncBlockLabel, null), /*#__PURE__*/React.createElement("div", {
|
|
9
9
|
"data-testid": SyncBlockRendererWrapperDataId
|
|
10
10
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop
|
|
11
11
|
,
|
|
12
12
|
className: SyncBlockSharedCssClassName.renderer
|
|
13
13
|
}, getSyncedBlockRenderer({
|
|
14
|
-
|
|
14
|
+
useFetchSyncBlockData: useFetchSyncBlockData
|
|
15
15
|
})));
|
|
16
16
|
};
|
|
17
17
|
export var SyncBlockRendererWrapper = /*#__PURE__*/React.memo(SyncBlockRendererWrapperComponent);
|
|
@@ -8,7 +8,7 @@ import { akEditorSelectedNodeClassName } from '@atlaskit/editor-shared-styles/co
|
|
|
8
8
|
import CopyIcon from '@atlaskit/icon/core/copy';
|
|
9
9
|
import DeleteIcon from '@atlaskit/icon/core/delete';
|
|
10
10
|
import LinkExternalIcon from '@atlaskit/icon/core/link-external';
|
|
11
|
-
import { copySyncedBlockReferenceToClipboard, editSyncedBlockSource, removeSyncedBlock } from '../
|
|
11
|
+
import { copySyncedBlockReferenceToClipboard, editSyncedBlockSource, removeSyncedBlock } from '../editor-commands';
|
|
12
12
|
import { findSyncBlockOrBodiedSyncBlock, isBodiedSyncBlockNode } from '../pm-plugins/utils/utils';
|
|
13
13
|
export var getToolbarConfig = function getToolbarConfig(state, intl) {
|
|
14
14
|
var _api$decorations;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { DocNode } from '@atlaskit/adf-schema';
|
|
2
1
|
import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
|
|
3
2
|
import type { EditorCommand, NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
|
|
4
3
|
import type { JSONDocNode } from '@atlaskit/editor-json-transformer';
|
|
@@ -9,7 +8,7 @@ import type { DecorationsPlugin } from '@atlaskit/editor-plugin-decorations';
|
|
|
9
8
|
import type { FloatingToolbarPlugin } from '@atlaskit/editor-plugin-floating-toolbar';
|
|
10
9
|
import type { SelectionPlugin } from '@atlaskit/editor-plugin-selection';
|
|
11
10
|
import type { EditorView } from '@atlaskit/editor-prosemirror/dist/types/view';
|
|
12
|
-
import type { SyncBlockDataProvider } from '@atlaskit/editor-synced-block-provider';
|
|
11
|
+
import type { FetchSyncBlockDataResult, SyncBlockDataProvider } from '@atlaskit/editor-synced-block-provider';
|
|
13
12
|
export type SyncedBlockEditorProps = {
|
|
14
13
|
defaultDocument: JSONDocNode;
|
|
15
14
|
onChange: (editorView: EditorView, meta: {
|
|
@@ -33,7 +32,7 @@ export type SyncedBlockEditorProps = {
|
|
|
33
32
|
popupsMountPoint: HTMLElement;
|
|
34
33
|
};
|
|
35
34
|
export type SyncedBlockRendererProps = {
|
|
36
|
-
|
|
35
|
+
useFetchSyncBlockData: () => FetchSyncBlockDataResult | null;
|
|
37
36
|
};
|
|
38
37
|
export type SyncedBlockPluginOptions = {
|
|
39
38
|
dataProvider?: SyncBlockDataProvider;
|
|
@@ -41,6 +40,16 @@ export type SyncedBlockPluginOptions = {
|
|
|
41
40
|
getSyncedBlockRenderer?: (props: SyncedBlockRendererProps) => React.JSX.Element;
|
|
42
41
|
};
|
|
43
42
|
export type SyncedBlockPlugin = NextEditorPlugin<'syncedBlock', {
|
|
43
|
+
actions: {
|
|
44
|
+
/**
|
|
45
|
+
* Save content of bodiedSyncBlock nodes in local cache to backend.
|
|
46
|
+
* This action allows bodiedSyncBlock to be saved in sync with product saving experience
|
|
47
|
+
* as per {@link https://hello.atlassian.net/wiki/spaces/egcuc/pages/5932393240/Synced+Blocks+Save+refresh+principles}
|
|
48
|
+
*
|
|
49
|
+
* @returns true if saving all nodes successfully, false if fail to save some/all nodes
|
|
50
|
+
*/
|
|
51
|
+
flushBodiedSyncBlocks: () => Promise<boolean>;
|
|
52
|
+
};
|
|
44
53
|
commands: {
|
|
45
54
|
insertSyncedBlock: () => EditorCommand;
|
|
46
55
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import type {
|
|
2
|
+
import type { FetchSyncBlockDataResult } from '@atlaskit/editor-synced-block-provider';
|
|
3
3
|
import type { SyncedBlockRendererProps } from '../syncedBlockPluginType';
|
|
4
4
|
type Props = {
|
|
5
5
|
getSyncedBlockRenderer: (props: SyncedBlockRendererProps) => React.JSX.Element;
|
|
6
|
-
|
|
6
|
+
useFetchSyncBlockData: () => FetchSyncBlockDataResult | null;
|
|
7
7
|
};
|
|
8
|
-
export declare const SyncBlockRendererWrapper: React.MemoExoticComponent<({ getSyncedBlockRenderer,
|
|
8
|
+
export declare const SyncBlockRendererWrapper: React.MemoExoticComponent<({ getSyncedBlockRenderer, useFetchSyncBlockData, }: Props) => React.JSX.Element>;
|
|
9
9
|
export {};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { DocNode } from '@atlaskit/adf-schema';
|
|
2
1
|
import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
|
|
3
2
|
import type { EditorCommand, NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
|
|
4
3
|
import type { JSONDocNode } from '@atlaskit/editor-json-transformer';
|
|
@@ -9,7 +8,7 @@ import type { DecorationsPlugin } from '@atlaskit/editor-plugin-decorations';
|
|
|
9
8
|
import type { FloatingToolbarPlugin } from '@atlaskit/editor-plugin-floating-toolbar';
|
|
10
9
|
import type { SelectionPlugin } from '@atlaskit/editor-plugin-selection';
|
|
11
10
|
import type { EditorView } from '@atlaskit/editor-prosemirror/dist/types/view';
|
|
12
|
-
import type { SyncBlockDataProvider } from '@atlaskit/editor-synced-block-provider';
|
|
11
|
+
import type { FetchSyncBlockDataResult, SyncBlockDataProvider } from '@atlaskit/editor-synced-block-provider';
|
|
13
12
|
export type SyncedBlockEditorProps = {
|
|
14
13
|
defaultDocument: JSONDocNode;
|
|
15
14
|
onChange: (editorView: EditorView, meta: {
|
|
@@ -33,7 +32,7 @@ export type SyncedBlockEditorProps = {
|
|
|
33
32
|
popupsMountPoint: HTMLElement;
|
|
34
33
|
};
|
|
35
34
|
export type SyncedBlockRendererProps = {
|
|
36
|
-
|
|
35
|
+
useFetchSyncBlockData: () => FetchSyncBlockDataResult | null;
|
|
37
36
|
};
|
|
38
37
|
export type SyncedBlockPluginOptions = {
|
|
39
38
|
dataProvider?: SyncBlockDataProvider;
|
|
@@ -41,6 +40,16 @@ export type SyncedBlockPluginOptions = {
|
|
|
41
40
|
getSyncedBlockRenderer?: (props: SyncedBlockRendererProps) => React.JSX.Element;
|
|
42
41
|
};
|
|
43
42
|
export type SyncedBlockPlugin = NextEditorPlugin<'syncedBlock', {
|
|
43
|
+
actions: {
|
|
44
|
+
/**
|
|
45
|
+
* Save content of bodiedSyncBlock nodes in local cache to backend.
|
|
46
|
+
* This action allows bodiedSyncBlock to be saved in sync with product saving experience
|
|
47
|
+
* as per {@link https://hello.atlassian.net/wiki/spaces/egcuc/pages/5932393240/Synced+Blocks+Save+refresh+principles}
|
|
48
|
+
*
|
|
49
|
+
* @returns true if saving all nodes successfully, false if fail to save some/all nodes
|
|
50
|
+
*/
|
|
51
|
+
flushBodiedSyncBlocks: () => Promise<boolean>;
|
|
52
|
+
};
|
|
44
53
|
commands: {
|
|
45
54
|
insertSyncedBlock: () => EditorCommand;
|
|
46
55
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import type {
|
|
2
|
+
import type { FetchSyncBlockDataResult } from '@atlaskit/editor-synced-block-provider';
|
|
3
3
|
import type { SyncedBlockRendererProps } from '../syncedBlockPluginType';
|
|
4
4
|
type Props = {
|
|
5
5
|
getSyncedBlockRenderer: (props: SyncedBlockRendererProps) => React.JSX.Element;
|
|
6
|
-
|
|
6
|
+
useFetchSyncBlockData: () => FetchSyncBlockDataResult | null;
|
|
7
7
|
};
|
|
8
|
-
export declare const SyncBlockRendererWrapper: React.MemoExoticComponent<({ getSyncedBlockRenderer,
|
|
8
|
+
export declare const SyncBlockRendererWrapper: React.MemoExoticComponent<({ getSyncedBlockRenderer, useFetchSyncBlockData, }: Props) => React.JSX.Element>;
|
|
9
9
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-synced-block",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.9.0",
|
|
4
4
|
"description": "SyncedBlock plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -38,11 +38,11 @@
|
|
|
38
38
|
"@atlaskit/editor-plugin-selection": "^6.1.0",
|
|
39
39
|
"@atlaskit/editor-prosemirror": "7.0.0",
|
|
40
40
|
"@atlaskit/editor-shared-styles": "^3.8.0",
|
|
41
|
-
"@atlaskit/editor-synced-block-provider": "^2.
|
|
41
|
+
"@atlaskit/editor-synced-block-provider": "^2.2.0",
|
|
42
42
|
"@atlaskit/editor-tables": "^2.9.0",
|
|
43
43
|
"@atlaskit/editor-toolbar": "^0.16.0",
|
|
44
44
|
"@atlaskit/icon": "28.5.3",
|
|
45
|
-
"@atlaskit/modal-dialog": "^14.
|
|
45
|
+
"@atlaskit/modal-dialog": "^14.6.0",
|
|
46
46
|
"@babel/runtime": "^7.0.0",
|
|
47
47
|
"react-intl-next": "npm:react-intl@^5.18.1"
|
|
48
48
|
},
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "../../../../tsconfig.entry-points.dev-agents.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"target": "es5",
|
|
5
|
-
"outDir": "../../../../../dev-agents/tsDist/@atlaskit__editor-plugin-synced-block/app",
|
|
6
|
-
"rootDir": "../",
|
|
7
|
-
"composite": true
|
|
8
|
-
},
|
|
9
|
-
"include": [
|
|
10
|
-
"../src/**/*.ts",
|
|
11
|
-
"../src/**/*.tsx"
|
|
12
|
-
],
|
|
13
|
-
"exclude": [
|
|
14
|
-
"../src/**/__tests__/*",
|
|
15
|
-
"../src/**/*.test.*",
|
|
16
|
-
"../src/**/test.*",
|
|
17
|
-
"../src/**/examples.*",
|
|
18
|
-
"../src/**/examples/*",
|
|
19
|
-
"../src/**/examples/**/*",
|
|
20
|
-
"../src/**/*.stories.*",
|
|
21
|
-
"../src/**/stories/*",
|
|
22
|
-
"../src/**/stories/**/*"
|
|
23
|
-
],
|
|
24
|
-
"references": [
|
|
25
|
-
{
|
|
26
|
-
"path": "../../../design-system/button/afm-dev-agents/tsconfig.json"
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
"path": "../../editor-json-transformer/afm-dev-agents/tsconfig.json"
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
"path": "../../editor-plugin-analytics/afm-dev-agents/tsconfig.json"
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
"path": "../../editor-plugin-block-menu/afm-dev-agents/tsconfig.json"
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
"path": "../../editor-plugin-decorations/afm-dev-agents/tsconfig.json"
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
"path": "../../editor-plugin-floating-toolbar/afm-dev-agents/tsconfig.json"
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
"path": "../../editor-plugin-selection/afm-dev-agents/tsconfig.json"
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
"path": "../../editor-shared-styles/afm-dev-agents/tsconfig.json"
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
"path": "../../editor-synced-block-provider/afm-dev-agents/tsconfig.json"
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
"path": "../../editor-tables/afm-dev-agents/tsconfig.json"
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
"path": "../../editor-toolbar/afm-dev-agents/tsconfig.json"
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
"path": "../../../design-system/icon/afm-dev-agents/tsconfig.json"
|
|
60
|
-
},
|
|
61
|
-
{
|
|
62
|
-
"path": "../../../design-system/modal-dialog/afm-dev-agents/tsconfig.json"
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
"path": "../../editor-common/afm-dev-agents/tsconfig.json"
|
|
66
|
-
}
|
|
67
|
-
]
|
|
68
|
-
}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "../../../../tsconfig.entry-points.passionfruit.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"target": "es5",
|
|
5
|
-
"outDir": "../../../../../passionfruit/tsDist/@atlaskit__editor-plugin-synced-block/app",
|
|
6
|
-
"rootDir": "../",
|
|
7
|
-
"composite": true
|
|
8
|
-
},
|
|
9
|
-
"include": [
|
|
10
|
-
"../src/**/*.ts",
|
|
11
|
-
"../src/**/*.tsx"
|
|
12
|
-
],
|
|
13
|
-
"exclude": [
|
|
14
|
-
"../src/**/__tests__/*",
|
|
15
|
-
"../src/**/*.test.*",
|
|
16
|
-
"../src/**/test.*",
|
|
17
|
-
"../src/**/examples.*",
|
|
18
|
-
"../src/**/examples/*",
|
|
19
|
-
"../src/**/examples/**/*",
|
|
20
|
-
"../src/**/*.stories.*",
|
|
21
|
-
"../src/**/stories/*",
|
|
22
|
-
"../src/**/stories/**/*"
|
|
23
|
-
],
|
|
24
|
-
"references": [
|
|
25
|
-
{
|
|
26
|
-
"path": "../../../design-system/button/afm-passionfruit/tsconfig.json"
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
"path": "../../editor-json-transformer/afm-passionfruit/tsconfig.json"
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
"path": "../../editor-plugin-analytics/afm-passionfruit/tsconfig.json"
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
"path": "../../editor-plugin-block-menu/afm-passionfruit/tsconfig.json"
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
"path": "../../editor-plugin-decorations/afm-passionfruit/tsconfig.json"
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
"path": "../../editor-plugin-floating-toolbar/afm-passionfruit/tsconfig.json"
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
"path": "../../editor-plugin-selection/afm-passionfruit/tsconfig.json"
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
"path": "../../editor-shared-styles/afm-passionfruit/tsconfig.json"
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
"path": "../../editor-synced-block-provider/afm-passionfruit/tsconfig.json"
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
"path": "../../editor-tables/afm-passionfruit/tsconfig.json"
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
"path": "../../editor-toolbar/afm-passionfruit/tsconfig.json"
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
"path": "../../../design-system/icon/afm-passionfruit/tsconfig.json"
|
|
60
|
-
},
|
|
61
|
-
{
|
|
62
|
-
"path": "../../../design-system/modal-dialog/afm-passionfruit/tsconfig.json"
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
"path": "../../editor-common/afm-passionfruit/tsconfig.json"
|
|
66
|
-
}
|
|
67
|
-
]
|
|
68
|
-
}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "../../../../tsconfig.entry-points.rovo-extension.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"target": "es5",
|
|
5
|
-
"outDir": "../../../../../rovo-extension/tsDist/@atlaskit__editor-plugin-synced-block/app",
|
|
6
|
-
"rootDir": "../",
|
|
7
|
-
"composite": true
|
|
8
|
-
},
|
|
9
|
-
"include": [
|
|
10
|
-
"../src/**/*.ts",
|
|
11
|
-
"../src/**/*.tsx"
|
|
12
|
-
],
|
|
13
|
-
"exclude": [
|
|
14
|
-
"../src/**/__tests__/*",
|
|
15
|
-
"../src/**/*.test.*",
|
|
16
|
-
"../src/**/test.*",
|
|
17
|
-
"../src/**/examples.*",
|
|
18
|
-
"../src/**/examples/*",
|
|
19
|
-
"../src/**/examples/**/*",
|
|
20
|
-
"../src/**/*.stories.*",
|
|
21
|
-
"../src/**/stories/*",
|
|
22
|
-
"../src/**/stories/**/*"
|
|
23
|
-
],
|
|
24
|
-
"references": [
|
|
25
|
-
{
|
|
26
|
-
"path": "../../../design-system/button/afm-rovo-extension/tsconfig.json"
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
"path": "../../editor-json-transformer/afm-rovo-extension/tsconfig.json"
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
"path": "../../editor-plugin-analytics/afm-rovo-extension/tsconfig.json"
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
"path": "../../editor-plugin-block-menu/afm-rovo-extension/tsconfig.json"
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
"path": "../../editor-plugin-decorations/afm-rovo-extension/tsconfig.json"
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
"path": "../../editor-plugin-floating-toolbar/afm-rovo-extension/tsconfig.json"
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
"path": "../../editor-plugin-selection/afm-rovo-extension/tsconfig.json"
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
"path": "../../editor-shared-styles/afm-rovo-extension/tsconfig.json"
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
"path": "../../editor-synced-block-provider/afm-rovo-extension/tsconfig.json"
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
"path": "../../editor-tables/afm-rovo-extension/tsconfig.json"
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
"path": "../../editor-toolbar/afm-rovo-extension/tsconfig.json"
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
"path": "../../../design-system/icon/afm-rovo-extension/tsconfig.json"
|
|
60
|
-
},
|
|
61
|
-
{
|
|
62
|
-
"path": "../../../design-system/modal-dialog/afm-rovo-extension/tsconfig.json"
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
"path": "../../editor-common/afm-rovo-extension/tsconfig.json"
|
|
66
|
-
}
|
|
67
|
-
]
|
|
68
|
-
}
|
|
File without changes
|
|
File without changes
|