@atlaskit/editor-common 72.5.0 → 72.6.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 (89) hide show
  1. package/CHANGELOG.md +47 -0
  2. package/dist/cjs/node-width/index.js +18 -4
  3. package/dist/cjs/preset/builder.js +180 -0
  4. package/dist/cjs/preset/index.js +19 -0
  5. package/dist/cjs/preset/plugin-injection-api.js +223 -0
  6. package/dist/cjs/styles/shared/media-single.js +1 -1
  7. package/dist/cjs/styles/shared/panel.js +2 -2
  8. package/dist/cjs/styles/shared/table.js +2 -1
  9. package/dist/cjs/styles/shared/tableCell.js +31 -0
  10. package/dist/cjs/ui/DropList/index.js +6 -3
  11. package/dist/cjs/ui-color/ColorPalette/Color/styles.js +1 -1
  12. package/dist/cjs/ui-color/ColorPalette/Palettes/index.js +14 -1
  13. package/dist/cjs/ui-color/ColorPalette/Palettes/paletteMessagesTokenModeNames.js +139 -8
  14. package/dist/cjs/ui-color/ColorPalette/index.js +10 -11
  15. package/dist/cjs/ui-color/index.js +13 -0
  16. package/dist/cjs/ui-menu/ArrowKeyNavigationProvider/MenuArrowKeyNavigationProvider/index.js +2 -2
  17. package/dist/cjs/ui-menu/Dropdown/index.js +18 -8
  18. package/dist/cjs/ui-menu/DropdownMenu/index.js +1 -1
  19. package/dist/cjs/utils/breakout.js +12 -4
  20. package/dist/cjs/utils/index.js +12 -7
  21. package/dist/cjs/utils/nodes.js +38 -2
  22. package/dist/cjs/version.json +1 -1
  23. package/dist/es2019/node-width/index.js +18 -4
  24. package/dist/es2019/preset/builder.js +138 -0
  25. package/dist/es2019/preset/index.js +2 -0
  26. package/dist/es2019/preset/plugin-injection-api.js +176 -0
  27. package/dist/es2019/styles/shared/media-single.js +9 -0
  28. package/dist/es2019/styles/shared/panel.js +2 -2
  29. package/dist/es2019/styles/shared/table.js +2 -0
  30. package/dist/es2019/styles/shared/tableCell.js +27 -0
  31. package/dist/es2019/ui/DropList/index.js +6 -3
  32. package/dist/es2019/ui-color/ColorPalette/Color/styles.js +3 -1
  33. package/dist/es2019/ui-color/ColorPalette/Palettes/index.js +2 -1
  34. package/dist/es2019/ui-color/ColorPalette/Palettes/paletteMessagesTokenModeNames.js +137 -7
  35. package/dist/es2019/ui-color/ColorPalette/index.js +10 -8
  36. package/dist/es2019/ui-color/index.js +1 -0
  37. package/dist/es2019/ui-menu/ArrowKeyNavigationProvider/MenuArrowKeyNavigationProvider/index.js +2 -2
  38. package/dist/es2019/ui-menu/Dropdown/index.js +18 -6
  39. package/dist/es2019/ui-menu/DropdownMenu/index.js +1 -1
  40. package/dist/es2019/utils/breakout.js +13 -5
  41. package/dist/es2019/utils/index.js +1 -2
  42. package/dist/es2019/utils/nodes.js +34 -0
  43. package/dist/es2019/version.json +1 -1
  44. package/dist/esm/node-width/index.js +18 -4
  45. package/dist/esm/preset/builder.js +172 -0
  46. package/dist/esm/preset/index.js +2 -0
  47. package/dist/esm/preset/plugin-injection-api.js +213 -0
  48. package/dist/esm/styles/shared/media-single.js +1 -1
  49. package/dist/esm/styles/shared/panel.js +2 -2
  50. package/dist/esm/styles/shared/table.js +2 -1
  51. package/dist/esm/styles/shared/tableCell.js +24 -0
  52. package/dist/esm/ui/DropList/index.js +6 -3
  53. package/dist/esm/ui-color/ColorPalette/Color/styles.js +1 -1
  54. package/dist/esm/ui-color/ColorPalette/Palettes/index.js +2 -1
  55. package/dist/esm/ui-color/ColorPalette/Palettes/paletteMessagesTokenModeNames.js +132 -5
  56. package/dist/esm/ui-color/ColorPalette/index.js +10 -11
  57. package/dist/esm/ui-color/index.js +1 -0
  58. package/dist/esm/ui-menu/ArrowKeyNavigationProvider/MenuArrowKeyNavigationProvider/index.js +2 -2
  59. package/dist/esm/ui-menu/Dropdown/index.js +18 -8
  60. package/dist/esm/ui-menu/DropdownMenu/index.js +1 -1
  61. package/dist/esm/utils/breakout.js +13 -5
  62. package/dist/esm/utils/index.js +1 -2
  63. package/dist/esm/utils/nodes.js +34 -0
  64. package/dist/esm/version.json +1 -1
  65. package/dist/types/card/cardOptions.d.ts +1 -0
  66. package/dist/types/preset/builder.d.ts +30 -0
  67. package/dist/types/preset/index.d.ts +2 -0
  68. package/dist/types/preset/plugin-injection-api.d.ts +43 -0
  69. package/dist/types/provider-factory/provider-factory.d.ts +1 -1
  70. package/dist/types/styles/shared/tableCell.d.ts +1 -0
  71. package/dist/types/types/feature-flags.d.ts +18 -3
  72. package/dist/types/types/index.d.ts +1 -1
  73. package/dist/types/types/next-editor-plugin.d.ts +56 -28
  74. package/dist/types/ui/DropList/index.d.ts +2 -1
  75. package/dist/types/ui-color/ColorPalette/Palettes/index.d.ts +1 -0
  76. package/dist/types/ui-color/ColorPalette/Palettes/paletteMessagesTokenModeNames.d.ts +648 -2
  77. package/dist/types/ui-color/ColorPalette/Palettes/type.d.ts +4 -0
  78. package/dist/types/ui-color/ColorPalette/index.d.ts +36 -17
  79. package/dist/types/ui-color/index.d.ts +2 -1
  80. package/dist/types/ui-menu/Dropdown/index.d.ts +3 -0
  81. package/dist/types/utils/breakout.d.ts +10 -2
  82. package/dist/types/utils/index.d.ts +1 -2
  83. package/dist/types/utils/nodes.d.ts +15 -1
  84. package/package.json +13 -12
  85. package/preset/package.json +15 -0
  86. package/dist/cjs/utils/builder.js +0 -34
  87. package/dist/es2019/utils/builder.js +0 -14
  88. package/dist/esm/utils/builder.js +0 -26
  89. package/dist/types/utils/builder.d.ts +0 -8
