@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,91 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.ExtensionNode = void 0;
8
+ exports.default = ExtensionNodeView;
9
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
10
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
11
+ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
12
+ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
13
+ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
14
+ var _react = _interopRequireDefault(require("react"));
15
+ var _reactNodeView = _interopRequireDefault(require("../react-node-view"));
16
+ var _Extension = require("./Extension");
17
+ var _ExtensionNodeWrapper = require("./ExtensionNodeWrapper");
18
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
19
+ 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; } }
20
+ // getInlineNodeViewProducer is a new api to use instead of ReactNodeView
21
+ // when creating inline node views, however, it is difficult to test the impact
22
+ // on selections when migrating inlineExtension to use the new api.
23
+ // The ReactNodeView api will be visited in the second phase of the selections
24
+ // project whilst investigating block nodes. We will revisit the Extension node view there too.
25
+ var ExtensionNode = exports.ExtensionNode = /*#__PURE__*/function (_ReactNodeView) {
26
+ (0, _inherits2.default)(ExtensionNode, _ReactNodeView);
27
+ var _super = _createSuper(ExtensionNode);
28
+ function ExtensionNode() {
29
+ (0, _classCallCheck2.default)(this, ExtensionNode);
30
+ return _super.apply(this, arguments);
31
+ }
32
+ (0, _createClass2.default)(ExtensionNode, [{
33
+ key: "ignoreMutation",
34
+ value: function ignoreMutation(mutation) {
35
+ // Extensions can perform async operations that will change the DOM.
36
+ // To avoid having their tree rebuilt, we need to ignore the mutation
37
+ // for atom based extensions if its not a layout, we need to give
38
+ // children a chance to recalc
39
+ return this.node.type.isAtom || mutation.type !== 'selection' && mutation.attributeName !== 'data-layout';
40
+ }
41
+ }, {
42
+ key: "getContentDOM",
43
+ value: function getContentDOM() {
44
+ if (this.node.isInline) {
45
+ return;
46
+ }
47
+ var dom = document.createElement('div');
48
+ dom.className = "".concat(this.node.type.name, "-content-dom-wrapper");
49
+ return {
50
+ dom: dom
51
+ };
52
+ }
53
+ }, {
54
+ key: "render",
55
+ value: function render(props, forwardRef) {
56
+ var _props$extensionNodeV;
57
+ return /*#__PURE__*/_react.default.createElement(_ExtensionNodeWrapper.ExtensionNodeWrapper, {
58
+ nodeType: this.node.type.name
59
+ }, /*#__PURE__*/_react.default.createElement(_Extension.Extension, {
60
+ editorView: this.view,
61
+ node: this.node,
62
+ eventDispatcher: this.eventDispatcher
63
+ // The getPos arg is always a function when used with nodes
64
+ // the version of the types we use has a union with the type
65
+ // for marks.
66
+ // This has been fixed in later versions of the definitly typed
67
+ // types (and also in prosmirror-views inbuilt types).
68
+ // https://github.com/DefinitelyTyped/DefinitelyTyped/pull/57384
69
+ ,
70
+ getPos: this.getPos,
71
+ providerFactory: props.providerFactory,
72
+ handleContentDOMRef: forwardRef,
73
+ extensionHandlers: props.extensionHandlers,
74
+ editorAppearance: (_props$extensionNodeV = props.extensionNodeViewOptions) === null || _props$extensionNodeV === void 0 ? void 0 : _props$extensionNodeV.appearance,
75
+ pluginInjectionApi: props.pluginInjectionApi
76
+ }));
77
+ }
78
+ }]);
79
+ return ExtensionNode;
80
+ }(_reactNodeView.default);
81
+ function ExtensionNodeView(portalProviderAPI, eventDispatcher, providerFactory, extensionHandlers, extensionNodeViewOptions, pluginInjectionApi) {
82
+ return function (node, view, getPos) {
83
+ var hasIntlContext = true;
84
+ return new ExtensionNode(node, view, getPos, portalProviderAPI, eventDispatcher, {
85
+ providerFactory: providerFactory,
86
+ extensionHandlers: extensionHandlers,
87
+ extensionNodeViewOptions: extensionNodeViewOptions,
88
+ pluginInjectionApi: pluginInjectionApi
89
+ }, undefined, undefined, undefined, hasIntlContext).init();
90
+ };
91
+ }
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+
3
+ var _typeof = require("@babel/runtime/helpers/typeof");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ Object.defineProperty(exports, "Extension", {
8
+ enumerable: true,
9
+ get: function get() {
10
+ return _Extension.Extension;
11
+ }
12
+ });
13
+ Object.defineProperty(exports, "ExtensionComponent", {
14
+ enumerable: true,
15
+ get: function get() {
16
+ return _ExtensionComponent.ExtensionComponent;
17
+ }
18
+ });
19
+ Object.defineProperty(exports, "ExtensionNode", {
20
+ enumerable: true,
21
+ get: function get() {
22
+ return _extensionNodeView.ExtensionNode;
23
+ }
24
+ });
25
+ Object.defineProperty(exports, "ExtensionNodeView", {
26
+ enumerable: true,
27
+ get: function get() {
28
+ return _extensionNodeView.default;
29
+ }
30
+ });
31
+ Object.defineProperty(exports, "ExtensionNodeWrapper", {
32
+ enumerable: true,
33
+ get: function get() {
34
+ return _ExtensionNodeWrapper.ExtensionNodeWrapper;
35
+ }
36
+ });
37
+ var _ExtensionNodeWrapper = require("./ExtensionNodeWrapper");
38
+ var _Extension = require("./Extension");
39
+ var _extensionNodeView = _interopRequireWildcard(require("./extensionNodeView"));
40
+ var _ExtensionComponent = require("./ExtensionComponent");
41
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
42
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -16,7 +16,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
16
16
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
17
17
  var SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
