@atlaskit/editor-core 189.3.38 → 189.4.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 +17 -0
- package/dist/cjs/plugins/extension/commands.js +9 -2
- package/dist/cjs/plugins/extension/index.js +15 -1
- package/dist/cjs/plugins/extension/pm-plugins/main.js +2 -1
- package/dist/cjs/plugins/extension/toolbar.js +1 -1
- package/dist/cjs/plugins/extension/ui/Extension/Extension/index.js +1 -8
- package/dist/cjs/plugins/extension/ui/Extension/ExtensionComponent.js +29 -10
- package/dist/cjs/plugins/extension/ui/Extension/ExtensionNodeWrapper.js +7 -0
- package/dist/cjs/plugins/extension/ui/Extension/MultiBodiedExtension/index.js +154 -0
- package/dist/cjs/plugins/extension/utils.js +6 -4
- package/dist/cjs/plugins/index.js +0 -7
- package/dist/cjs/presets/universal.js +2 -1
- package/dist/cjs/ui/ContentStyles/extension.js +2 -1
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/es2019/plugins/extension/commands.js +10 -3
- package/dist/es2019/plugins/extension/index.js +16 -2
- package/dist/es2019/plugins/extension/pm-plugins/main.js +2 -1
- package/dist/es2019/plugins/extension/toolbar.js +1 -1
- package/dist/es2019/plugins/extension/ui/Extension/Extension/index.js +1 -8
- package/dist/es2019/plugins/extension/ui/Extension/ExtensionComponent.js +29 -10
- package/dist/es2019/plugins/extension/ui/Extension/ExtensionNodeWrapper.js +7 -0
- package/dist/es2019/plugins/extension/ui/Extension/MultiBodiedExtension/index.js +159 -0
- package/dist/es2019/plugins/extension/utils.js +6 -4
- package/dist/es2019/plugins/index.js +0 -1
- package/dist/es2019/presets/universal.js +2 -1
- package/dist/es2019/ui/ContentStyles/extension.js +6 -0
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/esm/plugins/extension/commands.js +9 -2
- package/dist/esm/plugins/extension/index.js +16 -2
- package/dist/esm/plugins/extension/pm-plugins/main.js +2 -1
- package/dist/esm/plugins/extension/toolbar.js +1 -1
- package/dist/esm/plugins/extension/ui/Extension/Extension/index.js +1 -8
- package/dist/esm/plugins/extension/ui/Extension/ExtensionComponent.js +29 -10
- package/dist/esm/plugins/extension/ui/Extension/ExtensionNodeWrapper.js +7 -0
- package/dist/esm/plugins/extension/ui/Extension/MultiBodiedExtension/index.js +146 -0
- package/dist/esm/plugins/extension/utils.js +6 -4
- package/dist/esm/plugins/index.js +0 -1
- package/dist/esm/presets/universal.js +2 -1
- package/dist/esm/ui/ContentStyles/extension.js +2 -1
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/types/plugins/extension/commands.d.ts +2 -0
- package/dist/types/plugins/extension/ui/Extension/ExtensionComponent.d.ts +1 -0
- package/dist/types/plugins/extension/ui/Extension/ExtensionNodeWrapper.d.ts +7 -0
- package/dist/types/plugins/extension/ui/Extension/MultiBodiedExtension/index.d.ts +16 -0
- package/dist/types/plugins/index.d.ts +0 -1
- package/dist/types-ts4.5/plugins/extension/commands.d.ts +2 -0
- package/dist/types-ts4.5/plugins/extension/ui/Extension/ExtensionComponent.d.ts +1 -0
- package/dist/types-ts4.5/plugins/extension/ui/Extension/ExtensionNodeWrapper.d.ts +7 -0
- package/dist/types-ts4.5/plugins/extension/ui/Extension/MultiBodiedExtension/index.d.ts +16 -0
- package/dist/types-ts4.5/plugins/index.d.ts +0 -1
- package/package.json +7 -6
- package/dist/cjs/plugins/insert-block/index.js +0 -165
- package/dist/cjs/plugins/insert-block/types.js +0 -5
- package/dist/cjs/plugins/insert-block/ui/ElementBrowser/InsertMenu.js +0 -152
- package/dist/cjs/plugins/insert-block/ui/ElementBrowser/types.js +0 -5
- package/dist/cjs/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-element-browser.js +0 -42
- package/dist/cjs/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-menu-legacy.js +0 -42
- package/dist/cjs/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-menu.js +0 -66
- package/dist/cjs/plugins/insert-block/ui/ToolbarInsertBlock/create-items.js +0 -217
- package/dist/cjs/plugins/insert-block/ui/ToolbarInsertBlock/dropdown-button.js +0 -49
- package/dist/cjs/plugins/insert-block/ui/ToolbarInsertBlock/index.js +0 -565
- package/dist/cjs/plugins/insert-block/ui/ToolbarInsertBlock/item.js +0 -250
- package/dist/cjs/plugins/insert-block/ui/ToolbarInsertBlock/messages.js +0 -12
- package/dist/cjs/plugins/insert-block/ui/ToolbarInsertBlock/shallow-equals.js +0 -20
- package/dist/cjs/plugins/insert-block/ui/ToolbarInsertBlock/sort-items.js +0 -30
- package/dist/cjs/plugins/insert-block/ui/ToolbarInsertBlock/styles.js +0 -11
- package/dist/cjs/plugins/insert-block/ui/ToolbarInsertBlock/types.js +0 -5
- package/dist/es2019/plugins/insert-block/index.js +0 -159
- package/dist/es2019/plugins/insert-block/types.js +0 -1
- package/dist/es2019/plugins/insert-block/ui/ElementBrowser/InsertMenu.js +0 -150
- package/dist/es2019/plugins/insert-block/ui/ElementBrowser/types.js +0 -1
- package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-element-browser.js +0 -35
- package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-menu-legacy.js +0 -35
- package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-menu.js +0 -59
- package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/create-items.js +0 -198
- package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/dropdown-button.js +0 -37
- package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/index.js +0 -558
- package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/item.js +0 -201
- package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/messages.js +0 -1
- package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/shallow-equals.js +0 -8
- package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/sort-items.js +0 -22
- package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/styles.js +0 -16
- package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/types.js +0 -1
- package/dist/esm/plugins/insert-block/index.js +0 -158
- package/dist/esm/plugins/insert-block/types.js +0 -1
- package/dist/esm/plugins/insert-block/ui/ElementBrowser/InsertMenu.js +0 -146
- package/dist/esm/plugins/insert-block/ui/ElementBrowser/types.js +0 -1
- package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-element-browser.js +0 -35
- package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-menu-legacy.js +0 -35
- package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-menu.js +0 -59
- package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/create-items.js +0 -210
- package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/dropdown-button.js +0 -41
- package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/index.js +0 -560
- package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/item.js +0 -243
- package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/messages.js +0 -1
- package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/shallow-equals.js +0 -13
- package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/sort-items.js +0 -24
- package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/styles.js +0 -4
- package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/types.js +0 -1
- package/dist/types/plugins/insert-block/index.d.ts +0 -16
- package/dist/types/plugins/insert-block/types.d.ts +0 -45
- package/dist/types/plugins/insert-block/ui/ElementBrowser/InsertMenu.d.ts +0 -4
- package/dist/types/plugins/insert-block/ui/ElementBrowser/types.d.ts +0 -22
- package/dist/types/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-element-browser.d.ts +0 -28
- package/dist/types/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-menu-legacy.d.ts +0 -18
- package/dist/types/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-menu.d.ts +0 -30
- package/dist/types/plugins/insert-block/ui/ToolbarInsertBlock/create-items.d.ts +0 -39
- package/dist/types/plugins/insert-block/ui/ToolbarInsertBlock/dropdown-button.d.ts +0 -16
- package/dist/types/plugins/insert-block/ui/ToolbarInsertBlock/index.d.ts +0 -46
- package/dist/types/plugins/insert-block/ui/ToolbarInsertBlock/item.d.ts +0 -34
- package/dist/types/plugins/insert-block/ui/ToolbarInsertBlock/messages.d.ts +0 -1
- package/dist/types/plugins/insert-block/ui/ToolbarInsertBlock/shallow-equals.d.ts +0 -1
- package/dist/types/plugins/insert-block/ui/ToolbarInsertBlock/sort-items.d.ts +0 -2
- package/dist/types/plugins/insert-block/ui/ToolbarInsertBlock/styles.d.ts +0 -1
- package/dist/types/plugins/insert-block/ui/ToolbarInsertBlock/types.d.ts +0 -59
- package/dist/types-ts4.5/plugins/insert-block/index.d.ts +0 -16
- package/dist/types-ts4.5/plugins/insert-block/types.d.ts +0 -45
- package/dist/types-ts4.5/plugins/insert-block/ui/ElementBrowser/InsertMenu.d.ts +0 -4
- package/dist/types-ts4.5/plugins/insert-block/ui/ElementBrowser/types.d.ts +0 -22
- package/dist/types-ts4.5/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-element-browser.d.ts +0 -28
- package/dist/types-ts4.5/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-menu-legacy.d.ts +0 -18
- package/dist/types-ts4.5/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-menu.d.ts +0 -30
- package/dist/types-ts4.5/plugins/insert-block/ui/ToolbarInsertBlock/create-items.d.ts +0 -42
- package/dist/types-ts4.5/plugins/insert-block/ui/ToolbarInsertBlock/dropdown-button.d.ts +0 -16
- package/dist/types-ts4.5/plugins/insert-block/ui/ToolbarInsertBlock/index.d.ts +0 -46
- package/dist/types-ts4.5/plugins/insert-block/ui/ToolbarInsertBlock/item.d.ts +0 -34
- package/dist/types-ts4.5/plugins/insert-block/ui/ToolbarInsertBlock/messages.d.ts +0 -1
- package/dist/types-ts4.5/plugins/insert-block/ui/ToolbarInsertBlock/shallow-equals.d.ts +0 -1
- package/dist/types-ts4.5/plugins/insert-block/ui/ToolbarInsertBlock/sort-items.d.ts +0 -2
- package/dist/types-ts4.5/plugins/insert-block/ui/ToolbarInsertBlock/styles.d.ts +0 -1
- package/dist/types-ts4.5/plugins/insert-block/ui/ToolbarInsertBlock/types.d.ts +0 -59
|
@@ -6,6 +6,7 @@ import { getNodeRenderer, getExtensionModuleNodePrivateProps } from '@atlaskit/e
|
|
|
6
6
|
import { getExtensionRenderer } from '@atlaskit/editor-common/utils';
|
|
7
7
|
import Extension from './Extension';
|
|
8
8
|
import InlineExtension from './InlineExtension';
|
|
9
|
+
import MultiBodiedExtension from './MultiBodiedExtension';
|
|
9
10
|
export default class ExtensionComponent extends Component {
|
|
10
11
|
constructor(...args) {
|
|
11
12
|
super(...args);
|
|
@@ -58,7 +59,7 @@ export default class ExtensionComponent extends Component {
|
|
|
58
59
|
/** We keep rendering the default content */
|
|
59
60
|
}
|
|
60
61
|
});
|
|
61
|
-
_defineProperty(this, "handleExtension", pmNode => {
|
|
62
|
+
_defineProperty(this, "handleExtension", (pmNode, actions) => {
|
|
62
63
|
var _pmNode$marks, _pmNode$marks$find, _pmNode$marks$find$at;
|
|
63
64
|
const {
|
|
64
65
|
extensionHandlers,
|
|
@@ -87,16 +88,24 @@ export default class ExtensionComponent extends Component {
|
|
|
87
88
|
let result;
|
|
88
89
|
if (extensionHandlers && extensionHandlers[extensionType]) {
|
|
89
90
|
const render = getExtensionRenderer(extensionHandlers[extensionType]);
|
|
90
|
-
result = render(node, editorView.state.doc);
|
|
91
|
+
result = render(node, editorView.state.doc, actions);
|
|
91
92
|
}
|
|
92
93
|
if (!result) {
|
|
93
94
|
const extensionHandlerFromProvider = this.state.extensionProvider && this.getNodeRenderer(this.state.extensionProvider, extensionType, extensionKey);
|
|
94
95
|
if (extensionHandlerFromProvider) {
|
|
95
96
|
const NodeRenderer = extensionHandlerFromProvider;
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
97
|
+
if (node.type === 'multiBodiedExtension') {
|
|
98
|
+
return /*#__PURE__*/React.createElement(NodeRenderer, {
|
|
99
|
+
node: node,
|
|
100
|
+
references: this.props.references,
|
|
101
|
+
actions: actions
|
|
102
|
+
});
|
|
103
|
+
} else {
|
|
104
|
+
return /*#__PURE__*/React.createElement(NodeRenderer, {
|
|
105
|
+
node: node,
|
|
106
|
+
references: this.props.references
|
|
107
|
+
});
|
|
108
|
+
}
|
|
100
109
|
}
|
|
101
110
|
}
|
|
102
111
|
return result;
|
|
@@ -135,9 +144,19 @@ export default class ExtensionComponent extends Component {
|
|
|
135
144
|
editorView,
|
|
136
145
|
references,
|
|
137
146
|
editorAppearance,
|
|
138
|
-
pluginInjectionApi
|
|
147
|
+
pluginInjectionApi,
|
|
148
|
+
getPos
|
|
139
149
|
} = this.props;
|
|
140
|
-
|
|
150
|
+
if (node.type.name === 'multiBodiedExtension') {
|
|
151
|
+
return /*#__PURE__*/React.createElement(MultiBodiedExtension, {
|
|
152
|
+
node: node,
|
|
153
|
+
editorView: editorView,
|
|
154
|
+
getPos: getPos,
|
|
155
|
+
handleContentDOMRef: handleContentDOMRef,
|
|
156
|
+
tryExtensionHandler: this.tryExtensionHandler.bind(this)
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
const extensionHandlerResult = this.tryExtensionHandler(undefined);
|
|
141
160
|
switch (node.type.name) {
|
|
142
161
|
case 'extension':
|
|
143
162
|
case 'bodiedExtension':
|
|
@@ -160,12 +179,12 @@ export default class ExtensionComponent extends Component {
|
|
|
160
179
|
return null;
|
|
161
180
|
}
|
|
162
181
|
}
|
|
163
|
-
tryExtensionHandler() {
|
|
182
|
+
tryExtensionHandler(actions) {
|
|
164
183
|
const {
|
|
165
184
|
node
|
|
166
185
|
} = this.props;
|
|
167
186
|
try {
|
|
168
|
-
const extensionContent = this.handleExtension(node);
|
|
187
|
+
const extensionContent = this.handleExtension(node, actions);
|
|
169
188
|
if (extensionContent && /*#__PURE__*/React.isValidElement(extensionContent)) {
|
|
170
189
|
return extensionContent;
|
|
171
190
|
}
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ZERO_WIDTH_SPACE } from '@atlaskit/editor-common/utils';
|
|
3
|
+
/**
|
|
4
|
+
* If inlineExtension, add zero width space to the end of the nodes and wrap with span;
|
|
5
|
+
* else wrap with a div (for multi bodied extensions)
|
|
6
|
+
*
|
|
7
|
+
* @param param0
|
|
8
|
+
* @returns
|
|
9
|
+
*/
|
|
3
10
|
const ExtensionNodeWrapper = ({
|
|
4
11
|
children,
|
|
5
12
|
nodeType
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
|
|
3
|
+
import { jsx, css } from '@emotion/react';
|
|
4
|
+
import { N30 } from '@atlaskit/theme/colors';
|
|
5
|
+
import React, { useState } from 'react';
|
|
6
|
+
const useMultiBodiedExtensionActions = ({
|
|
7
|
+
updateActiveChild,
|
|
8
|
+
editorView,
|
|
9
|
+
getPos,
|
|
10
|
+
node
|
|
11
|
+
}) => {
|
|
12
|
+
const actions = React.useMemo(() => {
|
|
13
|
+
return {
|
|
14
|
+
changeActive(index) {
|
|
15
|
+
return updateActiveChild(index);
|
|
16
|
+
},
|
|
17
|
+
addChild() {
|
|
18
|
+
const {
|
|
19
|
+
state,
|
|
20
|
+
dispatch
|
|
21
|
+
} = editorView;
|
|
22
|
+
if (node.content.childCount >= node.attrs.maxFrames) {
|
|
23
|
+
// TODO: add proper log on this
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
const p = state.schema.nodes.paragraph.createAndFill({});
|
|
27
|
+
if (!p) {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
const frame = state.schema.nodes.extensionFrame.createAndFill({}, [p]);
|
|
31
|
+
const pos = getPos();
|
|
32
|
+
if (typeof pos !== 'number' || !frame) {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
const insertAt = Math.min((pos || 1) + node.content.size, state.doc.content.size);
|
|
36
|
+
dispatch(state.tr.insert(insertAt, frame));
|
|
37
|
+
return true;
|
|
38
|
+
},
|
|
39
|
+
getChildrenCount() {
|
|
40
|
+
return node.content.childCount;
|
|
41
|
+
},
|
|
42
|
+
removeChild(index) {
|
|
43
|
+
const pos = getPos();
|
|
44
|
+
// TODO: Add child index validation here, don't trust this data
|
|
45
|
+
if (typeof pos !== 'number' || typeof index !== 'number') {
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
const {
|
|
49
|
+
state,
|
|
50
|
+
dispatch
|
|
51
|
+
} = editorView;
|
|
52
|
+
if (node.content.childCount === 1) {
|
|
53
|
+
const tr = state.tr;
|
|
54
|
+
tr.deleteRange(pos, pos + node.content.size);
|
|
55
|
+
dispatch(tr);
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
const $pos = state.doc.resolve(pos);
|
|
59
|
+
const $startNodePos = state.doc.resolve($pos.start($pos.depth + 1));
|
|
60
|
+
const startFramePosition = $startNodePos.posAtIndex(index);
|
|
61
|
+
const maybeFrameNode = state.doc.nodeAt(startFramePosition);
|
|
62
|
+
if (!maybeFrameNode) {
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
const endFramePosition = maybeFrameNode.content.size + startFramePosition;
|
|
66
|
+
const tr = state.tr;
|
|
67
|
+
tr.deleteRange(startFramePosition, endFramePosition);
|
|
68
|
+
dispatch(tr);
|
|
69
|
+
return true;
|
|
70
|
+
},
|
|
71
|
+
updateParameters(parameters) {
|
|
72
|
+
const {
|
|
73
|
+
state,
|
|
74
|
+
dispatch
|
|
75
|
+
} = editorView;
|
|
76
|
+
const pos = getPos();
|
|
77
|
+
if (typeof pos !== 'number') {
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
const tr = state.tr.setNodeMarkup(pos, undefined, {
|
|
81
|
+
...node.attrs,
|
|
82
|
+
parameters
|
|
83
|
+
});
|
|
84
|
+
dispatch(tr);
|
|
85
|
+
return true;
|
|
86
|
+
},
|
|
87
|
+
getChildren() {
|
|
88
|
+
var _state$doc$nodeAt;
|
|
89
|
+
const {
|
|
90
|
+
state
|
|
91
|
+
} = editorView;
|
|
92
|
+
const pos = getPos();
|
|
93
|
+
if (typeof pos !== 'number') {
|
|
94
|
+
return [];
|
|
95
|
+
}
|
|
96
|
+
const children = (_state$doc$nodeAt = state.doc.nodeAt(pos)) === null || _state$doc$nodeAt === void 0 ? void 0 : _state$doc$nodeAt.content;
|
|
97
|
+
return children ? children.toJSON() : [];
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
}, [node, editorView, getPos, updateActiveChild]);
|
|
101
|
+
return actions;
|
|
102
|
+
};
|
|
103
|
+
const MultiBodiedExtension = ({
|
|
104
|
+
node,
|
|
105
|
+
handleContentDOMRef,
|
|
106
|
+
getPos,
|
|
107
|
+
tryExtensionHandler,
|
|
108
|
+
editorView
|
|
109
|
+
}) => {
|
|
110
|
+
const [activeChildIndex, setActiveChildIndex] = useState(0);
|
|
111
|
+
// Adding to avoid aliasing `this` for the callbacks
|
|
112
|
+
const updateActiveChild = React.useCallback(index => {
|
|
113
|
+
if (typeof index !== 'number') {
|
|
114
|
+
// TODO: Make sure we log this somewhere if this happens
|
|
115
|
+
setActiveChildIndex(0);
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
setActiveChildIndex(index);
|
|
119
|
+
return true;
|
|
120
|
+
}, [setActiveChildIndex]);
|
|
121
|
+
const actions = useMultiBodiedExtensionActions({
|
|
122
|
+
updateActiveChild,
|
|
123
|
+
editorView,
|
|
124
|
+
getPos,
|
|
125
|
+
node
|
|
126
|
+
});
|
|
127
|
+
const extensionHandlerResult = React.useMemo(() => {
|
|
128
|
+
return tryExtensionHandler(actions);
|
|
129
|
+
}, [tryExtensionHandler, actions]);
|
|
130
|
+
const articleRef = React.useCallback(node => {
|
|
131
|
+
return handleContentDOMRef(node);
|
|
132
|
+
}, [handleContentDOMRef]);
|
|
133
|
+
const containerCss = css`
|
|
134
|
+
border: 1px solid ${`var(--ds-border, ${N30})`};
|
|
135
|
+
padding: ${"var(--ds-space-050, 4px)"};
|
|
136
|
+
.multiBodiedExtension-content-dom-wrapper > [data-extension-frame='true'] {
|
|
137
|
+
display: none;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.multiBodiedExtension-content-dom-wrapper
|
|
141
|
+
> [data-extension-frame='true']:nth-of-type(${activeChildIndex + 1}) {
|
|
142
|
+
display: block;
|
|
143
|
+
}
|
|
144
|
+
`;
|
|
145
|
+
return jsx("section", {
|
|
146
|
+
className: "multiBodiedExtension--container",
|
|
147
|
+
css: containerCss,
|
|
148
|
+
"data-testid": "multiBodiedExtension--container",
|
|
149
|
+
"data-active-child-index": activeChildIndex
|
|
150
|
+
}, jsx("nav", {
|
|
151
|
+
className: "multiBodiedExtension-navigation",
|
|
152
|
+
"data-testid": "multiBodiedExtension-navigation"
|
|
153
|
+
}, extensionHandlerResult), jsx("article", {
|
|
154
|
+
className: "multiBodiedExtension--frames",
|
|
155
|
+
"data-testid": "multiBodiedExtension--frames",
|
|
156
|
+
ref: articleRef
|
|
157
|
+
}));
|
|
158
|
+
};
|
|
159
|
+
export default MultiBodiedExtension;
|
|
@@ -4,9 +4,10 @@ export const getSelectedExtension = (state, searchParent = false) => {
|
|
|
4
4
|
const {
|
|
5
5
|
inlineExtension,
|
|
6
6
|
extension,
|
|
7
|
-
bodiedExtension
|
|
7
|
+
bodiedExtension,
|
|
8
|
+
multiBodiedExtension
|
|
8
9
|
} = state.schema.nodes;
|
|
9
|
-
const nodeTypes = [extension, bodiedExtension, inlineExtension];
|
|
10
|
+
const nodeTypes = [extension, bodiedExtension, inlineExtension, multiBodiedExtension];
|
|
10
11
|
return findSelectedNodeOfType(nodeTypes)(state.selection) || searchParent && findParentNodeOfType(nodeTypes)(state.selection) || undefined;
|
|
11
12
|
};
|
|
12
13
|
export const findExtensionWithLocalId = (state, localId) => {
|
|
@@ -20,9 +21,10 @@ export const findExtensionWithLocalId = (state, localId) => {
|
|
|
20
21
|
const {
|
|
21
22
|
inlineExtension,
|
|
22
23
|
extension,
|
|
23
|
-
bodiedExtension
|
|
24
|
+
bodiedExtension,
|
|
25
|
+
multiBodiedExtension
|
|
24
26
|
} = state.schema.nodes;
|
|
25
|
-
const nodeTypes = [extension, bodiedExtension, inlineExtension];
|
|
27
|
+
const nodeTypes = [extension, bodiedExtension, inlineExtension, multiBodiedExtension];
|
|
26
28
|
let matched;
|
|
27
29
|
state.doc.descendants((node, pos) => {
|
|
28
30
|
if (nodeTypes.includes(node.type) && node.attrs.localId === localId) {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
export { default as clearMarksOnChangeToEmptyDocumentPlugin } from './clear-marks-on-change-to-empty-document';
|
|
2
2
|
export { default as collabEditPlugin } from './collab-edit';
|
|
3
3
|
export { default as extensionPlugin } from './extension';
|
|
4
|
-
export { default as insertBlockPlugin } from './insert-block';
|
|
5
4
|
export { default as jiraIssuePlugin } from './jira-issue';
|
|
6
5
|
export { default as toolbarListsIndentationPlugin } from './toolbar-lists-indentation';
|
|
7
6
|
export { default as pastePlugin } from './paste';
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { breakoutPlugin, collabEditPlugin, dataConsumerMarkPlugin, extensionPlugin,
|
|
1
|
+
import { breakoutPlugin, collabEditPlugin, dataConsumerMarkPlugin, extensionPlugin, jiraIssuePlugin, toolbarListsIndentationPlugin, alignmentPlugin, customAutoformatPlugin, feedbackDialogPlugin, mobileDimensionsPlugin, findReplacePlugin, mobileSelectionPlugin, annotationPlugin, avatarGroupPlugin, viewUpdateSubscriptionPlugin, beforePrimaryToolbarPlugin, codeBidiWarningPlugin } from '../plugins';
|
|
2
2
|
import { tasksAndDecisionsPlugin } from '@atlaskit/editor-plugin-tasks-and-decisions';
|
|
3
3
|
import { panelPlugin } from '@atlaskit/editor-plugin-panel';
|
|
4
4
|
import { textColorPlugin } from '@atlaskit/editor-plugin-text-color';
|
|
5
5
|
import { historyPlugin } from '@atlaskit/editor-plugin-history';
|
|
6
6
|
import { indentationPlugin } from '@atlaskit/editor-plugin-indentation';
|
|
7
7
|
import { statusPlugin } from '@atlaskit/editor-plugin-status';
|
|
8
|
+
import { insertBlockPlugin } from '@atlaskit/editor-plugin-insert-block';
|
|
8
9
|
import { datePlugin } from '@atlaskit/editor-plugin-date';
|
|
9
10
|
import { maxContentSizePlugin } from '@atlaskit/editor-plugin-max-content-size';
|
|
10
11
|
import { captionPlugin } from '@atlaskit/editor-plugin-caption';
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import { css } from '@emotion/react';
|
|
2
2
|
import { blockNodesVerticalMargin, akEditorSelectedBorderSize, akEditorDeleteBorder, akEditorDeleteBackground, SelectionStyle, getSelectionStyles, akEditorSelectedNodeClassName } from '@atlaskit/editor-shared-styles';
|
|
3
|
+
// eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage
|
|
3
4
|
export const extensionStyles = css`
|
|
5
|
+
.multiBodiedExtensionView-content-wrap.${akEditorSelectedNodeClassName}:not(.danger) {
|
|
6
|
+
${getSelectionStyles([SelectionStyle.BoxShadow, SelectionStyle.Blanket])}
|
|
7
|
+
}
|
|
8
|
+
|
|
4
9
|
.extensionView-content-wrap,
|
|
10
|
+
.multiBodiedExtensionView-content-wrap,
|
|
5
11
|
.bodiedExtensionView-content-wrap {
|
|
6
12
|
margin: ${blockNodesVerticalMargin} 0;
|
|
7
13
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export const name = "@atlaskit/editor-core";
|
|
2
|
-
export const version = "189.
|
|
2
|
+
export const version = "189.4.1";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
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; }
|
|
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
|
-
import { removeSelectedNode, removeParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
4
|
+
import { removeSelectedNode, removeParentNodeOfType, findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
5
5
|
import { createCommand } from './plugin-factory';
|
|
6
6
|
import { getSelectedExtension } from './utils';
|
|
7
7
|
import { removeConnectedNodes } from '@atlaskit/editor-common/utils';
|
|
@@ -72,7 +72,7 @@ export var removeExtension = function removeExtension() {
|
|
|
72
72
|
if (getSelectedExtension(state)) {
|
|
73
73
|
return removeSelectedNode(tr);
|
|
74
74
|
} else {
|
|
75
|
-
return
|
|
75
|
+
return checkAndRemoveExtensionNode(state, tr);
|
|
76
76
|
}
|
|
77
77
|
});
|
|
78
78
|
};
|
|
@@ -85,4 +85,11 @@ export var removeDescendantNodes = function removeDescendantNodes(sourceNode) {
|
|
|
85
85
|
}, function (tr, state) {
|
|
86
86
|
return sourceNode ? removeConnectedNodes(state, sourceNode) : tr;
|
|
87
87
|
});
|
|
88
|
+
};
|
|
89
|
+
export var checkAndRemoveExtensionNode = function checkAndRemoveExtensionNode(state, tr) {
|
|
90
|
+
var nodeType = state.schema.nodes.bodiedExtension;
|
|
91
|
+
if (findParentNodeOfType(state.schema.nodes.multiBodiedExtension)(state.selection)) {
|
|
92
|
+
nodeType = state.schema.nodes.multiBodiedExtension;
|
|
93
|
+
}
|
|
94
|
+
return removeParentNodeOfType(nodeType)(tr);
|
|
88
95
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { extension, bodiedExtension, inlineExtension } from '@atlaskit/adf-schema';
|
|
1
|
+
import { extension, bodiedExtension, inlineExtension, multiBodiedExtension, extensionFrame } from '@atlaskit/adf-schema';
|
|
2
2
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
3
3
|
import { createPlugin } from './pm-plugins/main';
|
|
4
4
|
import { createPlugin as createMacroPlugin } from './pm-plugins/macro';
|
|
@@ -9,6 +9,7 @@ import { getToolbarConfig } from './toolbar';
|
|
|
9
9
|
import { getContextPanel } from './context-panel';
|
|
10
10
|
import { createExtensionAPI } from './extension-api';
|
|
11
11
|
import { createEditSelectedExtensionAction } from './actions';
|
|
12
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
12
13
|
var extensionPlugin = function extensionPlugin(_ref) {
|
|
13
14
|
var _api$featureFlags, _api$analytics2, _api$analytics3, _api$contextPanel3, _api$analytics4, _api$contextPanel4;
|
|
14
15
|
var _ref$config = _ref.config,
|
|
@@ -23,7 +24,7 @@ var extensionPlugin = function extensionPlugin(_ref) {
|
|
|
23
24
|
return {
|
|
24
25
|
name: 'extension',
|
|
25
26
|
nodes: function nodes() {
|
|
26
|
-
|
|
27
|
+
var extensionNodes = [{
|
|
27
28
|
name: 'extension',
|
|
28
29
|
node: extension
|
|
29
30
|
}, {
|
|
@@ -33,6 +34,19 @@ var extensionPlugin = function extensionPlugin(_ref) {
|
|
|
33
34
|
name: 'inlineExtension',
|
|
34
35
|
node: inlineExtension
|
|
35
36
|
}];
|
|
37
|
+
|
|
38
|
+
// Revert to returning all nodes without local variable, once FF is removed
|
|
39
|
+
if (getBooleanFF('platform.editor.multi-bodied-extension_0rygg')) {
|
|
40
|
+
extensionNodes.push({
|
|
41
|
+
name: 'extensionFrame',
|
|
42
|
+
node: extensionFrame
|
|
43
|
+
});
|
|
44
|
+
extensionNodes.push({
|
|
45
|
+
name: 'multiBodiedExtension',
|
|
46
|
+
node: multiBodiedExtension
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
return extensionNodes;
|
|
36
50
|
},
|
|
37
51
|
pmPlugins: function pmPlugins() {
|
|
38
52
|
return [{
|
|
@@ -284,7 +284,8 @@ var createPlugin = function createPlugin(dispatch, providerFactory, extensionHan
|
|
|
284
284
|
// WARNING: referentiality-plugin also creates these nodeviews
|
|
285
285
|
bodiedExtension: ExtensionNodeView(portalProviderAPI, eventDispatcher, providerFactory, extensionHandlers, extensionNodeViewOptions, pluginInjectionApi),
|
|
286
286
|
// WARNING: referentiality-plugin also creates these nodeviews
|
|
287
|
-
inlineExtension: ExtensionNodeView(portalProviderAPI, eventDispatcher, providerFactory, extensionHandlers, extensionNodeViewOptions, pluginInjectionApi)
|
|
287
|
+
inlineExtension: ExtensionNodeView(portalProviderAPI, eventDispatcher, providerFactory, extensionHandlers, extensionNodeViewOptions, pluginInjectionApi),
|
|
288
|
+
multiBodiedExtension: ExtensionNodeView(portalProviderAPI, eventDispatcher, providerFactory, extensionHandlers, extensionNodeViewOptions, pluginInjectionApi)
|
|
288
289
|
},
|
|
289
290
|
handleClickOn: createSelectionClickHandler(['extension', 'bodiedExtension'], function (target) {
|
|
290
291
|
return !target.closest('.extension-content');
|
|
@@ -121,7 +121,7 @@ export var getToolbarConfig = function getToolbarConfig(_ref) {
|
|
|
121
121
|
var formatMessage = intl.formatMessage;
|
|
122
122
|
var extensionState = getPluginState(state);
|
|
123
123
|
if (extensionState && !extensionState.showContextPanel && extensionState.element) {
|
|
124
|
-
var nodeType = [state.schema.nodes.extension, state.schema.nodes.inlineExtension, state.schema.nodes.bodiedExtension];
|
|
124
|
+
var nodeType = [state.schema.nodes.extension, state.schema.nodes.inlineExtension, state.schema.nodes.bodiedExtension, state.schema.nodes.multiBodiedExtension];
|
|
125
125
|
var editButtonArray = editButton(formatMessage, extensionState, applyChangeToContextPanel, editorAnalyticsAPI);
|
|
126
126
|
var breakoutButtonArray = breakoutOptions(state, formatMessage, extensionState, breakoutEnabled);
|
|
127
127
|
var extensionObj = getSelectedExtension(state, true);
|
|
@@ -15,7 +15,6 @@ import { overlay } from '../styles';
|
|
|
15
15
|
import ExtensionLozenge from '../Lozenge';
|
|
16
16
|
import classnames from 'classnames';
|
|
17
17
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
18
|
-
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
19
18
|
function ExtensionWithPluginState(props) {
|
|
20
19
|
var node = props.node,
|
|
21
20
|
handleContentDOMRef = props.handleContentDOMRef,
|
|
@@ -28,13 +27,7 @@ function ExtensionWithPluginState(props) {
|
|
|
28
27
|
shadowClassNames = props.shadowClassNames,
|
|
29
28
|
hideFrame = props.hideFrame,
|
|
30
29
|
editorAppearance = props.editorAppearance;
|
|
31
|
-
var
|
|
32
|
-
if (getBooleanFF('platform.editor.multi-bodied-extension_0rygg')) {
|
|
33
|
-
isMultiBodiedExtension = true;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
//TODO: clean-up after removing multi-bodied-extension FF
|
|
37
|
-
var hasBody = node.type.name === 'bodiedExtension' || isMultiBodiedExtension && node.type.name === 'multiBodiedExtension';
|
|
30
|
+
var hasBody = ['bodiedExtension', 'multiBodiedExtension'].includes(node.type.name);
|
|
38
31
|
var isMobile = editorAppearance === 'mobile';
|
|
39
32
|
var hasChildren = !!children;
|
|
40
33
|
var removeBorder = hideFrame && !isMobile && !hasBody || false;
|
|
@@ -16,6 +16,7 @@ import { getNodeRenderer, getExtensionModuleNodePrivateProps } from '@atlaskit/e
|
|
|
16
16
|
import { getExtensionRenderer } from '@atlaskit/editor-common/utils';
|
|
17
17
|
import Extension from './Extension';
|
|
18
18
|
import InlineExtension from './InlineExtension';
|
|
19
|
+
import MultiBodiedExtension from './MultiBodiedExtension';
|
|
19
20
|
var ExtensionComponent = /*#__PURE__*/function (_Component) {
|
|
20
21
|
_inherits(ExtensionComponent, _Component);
|
|
21
22
|
var _super = _createSuper(ExtensionComponent);
|
|
@@ -87,7 +88,7 @@ var ExtensionComponent = /*#__PURE__*/function (_Component) {
|
|
|
87
88
|
}
|
|
88
89
|
}, _callee, null, [[4, 11]]);
|
|
89
90
|
})));
|
|
90
|
-
_defineProperty(_assertThisInitialized(_this), "handleExtension", function (pmNode) {
|
|
91
|
+
_defineProperty(_assertThisInitialized(_this), "handleExtension", function (pmNode, actions) {
|
|
91
92
|
var _pmNode$marks;
|
|
92
93
|
var _this$props = _this.props,
|
|
93
94
|
extensionHandlers = _this$props.extensionHandlers,
|
|
@@ -116,16 +117,24 @@ var ExtensionComponent = /*#__PURE__*/function (_Component) {
|
|
|
116
117
|
var result;
|
|
117
118
|
if (extensionHandlers && extensionHandlers[extensionType]) {
|
|
118
119
|
var render = getExtensionRenderer(extensionHandlers[extensionType]);
|
|
119
|
-
result = render(node, editorView.state.doc);
|
|
120
|
+
result = render(node, editorView.state.doc, actions);
|
|
120
121
|
}
|
|
121
122
|
if (!result) {
|
|
122
123
|
var extensionHandlerFromProvider = _this.state.extensionProvider && _this.getNodeRenderer(_this.state.extensionProvider, extensionType, extensionKey);
|
|
123
124
|
if (extensionHandlerFromProvider) {
|
|
124
125
|
var NodeRenderer = extensionHandlerFromProvider;
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
126
|
+
if (node.type === 'multiBodiedExtension') {
|
|
127
|
+
return /*#__PURE__*/React.createElement(NodeRenderer, {
|
|
128
|
+
node: node,
|
|
129
|
+
references: _this.props.references,
|
|
130
|
+
actions: actions
|
|
131
|
+
});
|
|
132
|
+
} else {
|
|
133
|
+
return /*#__PURE__*/React.createElement(NodeRenderer, {
|
|
134
|
+
node: node,
|
|
135
|
+
references: _this.props.references
|
|
136
|
+
});
|
|
137
|
+
}
|
|
129
138
|
}
|
|
130
139
|
}
|
|
131
140
|
return result;
|
|
@@ -173,8 +182,18 @@ var ExtensionComponent = /*#__PURE__*/function (_Component) {
|
|
|
173
182
|
editorView = _this$props2.editorView,
|
|
174
183
|
references = _this$props2.references,
|
|
175
184
|
editorAppearance = _this$props2.editorAppearance,
|
|
176
|
-
pluginInjectionApi = _this$props2.pluginInjectionApi
|
|
177
|
-
|
|
185
|
+
pluginInjectionApi = _this$props2.pluginInjectionApi,
|
|
186
|
+
getPos = _this$props2.getPos;
|
|
187
|
+
if (node.type.name === 'multiBodiedExtension') {
|
|
188
|
+
return /*#__PURE__*/React.createElement(MultiBodiedExtension, {
|
|
189
|
+
node: node,
|
|
190
|
+
editorView: editorView,
|
|
191
|
+
getPos: getPos,
|
|
192
|
+
handleContentDOMRef: handleContentDOMRef,
|
|
193
|
+
tryExtensionHandler: this.tryExtensionHandler.bind(this)
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
var extensionHandlerResult = this.tryExtensionHandler(undefined);
|
|
178
197
|
switch (node.type.name) {
|
|
179
198
|
case 'extension':
|
|
180
199
|
case 'bodiedExtension':
|
|
@@ -199,10 +218,10 @@ var ExtensionComponent = /*#__PURE__*/function (_Component) {
|
|
|
199
218
|
}
|
|
200
219
|
}, {
|
|
201
220
|
key: "tryExtensionHandler",
|
|
202
|
-
value: function tryExtensionHandler() {
|
|
221
|
+
value: function tryExtensionHandler(actions) {
|
|
203
222
|
var node = this.props.node;
|
|
204
223
|
try {
|
|
205
|
-
var extensionContent = this.handleExtension(node);
|
|
224
|
+
var extensionContent = this.handleExtension(node, actions);
|
|
206
225
|
if (extensionContent && /*#__PURE__*/React.isValidElement(extensionContent)) {
|
|
207
226
|
return extensionContent;
|
|
208
227
|
}
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ZERO_WIDTH_SPACE } from '@atlaskit/editor-common/utils';
|
|
3
|
+
/**
|
|
4
|
+
* If inlineExtension, add zero width space to the end of the nodes and wrap with span;
|
|
5
|
+
* else wrap with a div (for multi bodied extensions)
|
|
6
|
+
*
|
|
7
|
+
* @param param0
|
|
8
|
+
* @returns
|
|
9
|
+
*/
|
|
3
10
|
var ExtensionNodeWrapper = function ExtensionNodeWrapper(_ref) {
|
|
4
11
|
var children = _ref.children,
|
|
5
12
|
nodeType = _ref.nodeType;
|