@@ -1,3 +1,4 @@
1
+ import { findParentNodeOfType } from 'prosemirror-utils';
1
2
  /**
2
3
  * Finds all top level nodes affected by the transaction
3
4
  * Uses from/to positions in transaction's steps to work out which nodes will
@@ -77,4 +78,37 @@ export const isSupportedInParent = (state, fragment, currentAppearance) => {
77
78
  const depth = currentAppearance === 'embed' || currentAppearance === 'block' ? undefined : -1;
78
79
  const parent = state.selection.$from.node(depth);
79
80
  return parent && parent.type.validContent(fragment);
81
+ };
82
+
83
+ /**
84
+ * Checks if the passed in node is a media node
85
+ * Includes media, mediaInline, mediaGroup, mediaSingle
86
+ * @param node The PM node to be checked
87
+ */
88
+ export const isMediaNode = node => {
89
+ return ['media', 'mediaInline', 'mediaGroup', 'mediaSingle'].includes(node.type.name);
90
+ };
91
+
92
+ /**
93
+ * Checks if the node before selection is a media node
94
+ * If there is no node before, checks the node before the parent node
95
+ * Includes media, mediaInline, mediaGroup, mediaSingle
96
+ * @param $pos The position of the selection
97
+ * @param state The editor state
98
+ */
99
+ export const isNodeBeforeMediaNode = ($pos, state) => {
100
+ let nodeBefore = $pos.nodeBefore;
101
+ if (!nodeBefore) {
102
+ const depthOfParent = $pos.depth - 1 || 1;
103
+ const parentNode = findParentNodeOfType([state.schema.nodes[`${$pos.node(depthOfParent).type.name}`]])(state.selection);
104
+ const resolvedPosOfParentNode = parentNode ? state.tr.doc.resolve(parentNode.pos) : undefined;
105
+ const nodeBeforeParent = resolvedPosOfParentNode && resolvedPosOfParentNode.pos < state.doc.nodeSize ? resolvedPosOfParentNode.nodeBefore : undefined;
106
+ if (nodeBeforeParent) {
107
+ nodeBefore = nodeBeforeParent;
108
+ }
109
+ }
110
+ if (nodeBefore) {
111
+ return ['media', 'mediaInline', 'mediaGroup', 'mediaSingle'].includes(nodeBefore.type.name);
112
+ }
113
+ return false;
80
114
  };
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-common",
3
- "version": "72.5.0",
3
+ "version": "72.6.0",
4
4
  "sideEffects": false
5
5
  }
@@ -1,5 +1,6 @@
1
1
  import { findParentNodeOfTypeClosestToPos } from 'prosemirror-utils';
2
2
  import { akEditorFullWidthLayoutWidth, akLayoutGutterOffset, gridMediumMaxWidth } from '@atlaskit/editor-shared-styles';
3
+ import { gridSize } from '@atlaskit/theme/constants';
3
4
  import { BODIED_EXT_PADDING } from '../styles/shared/extension';
4
5
  import { LAYOUT_COLUMN_PADDING, LAYOUT_SECTION_MARGIN } from '../styles/shared/layout';
5
6
  import { absoluteBreakoutWidth } from '../utils/breakout';
@@ -39,10 +40,23 @@ export var getParentNodeWidth = function getParentNodeWidth(pos, state, containe
39
40
  }
40
41
 
41
42
  // account for the padding of the parent node