18
18
  var packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
19
- var packageVersion = "76.34.0";
19
+ var packageVersion = "76.35.0";
20
20
  var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
21
21
  // Remove URL as it has UGC
22
22
  // TODO: Sanitise the URL instead of just removing it
@@ -79,13 +79,14 @@ var logException = exports.logException = /*#__PURE__*/function () {
79
79
  hub = getCurrentHub();
80
80
  hub.bindClient(client);
81
81
  hub.withScope(function (scope) {
82
+ var _buildInfo;
82
83
  scope.setTags(_objectSpread({
83
84
  // Jira environment variables
84
85
  'jira-bundler': window.BUNDLER_VERSION,
85
86
  'jira-variant': window.BUILD_VARIANT,
86
87
  'jira-release': window.BUILD_KEY,
87
88
  // Confluence environment variables
88
- 'confluence-frontend-version': window.__buildInfo.FRONTEND_VERSION
89
+ 'confluence-frontend-version': (_buildInfo = window.__buildInfo) === null || _buildInfo === void 0 ? void 0 : _buildInfo.FRONTEND_VERSION
89
90
  }, tags));
90
91
  // Explicitly remove the breadcrumbs as it's too likely to log UGC/PII to side-step the hub integrations not being respected
91
92
  scope.clearBreadcrumbs();
@@ -22,7 +22,7 @@ var _templateObject, _templateObject2, _templateObject3;
22
22
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
23
23
  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; } } /** @jsx jsx */
24
24
  var packageName = "@atlaskit/editor-common";
25
- var packageVersion = "76.34.0";
25
+ var packageVersion = "76.35.0";
26
26
  var halfFocusRing = 1;
27
27
  var dropOffset = '0, 8';
28
28
  var DropList = /*#__PURE__*/function (_Component) {
@@ -1,3 +1,8 @@
1
+ import { css } from '@emotion/react';
2
+ import { hexToRgba } from '@atlaskit/adf-schema';
3
+ import { relativeFontSizeToBase16 } from '@atlaskit/editor-shared-styles';
4
+ import * as themeColors from '@atlaskit/theme/colors';
5
+
1
6
  // Format of the payload returned by the callback function passed to the collab provider
2
7
  // that gets called when syncing with the back-end service fails.
3
8
  // Format of the document and its metadata returned from the collab provider
@@ -118,4 +123,52 @@ export let DisconnectReason = /*#__PURE__*/function (DisconnectReason) {
118
123
  DisconnectReason["SOCKET_TIMEOUT"] = "SOCKET_TIMEOUT";
119
124
  DisconnectReason["UNKNOWN_DISCONNECT"] = "UNKNOWN_DISCONNECT";
120
125
  return DisconnectReason;
121
- }({});
126
+ }({});
127
+ // TODO: https://product-fabric.atlassian.net/browse/DSP-7269
128
+ /* eslint-disable @atlaskit/design-system/ensure-design-token-usage */
129
+ export const 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(solid => ({
130
+ solid,
131
+ selection: hexToRgba(solid, 0.2)
132
+ }));
133
+ const telepointerColorStyle = (color, index) => `
134
+ &.color-${index} {
135
+ background-color: ${color.selection};
136
+ &::after {
137
+ background-color: ${color.solid};
138
+ color: ${"var(--ds-text-inverse, #fff)"};
139
+ border-color: ${color.solid};
140
+ }
141
+ }
142
+ `;
143
+ export const TELEPOINTER_DIM_CLASS = 'telepointer-dim';
144
+ export const telepointerStyle = css`
145
+ .ProseMirror .telepointer {
146
+ position: relative;
147
+ transition: opacity 200ms;
148
+
149
+ &.telepointer-selection {
150
+ line-height: 1.2;
151
+ pointer-events: none;
152
+ user-select: none;
153
+ }
154
+
155
+ &.telepointer-selection-badge::after {
156
+ content: attr(data-initial);
157
+ position: absolute;
158
+ display: block;
159
+ top: -14px;
160
+ font-size: ${relativeFontSizeToBase16(9)};
161
+ padding: ${"var(--ds-space-025, 2px)"};
162
+ color: ${"var(--ds-text-inverse, white)"};
163
+ left: -1px;
164
+ border-radius: 2px 2px 2px 0;
165
+ line-height: initial;
166
+ }
167
+
168
+ &.${TELEPOINTER_DIM_CLASS} {
169
+ opacity: 0.2;
170
+ }
171
+
172
+ ${colors.map((color, index) => telepointerColorStyle(color, index))};
173
+ }
174
+ `;
@@ -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
+ `;