@atlaskit/editor-common 76.34.0 → 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.
Files changed (99) hide show
  1. package/CHANGELOG.md +42 -0
  2. package/dist/cjs/collab/index.js +27 -2
  3. package/dist/cjs/core-utils/document-logger.js +171 -0
  4. package/dist/cjs/core-utils/index.js +8 -1
  5. package/dist/cjs/extensibility/Extension/Extension/index.js +151 -0
  6. package/dist/cjs/extensibility/Extension/Extension/styles.js +17 -0
  7. package/dist/cjs/extensibility/Extension/InlineExtension/index.js +50 -0
  8. package/dist/cjs/extensibility/Extension/InlineExtension/styles.js +12 -0
  9. package/dist/cjs/extensibility/Extension/Lozenge.js +95 -0
  10. package/dist/cjs/extensibility/Extension/styles.js +30 -0
  11. package/dist/cjs/extensibility/Extension.js +79 -0
  12. package/dist/cjs/extensibility/ExtensionComponent.js +252 -0
  13. package/dist/cjs/extensibility/ExtensionNodeWrapper.js +21 -0
  14. package/dist/cjs/extensibility/MultiBodiedExtension/index.js +264 -0
  15. package/dist/cjs/extensibility/extensionNodeView.js +91 -0
  16. package/dist/cjs/extensibility/index.js +42 -0
  17. package/dist/cjs/extensibility/types.js +5 -0
  18. package/dist/cjs/monitoring/error.js +3 -2
  19. package/dist/cjs/ui/DropList/index.js +1 -1
  20. package/dist/es2019/collab/index.js +54 -1
  21. package/dist/es2019/core-utils/document-logger.js +161 -0
  22. package/dist/es2019/core-utils/index.js +2 -1
  23. package/dist/es2019/extensibility/Extension/Extension/index.js +155 -0
  24. package/dist/es2019/extensibility/Extension/Extension/styles.js +42 -0
  25. package/dist/es2019/extensibility/Extension/InlineExtension/index.js +26 -0
  26. package/dist/es2019/extensibility/Extension/InlineExtension/styles.js +26 -0
  27. package/dist/es2019/extensibility/Extension/Lozenge.js +71 -0
  28. package/dist/es2019/extensibility/Extension/styles.js +62 -0
  29. package/dist/es2019/extensibility/Extension.js +52 -0
  30. package/dist/es2019/extensibility/ExtensionComponent.js +204 -0
  31. package/dist/es2019/extensibility/ExtensionNodeWrapper.js +13 -0
  32. package/dist/es2019/extensibility/MultiBodiedExtension/index.js +283 -0
  33. package/dist/es2019/extensibility/extensionNodeView.js +62 -0
  34. package/dist/es2019/extensibility/index.js +4 -0
  35. package/dist/es2019/extensibility/types.js +1 -0
  36. package/dist/es2019/monitoring/error.js +3 -2
  37. package/dist/es2019/ui/DropList/index.js +1 -1
  38. package/dist/esm/collab/index.js +23 -1
  39. package/dist/esm/core-utils/document-logger.js +165 -0
  40. package/dist/esm/core-utils/index.js +2 -1
  41. package/dist/esm/extensibility/Extension/Extension/index.js +146 -0
  42. package/dist/esm/extensibility/Extension/Extension/styles.js +10 -0
  43. package/dist/esm/extensibility/Extension/InlineExtension/index.js +43 -0
  44. package/dist/esm/extensibility/Extension/InlineExtension/styles.js +5 -0
  45. package/dist/esm/extensibility/Extension/Lozenge.js +90 -0
  46. package/dist/esm/extensibility/Extension/styles.js +11 -0
  47. package/dist/esm/extensibility/Extension.js +69 -0
  48. package/dist/esm/extensibility/ExtensionComponent.js +243 -0
  49. package/dist/esm/extensibility/ExtensionNodeWrapper.js +14 -0
  50. package/dist/esm/extensibility/MultiBodiedExtension/index.js +257 -0
  51. package/dist/esm/extensibility/extensionNodeView.js +83 -0
  52. package/dist/esm/extensibility/index.js +4 -0
  53. package/dist/esm/extensibility/types.js +1 -0
  54. package/dist/esm/monitoring/error.js +3 -2
  55. package/dist/esm/ui/DropList/index.js +1 -1
  56. package/dist/types/collab/index.d.ts +7 -0
  57. package/dist/types/core-utils/document-logger.d.ts +6 -0
  58. package/dist/types/core-utils/index.d.ts +1 -0
  59. package/dist/types/extensibility/Extension/Extension/index.d.ts +108 -0
  60. package/dist/types/extensibility/Extension/Extension/styles.d.ts +5 -0
  61. package/dist/types/extensibility/Extension/InlineExtension/index.d.ts +12 -0
  62. package/dist/types/extensibility/Extension/InlineExtension/styles.d.ts +1 -0
  63. package/dist/types/extensibility/Extension/Lozenge.d.ts +14 -0
  64. package/dist/types/extensibility/Extension/styles.d.ts +7 -0
  65. package/dist/types/extensibility/Extension.d.ts +29 -0
  66. package/dist/types/extensibility/ExtensionComponent.d.ts +53 -0
  67. package/dist/types/extensibility/ExtensionNodeWrapper.d.ts +14 -0
  68. package/dist/types/extensibility/MultiBodiedExtension/index.d.ts +26 -0
  69. package/dist/types/extensibility/extensionNodeView.d.ts +31 -0
  70. package/dist/types/extensibility/index.d.ts +4 -0
  71. package/dist/types/extensibility/types.d.ts +6 -0
  72. package/dist/types/types/index.d.ts +1 -1
  73. package/dist/types/types/next-editor-plugin.d.ts +0 -1
  74. package/dist/types/ui/DropList/index.d.ts +1 -1
  75. package/dist/types/ui-menu/ColorPickerButton/index.d.ts +1 -1
  76. package/dist/types/ui-menu/ToolbarButton/index.d.ts +1 -1
  77. package/dist/types-ts4.5/collab/index.d.ts +7 -0
  78. package/dist/types-ts4.5/core-utils/document-logger.d.ts +6 -0
  79. package/dist/types-ts4.5/core-utils/index.d.ts +1 -0
  80. package/dist/types-ts4.5/extensibility/Extension/Extension/index.d.ts +108 -0
  81. package/dist/types-ts4.5/extensibility/Extension/Extension/styles.d.ts +5 -0
  82. package/dist/types-ts4.5/extensibility/Extension/InlineExtension/index.d.ts +12 -0
  83. package/dist/types-ts4.5/extensibility/Extension/InlineExtension/styles.d.ts +1 -0
  84. package/dist/types-ts4.5/extensibility/Extension/Lozenge.d.ts +14 -0
  85. package/dist/types-ts4.5/extensibility/Extension/styles.d.ts +7 -0
  86. package/dist/types-ts4.5/extensibility/Extension.d.ts +29 -0
  87. package/dist/types-ts4.5/extensibility/ExtensionComponent.d.ts +53 -0
  88. package/dist/types-ts4.5/extensibility/ExtensionNodeWrapper.d.ts +14 -0
  89. package/dist/types-ts4.5/extensibility/MultiBodiedExtension/index.d.ts +26 -0
  90. package/dist/types-ts4.5/extensibility/extensionNodeView.d.ts +31 -0
  91. package/dist/types-ts4.5/extensibility/index.d.ts +4 -0
  92. package/dist/types-ts4.5/extensibility/types.d.ts +8 -0
  93. package/dist/types-ts4.5/types/index.d.ts +1 -1
  94. package/dist/types-ts4.5/types/next-editor-plugin.d.ts +0 -3
  95. package/dist/types-ts4.5/ui/DropList/index.d.ts +1 -1
  96. package/dist/types-ts4.5/ui-menu/ColorPickerButton/index.d.ts +1 -1
  97. package/dist/types-ts4.5/ui-menu/ToolbarButton/index.d.ts +1 -1
  98. package/extensibility/package.json +15 -0
  99. package/package.json +5 -4