42
- if (node.type === schema.nodes.layoutSection) {
43
- parentWidth -= LAYOUT_COLUMN_PADDING * 2;
44
- } else if (node.type === schema.nodes.bodiedExtension) {
45
- parentWidth -= BODIED_EXT_PADDING * 2;
43
+ switch (node.type) {
44
+ case schema.nodes.layoutSection:
45
+ parentWidth -= LAYOUT_COLUMN_PADDING * 2;
46
+ break;
47
+ case schema.nodes.bodiedExtension:
48
+ parentWidth -= BODIED_EXT_PADDING * 2;
49
+ break;
50
+ case schema.nodes.expand:
51
+ // padding
52
+ parentWidth -= gridSize() * 2;
53
+ // gutter offset
54
+ parentWidth += gridSize() * 1.5 * 2;
55
+ // padding right
56
+ parentWidth -= gridSize();
57
+ // padding left
58
+ parentWidth -= gridSize() * 4 - gridSize() / 2;
59
+ break;
46
60
  }
47
61
  parentWidth -= 2; // border
48
62
 
@@ -0,0 +1,172 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
+ import _construct from "@babel/runtime/helpers/construct";
3
+ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
4
+ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
5
+ import _createClass from "@babel/runtime/helpers/createClass";
6
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
7
+ export var EditorPresetBuilder = /*#__PURE__*/function () {
8
+ function EditorPresetBuilder() {
9
+ _classCallCheck(this, EditorPresetBuilder);
10
+ _defineProperty(this, "safeEntry", function (plugin) {
11
+ return Array.isArray(plugin) ? plugin : [plugin, undefined];
12
+ });
13
+ for (var _len = arguments.length, more = new Array(_len), _key = 0; _key < _len; _key++) {
14
+ more[_key] = arguments[_key];
15
+ }
16
+ this.data = [].concat(more) || [];
17
+ }
18
+ _createClass(EditorPresetBuilder, [{
19
+ key: "add",
20
+ value: function add(nextOrTuple) {
21
+ return _construct(EditorPresetBuilder, [
22
+ /**
23
+ * re-cast this to NewPlugin as we've done all the type
24
+ * safety, dependency checking, narrowing, during
25
+ * `SafePresetCheck & VerifyPluginDependencies`
26
+ */
27
+ nextOrTuple].concat(_toConsumableArray(this.data)));
28
+ }
29
+
30
+ //hasPlugin<Plugin extends NextEditorPlugin<any, any>>(
31
+ // pluginToAdd: Plugin,
32
+ //): this is TryCastEditorPresetBuilderByCheckingPlugins<this, Plugin> {
33
+ // const hasPluginQueryExists = this.data.find((pluginEntry) => {
34
+ // const pluginFunction: NextEditorPlugin<any, any> = !Array.isArray(
35
+ // pluginEntry,
36
+ // )
37
+ // ? pluginEntry
38
+ // : pluginEntry[0];
39
+
40
+ // return pluginFunction === pluginToAdd;
41
+ // });
42
+
43
+ // return Boolean(hasPluginQueryExists);
44
+ //}
45
+ }, {
46
+ key: "maybeAdd",
47
+ value: function maybeAdd(pluginToAdd, add) {
48
+ return add(pluginToAdd,
49
+ // @ts-ignore
50
+ this);
51
+ }
52
+ }, {
53
+ key: "has",
54
+ value: function has(plugin) {
55
+ return this.data.some(function (pluginPreset) {
56
+ if (Array.isArray(pluginPreset)) {
57
+ return pluginPreset[0] === plugin;
58
+ }
59
+ return pluginPreset === plugin;
60
+ });
61
+ }
62
+ }, {
63
+ key: "build",
64
+ value: function build() {
65
+ var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
66
+ pluginInjectionAPI = _ref.pluginInjectionAPI,
67
+ maybeExcludePlugins = _ref.excludePlugins;
68
+ var excludePlugins = new Set(maybeExcludePlugins ? maybeExcludePlugins : []);
69
+ var editorPlugins = this.processEditorPlugins({
70
+ pluginInjectionAPI: pluginInjectionAPI,
71
+ excludePlugins: excludePlugins
72
+ });
73
+ return this.removeExcludedPlugins(editorPlugins, excludePlugins);
74
+ }
75
+ }, {
76
+ key: "verifyDuplicatedPlugins",
77
+ value: function verifyDuplicatedPlugins() {
78
+ var cache = new Set();
79
+ this.data.forEach(function (pluginEntry) {
80
+ var _ref2 = Array.isArray(pluginEntry) ? pluginEntry : [pluginEntry, undefined],
81
+ _ref3 = _slicedToArray(_ref2, 2),
82
+ pluginFn = _ref3[0],
83
+ _ = _ref3[1];
84
+ if (cache.has(pluginFn)) {
85
+ throw new Error("".concat(pluginFn, " is already included!"));
86
+ }
87
+ cache.add(pluginFn);
88
+ });
89
+ return true;
90
+ }
91
+ }, {
92
+ key: "processEditorPlugins",
93
+ value: function processEditorPlugins(_ref4) {
94
+ var _this = this;
95
+ var pluginInjectionAPI = _ref4.pluginInjectionAPI,
96
+ excludePlugins = _ref4.excludePlugins;
97
+ this.verifyDuplicatedPlugins();
98
+ var seen = new Set();
99
+ var plugins = this.data.reverse().map(function (entry) {
100
+ var _this$safeEntry = _this.safeEntry(entry),
101
+ _this$safeEntry2 = _slicedToArray(_this$safeEntry, 2),
102
+ fn = _this$safeEntry2[0],
103
+ config = _this$safeEntry2[1];
104
+ if (seen.has(fn)) {
105
+ return null;
106
+ }
107
+ seen.add(fn);
108
+ if (typeof fn !== 'function') {
109
+ return null;
110
+ }
111
+ var plugin = pluginInjectionAPI ? fn(config, pluginInjectionAPI.api()) : fn(config);
112
+ if (plugin && excludePlugins !== null && excludePlugins !== void 0 && excludePlugins.has(plugin.name)) {
113
+ return null;
114
+ }
115
+ if (!pluginInjectionAPI) {
116
+ return plugin;
117
+ }
118
+ pluginInjectionAPI.onEditorPluginInitialized(plugin);
119
+ return plugin;
120
+ }).filter(Boolean);
121
+ return plugins;
122
+ }
123
+ }, {
124
+ key: "removeExcludedPlugins",
125
+ value: function removeExcludedPlugins(plugins, excludes) {
126
+ if (excludes) {
127
+ return plugins.filter(function (plugin) {
128
+ return !plugin || !excludes.has(plugin.name);
129
+ });
130
+ }
131
+ return plugins;
132
+ }
133
+
134
+ // TODO: ED-17023 - Bring back type safety to the EditorPresetBuilder.add preset
135
+ //import type {
136
+ // ExtractPluginDependencies,
137
+ //} from '../types/next-editor-plugin';
138
+ //type TryCastEditorPresetBuilderByCheckingDependencies<MaybeEditorPresetBuilder, Plugin> =
139
+ // MaybeEditorPresetBuilder extends EditorPresetBuilder<any, infer StackPlugins>
140
+ // ? Plugin extends NextEditorPlugin<any, any>
141
+ // ? ExtractPluginDependencies<Plugin>[number] extends StackPlugins[number]
142
+ // ? MaybeEditorPresetBuilder
143
+ // : never
144
+ // : never
145
+ // : never;
146
+ // Because how our plugins are added in the preset, we can't use the type safe system
147
+ // in the EditorPresetBuilder.
148
+ // TODO: ED-17023 - Bring back type safety to the EditorPresetBuilder.add preset
149
+ //maybeAdd<
150
+ // MaybePlugin extends NextEditorPlugin<any, any>,
151
+ // MaybePluginNames extends string[],
152
+ // MaybeStackPlugins extends AllEditorPresetPluginTypes[],
153
+ // MaybeEditorPresetBuilder extends EditorPresetBuilder<
154
+ // MaybePluginNames,
155
+ // MaybeStackPlugins
156
+ // >,
157
+ //>(
158
+ // pluginToAdd: MaybePlugin,
159
+ // add: (
160
+ // pluginToAdd: MaybePlugin,
161
+ // maybeEditorPresetBuilder: TryCastEditorPresetBuilderByCheckingDependencies<this, MaybePlugin>,
162
+ // ) => MaybeEditorPresetBuilder,
163
+ //): MaybeEditorPresetBuilder | this {
164
+ // return add(
165
+ // pluginToAdd,
166
+ // // @ts-ignore
167
+ // this as any,
168
+ // );
169
+ //}
170
+ }]);
171
+ return EditorPresetBuilder;
172
+ }();
@@ -0,0 +1,2 @@
1
+ export { EditorPresetBuilder } from './builder';
2
+ export { EditorPluginInjectionAPI } from './plugin-injection-api';
@@ -0,0 +1,213 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ import _createClass from "@babel/runtime/helpers/createClass";
3
+ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
4
+ import _typeof from "@babel/runtime/helpers/typeof";
5
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
6
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
7
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
8
+ import isEqual from 'lodash/isEqual';
9
+ import throttle from 'lodash/throttle';
10
+ function hasGetSharedState(plugin) {
11
+ return typeof plugin.getSharedState === 'function';
12
+ }
13
+ function hasActions(plugin) {
14
+ return _typeof(plugin.actions) === 'object';
15
+ }
16
+ var DREAM_TARGET_60_FPS = 16;
17
+ /*
18
+ *
19
+ * After some investigations, we discovered this is the best ratio for our current Editor: 80ms. That means is five times bigger than the 60fps dream target.
20
+ *
21
+ * In the future, once we remove the entire WithPluginState, We may decide to reduce this value.
22
+ *
23
+ */
24
+ var THROTTLE_CALLS_FOR_MILLISECONDS = DREAM_TARGET_60_FPS * 5;
25
+ var notifyListenersThrottled = throttle(function (_ref) {
26
+ var newEditorState = _ref.newEditorState,
27
+ oldEditorState = _ref.oldEditorState,
28
+ listeners = _ref.listeners,
29
+ plugins = _ref.plugins;
30
+ var isInitialization = !oldEditorState && newEditorState;
31
+ var callbacks = [];
32
+ var _iterator = _createForOfIteratorHelper(listeners.keys()),
33
+ _step;
34
+ try {
35
+ var _loop = function _loop() {
36
+ var pluginName = _step.value;
37
+ var plugin = plugins.get(pluginName);
38
+ if (!plugin || !hasGetSharedState(plugin)) {
39
+ return "continue";
40
+ }
41
+ var nextSharedState = plugin.getSharedState(newEditorState);
42
+ var prevSharedState = !isInitialization && oldEditorState ? plugin.getSharedState(oldEditorState) : undefined;
43
+ var isSamePluginState = isEqual(prevSharedState, nextSharedState);
44
+ if (isInitialization || !isSamePluginState) {
45
+ (listeners.get(pluginName) || new Set()).forEach(function (callback) {
46
+ callbacks.push(callback.bind(callback, {
47
+ nextSharedState: nextSharedState,
48
+ prevSharedState: prevSharedState
49
+ }));
50
+ });
51
+ }
52
+ };
53
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
54
+ var _ret = _loop();
55
+ if (_ret === "continue") continue;
56
+ }
57
+ } catch (err) {
58
+ _iterator.e(err);
59
+ } finally {
60
+ _iterator.f();
61
+ }
62
+ if (callbacks.length === 0) {
63
+ return;
64
+ }
65
+ callbacks.forEach(function (cb) {
66
+ cb();
67
+ });
68
+ }, THROTTLE_CALLS_FOR_MILLISECONDS);
69
+ export var PluginsData = /*#__PURE__*/_createClass(function PluginsData() {
70
+ _classCallCheck(this, PluginsData);
71
+ });
72
+ var ActionsAPI = /*#__PURE__*/function () {
73
+ function ActionsAPI() {
74
+ _classCallCheck(this, ActionsAPI);
75
+ }
76
+ _createClass(ActionsAPI, [{
77
+ key: "createAPI",
78
+ value: function createAPI(plugin) {
79
+ if (!plugin || !hasActions(plugin)) {
80
+ return {};
81
+ }
82
+ return new Proxy(plugin.actions || {}, {
83
+ get: function get(target, prop, receiver) {
84
+ // We will be able to track perfomance here
85
+ return Reflect.get(target, prop);
86
+ }
87
+ });
88
+ }
89
+ }]);
90
+ return ActionsAPI;
91
+ }();
92
+ export var SharedStateAPI = /*#__PURE__*/function () {
93
+ function SharedStateAPI(_ref2) {
94
+ var getEditorState = _ref2.getEditorState;
95
+ _classCallCheck(this, SharedStateAPI);
96
+ this.getEditorState = getEditorState;
97
+ this.listeners = new Map();
98
+ }
99
+ _createClass(SharedStateAPI, [{
100
+ key: "createAPI",
101
+ value: function createAPI(plugin) {
102
+ var _this = this;
103
+ if (!plugin) {
104
+ return {
105
+ currentState: function currentState() {
106
+ return undefined;
107
+ },
108
+ onChange: function onChange(sub) {
109
+ return function () {};
110
+ }
111
+ };
112
+ }
113
+ var pluginName = plugin.name;
114
+ return {
115
+ currentState: function currentState() {
116
+ var state = _this.getEditorState();
117
+ if (!state || !hasGetSharedState(plugin)) {
118
+ return undefined;
119
+ }
120
+ return plugin.getSharedState(state);
121
+ },
122
+ onChange: function onChange(sub) {
123
+ var pluginListeners = _this.listeners.get(pluginName) || new Set();
124
+ pluginListeners.add(sub);
125
+ _this.listeners.set(pluginName, pluginListeners);
126
+ return function () {
127
+ (_this.listeners.get(pluginName) || new Set()).delete(sub);
128
+ };
129
+ }
130
+ };
131
+ }
132
+ }, {
133
+ key: "notifyListeners",
134
+ value: function notifyListeners(_ref3) {
135
+ var newEditorState = _ref3.newEditorState,
136
+ oldEditorState = _ref3.oldEditorState,
137
+ plugins = _ref3.plugins;
138
+ var listeners = this.listeners;
139
+ notifyListenersThrottled({
140
+ newEditorState: newEditorState,
141
+ oldEditorState: oldEditorState,
142
+ listeners: listeners,
143
+ plugins: plugins
144
+ });
145
+ }
146
+ }, {
147
+ key: "destroy",
148
+ value: function destroy() {
149
+ this.listeners.clear();
150
+ }
151
+ }]);
152
+ return SharedStateAPI;
153
+ }();
154
+ export var EditorPluginInjectionAPI = /*#__PURE__*/function () {
155
+ function EditorPluginInjectionAPI(_ref4) {
156
+ var _this2 = this;
157
+ var getEditorState = _ref4.getEditorState;
158
+ _classCallCheck(this, EditorPluginInjectionAPI);
159
+ _defineProperty(this, "onEditorViewUpdated", function (_ref5) {
160
+ var newEditorState = _ref5.newEditorState,
161
+ oldEditorState = _ref5.oldEditorState;
162
+ _this2.sharedStateAPI.notifyListeners({
163
+ newEditorState: newEditorState,
164
+ oldEditorState: oldEditorState,
165
+ plugins: _this2.plugins
166
+ });
167
+ });
168
+ _defineProperty(this, "onEditorPluginInitialized", function (plugin) {
169
+ _this2.addPlugin(plugin);
170
+ });
171
+ _defineProperty(this, "addPlugin", function (plugin) {
172
+ _this2.plugins.set(plugin.name, plugin);
173
+ });
174
+ _defineProperty(this, "getPluginByName", function (pluginName) {
175
+ var plugin = _this2.plugins.get(pluginName);
176
+ return plugin;
177
+ });
178
+ this.sharedStateAPI = new SharedStateAPI({
179
+ getEditorState: getEditorState
180
+ });
181
+ this.plugins = new Map();
182
+ this.actionsAPI = new ActionsAPI();
183
+ }
184
+ _createClass(EditorPluginInjectionAPI, [{
185
+ key: "api",
186
+ value: function api() {
187
+ var sharedStateAPI = this.sharedStateAPI,
188
+ actionsAPI = this.actionsAPI,
189
+ getPluginByName = this.getPluginByName;
190
+ var externalPlugins = new Proxy({}, {
191
+ get: function get(target, prop, receiver) {
192
+ var plugin = getPluginByName(prop);
193
+ if (!plugin) {
194
+ // eslint-disable-next-line
195
+ console.error("Plugin: ".concat(prop, " does not exist"));
196
+ return undefined;
197
+ }
198
+ var sharedState = sharedStateAPI.createAPI(plugin);
199
+ var actions = actionsAPI.createAPI(plugin);
200
+ var proxyCoreAPI = {
201
+ sharedState: sharedState,
202
+ actions: actions
203
+ };
204
+ return proxyCoreAPI;
205
+ }
206
+ });
207
+ return {
208
+ externalPlugins: externalPlugins
209
+ };
210
+ }
211
+ }]);
212
+ return EditorPluginInjectionAPI;
213
+ }();
@@ -3,5 +3,5 @@ var _templateObject;
3
3
  import { css } from '@emotion/react';
