@atlaskit/editor-common 76.33.2 → 76.35.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 +54 -0
- package/dist/cjs/collab/index.js +27 -2
- package/dist/cjs/core-utils/document-logger.js +171 -0
- package/dist/cjs/core-utils/index.js +8 -1
- package/dist/cjs/extensibility/Extension/Extension/index.js +151 -0
- package/dist/cjs/extensibility/Extension/Extension/styles.js +17 -0
- package/dist/cjs/extensibility/Extension/InlineExtension/index.js +50 -0
- package/dist/cjs/extensibility/Extension/InlineExtension/styles.js +12 -0
- package/dist/cjs/extensibility/Extension/Lozenge.js +95 -0
- package/dist/cjs/extensibility/Extension/styles.js +30 -0
- package/dist/cjs/extensibility/Extension.js +79 -0
- package/dist/cjs/extensibility/ExtensionComponent.js +252 -0
- package/dist/cjs/extensibility/ExtensionNodeWrapper.js +21 -0
- package/dist/cjs/extensibility/MultiBodiedExtension/index.js +264 -0
- package/dist/cjs/extensibility/extensionNodeView.js +91 -0
- package/dist/cjs/extensibility/index.js +42 -0
- package/dist/cjs/extensibility/types.js +5 -0
- package/dist/cjs/media-inline/media-inline-image-card.js +24 -19
- package/dist/cjs/monitoring/error.js +3 -2
- package/dist/cjs/ui/DropList/index.js +1 -1
- package/dist/cjs/utils/index.js +7 -0
- package/dist/cjs/utils/insert-node-into-ordered-list.js +91 -0
- package/dist/es2019/collab/index.js +54 -1
- package/dist/es2019/core-utils/document-logger.js +161 -0
- package/dist/es2019/core-utils/index.js +2 -1
- package/dist/es2019/extensibility/Extension/Extension/index.js +155 -0
- package/dist/es2019/extensibility/Extension/Extension/styles.js +42 -0
- package/dist/es2019/extensibility/Extension/InlineExtension/index.js +26 -0
- package/dist/es2019/extensibility/Extension/InlineExtension/styles.js +26 -0
- package/dist/es2019/extensibility/Extension/Lozenge.js +71 -0
- package/dist/es2019/extensibility/Extension/styles.js +62 -0
- package/dist/es2019/extensibility/Extension.js +52 -0
- package/dist/es2019/extensibility/ExtensionComponent.js +204 -0
- package/dist/es2019/extensibility/ExtensionNodeWrapper.js +13 -0
- package/dist/es2019/extensibility/MultiBodiedExtension/index.js +283 -0
- package/dist/es2019/extensibility/extensionNodeView.js +62 -0
- package/dist/es2019/extensibility/index.js +4 -0
- package/dist/es2019/extensibility/types.js +1 -0
- package/dist/es2019/media-inline/media-inline-image-card.js +24 -19
- package/dist/es2019/monitoring/error.js +3 -2
- package/dist/es2019/ui/DropList/index.js +1 -1
- package/dist/es2019/utils/index.js +1 -0
- package/dist/es2019/utils/insert-node-into-ordered-list.js +84 -0
- package/dist/esm/collab/index.js +23 -1
- package/dist/esm/core-utils/document-logger.js +165 -0
- package/dist/esm/core-utils/index.js +2 -1
- package/dist/esm/extensibility/Extension/Extension/index.js +146 -0
- package/dist/esm/extensibility/Extension/Extension/styles.js +10 -0
- package/dist/esm/extensibility/Extension/InlineExtension/index.js +43 -0
- package/dist/esm/extensibility/Extension/InlineExtension/styles.js +5 -0
- package/dist/esm/extensibility/Extension/Lozenge.js +90 -0
- package/dist/esm/extensibility/Extension/styles.js +11 -0
- package/dist/esm/extensibility/Extension.js +69 -0
- package/dist/esm/extensibility/ExtensionComponent.js +243 -0
- package/dist/esm/extensibility/ExtensionNodeWrapper.js +14 -0
- package/dist/esm/extensibility/MultiBodiedExtension/index.js +257 -0
- package/dist/esm/extensibility/extensionNodeView.js +83 -0
- package/dist/esm/extensibility/index.js +4 -0
- package/dist/esm/extensibility/types.js +1 -0
- package/dist/esm/media-inline/media-inline-image-card.js +24 -19
- package/dist/esm/monitoring/error.js +3 -2
- package/dist/esm/ui/DropList/index.js +1 -1
- package/dist/esm/utils/index.js +1 -0
- package/dist/esm/utils/insert-node-into-ordered-list.js +84 -0
- package/dist/types/collab/index.d.ts +7 -0
- package/dist/types/core-utils/document-logger.d.ts +6 -0
- package/dist/types/core-utils/index.d.ts +1 -0
- package/dist/types/extensibility/Extension/Extension/index.d.ts +108 -0
- package/dist/types/extensibility/Extension/Extension/styles.d.ts +5 -0
- package/dist/types/extensibility/Extension/InlineExtension/index.d.ts +12 -0
- package/dist/types/extensibility/Extension/InlineExtension/styles.d.ts +1 -0
- package/dist/types/extensibility/Extension/Lozenge.d.ts +14 -0
- package/dist/types/extensibility/Extension/styles.d.ts +7 -0
- package/dist/types/extensibility/Extension.d.ts +29 -0
- package/dist/types/extensibility/ExtensionComponent.d.ts +53 -0
- package/dist/types/extensibility/ExtensionNodeWrapper.d.ts +14 -0
- package/dist/types/extensibility/MultiBodiedExtension/index.d.ts +26 -0
- package/dist/types/extensibility/extensionNodeView.d.ts +31 -0
- package/dist/types/extensibility/index.d.ts +4 -0
- package/dist/types/extensibility/types.d.ts +6 -0
- package/dist/types/extensions/types/extension-handler.d.ts +2 -0
- package/dist/types/media-inline/media-inline-image-card.d.ts +3 -2
- package/dist/types/media-inline/types.d.ts +6 -2
- package/dist/types/types/index.d.ts +1 -1
- package/dist/types/types/next-editor-plugin.d.ts +0 -1
- package/dist/types/ui/DropList/index.d.ts +1 -1
- package/dist/types/ui-menu/ColorPickerButton/index.d.ts +1 -1
- package/dist/types/ui-menu/ToolbarButton/index.d.ts +1 -1
- package/dist/types/utils/index.d.ts +1 -0
- package/dist/types/utils/insert-node-into-ordered-list.d.ts +3 -0
- package/dist/types-ts4.5/collab/index.d.ts +7 -0
- package/dist/types-ts4.5/core-utils/document-logger.d.ts +6 -0
- package/dist/types-ts4.5/core-utils/index.d.ts +1 -0
- package/dist/types-ts4.5/extensibility/Extension/Extension/index.d.ts +108 -0
- package/dist/types-ts4.5/extensibility/Extension/Extension/styles.d.ts +5 -0
- package/dist/types-ts4.5/extensibility/Extension/InlineExtension/index.d.ts +12 -0
- package/dist/types-ts4.5/extensibility/Extension/InlineExtension/styles.d.ts +1 -0
- package/dist/types-ts4.5/extensibility/Extension/Lozenge.d.ts +14 -0
- package/dist/types-ts4.5/extensibility/Extension/styles.d.ts +7 -0
- package/dist/types-ts4.5/extensibility/Extension.d.ts +29 -0
- package/dist/types-ts4.5/extensibility/ExtensionComponent.d.ts +53 -0
- package/dist/types-ts4.5/extensibility/ExtensionNodeWrapper.d.ts +14 -0
- package/dist/types-ts4.5/extensibility/MultiBodiedExtension/index.d.ts +26 -0
- package/dist/types-ts4.5/extensibility/extensionNodeView.d.ts +31 -0
- package/dist/types-ts4.5/extensibility/index.d.ts +4 -0
- package/dist/types-ts4.5/extensibility/types.d.ts +8 -0
- package/dist/types-ts4.5/extensions/types/extension-handler.d.ts +2 -0
- package/dist/types-ts4.5/media-inline/media-inline-image-card.d.ts +3 -2
- package/dist/types-ts4.5/media-inline/types.d.ts +6 -2
- package/dist/types-ts4.5/types/index.d.ts +1 -1
- package/dist/types-ts4.5/types/next-editor-plugin.d.ts +0 -3
- package/dist/types-ts4.5/ui/DropList/index.d.ts +1 -1
- package/dist/types-ts4.5/ui-menu/ColorPickerButton/index.d.ts +1 -1
- package/dist/types-ts4.5/ui-menu/ToolbarButton/index.d.ts +1 -1
- package/dist/types-ts4.5/utils/index.d.ts +1 -0
- package/dist/types-ts4.5/utils/insert-node-into-ordered-list.d.ts +3 -0
- package/extensibility/package.json +15 -0
- package/package.json +6 -5
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
var hash = {
|
|
2
|
+
nodes: {
|
|
3
|
+
doc: 'doc',
|
|
4
|
+
paragraph: 'p',
|
|
5
|
+
text: 't',
|
|
6
|
+
bulletList: 'ul',
|
|
7
|
+
orderedList: 'ol',
|
|
8
|
+
listItem: 'li',
|
|
9
|
+
heading: 'h',
|
|
10
|
+
blockquote: 'blockq',
|
|
11
|
+
codeBlock: 'codebl',
|
|
12
|
+
panel: 'pnl',
|
|
13
|
+
rule: 'rl',
|
|
14
|
+
hardBreak: 'br',
|
|
15
|
+
mention: 'ment',
|
|
16
|
+
emoji: 'emj',
|
|
17
|
+
image: 'img',
|
|
18
|
+
caption: 'cap',
|
|
19
|
+
media: 'media',
|
|
20
|
+
mediaGroup: 'mediag',
|
|
21
|
+
mediaSingle: 'medias',
|
|
22
|
+
plain: 'pln',
|
|
23
|
+
table: 'table',
|
|
24
|
+
tableCell: 'td',
|
|
25
|
+
tableHeader: 'th',
|
|
26
|
+
tableRow: 'tr',
|
|
27
|
+
decisionList: 'dl',
|
|
28
|
+
decisionItem: 'di',
|
|
29
|
+
taskList: 'tl',
|
|
30
|
+
taskItem: 'ti',
|
|
31
|
+
extension: 'ext',
|
|
32
|
+
inlineExtension: 'exti',
|
|
33
|
+
bodiedExtension: 'extb',
|
|
34
|
+
multiBodiedExtension: 'extmbe',
|
|
35
|
+
extensionFrame: 'extfrm',
|
|
36
|
+
status: 'sts',
|
|
37
|
+
placeholder: 'plh',
|
|
38
|
+
inlineCard: 'cardi',
|
|
39
|
+
blockCard: 'cardb',
|
|
40
|
+
embedCard: 'carde',
|
|
41
|
+
expand: 'exp',
|
|
42
|
+
nestedExpand: 'expn',
|
|
43
|
+
unsupportedBlock: 'unsupb',
|
|
44
|
+
unsupportedInline: 'unsupi',
|
|
45
|
+
unknownBlock: 'unkb',
|
|
46
|
+
date: 'date'
|
|
47
|
+
},
|
|
48
|
+
marks: {
|
|
49
|
+
em: 'em',
|
|
50
|
+
strong: 'strong',
|
|
51
|
+
code: 'code',
|
|
52
|
+
strike: 'strike',
|
|
53
|
+
underline: 'undline',
|
|
54
|
+
link: 'lnk',
|
|
55
|
+
subsup: 'subsup',
|
|
56
|
+
textColor: 'txtclr',
|
|
57
|
+
unsupportedMark: 'unsupmrk',
|
|
58
|
+
unsupportedNodeAttribute: 'unsupnattr',
|
|
59
|
+
annotation: 'anno'
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
function shortHash(type, isMark) {
|
|
63
|
+
var code = hash[isMark ? 'marks' : 'nodes'][type];
|
|
64
|
+
return code ? code : type;
|
|
65
|
+
}
|
|
66
|
+
function compactStringifier(node) {
|
|
67
|
+
var _node$marks;
|
|
68
|
+
var isContentEmpty = !node.content;
|
|
69
|
+
var isTextNode = (node === null || node === void 0 ? void 0 : node.type) === 'text';
|
|
70
|
+
var hasMarks = (_node$marks = node.marks) === null || _node$marks === void 0 ? void 0 : _node$marks.length;
|
|
71
|
+
var isContentArray = Array.isArray(node.content);
|
|
72
|
+
var marks = function marks(child) {
|
|
73
|
+
if (hasMarks) {
|
|
74
|
+
return node.marks.reduce(function (str, mark) {
|
|
75
|
+
return "".concat(shortHash(mark, true), "(").concat(str, ")");
|
|
76
|
+
}, child);
|
|
77
|
+
}
|
|
78
|
+
return child;
|
|
79
|
+
};
|
|
80
|
+
var content;
|
|
81
|
+
if (isTextNode) {
|
|
82
|
+
content = String(node.nodeSize);
|
|
83
|
+
} else if (isContentEmpty) {
|
|
84
|
+
content = '';
|
|
85
|
+
} else if (isContentArray) {
|
|
86
|
+
content = node.content.map(function (node) {
|
|
87
|
+
return compactStringifier(node);
|
|
88
|
+
}).join(',');
|
|
89
|
+
}
|
|
90
|
+
return marks("".concat(shortHash(node.type, false), "(").concat(content, ")"));
|
|
91
|
+
}
|
|
92
|
+
export var getDocStructure = function getDocStructure(doc, options) {
|
|
93
|
+
try {
|
|
94
|
+
var result = getBlockNode(doc, 0);
|
|
95
|
+
if (options !== null && options !== void 0 && options.compact) {
|
|
96
|
+
return compactStringifier(result);
|
|
97
|
+
}
|
|
98
|
+
return result;
|
|
99
|
+
} catch (error) {
|
|
100
|
+
return "Error logging document structure: ".concat(error);
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
var getBlockNode = function getBlockNode(node, pos) {
|
|
104
|
+
var blockNode = {
|
|
105
|
+
type: node.type.name,
|
|
106
|
+
pos: pos,
|
|
107
|
+
nodeSize: node.nodeSize
|
|
108
|
+
};
|
|
109
|
+
var content = getBlockNodeContent(node.content, pos);
|
|
110
|
+
if (content.length > 0) {
|
|
111
|
+
blockNode.content = content;
|
|
112
|
+
}
|
|
113
|
+
var marks = getMarks(node);
|
|
114
|
+
if (marks.length > 0) {
|
|
115
|
+
blockNode.marks = marks;
|
|
116
|
+
}
|
|
117
|
+
return blockNode;
|
|
118
|
+
};
|
|
119
|
+
var getBlockNodeContent = function getBlockNodeContent(node, pos) {
|
|
120
|
+
if (!node || !node.content || !node.content.length) {
|
|
121
|
+
return [];
|
|
122
|
+
}
|
|
123
|
+
var blockNodeContent = [];
|
|
124
|
+
var content = node.content;
|
|
125
|
+
if (content[0].isBlock) {
|
|
126
|
+
// children are block nodes
|
|
127
|
+
var prevNode;
|
|
128
|
+
blockNodeContent = content.map(function (node) {
|
|
129
|
+
pos += prevNode ? prevNode.nodeSize : 1;
|
|
130
|
+
prevNode = node;
|
|
131
|
+
return getBlockNode(node, pos);
|
|
132
|
+
});
|
|
133
|
+
} else {
|
|
134
|
+
// children are inline nodes .
|
|
135
|
+
var result = getInlineNodes(content, pos);
|
|
136
|
+
blockNodeContent = result.inlineNodes;
|
|
137
|
+
pos = result.pos;
|
|
138
|
+
}
|
|
139
|
+
return blockNodeContent;
|
|
140
|
+
};
|
|
141
|
+
var getInlineNodes = function getInlineNodes(nodes, pos) {
|
|
142
|
+
var inlineNodes = nodes.map(function (node) {
|
|
143
|
+
var nodeSize = node.nodeSize;
|
|
144
|
+
var inlineNode = {
|
|
145
|
+
type: node.type.name,
|
|
146
|
+
pos: pos,
|
|
147
|
+
nodeSize: nodeSize
|
|
148
|
+
};
|
|
149
|
+
var marks = getMarks(node);
|
|
150
|
+
if (marks.length > 0) {
|
|
151
|
+
inlineNode.marks = marks;
|
|
152
|
+
}
|
|
153
|
+
pos += nodeSize;
|
|
154
|
+
return inlineNode;
|
|
155
|
+
});
|
|
156
|
+
return {
|
|
157
|
+
inlineNodes: inlineNodes,
|
|
158
|
+
pos: pos
|
|
159
|
+
};
|
|
160
|
+
};
|
|
161
|
+
var getMarks = function getMarks(node) {
|
|
162
|
+
return node.marks.map(function (mark) {
|
|
163
|
+
return mark.type.name;
|
|
164
|
+
});
|
|
165
|
+
};
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export { insideTable } from './inside';
|
|
1
|
+
export { insideTable } from './inside';
|
|
2
|
+
export { getDocStructure } from './document-logger';
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
4
|
+
var _excluded = ["type"];
|
|
5
|
+
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; }
|
|
6
|
+
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; }
|
|
7
|
+
/** @jsx jsx */
|
|
8
|
+
|
|
9
|
+
import React from 'react';
|
|
10
|
+
import { jsx } from '@emotion/react';
|
|
11
|
+
import classnames from 'classnames';
|
|
12
|
+
import { WithPluginState } from '../../..//with-plugin-state';
|
|
13
|
+
import { useSharedPluginState } from '../../../hooks';
|
|
14
|
+
import { overflowShadow } from '../../../ui';
|
|
15
|
+
import { calculateBreakoutStyles } from '../../../utils';
|
|
16
|
+
import ExtensionLozenge from '../Lozenge';
|
|
17
|
+
import { overlay } from '../styles';
|
|
18
|
+
import { content, contentWrapper, header, widerLayoutClassName, wrapperStyle } from './styles';
|
|
19
|
+
function ExtensionWithPluginState(props) {
|
|
20
|
+
var node = props.node,
|
|
21
|
+
handleContentDOMRef = props.handleContentDOMRef,
|
|
22
|
+
children = props.children,
|
|
23
|
+
_props$widthState = props.widthState,
|
|
24
|
+
widthState = _props$widthState === void 0 ? {
|
|
25
|
+
width: 0
|
|
26
|
+
} : _props$widthState,
|
|
27
|
+
handleRef = props.handleRef,
|
|
28
|
+
shadowClassNames = props.shadowClassNames,
|
|
29
|
+
hideFrame = props.hideFrame,
|
|
30
|
+
editorAppearance = props.editorAppearance;
|
|
31
|
+
var hasBody = ['bodiedExtension', 'multiBodiedExtension'].includes(node.type.name);
|
|
32
|
+
var isMobile = editorAppearance === 'mobile';
|
|
33
|
+
var hasChildren = !!children;
|
|
34
|
+
var removeBorder = hideFrame && !isMobile && !hasBody || false;
|
|
35
|
+
var getPos = props.getPos,
|
|
36
|
+
view = props.view;
|
|
37
|
+
var isTopLevelNode = React.useMemo(function () {
|
|
38
|
+
var pos = typeof getPos === 'function' ? getPos() : undefined;
|
|
39
|
+
return typeof pos !== 'undefined' && !isNaN(pos) && view.state.doc.resolve(pos).depth === 0;
|
|
40
|
+
return false;
|
|
41
|
+
}, [view, getPos]);
|
|
42
|
+
var shouldBreakout =
|
|
43
|
+
// Extension should breakout when the layout is set to 'full-width' or 'wide'.
|
|
44
|
+
['full-width', 'wide'].includes(node.attrs.layout) &&
|
|
45
|
+
// Extension breakout state should only be respected for top level nodes.
|
|
46
|
+
isTopLevelNode &&
|
|
47
|
+
// Extension breakout state should not be respected when the editor appearance is full-width mode
|
|
48
|
+
editorAppearance !== 'full-width';
|
|
49
|
+
var classNames = classnames('extension-container', 'block', shadowClassNames, _defineProperty({
|
|
50
|
+
'with-overlay': !hasBody,
|
|
51
|
+
'without-frame': removeBorder
|
|
52
|
+
}, widerLayoutClassName, shouldBreakout));
|
|
53
|
+
var headerClassNames = classnames({
|
|
54
|
+
'with-children': hasChildren,
|
|
55
|
+
'without-frame': removeBorder
|
|
56
|
+
});
|
|
57
|
+
var customContainerStyles = {
|
|
58
|
+
width: '100%'
|
|
59
|
+
};
|
|
60
|
+
var newContentStyles = {};
|
|
61
|
+
if (shouldBreakout) {
|
|
62
|
+
var _calculateBreakoutSty = calculateBreakoutStyles({
|
|
63
|
+
mode: node.attrs.layout,
|
|
64
|
+
widthStateWidth: widthState.width,
|
|
65
|
+
widthStateLineLength: widthState.lineLength
|
|
66
|
+
}),
|
|
67
|
+
type = _calculateBreakoutSty.type,
|
|
68
|
+
breakoutStyles = _objectWithoutProperties(_calculateBreakoutSty, _excluded);
|
|
69
|
+
newContentStyles = _objectSpread({}, breakoutStyles);
|
|
70
|
+
customContainerStyles = breakoutStyles;
|
|
71
|
+
}
|
|
72
|
+
newContentStyles = _objectSpread(_objectSpread({}, newContentStyles), contentWrapper);
|
|
73
|
+
return jsx("div", {
|
|
74
|
+
ref: handleRef,
|
|
75
|
+
"data-layout": node.attrs.layout,
|
|
76
|
+
className: classNames,
|
|
77
|
+
css: wrapperStyle,
|
|
78
|
+
style: customContainerStyles
|
|
79
|
+
}, jsx("div", {
|
|
80
|
+
className: "extension-overflow-wrapper ".concat(hasBody ? 'with-body' : '')
|
|
81
|
+
}, jsx("div", {
|
|
82
|
+
css: overlay,
|
|
83
|
+
className: "extension-overlay"
|
|
84
|
+
}), jsx("div", {
|
|
85
|
+
css: header,
|
|
86
|
+
contentEditable: false,
|
|
87
|
+
className: headerClassNames
|
|
88
|
+
}, !removeBorder && jsx(ExtensionLozenge, {
|
|
89
|
+
node: node
|
|
90
|
+
}), children), hasBody && jsx("div", {
|
|
91
|
+
css: newContentStyles
|
|
92
|
+
}, jsx("div", {
|
|
93
|
+
css: content,
|
|
94
|
+
ref: handleContentDOMRef,
|
|
95
|
+
className: "extension-content block"
|
|
96
|
+
}))));
|
|
97
|
+
}
|
|
98
|
+
var Extension = function Extension(props) {
|
|
99
|
+
// TODO: ED-17836 This code is here because confluence injects
|
|
100
|
+
// the `editor-referentiality` plugin via `dangerouslyAppendPlugins`
|
|
101
|
+
// which cannot access the `pluginInjectionApi`. When we move
|
|
102
|
+
// Confluence to using presets we can remove this workaround.
|
|
103
|
+
var pluginInjectionApi = props.pluginInjectionApi;
|
|
104
|
+
return pluginInjectionApi === undefined ? jsx(ExtensionDeprecated, props) : jsx(ExtensionWithSharedState, props);
|
|
105
|
+
};
|
|
106
|
+
var ExtensionWithSharedState = function ExtensionWithSharedState(props) {
|
|
107
|
+
var pluginInjectionApi = props.pluginInjectionApi;
|
|
108
|
+
var _useSharedPluginState = useSharedPluginState(pluginInjectionApi, ['width']),
|
|
109
|
+
widthState = _useSharedPluginState.widthState;
|
|
110
|
+
return jsx(ExtensionWithPluginState, _extends({
|
|
111
|
+
widthState: widthState
|
|
112
|
+
}, props));
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
// TODO: ED-17836 This code is here because Confluence injects
|
|
116
|
+
// the `editor-referentiality` plugin via `dangerouslyAppendPlugins`
|
|
117
|
+
// which cannot access the `pluginInjectionApi`. When we move
|
|
118
|
+
// Confluence to using presets we can remove this workaround.
|
|
119
|
+
// @ts-ignore
|
|
120
|
+
var widthPluginKey = {
|
|
121
|
+
key: 'widthPlugin$',
|
|
122
|
+
getState: function getState(state) {
|
|
123
|
+
return state['widthPlugin$'];
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
var ExtensionDeprecated = function ExtensionDeprecated(props) {
|
|
127
|
+
return jsx(WithPluginState, {
|
|
128
|
+
editorView: props.view,
|
|
129
|
+
plugins: {
|
|
130
|
+
widthState: widthPluginKey
|
|
131
|
+
},
|
|
132
|
+
render: function render(_ref) {
|
|
133
|
+
var widthState = _ref.widthState;
|
|
134
|
+
return jsx(ExtensionWithPluginState, _extends({
|
|
135
|
+
widthState: widthState
|
|
136
|
+
}, props));
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
};
|
|
140
|
+
/**
|
|
141
|
+
* End workaround
|
|
142
|
+
*/
|
|
143
|
+
|
|
144
|
+
export default overflowShadow(Extension, {
|
|
145
|
+
overflowSelector: '.extension-overflow-wrapper'
|
|
146
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
2
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4;
|
|
3
|
+
import { css } from '@emotion/react';
|
|
4
|
+
import { N30 } from '@atlaskit/theme/colors';
|
|
5
|
+
import { padding, wrapperDefault } from '../styles';
|
|
6
|
+
export var widerLayoutClassName = 'wider-layout';
|
|
7
|
+
export var wrapperStyle = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n ", "\n\n &.without-frame {\n background: transparent;\n }\n cursor: pointer;\n width: 100%;\n\n .extension-overflow-wrapper:not(.with-body) {\n overflow-x: auto;\n }\n"])), wrapperDefault);
|
|
8
|
+
export var header = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n padding: ", "px ", "px 0px;\n vertical-align: middle;\n\n &.with-children:not(.without-frame) {\n padding: ", " ", "\n ", ";\n }\n &.without-frame {\n padding: 0;\n }\n"])), padding / 2, padding / 2, "var(--ds-space-050, 4px)", "var(--ds-space-100, 8px)", "var(--ds-space-100, 8px)");
|
|
9
|
+
export var content = css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n padding: ", "px;\n background: ", ";\n border: 1px solid ", ";\n border-radius: ", ";\n cursor: initial;\n width: 100%;\n"])), padding, "var(--ds-surface, white)", "var(--ds-border, ".concat(N30, ")"), "var(--ds-border-radius, 3px)");
|
|
10
|
+
export var contentWrapper = css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n padding: 0 ", "px ", "px;\n display: flex;\n justify-content: center;\n"])), padding, padding);
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
|
4
|
+
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
5
|
+
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
6
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
7
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
8
|
+
/** @jsx jsx */
|
|
9
|
+
import React from 'react';
|
|
10
|
+
import { Component } from 'react';
|
|
11
|
+
import { jsx } from '@emotion/react';
|
|
12
|
+
import ExtensionLozenge from '../Lozenge';
|
|
13
|
+
import { overlay } from '../styles';
|
|
14
|
+
import { wrapperStyle } from './styles';
|
|
15
|
+
var InlineExtension = /*#__PURE__*/function (_Component) {
|
|
16
|
+
_inherits(InlineExtension, _Component);
|
|
17
|
+
var _super = _createSuper(InlineExtension);
|
|
18
|
+
function InlineExtension() {
|
|
19
|
+
_classCallCheck(this, InlineExtension);
|
|
20
|
+
return _super.apply(this, arguments);
|
|
21
|
+
}
|
|
22
|
+
_createClass(InlineExtension, [{
|
|
23
|
+
key: "render",
|
|
24
|
+
value: function render() {
|
|
25
|
+
var _this$props = this.props,
|
|
26
|
+
node = _this$props.node,
|
|
27
|
+
children = _this$props.children;
|
|
28
|
+
var hasChildren = !!children;
|
|
29
|
+
var className = hasChildren ? 'with-overlay with-children' : 'with-overlay';
|
|
30
|
+
return jsx("div", {
|
|
31
|
+
css: wrapperStyle,
|
|
32
|
+
className: "extension-container inline ".concat(className)
|
|
33
|
+
}, jsx("div", {
|
|
34
|
+
css: overlay,
|
|
35
|
+
className: "extension-overlay"
|
|
36
|
+
}), children ? children : jsx(ExtensionLozenge, {
|
|
37
|
+
node: node
|
|
38
|
+
}));
|
|
39
|
+
}
|
|
40
|
+
}]);
|
|
41
|
+
return InlineExtension;
|
|
42
|
+
}(Component);
|
|
43
|
+
export { InlineExtension as default };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
2
|
+
var _templateObject;
|
|
3
|
+
import { css } from '@emotion/react';
|
|
4
|
+
import { wrapperDefault } from '../styles';
|
|
5
|
+
export var wrapperStyle = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n ", "\n\n cursor: pointer;\n display: inline-flex;\n margin: 1px 1px ", ";\n\n > img {\n border-radius: ", ";\n }\n\n &::after,\n &::before {\n vertical-align: text-top;\n display: inline-block;\n width: 1px;\n content: '';\n }\n\n &.with-children {\n padding: 0;\n background: ", ";\n }\n"])), wrapperDefault, "var(--ds-space-050, 4px)", "var(--ds-border-radius, 3px)", "var(--ds-background-neutral-subtle, white)");
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
3
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
4
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
5
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
6
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
|
7
|
+
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
8
|
+
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
9
|
+
var _excluded = ["url"];
|
|
10
|
+
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; }
|
|
11
|
+
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; }
|
|
12
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
13
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
14
|
+
/** @jsx jsx */
|
|
15
|
+
import { Component } from 'react';
|
|
16
|
+
import { jsx } from '@emotion/react';
|
|
17
|
+
import EditorFileIcon from '@atlaskit/icon/glyph/editor/file';
|
|
18
|
+
import { getExtensionLozengeData } from '../../utils';
|
|
19
|
+
import { placeholderFallback, placeholderFallbackParams, styledImage } from './styles';
|
|
20
|
+
export var capitalizeFirstLetter = function capitalizeFirstLetter(str) {
|
|
21
|
+
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
22
|
+
};
|
|
23
|
+
export var ICON_SIZE = 24;
|
|
24
|
+
var ExtensionLozenge = /*#__PURE__*/function (_Component) {
|
|
25
|
+
_inherits(ExtensionLozenge, _Component);
|
|
26
|
+
var _super = _createSuper(ExtensionLozenge);
|
|
27
|
+
function ExtensionLozenge() {
|
|
28
|
+
_classCallCheck(this, ExtensionLozenge);
|
|
29
|
+
return _super.apply(this, arguments);
|
|
30
|
+
}
|
|
31
|
+
_createClass(ExtensionLozenge, [{
|
|
32
|
+
key: "render",
|
|
33
|
+
value: function render() {
|
|
34
|
+
var node = this.props.node;
|
|
35
|
+
var imageData = getExtensionLozengeData({
|
|
36
|
+
node: node,
|
|
37
|
+
type: 'image'
|
|
38
|
+
});
|
|
39
|
+
if (imageData && node.type.name !== 'extension') {
|
|
40
|
+
return this.renderImage(imageData);
|
|
41
|
+
}
|
|
42
|
+
var iconData = getExtensionLozengeData({
|
|
43
|
+
node: node,
|
|
44
|
+
type: 'icon'
|
|
45
|
+
});
|
|
46
|
+
return this.renderFallback(iconData);
|
|
47
|
+
}
|
|
48
|
+
}, {
|
|
49
|
+
key: "renderImage",
|
|
50
|
+
value: function renderImage(lozengeData) {
|
|
51
|
+
var extensionKey = this.props.node.attrs.extensionKey;
|
|
52
|
+
var url = lozengeData.url,
|
|
53
|
+
rest = _objectWithoutProperties(lozengeData, _excluded);
|
|
54
|
+
return jsx("img", _extends({
|
|
55
|
+
css: styledImage,
|
|
56
|
+
src: url
|
|
57
|
+
}, rest, {
|
|
58
|
+
alt: extensionKey
|
|
59
|
+
}));
|
|
60
|
+
}
|
|
61
|
+
}, {
|
|
62
|
+
key: "renderFallback",
|
|
63
|
+
value: function renderFallback(lozengeData) {
|
|
64
|
+
var _this$props$node$attr = this.props.node.attrs,
|
|
65
|
+
parameters = _this$props$node$attr.parameters,
|
|
66
|
+
extensionKey = _this$props$node$attr.extensionKey;
|
|
67
|
+
var name = this.props.node.type.name;
|
|
68
|
+
var params = parameters && parameters.macroParams;
|
|
69
|
+
var title = parameters && parameters.extensionTitle || parameters && parameters.macroMetadata && parameters.macroMetadata.title || extensionKey;
|
|
70
|
+
var isBlockExtension = name === 'extension';
|
|
71
|
+
return jsx("div", {
|
|
72
|
+
"data-testid": "lozenge-fallback",
|
|
73
|
+
css: placeholderFallback
|
|
74
|
+
}, lozengeData && !isBlockExtension ? this.renderImage(_objectSpread({
|
|
75
|
+
height: ICON_SIZE,
|
|
76
|
+
width: ICON_SIZE
|
|
77
|
+
}, lozengeData)) : jsx(EditorFileIcon, {
|
|
78
|
+
label: title
|
|
79
|
+
}), jsx("span", {
|
|
80
|
+
className: "extension-title"
|
|
81
|
+
}, capitalizeFirstLetter(title)), params && !isBlockExtension && jsx("span", {
|
|
82
|
+
css: placeholderFallbackParams
|
|
83
|
+
}, Object.keys(params).map(function (key) {
|
|
84
|
+
return key && " | ".concat(key, " = ").concat(params[key].value);
|
|
85
|
+
})));
|
|
86
|
+
}
|
|
87
|
+
}]);
|
|
88
|
+
return ExtensionLozenge;
|
|
89
|
+
}(Component);
|
|
90
|
+
export { ExtensionLozenge as default };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
2
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5;
|
|
3
|
+
import { css } from '@emotion/react';
|
|
4
|
+
import { B200, N20, N20A, N70 } from '@atlaskit/theme/colors';
|
|
5
|
+
import { BODIED_EXT_PADDING, EXTENSION_PADDING } from '../../styles';
|
|
6
|
+
export { EXTENSION_PADDING as padding, BODIED_EXT_PADDING };
|
|
7
|
+
export var wrapperDefault = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n background: ", ";\n border-radius: ", ";\n position: relative;\n vertical-align: middle;\n\n .ProseMirror-selectednode > span > & > .extension-overlay {\n box-shadow: inset 0px 0px 0px 2px ", ";\n opacity: 1;\n }\n\n &.with-overlay {\n .extension-overlay {\n background: ", ";\n color: transparent;\n }\n\n &:hover .extension-overlay {\n opacity: 1;\n }\n }\n"])), "var(--ds-background-neutral, ".concat(N20, ")"), "var(--ds-border-radius, 3px)", "var(--ds-border-selected, ".concat(B200, ")"), "var(--ds-background-neutral-hovered, ".concat(N20A, ")"));
|
|
8
|
+
export var overlay = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n border-radius: ", ";\n position: absolute;\n width: 100%;\n height: 100%;\n opacity: 0;\n pointer-events: none;\n transition: opacity 0.3s;\n"])), "var(--ds-border-radius, 3px)");
|
|
9
|
+
export var placeholderFallback = css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n display: inline-flex;\n align-items: center;\n\n & > img {\n margin: 0 ", ";\n }\n /* TODO: fix in develop: https://atlassian.slack.com/archives/CFG3PSQ9E/p1647395052443259?thread_ts=1647394572.556029&cid=CFG3PSQ9E */\n /* stylelint-disable-next-line */\n label: placeholder-fallback;\n"])), "var(--ds-space-050, 4px)");
|
|
10
|
+
export var placeholderFallbackParams = css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n display: inline-block;\n max-width: 200px;\n margin-left: 5px;\n color: ", ";\n text-overflow: ellipsis;\n white-space: nowrap;\n overflow: hidden;\n"])), "var(--ds-text-subtlest, ".concat(N70, ")"));
|
|
11
|
+
export var styledImage = css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n max-height: 16px;\n max-width: 16px;\n /* TODO: fix in develop: https://atlassian.slack.com/archives/CFG3PSQ9E/p1647395052443259?thread_ts=1647394572.556029&cid=CFG3PSQ9E */\n /* stylelint-disable-next-line */\n label: lozenge-image;\n"])));
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
+
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
4
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
|
5
|
+
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
6
|
+
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
7
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
8
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
9
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
10
|
+
import React, { Component } from 'react';
|
|
11
|
+
import { ProviderFactory, WithProviders } from '../provider-factory';
|
|
12
|
+
import { ExtensionComponent } from './ExtensionComponent';
|
|
13
|
+
export var Extension = /*#__PURE__*/function (_Component) {
|
|
14
|
+
_inherits(Extension, _Component);
|
|
15
|
+
var _super = _createSuper(Extension);
|
|
16
|
+
function Extension(props) {
|
|
17
|
+
var _this;
|
|
18
|
+
_classCallCheck(this, Extension);
|
|
19
|
+
_this = _super.call(this, props);
|
|
20
|
+
_defineProperty(_assertThisInitialized(_this), "renderWithProvider", function (_ref) {
|
|
21
|
+
var extensionProvider = _ref.extensionProvider;
|
|
22
|
+
var _this$props = _this.props,
|
|
23
|
+
node = _this$props.node,
|
|
24
|
+
getPos = _this$props.getPos,
|
|
25
|
+
editorView = _this$props.editorView,
|
|
26
|
+
handleContentDOMRef = _this$props.handleContentDOMRef,
|
|
27
|
+
extensionHandlers = _this$props.extensionHandlers,
|
|
28
|
+
references = _this$props.references,
|
|
29
|
+
editorAppearance = _this$props.editorAppearance,
|
|
30
|
+
pluginInjectionApi = _this$props.pluginInjectionApi,
|
|
31
|
+
eventDispatcher = _this$props.eventDispatcher;
|
|
32
|
+
return /*#__PURE__*/React.createElement(ExtensionComponent, {
|
|
33
|
+
editorView: editorView,
|
|
34
|
+
node: node,
|
|
35
|
+
getPos: getPos,
|
|
36
|
+
references: references,
|
|
37
|
+
extensionProvider: extensionProvider,
|
|
38
|
+
handleContentDOMRef: handleContentDOMRef,
|
|
39
|
+
extensionHandlers: extensionHandlers,
|
|
40
|
+
editorAppearance: editorAppearance,
|
|
41
|
+
pluginInjectionApi: pluginInjectionApi,
|
|
42
|
+
eventDispatcher: eventDispatcher
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
_this.providerFactory = props.providerFactory || new ProviderFactory();
|
|
46
|
+
return _this;
|
|
47
|
+
}
|
|
48
|
+
_createClass(Extension, [{
|
|
49
|
+
key: "componentWillUnmount",
|
|
50
|
+
value: function componentWillUnmount() {
|
|
51
|
+
if (!this.props.providerFactory) {
|
|
52
|
+
// new ProviderFactory is created if no `providers` has been set
|
|
53
|
+
// in this case when component is unmounted it's safe to destroy this providerFactory
|
|
54
|
+
this.providerFactory.destroy();
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}, {
|
|
58
|
+
key: "render",
|
|
59
|
+
value: function render() {
|
|
60
|
+
return /*#__PURE__*/React.createElement(WithProviders, {
|
|
61
|
+
providers: ['extensionProvider'],
|
|
62
|
+
providerFactory: this.providerFactory,
|
|
63
|
+
renderNode: this.renderWithProvider
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}]);
|
|
67
|
+
return Extension;
|
|
68
|
+
}(Component);
|
|
69
|
+
_defineProperty(Extension, "displayName", 'Extension');
|