@atlaskit/editor-plugin-synced-block 2.0.1 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/afm-cc/tsconfig.json +3 -0
- package/afm-dev-agents/tsconfig.json +3 -0
- package/afm-jira/tsconfig.json +3 -0
- package/afm-passionfruit/tsconfig.json +3 -0
- package/afm-post-office/tsconfig.json +3 -0
- package/afm-rovo-extension/tsconfig.json +3 -0
- package/afm-townsquare/tsconfig.json +3 -0
- package/dist/cjs/nodeviews/syncedBlock.js +118 -75
- package/dist/cjs/pm-plugins/actions.js +23 -9
- package/dist/cjs/pm-plugins/main.js +4 -3
- package/dist/cjs/pm-plugins/utils/utils.js +11 -0
- package/dist/cjs/syncedBlockPlugin.js +8 -3
- package/dist/cjs/ui/SyncBlockEditorWrapper.js +38 -0
- package/dist/cjs/ui/SyncBlockRendererWrapper.js +26 -0
- package/dist/cjs/ui/floating-toolbar.js +58 -3
- package/dist/es2019/nodeviews/syncedBlock.js +103 -67
- package/dist/es2019/pm-plugins/actions.js +23 -8
- package/dist/es2019/pm-plugins/main.js +4 -3
- package/dist/es2019/pm-plugins/utils/utils.js +7 -0
- package/dist/es2019/syncedBlockPlugin.js +38 -33
- package/dist/es2019/ui/SyncBlockEditorWrapper.js +28 -0
- package/dist/es2019/ui/SyncBlockRendererWrapper.js +20 -0
- package/dist/es2019/ui/floating-toolbar.js +56 -2
- package/dist/esm/nodeviews/syncedBlock.js +116 -72
- package/dist/esm/pm-plugins/actions.js +21 -8
- package/dist/esm/pm-plugins/main.js +4 -3
- package/dist/esm/pm-plugins/utils/utils.js +5 -0
- package/dist/esm/syncedBlockPlugin.js +8 -3
- package/dist/esm/ui/SyncBlockEditorWrapper.js +31 -0
- package/dist/esm/ui/SyncBlockRendererWrapper.js +19 -0
- package/dist/esm/ui/floating-toolbar.js +57 -3
- package/dist/types/nodeviews/syncedBlock.d.ts +29 -15
- package/dist/types/pm-plugins/actions.d.ts +3 -1
- package/dist/types/pm-plugins/main.d.ts +4 -3
- package/dist/types/pm-plugins/utils/utils.d.ts +3 -0
- package/dist/types/syncedBlockPluginType.d.ts +6 -2
- package/dist/types/ui/SyncBlockEditorWrapper.d.ts +16 -0
- package/dist/types/ui/SyncBlockRendererWrapper.d.ts +9 -0
- package/dist/types/ui/floating-toolbar.d.ts +6 -2
- package/dist/types-ts4.5/nodeviews/syncedBlock.d.ts +29 -15
- package/dist/types-ts4.5/pm-plugins/actions.d.ts +3 -1
- package/dist/types-ts4.5/pm-plugins/main.d.ts +4 -3
- package/dist/types-ts4.5/pm-plugins/utils/utils.d.ts +3 -0
- package/dist/types-ts4.5/syncedBlockPluginType.d.ts +8 -2
- package/dist/types-ts4.5/ui/SyncBlockEditorWrapper.d.ts +16 -0
- package/dist/types-ts4.5/ui/SyncBlockRendererWrapper.d.ts +9 -0
- package/dist/types-ts4.5/ui/floating-toolbar.d.ts +6 -2
- package/package.json +6 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-synced-block
|
|
2
2
|
|
|
3
|
+
## 2.1.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`7846d87959f7a`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/7846d87959f7a) -
|
|
8
|
+
Initial implementation of the floating toolbar
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
|
|
11
|
+
## 2.1.0
|
|
12
|
+
|
|
13
|
+
### Minor Changes
|
|
14
|
+
|
|
15
|
+
- [`2ce1b7efe1d2e`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/2ce1b7efe1d2e) -
|
|
16
|
+
EDITOR-1640 Create Sync-Block data manager scaffolding
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- Updated dependencies
|
|
21
|
+
|
|
3
22
|
## 2.0.1
|
|
4
23
|
|
|
5
24
|
### Patch Changes
|
package/afm-cc/tsconfig.json
CHANGED
package/afm-jira/tsconfig.json
CHANGED
|
@@ -1,108 +1,118 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
|
-
exports.syncBlockNodeView =
|
|
7
|
+
exports.syncBlockNodeView = void 0;
|
|
9
8
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
10
9
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
11
10
|
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
12
11
|
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
13
12
|
var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
|
|
14
13
|
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
15
|
-
var
|
|
16
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
14
|
+
var _react = _interopRequireDefault(require("react"));
|
|
17
15
|
var _reactNodeView = _interopRequireDefault(require("@atlaskit/editor-common/react-node-view"));
|
|
18
|
-
|
|
16
|
+
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
17
|
+
var _SyncBlockEditorWrapper = require("../ui/SyncBlockEditorWrapper");
|
|
18
|
+
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
|
-
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
|
|
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 defaultSyncBlockEditorDocument = {
|
|
23
23
|
version: 1,
|
|
24
24
|
type: 'doc',
|
|
25
25
|
content: [{
|
|
26
26
|
type: 'paragraph',
|
|
27
27
|
content: [{
|
|
28
28
|
type: 'text',
|
|
29
|
-
text: 'This is a
|
|
29
|
+
text: 'This is a source sync block. Edit me to update the content.'
|
|
30
30
|
}]
|
|
31
31
|
}]
|
|
32
32
|
};
|
|
33
|
-
var
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
setRendererDocument = _useState2[1];
|
|
44
|
-
var onChange = function onChange(editorView, _meta) {
|
|
45
|
-
var content = editorView.state.doc.toJSON().content;
|
|
46
|
-
var rendererDocument = {
|
|
47
|
-
version: 1,
|
|
48
|
-
type: 'doc',
|
|
49
|
-
content: content
|
|
50
|
-
};
|
|
51
|
-
setRendererDocument(rendererDocument);
|
|
52
|
-
};
|
|
53
|
-
var onEditorReady = function onEditorReady(_ref2) {
|
|
54
|
-
var editorView = _ref2.editorView;
|
|
55
|
-
innerEditorView.current = editorView || null;
|
|
56
|
-
};
|
|
57
|
-
var boundariesElement = (0, _react.useMemo)(function () {
|
|
58
|
-
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
59
|
-
return dom.closest('.fabric-editor-popup-scroll-parent');
|
|
60
|
-
}, [dom]);
|
|
61
|
-
if (!boundariesElement || !(boundariesElement instanceof HTMLElement)) {
|
|
62
|
-
return null;
|
|
63
|
-
}
|
|
64
|
-
if (!(config !== null && config !== void 0 && config.getSyncedBlockEditor) || !(config !== null && config !== void 0 && config.getSyncedBlockRenderer)) {
|
|
65
|
-
return null;
|
|
66
|
-
}
|
|
67
|
-
return /*#__PURE__*/_react.default.createElement("div", {
|
|
68
|
-
"data-testid": SyncBlockEditorWrapperDataId
|
|
69
|
-
}, config.getSyncedBlockEditor({
|
|
70
|
-
boundariesElement: boundariesElement,
|
|
71
|
-
defaultDocument: defaultSyncBlockDocument,
|
|
72
|
-
mountPoint: dom,
|
|
73
|
-
onChange: onChange,
|
|
74
|
-
onEditorReady: onEditorReady
|
|
75
|
-
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
76
|
-
style: {
|
|
77
|
-
width: '100%',
|
|
78
|
-
height: '1px',
|
|
79
|
-
// eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage
|
|
80
|
-
backgroundColor: 'purple'
|
|
81
|
-
}
|
|
82
|
-
}), config.getSyncedBlockRenderer({
|
|
83
|
-
docNode: rendererDocument
|
|
84
|
-
}));
|
|
33
|
+
var defaultSyncBlockRendererDocument = {
|
|
34
|
+
version: 1,
|
|
35
|
+
type: 'doc',
|
|
36
|
+
content: [{
|
|
37
|
+
type: 'paragraph',
|
|
38
|
+
content: [{
|
|
39
|
+
type: 'text',
|
|
40
|
+
text: 'This is a reference sync block. Stay tuned for updates...'
|
|
41
|
+
}]
|
|
42
|
+
}]
|
|
85
43
|
};
|
|
86
44
|
var SyncBlock = /*#__PURE__*/function (_ReactNodeView) {
|
|
87
|
-
function SyncBlock() {
|
|
45
|
+
function SyncBlock(props) {
|
|
46
|
+
var _this;
|
|
88
47
|
(0, _classCallCheck2.default)(this, SyncBlock);
|
|
89
|
-
|
|
48
|
+
_this = _callSuper(this, SyncBlock, [props.node, props.view, props.getPos, props.portalProviderAPI, props.eventDispatcher, props]);
|
|
49
|
+
var _props$node$attrs = props.node.attrs,
|
|
50
|
+
resourceId = _props$node$attrs.resourceId,
|
|
51
|
+
localId = _props$node$attrs.localId;
|
|
52
|
+
// Temporary solution to identify the source
|
|
53
|
+
_this.isSource = resourceId === localId;
|
|
54
|
+
_this.options = props.options;
|
|
55
|
+
return _this;
|
|
90
56
|
}
|
|
91
57
|
(0, _inherits2.default)(SyncBlock, _ReactNodeView);
|
|
92
58
|
return (0, _createClass2.default)(SyncBlock, [{
|
|
93
59
|
key: "createDomRef",
|
|
94
60
|
value: function createDomRef() {
|
|
95
61
|
var domRef = document.createElement('div');
|
|
96
|
-
domRef.setAttribute('style', 'border: purple solid 1px;');
|
|
97
62
|
return domRef;
|
|
98
63
|
}
|
|
64
|
+
}, {
|
|
65
|
+
key: "handleContentChanges",
|
|
66
|
+
value: function handleContentChanges(_updatedDoc) {
|
|
67
|
+
// write data
|
|
68
|
+
}
|
|
69
|
+
}, {
|
|
70
|
+
key: "setInnerEditorView",
|
|
71
|
+
value: function setInnerEditorView(_editorView) {
|
|
72
|
+
// set inner editor view
|
|
73
|
+
}
|
|
74
|
+
}, {
|
|
75
|
+
key: "renderEditor",
|
|
76
|
+
value: function renderEditor() {
|
|
77
|
+
var _this$options, _this$options2;
|
|
78
|
+
var popupsBoundariesElement = this.dom.closest('.fabric-editor-popup-scroll-parent');
|
|
79
|
+
if (!(popupsBoundariesElement instanceof HTMLElement)) {
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
if (!((_this$options = this.options) !== null && _this$options !== void 0 && _this$options.getSyncedBlockEditor)) {
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
return /*#__PURE__*/_react.default.createElement(_SyncBlockEditorWrapper.SyncBlockEditorWrapper, {
|
|
86
|
+
popupsBoundariesElement: popupsBoundariesElement,
|
|
87
|
+
popupsMountPoint: this.dom,
|
|
88
|
+
defaultDocument: defaultSyncBlockEditorDocument,
|
|
89
|
+
handleContentChanges: this.handleContentChanges,
|
|
90
|
+
setInnerEditorView: this.setInnerEditorView,
|
|
91
|
+
getSyncedBlockEditor: (_this$options2 = this.options) === null || _this$options2 === void 0 ? void 0 : _this$options2.getSyncedBlockEditor
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
}, {
|
|
95
|
+
key: "renderRenderer",
|
|
96
|
+
value: function renderRenderer() {
|
|
97
|
+
var _this$options3, _this$options4;
|
|
98
|
+
if (!((_this$options3 = this.options) !== null && _this$options3 !== void 0 && _this$options3.getSyncedBlockRenderer)) {
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// get document node from data provider
|
|
103
|
+
var docNode = defaultSyncBlockRendererDocument;
|
|
104
|
+
return /*#__PURE__*/_react.default.createElement(_SyncBlockRendererWrapper.SyncBlockRendererWrapper, {
|
|
105
|
+
docNode: docNode,
|
|
106
|
+
getSyncedBlockRenderer: (_this$options4 = this.options) === null || _this$options4 === void 0 ? void 0 : _this$options4.getSyncedBlockRenderer
|
|
107
|
+
});
|
|
108
|
+
}
|
|
99
109
|
}, {
|
|
100
110
|
key: "render",
|
|
101
111
|
value: function render() {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
112
|
+
if (this.isSource) {
|
|
113
|
+
return this.renderEditor();
|
|
114
|
+
}
|
|
115
|
+
return this.renderRenderer();
|
|
106
116
|
}
|
|
107
117
|
}, {
|
|
108
118
|
key: "stopEvent",
|
|
@@ -112,7 +122,17 @@ var SyncBlock = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
112
122
|
if (!target) {
|
|
113
123
|
return false;
|
|
114
124
|
}
|
|
115
|
-
|
|
125
|
+
var isInNestedEditor = ((_target$closest = target.closest) === null || _target$closest === void 0 ? void 0 : _target$closest.call(target, "[data-testid=\"".concat(_SyncBlockEditorWrapper.SyncBlockEditorWrapperDataId, "\"]"))) != null;
|
|
126
|
+
if (isInNestedEditor) {
|
|
127
|
+
this.selectNode();
|
|
128
|
+
return true;
|
|
129
|
+
}
|
|
130
|
+
return false;
|
|
131
|
+
}
|
|
132
|
+
}, {
|
|
133
|
+
key: "selectNode",
|
|
134
|
+
value: function selectNode() {
|
|
135
|
+
this.selectSyncBlockNode(undefined);
|
|
116
136
|
}
|
|
117
137
|
}, {
|
|
118
138
|
key: "destroy",
|
|
@@ -121,17 +141,40 @@ var SyncBlock = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
121
141
|
(_this$unsubscribe = this.unsubscribe) === null || _this$unsubscribe === void 0 || _this$unsubscribe.call(this);
|
|
122
142
|
_superPropGet(SyncBlock, "destroy", this, 3)([]);
|
|
123
143
|
}
|
|
144
|
+
}, {
|
|
145
|
+
key: "selectSyncBlockNode",
|
|
146
|
+
value: function selectSyncBlockNode(relativeSelectionPos) {
|
|
147
|
+
var _this$reactComponentP;
|
|
148
|
+
var getPos = typeof this.getPos === 'function' ? this.getPos() : 0;
|
|
149
|
+
var selectionAPI = (_this$reactComponentP = this.reactComponentProps.api) === null || _this$reactComponentP === void 0 || (_this$reactComponentP = _this$reactComponentP.selection) === null || _this$reactComponentP === void 0 ? void 0 : _this$reactComponentP.actions;
|
|
150
|
+
if (!selectionAPI) {
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
var tr = selectionAPI.selectNearNode({
|
|
154
|
+
selectionRelativeToNode: relativeSelectionPos,
|
|
155
|
+
selection: _state.NodeSelection.create(this.view.state.doc, getPos !== null && getPos !== void 0 ? getPos : 0)
|
|
156
|
+
})(this.view.state);
|
|
157
|
+
if (tr) {
|
|
158
|
+
this.view.dispatch(tr);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
124
161
|
}]);
|
|
125
162
|
}(_reactNodeView.default);
|
|
126
|
-
var syncBlockNodeView = exports.syncBlockNodeView = function syncBlockNodeView(
|
|
127
|
-
var
|
|
128
|
-
pmPluginFactoryParams =
|
|
163
|
+
var syncBlockNodeView = exports.syncBlockNodeView = function syncBlockNodeView(_ref) {
|
|
164
|
+
var options = _ref.options,
|
|
165
|
+
pmPluginFactoryParams = _ref.pmPluginFactoryParams,
|
|
166
|
+
api = _ref.api;
|
|
129
167
|
return function (node, view, getPos) {
|
|
130
168
|
var portalProviderAPI = pmPluginFactoryParams.portalProviderAPI,
|
|
131
169
|
eventDispatcher = pmPluginFactoryParams.eventDispatcher;
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
170
|
+
return new SyncBlock({
|
|
171
|
+
api: api,
|
|
172
|
+
options: options,
|
|
173
|
+
node: node,
|
|
174
|
+
view: view,
|
|
175
|
+
getPos: getPos,
|
|
176
|
+
portalProviderAPI: portalProviderAPI,
|
|
177
|
+
eventDispatcher: eventDispatcher
|
|
178
|
+
}).init();
|
|
136
179
|
};
|
|
137
180
|
};
|
|
@@ -1,25 +1,39 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
|
-
exports.createSyncedBlock = void 0;
|
|
7
|
+
exports.createSyncedBlock = exports.copySyncedBlockReferenceToClipboard = void 0;
|
|
8
|
+
var _uuid = _interopRequireDefault(require("uuid"));
|
|
9
|
+
var _copyButton = require("@atlaskit/editor-common/copy-button");
|
|
10
|
+
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
7
11
|
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
8
|
-
var getRandomId = function getRandomId() {
|
|
9
|
-
if (!globalThis.crypto || typeof globalThis.crypto.randomUUID !== 'function') {
|
|
10
|
-
return new Date().toISOString();
|
|
11
|
-
}
|
|
12
|
-
return globalThis.crypto.randomUUID();
|
|
13
|
-
};
|
|
14
12
|
var createSyncedBlock = exports.createSyncedBlock = function createSyncedBlock(state) {
|
|
13
|
+
var id = (0, _uuid.default)();
|
|
15
14
|
var tr = state.tr;
|
|
16
15
|
// const { breakout } = state.schema.marks;
|
|
17
16
|
var node = state.schema.nodes.syncBlock.createChecked({
|
|
18
|
-
resourceId:
|
|
19
|
-
localId:
|
|
17
|
+
resourceId: id,
|
|
18
|
+
localId: id
|
|
20
19
|
}, null
|
|
21
20
|
// [breakout.create({ mode: 'wide' })],
|
|
22
21
|
);
|
|
23
22
|
(0, _utils.safeInsert)(node)(tr);
|
|
24
23
|
return tr;
|
|
24
|
+
};
|
|
25
|
+
var copySyncedBlockReferenceToClipboard = exports.copySyncedBlockReferenceToClipboard = function copySyncedBlockReferenceToClipboard(state, _dispatch, _view) {
|
|
26
|
+
var schema = state.schema,
|
|
27
|
+
selection = state.selection;
|
|
28
|
+
if (selection instanceof _state.NodeSelection) {
|
|
29
|
+
var nodeType = selection.node.type;
|
|
30
|
+
var domNode = (0, _copyButton.toDOM)(selection.node, schema);
|
|
31
|
+
// clear local-id
|
|
32
|
+
if (domNode instanceof HTMLElement) {
|
|
33
|
+
domNode.setAttribute('data-local-id', '');
|
|
34
|
+
}
|
|
35
|
+
(0, _copyButton.copyDomNode)(domNode, nodeType, selection);
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
return false;
|
|
25
39
|
};
|
|
@@ -11,7 +11,7 @@ var syncedBlockPluginKey = exports.syncedBlockPluginKey = new _state.PluginKey('
|
|
|
11
11
|
|
|
12
12
|
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
13
13
|
|
|
14
|
-
var createPlugin = exports.createPlugin = function createPlugin(
|
|
14
|
+
var createPlugin = exports.createPlugin = function createPlugin(options, pmPluginFactoryParams, _syncBlockStore, api) {
|
|
15
15
|
return new _safePlugin.SafePlugin({
|
|
16
16
|
key: syncedBlockPluginKey,
|
|
17
17
|
state: {
|
|
@@ -29,8 +29,9 @@ var createPlugin = exports.createPlugin = function createPlugin(config, pmPlugin
|
|
|
29
29
|
props: {
|
|
30
30
|
nodeViews: {
|
|
31
31
|
syncBlock: (0, _lazySyncedBlock.lazySyncBlockView)({
|
|
32
|
-
|
|
33
|
-
pmPluginFactoryParams: pmPluginFactoryParams
|
|
32
|
+
options: options,
|
|
33
|
+
pmPluginFactoryParams: pmPluginFactoryParams,
|
|
34
|
+
api: api
|
|
34
35
|
})
|
|
35
36
|
}
|
|
36
37
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.findSyncBlock = void 0;
|
|
7
|
+
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
8
|
+
var findSyncBlock = exports.findSyncBlock = function findSyncBlock(state, selection) {
|
|
9
|
+
var syncBlock = state.schema.nodes.syncBlock;
|
|
10
|
+
return (0, _utils.findSelectedNodeOfType)(syncBlock)(selection || state.selection) || (0, _utils.findParentNodeOfType)(syncBlock)(selection || state.selection);
|
|
11
|
+
};
|
|
@@ -7,12 +7,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.syncedBlockPlugin = void 0;
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _adfSchema = require("@atlaskit/adf-schema");
|
|
10
|
+
var _syncBlock = require("@atlaskit/editor-common/sync-block");
|
|
10
11
|
var _smartLink = _interopRequireDefault(require("@atlaskit/icon/core/smart-link"));
|
|
11
12
|
var _actions = require("./pm-plugins/actions");
|
|
12
13
|
var _main = require("./pm-plugins/main");
|
|
13
14
|
var _floatingToolbar = require("./ui/floating-toolbar");
|
|
14
15
|
var syncedBlockPlugin = exports.syncedBlockPlugin = function syncedBlockPlugin(_ref) {
|
|
15
|
-
var config = _ref.config
|
|
16
|
+
var config = _ref.config,
|
|
17
|
+
api = _ref.api;
|
|
18
|
+
var syncBlockStore = new _syncBlock.SyncBlockStoreManager(config === null || config === void 0 ? void 0 : config.dataProvider);
|
|
16
19
|
return {
|
|
17
20
|
name: 'syncedBlock',
|
|
18
21
|
nodes: function nodes() {
|
|
@@ -25,7 +28,7 @@ var syncedBlockPlugin = exports.syncedBlockPlugin = function syncedBlockPlugin(_
|
|
|
25
28
|
return [{
|
|
26
29
|
name: 'syncedBlockPlugin',
|
|
27
30
|
plugin: function plugin(params) {
|
|
28
|
-
return (0, _main.createPlugin)(config, params);
|
|
31
|
+
return (0, _main.createPlugin)(config, params, syncBlockStore, api);
|
|
29
32
|
}
|
|
30
33
|
}];
|
|
31
34
|
},
|
|
@@ -48,7 +51,9 @@ var syncedBlockPlugin = exports.syncedBlockPlugin = function syncedBlockPlugin(_
|
|
|
48
51
|
}
|
|
49
52
|
}];
|
|
50
53
|
},
|
|
51
|
-
floatingToolbar: (
|
|
54
|
+
floatingToolbar: function floatingToolbar(state, intl, providerFactory) {
|
|
55
|
+
return (0, _floatingToolbar.getToolbarConfig)(state, intl, config, providerFactory);
|
|
56
|
+
}
|
|
52
57
|
}
|
|
53
58
|
};
|
|
54
59
|
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.SyncBlockEditorWrapperDataId = exports.SyncBlockEditorWrapper = void 0;
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var SyncBlockEditorWrapperDataId = exports.SyncBlockEditorWrapperDataId = 'sync-block-plugin-editor-wrapper';
|
|
10
|
+
var SyncBlockEditorWrapperComponent = function SyncBlockEditorWrapperComponent(_ref) {
|
|
11
|
+
var defaultDocument = _ref.defaultDocument,
|
|
12
|
+
getSyncedBlockEditor = _ref.getSyncedBlockEditor,
|
|
13
|
+
popupsBoundariesElement = _ref.popupsBoundariesElement,
|
|
14
|
+
popupsMountPoint = _ref.popupsMountPoint,
|
|
15
|
+
setInnerEditorView = _ref.setInnerEditorView,
|
|
16
|
+
handleContentChanges = _ref.handleContentChanges;
|
|
17
|
+
return (
|
|
18
|
+
/*#__PURE__*/
|
|
19
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop, @atlaskit/design-system/ensure-design-token-usage
|
|
20
|
+
_react.default.createElement("div", {
|
|
21
|
+
"data-testid": SyncBlockEditorWrapperDataId,
|
|
22
|
+
style: {
|
|
23
|
+
border: 'purple solid 1px'
|
|
24
|
+
}
|
|
25
|
+
}, getSyncedBlockEditor({
|
|
26
|
+
popupsBoundariesElement: popupsBoundariesElement,
|
|
27
|
+
defaultDocument: defaultDocument,
|
|
28
|
+
popupsMountPoint: popupsMountPoint,
|
|
29
|
+
onChange: function onChange(value) {
|
|
30
|
+
return handleContentChanges(value.state.doc);
|
|
31
|
+
},
|
|
32
|
+
onEditorReady: function onEditorReady(value) {
|
|
33
|
+
return setInnerEditorView(value.editorView);
|
|
34
|
+
}
|
|
35
|
+
}))
|
|
36
|
+
);
|
|
37
|
+
};
|
|
38
|
+
var SyncBlockEditorWrapper = exports.SyncBlockEditorWrapper = /*#__PURE__*/_react.default.memo(SyncBlockEditorWrapperComponent);
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.SyncBlockRendererWrapper = void 0;
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var SyncBlockRendererWrapperDataId = 'sync-block-plugin-renderer-wrapper';
|
|
10
|
+
var SyncBlockRendererWrapperComponent = function SyncBlockRendererWrapperComponent(_ref) {
|
|
11
|
+
var getSyncedBlockRenderer = _ref.getSyncedBlockRenderer,
|
|
12
|
+
docNode = _ref.docNode;
|
|
13
|
+
return (
|
|
14
|
+
/*#__PURE__*/
|
|
15
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop, @atlaskit/design-system/ensure-design-token-usage
|
|
16
|
+
_react.default.createElement("div", {
|
|
17
|
+
"data-testid": SyncBlockRendererWrapperDataId,
|
|
18
|
+
style: {
|
|
19
|
+
border: 'blue solid 1px'
|
|
20
|
+
}
|
|
21
|
+
}, getSyncedBlockRenderer({
|
|
22
|
+
docNode: docNode
|
|
23
|
+
}))
|
|
24
|
+
);
|
|
25
|
+
};
|
|
26
|
+
var SyncBlockRendererWrapper = exports.SyncBlockRendererWrapper = /*#__PURE__*/_react.default.memo(SyncBlockRendererWrapperComponent);
|
|
@@ -1,11 +1,66 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
7
|
exports.getToolbarConfig = void 0;
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
9
|
+
var _copy = _interopRequireDefault(require("@atlaskit/icon/core/copy"));
|
|
10
|
+
var _linkExternal = _interopRequireDefault(require("@atlaskit/icon/core/link-external"));
|
|
11
|
+
var _actions = require("../pm-plugins/actions");
|
|
12
|
+
var _utils2 = require("../pm-plugins/utils/utils");
|
|
13
|
+
var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig(state, _intl) {
|
|
14
|
+
var _options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
15
|
+
var _providerFactory = arguments.length > 3 ? arguments[3] : undefined;
|
|
16
|
+
var syncBlockObject = (0, _utils2.findSyncBlock)(state);
|
|
17
|
+
if (!syncBlockObject) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
var nodeType = state.schema.nodes.syncBlock;
|
|
21
|
+
var items = [];
|
|
22
|
+
var copyButton = {
|
|
23
|
+
id: 'editor.syncedBlock.copy',
|
|
24
|
+
type: 'button',
|
|
25
|
+
appearance: 'subtle',
|
|
26
|
+
icon: _copy.default,
|
|
27
|
+
title: 'Copy',
|
|
28
|
+
showTitle: true,
|
|
29
|
+
tooltipContent: 'Copy reference to clipboard',
|
|
30
|
+
onClick: _actions.copySyncedBlockReferenceToClipboard
|
|
31
|
+
};
|
|
32
|
+
items.push(copyButton);
|
|
33
|
+
if (syncBlockObject.node.attrs.resourceId !== syncBlockObject.node.attrs.localId) {
|
|
34
|
+
var editSourceButton = {
|
|
35
|
+
id: 'editor.syncedBlock.editSource',
|
|
36
|
+
type: 'button',
|
|
37
|
+
appearance: 'subtle',
|
|
38
|
+
icon: _linkExternal.default,
|
|
39
|
+
title: 'Edit source',
|
|
40
|
+
showTitle: true,
|
|
41
|
+
tooltipContent: 'Navigate to source page of the sync block',
|
|
42
|
+
disabled: true,
|
|
43
|
+
onClick: function onClick(_state, _dispatch, view) {
|
|
44
|
+
if (!view) {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
// to be implemented in a follow up PR
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
items.push(editSourceButton);
|
|
52
|
+
}
|
|
53
|
+
var getDomRef = function getDomRef(editorView) {
|
|
54
|
+
var domAtPos = editorView.domAtPos.bind(editorView);
|
|
55
|
+
var element = (0, _utils.findDomRefAtPos)(syncBlockObject.pos, domAtPos);
|
|
56
|
+
return element;
|
|
57
|
+
};
|
|
58
|
+
return {
|
|
59
|
+
title: 'Synced Block floating controls',
|
|
60
|
+
getDomRef: getDomRef,
|
|
61
|
+
nodeType: nodeType,
|
|
62
|
+
items: items,
|
|
63
|
+
scrollable: true,
|
|
64
|
+
groupLabel: 'Synced blocks'
|
|
10
65
|
};
|
|
11
66
|
};
|