@atlaskit/editor-common 76.34.0 → 76.36.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 +53 -1
- 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/i18n/cs.js +5 -2
- package/dist/cjs/i18n/da.js +5 -2
- package/dist/cjs/i18n/de.js +5 -2
- package/dist/cjs/i18n/en.js +7 -1
- package/dist/cjs/i18n/en_GB.js +8 -2
- package/dist/cjs/i18n/en_ZZ.js +8 -2
- package/dist/cjs/i18n/es.js +5 -2
- package/dist/cjs/i18n/fi.js +5 -2
- package/dist/cjs/i18n/fr.js +5 -2
- package/dist/cjs/i18n/hu.js +5 -2
- package/dist/cjs/i18n/it.js +5 -2
- package/dist/cjs/i18n/ja.js +1 -2
- package/dist/cjs/i18n/ko.js +5 -2
- package/dist/cjs/i18n/nb.js +1 -2
- package/dist/cjs/i18n/nl.js +5 -2
- package/dist/cjs/i18n/pl.js +5 -2
- package/dist/cjs/i18n/pt_BR.js +5 -2
- package/dist/cjs/i18n/ru.js +5 -2
- package/dist/cjs/i18n/sv.js +5 -2
- package/dist/cjs/i18n/th.js +5 -2
- package/dist/cjs/i18n/tr.js +5 -2
- package/dist/cjs/i18n/uk.js +5 -2
- package/dist/cjs/i18n/vi.js +5 -2
- package/dist/cjs/i18n/zh.js +5 -2
- package/dist/cjs/i18n/zh_TW.js +5 -2
- package/dist/cjs/link/LinkPicker/HyperlinkAddToolbar/HyperlinkAddToolbar.js +2 -1
- package/dist/cjs/link/LinkPicker/HyperlinkAddToolbar/index.js +1 -2
- package/dist/cjs/monitoring/error.js +3 -2
- package/dist/cjs/ui/DropList/index.js +1 -1
- 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/i18n/cs.js +5 -2
- package/dist/es2019/i18n/da.js +5 -2
- package/dist/es2019/i18n/de.js +5 -2
- package/dist/es2019/i18n/en.js +7 -1
- package/dist/es2019/i18n/en_GB.js +8 -2
- package/dist/es2019/i18n/en_ZZ.js +8 -2
- package/dist/es2019/i18n/es.js +5 -2
- package/dist/es2019/i18n/fi.js +5 -2
- package/dist/es2019/i18n/fr.js +5 -2
- package/dist/es2019/i18n/hu.js +5 -2
- package/dist/es2019/i18n/it.js +5 -2
- package/dist/es2019/i18n/ja.js +1 -2
- package/dist/es2019/i18n/ko.js +5 -2
- package/dist/es2019/i18n/nb.js +1 -2
- package/dist/es2019/i18n/nl.js +5 -2
- package/dist/es2019/i18n/pl.js +5 -2
- package/dist/es2019/i18n/pt_BR.js +5 -2
- package/dist/es2019/i18n/ru.js +5 -2
- package/dist/es2019/i18n/sv.js +5 -2
- package/dist/es2019/i18n/th.js +5 -2
- package/dist/es2019/i18n/tr.js +5 -2
- package/dist/es2019/i18n/uk.js +5 -2
- package/dist/es2019/i18n/vi.js +5 -2
- package/dist/es2019/i18n/zh.js +5 -2
- package/dist/es2019/i18n/zh_TW.js +5 -2
- package/dist/es2019/link/LinkPicker/HyperlinkAddToolbar/HyperlinkAddToolbar.js +2 -1
- package/dist/es2019/link/LinkPicker/HyperlinkAddToolbar/index.js +1 -4
- package/dist/es2019/monitoring/error.js +3 -2
- package/dist/es2019/ui/DropList/index.js +1 -1
- 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/i18n/cs.js +5 -2
- package/dist/esm/i18n/da.js +5 -2
- package/dist/esm/i18n/de.js +5 -2
- package/dist/esm/i18n/en.js +7 -1
- package/dist/esm/i18n/en_GB.js +8 -2
- package/dist/esm/i18n/en_ZZ.js +8 -2
- package/dist/esm/i18n/es.js +5 -2
- package/dist/esm/i18n/fi.js +5 -2
- package/dist/esm/i18n/fr.js +5 -2
- package/dist/esm/i18n/hu.js +5 -2
- package/dist/esm/i18n/it.js +5 -2
- package/dist/esm/i18n/ja.js +1 -2
- package/dist/esm/i18n/ko.js +5 -2
- package/dist/esm/i18n/nb.js +1 -2
- package/dist/esm/i18n/nl.js +5 -2
- package/dist/esm/i18n/pl.js +5 -2
- package/dist/esm/i18n/pt_BR.js +5 -2
- package/dist/esm/i18n/ru.js +5 -2
- package/dist/esm/i18n/sv.js +5 -2
- package/dist/esm/i18n/th.js +5 -2
- package/dist/esm/i18n/tr.js +5 -2
- package/dist/esm/i18n/uk.js +5 -2
- package/dist/esm/i18n/vi.js +5 -2
- package/dist/esm/i18n/zh.js +5 -2
- package/dist/esm/i18n/zh_TW.js +5 -2
- package/dist/esm/link/LinkPicker/HyperlinkAddToolbar/HyperlinkAddToolbar.js +2 -1
- package/dist/esm/link/LinkPicker/HyperlinkAddToolbar/index.js +1 -2
- package/dist/esm/monitoring/error.js +3 -2
- package/dist/esm/ui/DropList/index.js +1 -1
- 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/i18n/cs.d.ts +5 -2
- package/dist/types/i18n/da.d.ts +5 -2
- package/dist/types/i18n/de.d.ts +5 -2
- package/dist/types/i18n/en.d.ts +7 -1
- package/dist/types/i18n/en_GB.d.ts +7 -1
- package/dist/types/i18n/en_ZZ.d.ts +7 -1
- package/dist/types/i18n/es.d.ts +5 -2
- package/dist/types/i18n/fi.d.ts +5 -2
- package/dist/types/i18n/fr.d.ts +5 -2
- package/dist/types/i18n/hu.d.ts +5 -2
- package/dist/types/i18n/it.d.ts +5 -2
- package/dist/types/i18n/ja.d.ts +1 -2
- package/dist/types/i18n/ko.d.ts +5 -2
- package/dist/types/i18n/nb.d.ts +1 -2
- package/dist/types/i18n/nl.d.ts +5 -2
- package/dist/types/i18n/pl.d.ts +5 -2
- package/dist/types/i18n/pt_BR.d.ts +5 -2
- package/dist/types/i18n/ru.d.ts +5 -2
- package/dist/types/i18n/sv.d.ts +5 -2
- package/dist/types/i18n/th.d.ts +5 -2
- package/dist/types/i18n/tr.d.ts +5 -2
- package/dist/types/i18n/uk.d.ts +5 -2
- package/dist/types/i18n/vi.d.ts +5 -2
- package/dist/types/i18n/zh.d.ts +5 -2
- package/dist/types/i18n/zh_TW.d.ts +5 -2
- package/dist/types/link/LinkPicker/HyperlinkAddToolbar/index.d.ts +7 -7
- package/dist/types/types/floating-toolbar.d.ts +1 -1
- package/dist/types/types/hyperlink.d.ts +1 -0
- 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/OverflowShadow/index.d.ts +1 -1
- package/dist/types/ui/with-outer-listeners.d.ts +2 -2
- 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/ui-react/with-react-editor-view-outer-listeners.d.ts +2 -2
- 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/i18n/cs.d.ts +5 -2
- package/dist/types-ts4.5/i18n/da.d.ts +5 -2
- package/dist/types-ts4.5/i18n/de.d.ts +5 -2
- package/dist/types-ts4.5/i18n/en.d.ts +7 -1
- package/dist/types-ts4.5/i18n/en_GB.d.ts +7 -1
- package/dist/types-ts4.5/i18n/en_ZZ.d.ts +7 -1
- package/dist/types-ts4.5/i18n/es.d.ts +5 -2
- package/dist/types-ts4.5/i18n/fi.d.ts +5 -2
- package/dist/types-ts4.5/i18n/fr.d.ts +5 -2
- package/dist/types-ts4.5/i18n/hu.d.ts +5 -2
- package/dist/types-ts4.5/i18n/it.d.ts +5 -2
- package/dist/types-ts4.5/i18n/ja.d.ts +1 -2
- package/dist/types-ts4.5/i18n/ko.d.ts +5 -2
- package/dist/types-ts4.5/i18n/nb.d.ts +1 -2
- package/dist/types-ts4.5/i18n/nl.d.ts +5 -2
- package/dist/types-ts4.5/i18n/pl.d.ts +5 -2
- package/dist/types-ts4.5/i18n/pt_BR.d.ts +5 -2
- package/dist/types-ts4.5/i18n/ru.d.ts +5 -2
- package/dist/types-ts4.5/i18n/sv.d.ts +5 -2
- package/dist/types-ts4.5/i18n/th.d.ts +5 -2
- package/dist/types-ts4.5/i18n/tr.d.ts +5 -2
- package/dist/types-ts4.5/i18n/uk.d.ts +5 -2
- package/dist/types-ts4.5/i18n/vi.d.ts +5 -2
- package/dist/types-ts4.5/i18n/zh.d.ts +5 -2
- package/dist/types-ts4.5/i18n/zh_TW.d.ts +5 -2
- package/dist/types-ts4.5/link/LinkPicker/HyperlinkAddToolbar/index.d.ts +7 -7
- package/dist/types-ts4.5/types/floating-toolbar.d.ts +1 -1
- package/dist/types-ts4.5/types/hyperlink.d.ts +1 -0
- 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/OverflowShadow/index.d.ts +1 -1
- package/dist/types-ts4.5/ui/with-outer-listeners.d.ts +2 -2
- 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/ui-react/with-react-editor-view-outer-listeners.d.ts +2 -2
- package/extensibility/package.json +15 -0
- package/package.json +8 -7
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
const 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
|
+
const code = hash[isMark ? 'marks' : 'nodes'][type];
|
|
64
|
+
return code ? code : type;
|
|
65
|
+
}
|
|
66
|
+
function compactStringifier(node) {
|
|
67
|
+
var _node$marks;
|
|
68
|
+
const isContentEmpty = !node.content;
|
|
69
|
+
const isTextNode = (node === null || node === void 0 ? void 0 : node.type) === 'text';
|
|
70
|
+
const hasMarks = (_node$marks = node.marks) === null || _node$marks === void 0 ? void 0 : _node$marks.length;
|
|
71
|
+
const isContentArray = Array.isArray(node.content);
|
|
72
|
+
const marks = child => {
|
|
73
|
+
if (hasMarks) {
|
|
74
|
+
return node.marks.reduce((str, mark) => `${shortHash(mark, true)}(${str})`, child);
|
|
75
|
+
}
|
|
76
|
+
return child;
|
|
77
|
+
};
|
|
78
|
+
let content;
|
|
79
|
+
if (isTextNode) {
|
|
80
|
+
content = String(node.nodeSize);
|
|
81
|
+
} else if (isContentEmpty) {
|
|
82
|
+
content = '';
|
|
83
|
+
} else if (isContentArray) {
|
|
84
|
+
content = node.content.map(node => compactStringifier(node)).join(',');
|
|
85
|
+
}
|
|
86
|
+
return marks(`${shortHash(node.type, false)}(${content})`);
|
|
87
|
+
}
|
|
88
|
+
export const getDocStructure = (doc, options) => {
|
|
89
|
+
try {
|
|
90
|
+
const result = getBlockNode(doc, 0);
|
|
91
|
+
if (options !== null && options !== void 0 && options.compact) {
|
|
92
|
+
return compactStringifier(result);
|
|
93
|
+
}
|
|
94
|
+
return result;
|
|
95
|
+
} catch (error) {
|
|
96
|
+
return `Error logging document structure: ${error}`;
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
const getBlockNode = (node, pos) => {
|
|
100
|
+
const blockNode = {
|
|
101
|
+
type: node.type.name,
|
|
102
|
+
pos,
|
|
103
|
+
nodeSize: node.nodeSize
|
|
104
|
+
};
|
|
105
|
+
const content = getBlockNodeContent(node.content, pos);
|
|
106
|
+
if (content.length > 0) {
|
|
107
|
+
blockNode.content = content;
|
|
108
|
+
}
|
|
109
|
+
const marks = getMarks(node);
|
|
110
|
+
if (marks.length > 0) {
|
|
111
|
+
blockNode.marks = marks;
|
|
112
|
+
}
|
|
113
|
+
return blockNode;
|
|
114
|
+
};
|
|
115
|
+
const getBlockNodeContent = (node, pos) => {
|
|
116
|
+
if (!node || !node.content || !node.content.length) {
|
|
117
|
+
return [];
|
|
118
|
+
}
|
|
119
|
+
let blockNodeContent = [];
|
|
120
|
+
const {
|
|
121
|
+
content
|
|
122
|
+
} = node;
|
|
123
|
+
if (content[0].isBlock) {
|
|
124
|
+
// children are block nodes
|
|
125
|
+
let prevNode;
|
|
126
|
+
blockNodeContent = content.map(node => {
|
|
127
|
+
pos += prevNode ? prevNode.nodeSize : 1;
|
|
128
|
+
prevNode = node;
|
|
129
|
+
return getBlockNode(node, pos);
|
|
130
|
+
});
|
|
131
|
+
} else {
|
|
132
|
+
// children are inline nodes .
|
|
133
|
+
const result = getInlineNodes(content, pos);
|
|
134
|
+
blockNodeContent = result.inlineNodes;
|
|
135
|
+
pos = result.pos;
|
|
136
|
+
}
|
|
137
|
+
return blockNodeContent;
|
|
138
|
+
};
|
|
139
|
+
const getInlineNodes = (nodes, pos) => {
|
|
140
|
+
let inlineNodes = nodes.map(node => {
|
|
141
|
+
const {
|
|
142
|
+
nodeSize
|
|
143
|
+
} = node;
|
|
144
|
+
const inlineNode = {
|
|
145
|
+
type: node.type.name,
|
|
146
|
+
pos,
|
|
147
|
+
nodeSize
|
|
148
|
+
};
|
|
149
|
+
const marks = getMarks(node);
|
|
150
|
+
if (marks.length > 0) {
|
|
151
|
+
inlineNode.marks = marks;
|
|
152
|
+
}
|
|
153
|
+
pos += nodeSize;
|
|
154
|
+
return inlineNode;
|
|
155
|
+
});
|
|
156
|
+
return {
|
|
157
|
+
inlineNodes,
|
|
158
|
+
pos
|
|
159
|
+
};
|
|
160
|
+
};
|
|
161
|
+
const getMarks = node => node.marks.map(mark => mark.type.name);
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export { insideTable } from './inside';
|
|
1
|
+
export { insideTable } from './inside';
|
|
2
|
+
export { getDocStructure } from './document-logger';
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
/** @jsx jsx */
|
|
3
|
+
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import { jsx } from '@emotion/react';
|
|
6
|
+
import classnames from 'classnames';
|
|
7
|
+
import { WithPluginState } from '../../..//with-plugin-state';
|
|
8
|
+
import { useSharedPluginState } from '../../../hooks';
|
|
9
|
+
import { overflowShadow } from '../../../ui';
|
|
10
|
+
import { calculateBreakoutStyles } from '../../../utils';
|
|
11
|
+
import ExtensionLozenge from '../Lozenge';
|
|
12
|
+
import { overlay } from '../styles';
|
|
13
|
+
import { content, contentWrapper, header, widerLayoutClassName, wrapperStyle } from './styles';
|
|
14
|
+
function ExtensionWithPluginState(props) {
|
|
15
|
+
const {
|
|
16
|
+
node,
|
|
17
|
+
handleContentDOMRef,
|
|
18
|
+
children,
|
|
19
|
+
widthState = {
|
|
20
|
+
width: 0
|
|
21
|
+
},
|
|
22
|
+
handleRef,
|
|
23
|
+
shadowClassNames,
|
|
24
|
+
hideFrame,
|
|
25
|
+
editorAppearance
|
|
26
|
+
} = props;
|
|
27
|
+
const hasBody = ['bodiedExtension', 'multiBodiedExtension'].includes(node.type.name);
|
|
28
|
+
const isMobile = editorAppearance === 'mobile';
|
|
29
|
+
const hasChildren = !!children;
|
|
30
|
+
const removeBorder = hideFrame && !isMobile && !hasBody || false;
|
|
31
|
+
const {
|
|
32
|
+
getPos,
|
|
33
|
+
view
|
|
34
|
+
} = props;
|
|
35
|
+
const isTopLevelNode = React.useMemo(() => {
|
|
36
|
+
const pos = typeof getPos === 'function' ? getPos() : undefined;
|
|
37
|
+
return typeof pos !== 'undefined' && !isNaN(pos) && view.state.doc.resolve(pos).depth === 0;
|
|
38
|
+
return false;
|
|
39
|
+
}, [view, getPos]);
|
|
40
|
+
const shouldBreakout =
|
|
41
|
+
// Extension should breakout when the layout is set to 'full-width' or 'wide'.
|
|
42
|
+
['full-width', 'wide'].includes(node.attrs.layout) &&
|
|
43
|
+
// Extension breakout state should only be respected for top level nodes.
|
|
44
|
+
isTopLevelNode &&
|
|
45
|
+
// Extension breakout state should not be respected when the editor appearance is full-width mode
|
|
46
|
+
editorAppearance !== 'full-width';
|
|
47
|
+
const classNames = classnames('extension-container', 'block', shadowClassNames, {
|
|
48
|
+
'with-overlay': !hasBody,
|
|
49
|
+
'without-frame': removeBorder,
|
|
50
|
+
[widerLayoutClassName]: shouldBreakout
|
|
51
|
+
});
|
|
52
|
+
const headerClassNames = classnames({
|
|
53
|
+
'with-children': hasChildren,
|
|
54
|
+
'without-frame': removeBorder
|
|
55
|
+
});
|
|
56
|
+
let customContainerStyles = {
|
|
57
|
+
width: '100%'
|
|
58
|
+
};
|
|
59
|
+
let newContentStyles = {};
|
|
60
|
+
if (shouldBreakout) {
|
|
61
|
+
const {
|
|
62
|
+
type,
|
|
63
|
+
...breakoutStyles
|
|
64
|
+
} = calculateBreakoutStyles({
|
|
65
|
+
mode: node.attrs.layout,
|
|
66
|
+
widthStateWidth: widthState.width,
|
|
67
|
+
widthStateLineLength: widthState.lineLength
|
|
68
|
+
});
|
|
69
|
+
newContentStyles = {
|
|
70
|
+
...breakoutStyles
|
|
71
|
+
};
|
|
72
|
+
customContainerStyles = breakoutStyles;
|
|
73
|
+
}
|
|
74
|
+
newContentStyles = {
|
|
75
|
+
...newContentStyles,
|
|
76
|
+
...contentWrapper
|
|
77
|
+
};
|
|
78
|
+
return jsx("div", {
|
|
79
|
+
ref: handleRef,
|
|
80
|
+
"data-layout": node.attrs.layout,
|
|
81
|
+
className: classNames,
|
|
82
|
+
css: wrapperStyle,
|
|
83
|
+
style: customContainerStyles
|
|
84
|
+
}, jsx("div", {
|
|
85
|
+
className: `extension-overflow-wrapper ${hasBody ? 'with-body' : ''}`
|
|
86
|
+
}, jsx("div", {
|
|
87
|
+
css: overlay,
|
|
88
|
+
className: "extension-overlay"
|
|
89
|
+
}), jsx("div", {
|
|
90
|
+
css: header,
|
|
91
|
+
contentEditable: false,
|
|
92
|
+
className: headerClassNames
|
|
93
|
+
}, !removeBorder && jsx(ExtensionLozenge, {
|
|
94
|
+
node: node
|
|
95
|
+
}), children), hasBody && jsx("div", {
|
|
96
|
+
css: newContentStyles
|
|
97
|
+
}, jsx("div", {
|
|
98
|
+
css: content,
|
|
99
|
+
ref: handleContentDOMRef,
|
|
100
|
+
className: "extension-content block"
|
|
101
|
+
}))));
|
|
102
|
+
}
|
|
103
|
+
const Extension = props => {
|
|
104
|
+
// TODO: ED-17836 This code is here because confluence injects
|
|
105
|
+
// the `editor-referentiality` plugin via `dangerouslyAppendPlugins`
|
|
106
|
+
// which cannot access the `pluginInjectionApi`. When we move
|
|
107
|
+
// Confluence to using presets we can remove this workaround.
|
|
108
|
+
const {
|
|
109
|
+
pluginInjectionApi
|
|
110
|
+
} = props;
|
|
111
|
+
return pluginInjectionApi === undefined ? jsx(ExtensionDeprecated, props) : jsx(ExtensionWithSharedState, props);
|
|
112
|
+
};
|
|
113
|
+
const ExtensionWithSharedState = props => {
|
|
114
|
+
const {
|
|
115
|
+
pluginInjectionApi
|
|
116
|
+
} = props;
|
|
117
|
+
const {
|
|
118
|
+
widthState
|
|
119
|
+
} = useSharedPluginState(pluginInjectionApi, ['width']);
|
|
120
|
+
return jsx(ExtensionWithPluginState, _extends({
|
|
121
|
+
widthState: widthState
|
|
122
|
+
}, props));
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
// TODO: ED-17836 This code is here because Confluence injects
|
|
126
|
+
// the `editor-referentiality` plugin via `dangerouslyAppendPlugins`
|
|
127
|
+
// which cannot access the `pluginInjectionApi`. When we move
|
|
128
|
+
// Confluence to using presets we can remove this workaround.
|
|
129
|
+
// @ts-ignore
|
|
130
|
+
const widthPluginKey = {
|
|
131
|
+
key: 'widthPlugin$',
|
|
132
|
+
getState: state => {
|
|
133
|
+
return state['widthPlugin$'];
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
const ExtensionDeprecated = props => {
|
|
137
|
+
return jsx(WithPluginState, {
|
|
138
|
+
editorView: props.view,
|
|
139
|
+
plugins: {
|
|
140
|
+
widthState: widthPluginKey
|
|
141
|
+
},
|
|
142
|
+
render: ({
|
|
143
|
+
widthState
|
|
144
|
+
}) => jsx(ExtensionWithPluginState, _extends({
|
|
145
|
+
widthState: widthState
|
|
146
|
+
}, props))
|
|
147
|
+
});
|
|
148
|
+
};
|
|
149
|
+
/**
|
|
150
|
+
* End workaround
|
|
151
|
+
*/
|
|
152
|
+
|
|
153
|
+
export default overflowShadow(Extension, {
|
|
154
|
+
overflowSelector: '.extension-overflow-wrapper'
|
|
155
|
+
});
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { css } from '@emotion/react';
|
|
2
|
+
import { N30 } from '@atlaskit/theme/colors';
|
|
3
|
+
import { padding, wrapperDefault } from '../styles';
|
|
4
|
+
export const widerLayoutClassName = 'wider-layout';
|
|
5
|
+
export const wrapperStyle = css`
|
|
6
|
+
${wrapperDefault}
|
|
7
|
+
|
|
8
|
+
&.without-frame {
|
|
9
|
+
background: transparent;
|
|
10
|
+
}
|
|
11
|
+
cursor: pointer;
|
|
12
|
+
width: 100%;
|
|
13
|
+
|
|
14
|
+
.extension-overflow-wrapper:not(.with-body) {
|
|
15
|
+
overflow-x: auto;
|
|
16
|
+
}
|
|
17
|
+
`;
|
|
18
|
+
export const header = css`
|
|
19
|
+
padding: ${padding / 2}px ${padding / 2}px 0px;
|
|
20
|
+
vertical-align: middle;
|
|
21
|
+
|
|
22
|
+
&.with-children:not(.without-frame) {
|
|
23
|
+
padding: ${"var(--ds-space-050, 4px)"} ${"var(--ds-space-100, 8px)"}
|
|
24
|
+
${"var(--ds-space-100, 8px)"};
|
|
25
|
+
}
|
|
26
|
+
&.without-frame {
|
|
27
|
+
padding: 0;
|
|
28
|
+
}
|
|
29
|
+
`;
|
|
30
|
+
export const content = css`
|
|
31
|
+
padding: ${padding}px;
|
|
32
|
+
background: ${"var(--ds-surface, white)"};
|
|
33
|
+
border: 1px solid ${`var(--ds-border, ${N30})`};
|
|
34
|
+
border-radius: ${"var(--ds-border-radius, 3px)"};
|
|
35
|
+
cursor: initial;
|
|
36
|
+
width: 100%;
|
|
37
|
+
`;
|
|
38
|
+
export const contentWrapper = css`
|
|
39
|
+
padding: 0 ${padding}px ${padding}px;
|
|
40
|
+
display: flex;
|
|
41
|
+
justify-content: center;
|
|
42
|
+
`;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { Component } from 'react';
|
|
4
|
+
import { jsx } from '@emotion/react';
|
|
5
|
+
import ExtensionLozenge from '../Lozenge';
|
|
6
|
+
import { overlay } from '../styles';
|
|
7
|
+
import { wrapperStyle } from './styles';
|
|
8
|
+
export default class InlineExtension extends Component {
|
|
9
|
+
render() {
|
|
10
|
+
const {
|
|
11
|
+
node,
|
|
12
|
+
children
|
|
13
|
+
} = this.props;
|
|
14
|
+
const hasChildren = !!children;
|
|
15
|
+
const className = hasChildren ? 'with-overlay with-children' : 'with-overlay';
|
|
16
|
+
return jsx("div", {
|
|
17
|
+
css: wrapperStyle,
|
|
18
|
+
className: `extension-container inline ${className}`
|
|
19
|
+
}, jsx("div", {
|
|
20
|
+
css: overlay,
|
|
21
|
+
className: "extension-overlay"
|
|
22
|
+
}), children ? children : jsx(ExtensionLozenge, {
|
|
23
|
+
node: node
|
|
24
|
+
}));
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { css } from '@emotion/react';
|
|
2
|
+
import { wrapperDefault } from '../styles';
|
|
3
|
+
export const wrapperStyle = css`
|
|
4
|
+
${wrapperDefault}
|
|
5
|
+
|
|
6
|
+
cursor: pointer;
|
|
7
|
+
display: inline-flex;
|
|
8
|
+
margin: 1px 1px ${"var(--ds-space-050, 4px)"};
|
|
9
|
+
|
|
10
|
+
> img {
|
|
11
|
+
border-radius: ${"var(--ds-border-radius, 3px)"};
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
&::after,
|
|
15
|
+
&::before {
|
|
16
|
+
vertical-align: text-top;
|
|
17
|
+
display: inline-block;
|
|
18
|
+
width: 1px;
|
|
19
|
+
content: '';
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
&.with-children {
|
|
23
|
+
padding: 0;
|
|
24
|
+
background: ${"var(--ds-background-neutral-subtle, white)"};
|
|
25
|
+
}
|
|
26
|
+
`;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
/** @jsx jsx */
|
|
3
|
+
import { Component } from 'react';
|
|
4
|
+
import { jsx } from '@emotion/react';
|
|
5
|
+
import EditorFileIcon from '@atlaskit/icon/glyph/editor/file';
|
|
6
|
+
import { getExtensionLozengeData } from '../../utils';
|
|
7
|
+
import { placeholderFallback, placeholderFallbackParams, styledImage } from './styles';
|
|
8
|
+
export const capitalizeFirstLetter = str => {
|
|
9
|
+
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
10
|
+
};
|
|
11
|
+
export const ICON_SIZE = 24;
|
|
12
|
+
export default class ExtensionLozenge extends Component {
|
|
13
|
+
render() {
|
|
14
|
+
const {
|
|
15
|
+
node
|
|
16
|
+
} = this.props;
|
|
17
|
+
const imageData = getExtensionLozengeData({
|
|
18
|
+
node,
|
|
19
|
+
type: 'image'
|
|
20
|
+
});
|
|
21
|
+
if (imageData && node.type.name !== 'extension') {
|
|
22
|
+
return this.renderImage(imageData);
|
|
23
|
+
}
|
|
24
|
+
const iconData = getExtensionLozengeData({
|
|
25
|
+
node,
|
|
26
|
+
type: 'icon'
|
|
27
|
+
});
|
|
28
|
+
return this.renderFallback(iconData);
|
|
29
|
+
}
|
|
30
|
+
renderImage(lozengeData) {
|
|
31
|
+
const {
|
|
32
|
+
extensionKey
|
|
33
|
+
} = this.props.node.attrs;
|
|
34
|
+
const {
|
|
35
|
+
url,
|
|
36
|
+
...rest
|
|
37
|
+
} = lozengeData;
|
|
38
|
+
return jsx("img", _extends({
|
|
39
|
+
css: styledImage,
|
|
40
|
+
src: url
|
|
41
|
+
}, rest, {
|
|
42
|
+
alt: extensionKey
|
|
43
|
+
}));
|
|
44
|
+
}
|
|
45
|
+
renderFallback(lozengeData) {
|
|
46
|
+
const {
|
|
47
|
+
parameters,
|
|
48
|
+
extensionKey
|
|
49
|
+
} = this.props.node.attrs;
|
|
50
|
+
const {
|
|
51
|
+
name
|
|
52
|
+
} = this.props.node.type;
|
|
53
|
+
const params = parameters && parameters.macroParams;
|
|
54
|
+
const title = parameters && parameters.extensionTitle || parameters && parameters.macroMetadata && parameters.macroMetadata.title || extensionKey;
|
|
55
|
+
const isBlockExtension = name === 'extension';
|
|
56
|
+
return jsx("div", {
|
|
57
|
+
"data-testid": "lozenge-fallback",
|
|
58
|
+
css: placeholderFallback
|
|
59
|
+
}, lozengeData && !isBlockExtension ? this.renderImage({
|
|
60
|
+
height: ICON_SIZE,
|
|
61
|
+
width: ICON_SIZE,
|
|
62
|
+
...lozengeData
|
|
63
|
+
}) : jsx(EditorFileIcon, {
|
|
64
|
+
label: title
|
|
65
|
+
}), jsx("span", {
|
|
66
|
+
className: "extension-title"
|
|
67
|
+
}, capitalizeFirstLetter(title)), params && !isBlockExtension && jsx("span", {
|
|
68
|
+
css: placeholderFallbackParams
|
|
69
|
+
}, Object.keys(params).map(key => key && ` | ${key} = ${params[key].value}`)));
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { css } from '@emotion/react';
|
|
2
|
+
import { B200, N20, N20A, N70 } from '@atlaskit/theme/colors';
|
|
3
|
+
import { BODIED_EXT_PADDING, EXTENSION_PADDING } from '../../styles';
|
|
4
|
+
export { EXTENSION_PADDING as padding, BODIED_EXT_PADDING };
|
|
5
|
+
export const wrapperDefault = css`
|
|
6
|
+
background: ${`var(--ds-background-neutral, ${N20})`};
|
|
7
|
+
border-radius: ${"var(--ds-border-radius, 3px)"};
|
|
8
|
+
position: relative;
|
|
9
|
+
vertical-align: middle;
|
|
10
|
+
|
|
11
|
+
.ProseMirror-selectednode > span > & > .extension-overlay {
|
|
12
|
+
box-shadow: inset 0px 0px 0px 2px ${`var(--ds-border-selected, ${B200})`};
|
|
13
|
+
opacity: 1;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
&.with-overlay {
|
|
17
|
+
.extension-overlay {
|
|
18
|
+
background: ${`var(--ds-background-neutral-hovered, ${N20A})`};
|
|
19
|
+
color: transparent;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
&:hover .extension-overlay {
|
|
23
|
+
opacity: 1;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
`;
|
|
27
|
+
export const overlay = css`
|
|
28
|
+
border-radius: ${"var(--ds-border-radius, 3px)"};
|
|
29
|
+
position: absolute;
|
|
30
|
+
width: 100%;
|
|
31
|
+
height: 100%;
|
|
32
|
+
opacity: 0;
|
|
33
|
+
pointer-events: none;
|
|
34
|
+
transition: opacity 0.3s;
|
|
35
|
+
`;
|
|
36
|
+
export const placeholderFallback = css`
|
|
37
|
+
display: inline-flex;
|
|
38
|
+
align-items: center;
|
|
39
|
+
|
|
40
|
+
& > img {
|
|
41
|
+
margin: 0 ${"var(--ds-space-050, 4px)"};
|
|
42
|
+
}
|
|
43
|
+
/* TODO: fix in develop: https://atlassian.slack.com/archives/CFG3PSQ9E/p1647395052443259?thread_ts=1647394572.556029&cid=CFG3PSQ9E */
|
|
44
|
+
/* stylelint-disable-next-line */
|
|
45
|
+
label: placeholder-fallback;
|
|
46
|
+
`;
|
|
47
|
+
export const placeholderFallbackParams = css`
|
|
48
|
+
display: inline-block;
|
|
49
|
+
max-width: 200px;
|
|
50
|
+
margin-left: 5px;
|
|
51
|
+
color: ${`var(--ds-text-subtlest, ${N70})`};
|
|
52
|
+
text-overflow: ellipsis;
|
|
53
|
+
white-space: nowrap;
|
|
54
|
+
overflow: hidden;
|
|
55
|
+
`;
|
|
56
|
+
export const styledImage = css`
|
|
57
|
+
max-height: 16px;
|
|
58
|
+
max-width: 16px;
|
|
59
|
+
/* TODO: fix in develop: https://atlassian.slack.com/archives/CFG3PSQ9E/p1647395052443259?thread_ts=1647394572.556029&cid=CFG3PSQ9E */
|
|
60
|
+
/* stylelint-disable-next-line */
|
|
61
|
+
label: lozenge-image;
|
|
62
|
+
`;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
import React, { Component } from 'react';
|
|
3
|
+
import { ProviderFactory, WithProviders } from '../provider-factory';
|
|
4
|
+
import { ExtensionComponent } from './ExtensionComponent';
|
|
5
|
+
export class Extension extends Component {
|
|
6
|
+
constructor(props) {
|
|
7
|
+
super(props);
|
|
8
|
+
_defineProperty(this, "renderWithProvider", ({
|
|
9
|
+
extensionProvider
|
|
10
|
+
}) => {
|
|
11
|
+
const {
|
|
12
|
+
node,
|
|
13
|
+
getPos,
|
|
14
|
+
editorView,
|
|
15
|
+
handleContentDOMRef,
|
|
16
|
+
extensionHandlers,
|
|
17
|
+
references,
|
|
18
|
+
editorAppearance,
|
|
19
|
+
pluginInjectionApi,
|
|
20
|
+
eventDispatcher
|
|
21
|
+
} = this.props;
|
|
22
|
+
return /*#__PURE__*/React.createElement(ExtensionComponent, {
|
|
23
|
+
editorView: editorView,
|
|
24
|
+
node: node,
|
|
25
|
+
getPos: getPos,
|
|
26
|
+
references: references,
|
|
27
|
+
extensionProvider: extensionProvider,
|
|
28
|
+
handleContentDOMRef: handleContentDOMRef,
|
|
29
|
+
extensionHandlers: extensionHandlers,
|
|
30
|
+
editorAppearance: editorAppearance,
|
|
31
|
+
pluginInjectionApi: pluginInjectionApi,
|
|
32
|
+
eventDispatcher: eventDispatcher
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
this.providerFactory = props.providerFactory || new ProviderFactory();
|
|
36
|
+
}
|
|
37
|
+
componentWillUnmount() {
|
|
38
|
+
if (!this.props.providerFactory) {
|
|
39
|
+
// new ProviderFactory is created if no `providers` has been set
|
|
40
|
+
// in this case when component is unmounted it's safe to destroy this providerFactory
|
|
41
|
+
this.providerFactory.destroy();
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
render() {
|
|
45
|
+
return /*#__PURE__*/React.createElement(WithProviders, {
|
|
46
|
+
providers: ['extensionProvider'],
|
|
47
|
+
providerFactory: this.providerFactory,
|
|
48
|
+
renderNode: this.renderWithProvider
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
_defineProperty(Extension, "displayName", 'Extension');
|