4
4
  var richMediaClassName = 'rich-media-item';
5
5
  var wrappedMediaBreakoutPoint = 410;
6
- var mediaSingleSharedStyle = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n li .", " {\n margin: 0;\n }\n\n /* Hack for chrome to fix media single position\n inside a list when media is the first child */\n &.ua-chrome li > .mediaSingleView-content-wrap::before {\n content: '';\n display: block;\n height: 0;\n }\n\n &.ua-firefox {\n .mediaSingleView-content-wrap {\n user-select: none;\n }\n\n .captionView-content-wrap {\n user-select: text;\n }\n }\n\n .mediaSingleView-content-wrap[layout='center'] {\n clear: both;\n }\n\n table .", " {\n margin-top: 12px;\n margin-bottom: 12px;\n clear: both;\n }\n\n .", ".image-wrap-right\n + .", ".image-wrap-left {\n clear: both;\n }\n\n .", ".image-wrap-left\n + .", ".image-wrap-right,\n .", ".image-wrap-right\n + .", ".image-wrap-left,\n .", ".image-wrap-left\n + .", ".image-wrap-left,\n .", ".image-wrap-right\n + .", ".image-wrap-right {\n margin-right: 0;\n margin-left: 0;\n }\n\n @media all and (max-width: ", "px) {\n div.mediaSingleView-content-wrap[layout='wrap-left'],\n div.mediaSingleView-content-wrap[data-layout='wrap-left'],\n div.mediaSingleView-content-wrap[layout='wrap-right'],\n div.mediaSingleView-content-wrap[data-layout='wrap-right'] {\n float: none;\n overflow: auto;\n margin: 12px 0;\n }\n }\n"])), richMediaClassName, richMediaClassName, richMediaClassName, richMediaClassName, richMediaClassName, richMediaClassName, richMediaClassName, richMediaClassName, richMediaClassName, richMediaClassName, richMediaClassName, richMediaClassName, wrappedMediaBreakoutPoint);
6
+ var mediaSingleSharedStyle = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n li .", " {\n margin: 0;\n }\n\n /* Hack for chrome to fix media single position\n inside a list when media is the first child */\n &.ua-chrome li > .mediaSingleView-content-wrap::before {\n content: '';\n display: block;\n height: 0;\n }\n\n &.ua-firefox {\n .mediaSingleView-content-wrap {\n user-select: none;\n }\n\n .captionView-content-wrap {\n user-select: text;\n }\n }\n\n .mediaSingleView-content-wrap[layout='center'] {\n clear: both;\n }\n\n table .", " {\n margin-top: 12px;\n margin-bottom: 12px;\n clear: both;\n\n &.image-wrap-left,\n &.image-wrap-right {\n clear: none;\n\n &:first-child {\n margin-top: 12px;\n }\n }\n }\n\n .", ".image-wrap-right\n + .", ".image-wrap-left {\n clear: both;\n }\n\n .", ".image-wrap-left\n + .", ".image-wrap-right,\n .", ".image-wrap-right\n + .", ".image-wrap-left,\n .", ".image-wrap-left\n + .", ".image-wrap-left,\n .", ".image-wrap-right\n + .", ".image-wrap-right {\n margin-right: 0;\n margin-left: 0;\n }\n\n @media all and (max-width: ", "px) {\n div.mediaSingleView-content-wrap[layout='wrap-left'],\n div.mediaSingleView-content-wrap[data-layout='wrap-left'],\n div.mediaSingleView-content-wrap[layout='wrap-right'],\n div.mediaSingleView-content-wrap[data-layout='wrap-right'] {\n float: none;\n overflow: auto;\n margin: 12px 0;\n }\n }\n"])), richMediaClassName, richMediaClassName, richMediaClassName, richMediaClassName, richMediaClassName, richMediaClassName, richMediaClassName, richMediaClassName, richMediaClassName, richMediaClassName, richMediaClassName, richMediaClassName, wrappedMediaBreakoutPoint);
7
7
  export { mediaSingleSharedStyle, richMediaClassName };