@@ -0,0 +1,62 @@
1
+ import React from 'react';
2
+ import ReactNodeView from '../react-node-view';
3
+ import { Extension } from './Extension';
4
+ import { ExtensionNodeWrapper } from './ExtensionNodeWrapper';
5
+ // getInlineNodeViewProducer is a new api to use instead of ReactNodeView
6
+ // when creating inline node views, however, it is difficult to test the impact
7
+ // on selections when migrating inlineExtension to use the new api.
8
+ // The ReactNodeView api will be visited in the second phase of the selections
9
+ // project whilst investigating block nodes. We will revisit the Extension node view there too.
10
+ export class ExtensionNode extends ReactNodeView {
11
+ ignoreMutation(mutation) {
12
+ // Extensions can perform async operations that will change the DOM.
13
+ // To avoid having their tree rebuilt, we need to ignore the mutation
14
+ // for atom based extensions if its not a layout, we need to give
15
+ // children a chance to recalc
16
+ return this.node.type.isAtom || mutation.type !== 'selection' && mutation.attributeName !== 'data-layout';
17
+ }
18
+ getContentDOM() {
19
+ if (this.node.isInline) {
20
+ return;
21
+ }
22
+ const dom = document.createElement('div');
23
+ dom.className = `${this.node.type.name}-content-dom-wrapper`;
24
+ return {
25
+ dom
26
+ };
27
+ }
28
+ render(props, forwardRef) {
29
+ var _props$extensionNodeV;
30
+ return /*#__PURE__*/React.createElement(ExtensionNodeWrapper, {
31
+ nodeType: this.node.type.name
32
+ }, /*#__PURE__*/React.createElement(Extension, {
33
+ editorView: this.view,
34
+ node: this.node,
35
+ eventDispatcher: this.eventDispatcher
36
+ // The getPos arg is always a function when used with nodes
37
+ // the version of the types we use has a union with the type
38
+ // for marks.
39
+ // This has been fixed in later versions of the definitly typed
40
+ // types (and also in prosmirror-views inbuilt types).
41
+ // https://github.com/DefinitelyTyped/DefinitelyTyped/pull/57384
42
+ ,
43
+ getPos: this.getPos,
44
+ providerFactory: props.providerFactory,
45
+ handleContentDOMRef: forwardRef,
46
+ extensionHandlers: props.extensionHandlers,
47
+ editorAppearance: (_props$extensionNodeV = props.extensionNodeViewOptions) === null || _props$extensionNodeV === void 0 ? void 0 : _props$extensionNodeV.appearance,
48
+ pluginInjectionApi: props.pluginInjectionApi
49
+ }));
50
+ }
51
+ }
52
+ export default function ExtensionNodeView(portalProviderAPI, eventDispatcher, providerFactory, extensionHandlers, extensionNodeViewOptions, pluginInjectionApi) {
53
+ return (node, view, getPos) => {
54
+ const hasIntlContext = true;
55
+ return new ExtensionNode(node, view, getPos, portalProviderAPI, eventDispatcher, {
56
+ providerFactory,
57
+ extensionHandlers,
58
+ extensionNodeViewOptions,
59
+ pluginInjectionApi
60
+ }, undefined, undefined, undefined, hasIntlContext).init();
61
+ };
62
+ }
@@ -0,0 +1,4 @@
1
+ export { ExtensionNodeWrapper } from './ExtensionNodeWrapper';
2
+ export { Extension } from './Extension';
3
+ export { default as ExtensionNodeView, ExtensionNode } from './extensionNodeView';
4
+ export { ExtensionComponent } from './ExtensionComponent';
@@ -0,0 +1 @@
1
+ export {};
@@ -1,6 +1,6 @@
1
1
  const SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