@@ -152,11 +152,11 @@ export var PanelSharedSelectors = {
152
152
  removeEmojiIcon: "[aria-label=\"Remove emoji\"]",
153
153
  emojiIcon: "[aria-label=\"editor-add-emoji\"]",
154
154
  selectedEmoji: "[aria-label=\":grinning:\"]",
155
- addYourOwnEmoji: "[aria-label=\"Add your own emoji\"]",
155
+ addYourOwnEmoji: "#add-custom-emoji",
156
156
  emojiNameInCustomEmoji: "[aria-label=\"Enter a name for the new emoji\"]",
157
157
  title: "#editor-title",
158
158
  emojiPopup: "[aria-label=\"Popup\"]",
159
- searchEmoji: "[aria-label=\"Search emoji\"]",
159
+ searchEmoji: "[aria-label=\"Emoji name\"]",
160
160
  orangeWarningIcon: "[aria-label=\":warning:\"]",
161
161
  yellowWarningIcon: "[aria-label=\":warning:\"] span:nth-child(1)",
162
162
  copyButton: "button[aria-label=\"Copy\"]"
@@ -10,6 +10,7 @@ import { themed } from '@atlaskit/theme/components';
10
10
  import { gridSize } from '@atlaskit/theme/constants';
11
11
  import browser from '../../utils/browser';
12
12
  import { CodeBlockSharedCssClassName } from './code-block';
13
+ import { tableCellBackgroundStyleOverride } from './tableCell';
13
14
  export var tableMarginTop = 24;
14
15
  export var tableMarginBottom = 16;
15
16
  export var tableMarginTopWithControl = 14;
@@ -35,7 +36,7 @@ export var TableSharedCssClassName = {
35
36
  TABLE_COLUMN_CONTROLS_DECORATIONS: "".concat(tablePrefixSelector, "-column-controls-decoration")
36
37
  };
37
38
  var tableSharedStyle = function tableSharedStyle(props) {
38
- return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n .", " {\n position: relative;\n margin: 0 auto ", "px;\n box-sizing: border-box;\n\n /**\n * Fix block top alignment inside table cells.\n */\n .decisionItemView-content-wrap:first-of-type > div {\n margin-top: 0;\n }\n }\n .", "[data-number-column='true'] {\n padding-left: ", "px;\n clear: both;\n }\n .", " > table {\n margin: ", "px 0 0 0;\n }\n\n .", " > table,\n .", " > table {\n margin: ", "px ", "px 0 0;\n }\n\n /* avoid applying styles to nested tables (possible via extensions) */\n .", " > table,\n .", " > table,\n .", " > table {\n border-collapse: collapse;\n border: ", "px solid\n ", ";\n table-layout: fixed;\n font-size: 1em;\n width: 100%;\n\n &[data-autosize='true'] {\n table-layout: auto;\n }\n\n & {\n * {\n box-sizing: border-box;\n }\n hr {\n box-sizing: content-box;\n }\n\n tbody {\n border-bottom: none;\n }\n th td {\n background-color: ", ";\n }\n th,\n td {\n min-width: ", "px;\n font-weight: normal;\n vertical-align: top;\n border: 1px solid\n ", ";\n border-right-width: 0;\n border-bottom-width: 0;\n padding: ", "px;\n /* https://stackoverflow.com/questions/7517127/borders-not-shown-in-firefox-with-border-collapse-on-table-position-relative-o */\n ", "\n\n ", ";\n\n > :first-child:not(style),\n > style:first-child + * {\n margin-top: 0;\n }\n\n > .ProseMirror-gapcursor:first-child + *,\n > style:first-child + .ProseMirror-gapcursor + * {\n margin-top: 0;\n }\n\n > .ProseMirror-gapcursor:first-child + span + *,\n > style:first-child + .ProseMirror-gapcursor + span + * {\n margin-top: 0;\n }\n\n th p:not(:first-of-type),\n td p:not(:first-of-type) {\n margin-top: 12px;\n }\n }\n th {\n background-color: ", ";\n text-align: left;\n\n /* only apply this styling to codeblocks in default background headercells */\n /* TODO this needs to be overhauled as it relies on unsafe selectors */\n &:not([style]):not(.danger) {\n .", ":not(.danger) {\n background-color: ", ";\n\n :not(.", ") {\n box-shadow: 0px 0px 0px 1px\n ", ";\n }\n\n .", " {\n background-image: ", ";\n\n background-color: ", ";\n }\n\n .", " {\n background-color: ", ";\n }\n\n /* this is only relevant to the element taken care of by renderer */\n > [data-ds--code--code-block] {\n background-image: ", "!important;\n\n background-color: ", "!important;\n\n // selector lives inside @atlaskit/code\n --ds--code--line-number-bg-color: ", ";\n }\n }\n }\n }\n }\n }\n"])), TableSharedCssClassName.TABLE_CONTAINER, tableMarginBottom, TableSharedCssClassName.TABLE_CONTAINER, akEditorTableNumberColumnWidth - 1, TableSharedCssClassName.TABLE_NODE_WRAPPER, tableMarginTop, TableSharedCssClassName.TABLE_CONTAINER, TableSharedCssClassName.TABLE_STICKY_WRAPPER, tableMarginTop, tableMarginSides, TableSharedCssClassName.TABLE_CONTAINER, TableSharedCssClassName.TABLE_NODE_WRAPPER, TableSharedCssClassName.TABLE_STICKY_WRAPPER, tableCellBorderWidth, themed({
39
+ return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n ", "\n .", " {\n position: relative;\n margin: 0 auto ", "px;\n box-sizing: border-box;\n\n /**\n * Fix block top alignment inside table cells.\n */\n .decisionItemView-content-wrap:first-of-type > div {\n margin-top: 0;\n }\n }\n .", "[data-number-column='true'] {\n padding-left: ", "px;\n clear: both;\n }\n .", " > table {\n margin: ", "px 0 0 0;\n }\n\n .", " > table,\n .", " > table {\n margin: ", "px ", "px 0 0;\n }\n\n /* avoid applying styles to nested tables (possible via extensions) */\n .", " > table,\n .", " > table,\n .", " > table {\n border-collapse: collapse;\n border: ", "px solid\n ", ";\n table-layout: fixed;\n font-size: 1em;\n width: 100%;\n\n &[data-autosize='true'] {\n table-layout: auto;\n }\n\n & {\n * {\n box-sizing: border-box;\n }\n hr {\n box-sizing: content-box;\n }\n\n tbody {\n border-bottom: none;\n }\n th td {\n background-color: ", ";\n }\n th,\n td {\n min-width: ", "px;\n font-weight: normal;\n vertical-align: top;\n border: 1px solid\n ", ";\n border-right-width: 0;\n border-bottom-width: 0;\n padding: ", "px;\n /* https://stackoverflow.com/questions/7517127/borders-not-shown-in-firefox-with-border-collapse-on-table-position-relative-o */\n ", "\n\n ", ";\n\n > :first-child:not(style),\n > style:first-child + * {\n margin-top: 0;\n }\n\n > .ProseMirror-gapcursor:first-child + *,\n > style:first-child + .ProseMirror-gapcursor + * {\n margin-top: 0;\n }\n\n > .ProseMirror-gapcursor:first-child + span + *,\n > style:first-child + .ProseMirror-gapcursor + span + * {\n margin-top: 0;\n }\n\n th p:not(:first-of-type),\n td p:not(:first-of-type) {\n margin-top: 12px;\n }\n }\n th {\n background-color: ", ";\n text-align: left;\n\n /* only apply this styling to codeblocks in default background headercells */\n /* TODO this needs to be overhauled as it relies on unsafe selectors */\n &:not([style]):not(.danger) {\n .", ":not(.danger) {\n background-color: ", ";\n\n :not(.", ") {\n box-shadow: 0px 0px 0px 1px\n ", ";\n }\n\n .", " {\n background-image: ", ";\n\n background-color: ", ";\n }\n\n .", " {\n background-color: ", ";\n }\n\n /* this is only relevant to the element taken care of by renderer */\n > [data-ds--code--code-block] {\n background-image: ", "!important;\n\n background-color: ", "!important;\n\n // selector lives inside @atlaskit/code\n --ds--code--line-number-bg-color: ", ";\n }\n }\n }\n }\n }\n }\n"])), tableCellBackgroundStyleOverride(), TableSharedCssClassName.TABLE_CONTAINER, tableMarginBottom, TableSharedCssClassName.TABLE_CONTAINER, akEditorTableNumberColumnWidth - 1, TableSharedCssClassName.TABLE_NODE_WRAPPER, tableMarginTop, TableSharedCssClassName.TABLE_CONTAINER, TableSharedCssClassName.TABLE_STICKY_WRAPPER, tableMarginTop, tableMarginSides, TableSharedCssClassName.TABLE_CONTAINER, TableSharedCssClassName.TABLE_NODE_WRAPPER, TableSharedCssClassName.TABLE_STICKY_WRAPPER, tableCellBorderWidth, themed({
39
40
  light: "var(--ds-border, ".concat(akEditorTableBorder, ")"),
40
41
  dark: "var(--ds-border, ".concat(akEditorTableBorderDark, ")")
41
42
  })(props), "var(--ds-background-neutral-subtle, white)", tableCellMinWidth, themed({
@@ -0,0 +1,24 @@
1
+ import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
2
+ var _templateObject;
3
+ /* eslint-disable @atlaskit/design-system/ensure-design-token-usage */
4
+ import { css } from '@emotion/react';
5
+ import { tableBackgroundColorNames } from '@atlaskit/adf-schema';
6
+ import { hexToEditorBackgroundPaletteColor } from '@atlaskit/editor-palette';
7
+ // This is used in order to support usage of DS tokens. Table cell background-color
8
+ // is set inline in '@atlaskit/adf-schema' and the color value is stored in ADF so
9
+ // it is not possible to use tokens there without polluting ADF.
10
+ // As table cell backgrounds are set inline, this should not break mobile as
11
+ // hexToEditorBackgroundPaletteColor() outputs a css variable with fallback hex.
12
+ var mapBackgroundColors = function mapBackgroundColors() {
13
+ var cssString = '';
14
+ tableBackgroundColorNames.forEach(function (value, key) {
15
+ var paletteColorValue = hexToEditorBackgroundPaletteColor(value);
16
+ if (paletteColorValue) {
17
+ cssString += "\n td[colorname='".concat(key, "' i],\n th[colorname='").concat(key, "' i] {\n background-color: ").concat(paletteColorValue, " !important;\n }\n ");
18
+ }
19
+ });
20
+ return cssString;
21
+ };
22
+ export var tableCellBackgroundStyleOverride = function tableCellBackgroundStyleOverride() {
23
+ return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n ", "\n"])), mapBackgroundColors());
24
+ };
@@ -18,7 +18,7 @@ import { themed } from '@atlaskit/theme/components';
18
18
  import { borderRadius, gridSize } from '@atlaskit/theme/constants';
19
19
  import Layer from '../Layer';
20
20
  var packageName = "@atlaskit/editor-common";
21
- var packageVersion = "72.5.0";
21
+ var packageVersion = "72.6.0";
22
22
  var halfFocusRing = 1;
23
23
  var dropOffset = "0, ".concat(gridSize(), "px");
24
24
  var DropList = /*#__PURE__*/function (_Component) {
@@ -131,7 +131,8 @@ var DropList = /*#__PURE__*/function (_Component) {
131
131
  position = _this$props.position,
132
132
  trigger = _this$props.trigger,
133
133
  onPositioned = _this$props.onPositioned,
134
- testId = _this$props.testId;
134
+ testId = _this$props.testId,
135
+ id = _this$props.id;
135
136
  var layerContent = isOpen ? jsx("div", {
136
137
  css: function css(theme) {
137
138
  return _this2.menuWrapper({
@@ -140,7 +141,9 @@ var DropList = /*#__PURE__*/function (_Component) {
140
141
  },
141
142
  "data-role": "droplistContent",
142
143
  "data-testid": testId && "".concat(testId, "--content"),
143
- ref: this.handleContentRef
144
+ ref: this.handleContentRef,
145
+ id: id,
146
+ role: "menu"
144
147
  }, children) : null;
145
148
  return jsx("div", {
146
149
  css: this.wrapperStyles
@@ -10,5 +10,5 @@ export var buttonStyle = css(_templateObject || (_templateObject = _taggedTempla
10
10
 
11
11
  /** this is not new usage - old code extracted from editor-core */
12
12
  /* eslint-disable @atlaskit/design-system/ensure-design-token-usage */
13
- export var buttonWrapperStyle = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n border: 1px solid transparent;\n margin: 1px;\n font-size: 0;\n display: flex;\n align-items: center;\n padding: 1px;\n border-radius: 6px;\n &:hover {\n border-color: ", ";\n }\n"])), N50);
13
+ export var buttonWrapperStyle = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n border: 1px solid transparent;\n margin: 1px;\n font-size: 0;\n display: flex;\n align-items: center;\n padding: 1px;\n border-radius: 6px;\n &:focus-within,\n &:focus,\n &:hover {\n border-color: ", " !important;\n }\n"])), N50);
14
14
  /* eslint-enable @atlaskit/design-system/ensure-design-token-usage */
@@ -1 +1,2 @@
1
- export { DEFAULT_BORDER_COLOR } from './common';
1
+ export { DEFAULT_BORDER_COLOR } from './common';
2
+ export { textPaletteTooltipMessages, backgroundPaletteTooltipMessages } from './paletteMessagesTokenModeNames';