2
2
  const packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
3
- const packageVersion = "76.34.0";
3
+ const packageVersion = "76.35.0";
4
4
  const sanitiseSentryEvents = (data, _hint) => {
5
5
  // Remove URL as it has UGC
6
6
  // TODO: Sanitise the URL instead of just removing it
@@ -50,13 +50,14 @@ export const logException = async (error, tags) => {
50
50
  const hub = getCurrentHub();
51
51
  hub.bindClient(client);
52
52
  hub.withScope(scope => {
53
+ var _buildInfo;
53
54
  scope.setTags({
54
55
  // Jira environment variables
55
56
  'jira-bundler': window.BUNDLER_VERSION,
56
57
  'jira-variant': window.BUILD_VARIANT,
57
58
  'jira-release': window.BUILD_KEY,
58
59
  // Confluence environment variables
59
- 'confluence-frontend-version': window.__buildInfo.FRONTEND_VERSION,
60
+ 'confluence-frontend-version': (_buildInfo = window.__buildInfo) === null || _buildInfo === void 0 ? void 0 : _buildInfo.FRONTEND_VERSION,
60
61
  ...tags
61
62
  });
62
63
  // Explicitly remove the breadcrumbs as it's too likely to log UGC/PII to side-step the hub integrations not being respected
@@ -7,7 +7,7 @@ import { createAndFireEvent, withAnalyticsContext, withAnalyticsEvents } from '@
7
7
  import { N0, N50A, N60A, N900 } from '@atlaskit/theme/colors';
8
8
  import Layer from '../Layer';
9
9
  const packageName = "@atlaskit/editor-common";
10
- const packageVersion = "76.34.0";
10
+ const packageVersion = "76.35.0";
11
11
  const halfFocusRing = 1;
12
12
  const dropOffset = '0, 8';
13
13
  class DropList extends Component {
@@ -1,3 +1,10 @@
1
+ import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
2
+ var _templateObject;
3
+ import { css } from '@emotion/react';
4
+ import { hexToRgba } from '@atlaskit/adf-schema';
5
+ import { relativeFontSizeToBase16 } from '@atlaskit/editor-shared-styles';
6
+ import * as themeColors from '@atlaskit/theme/colors';
7
+
1
8
  // Format of the payload returned by the callback function passed to the collab provider
2
9
  // that gets called when syncing with the back-end service fails.
3
10
  // Format of the document and its metadata returned from the collab provider
@@ -118,4 +125,19 @@ export var DisconnectReason = /*#__PURE__*/function (DisconnectReason) {
118
125
  DisconnectReason["SOCKET_TIMEOUT"] = "SOCKET_TIMEOUT";
119
126
  DisconnectReason["UNKNOWN_DISCONNECT"] = "UNKNOWN_DISCONNECT";
120
127
  return DisconnectReason;
121
- }({});
128
+ }({});
129
+ // TODO: https://product-fabric.atlassian.net/browse/DSP-7269
130
+ /* eslint-disable @atlaskit/design-system/ensure-design-token-usage */
131
+ export var colors = [themeColors.R100, themeColors.R300, themeColors.R500, themeColors.Y100, themeColors.Y300, themeColors.Y500, themeColors.G100, themeColors.G300, themeColors.G500, themeColors.T100, themeColors.T300, themeColors.T500, themeColors.B100, themeColors.B300, themeColors.B500, themeColors.P100, themeColors.P300, themeColors.P500, themeColors.N70, themeColors.N200, themeColors.N800].map(function (solid) {
132
+ return {
133
+ solid: solid,
134
+ selection: hexToRgba(solid, 0.2)
135
+ };
136
+ });
137
+ var telepointerColorStyle = function telepointerColorStyle(color, index) {
138
+ return "\n &.color-".concat(index, " {\n background-color: ").concat(color.selection, ";\n &::after {\n background-color: ").concat(color.solid, ";\n color: ", "var(--ds-text-inverse, #fff)", ";\n border-color: ").concat(color.solid, ";\n }\n }\n");
139
+ };
140
+ export var TELEPOINTER_DIM_CLASS = 'telepointer-dim';
141
+ export var telepointerStyle = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n .ProseMirror .telepointer {\n position: relative;\n transition: opacity 200ms;\n\n &.telepointer-selection {\n line-height: 1.2;\n pointer-events: none;\n user-select: none;\n }\n\n &.telepointer-selection-badge::after {\n content: attr(data-initial);\n position: absolute;\n display: block;\n top: -14px;\n font-size: ", ";\n padding: ", ";\n color: ", ";\n left: -1px;\n border-radius: 2px 2px 2px 0;\n line-height: initial;\n }\n\n &.", " {\n opacity: 0.2;\n }\n\n ", ";\n }\n"])), relativeFontSizeToBase16(9), "var(--ds-space-025, 2px)", "var(--ds-text-inverse, white)", TELEPOINTER_DIM_CLASS, colors.map(function (color, index) {
142
+ return telepointerColorStyle(color, index);
143
+ }));
@@ -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"])));