@atlaskit/native-embeds-common 2.3.1 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # @atlaskit/native-embeds-common
2
2
 
3
+ ## 2.4.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`0394648ac08c8`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/0394648ac08c8) -
8
+ [ux] Group MAUI text edits by revision and link delayed version creation without adding another
9
+ history step. Undoing the first edit on a fresh embed now restores the pre-edit text.
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies
14
+
15
+ ## 2.3.2
16
+
17
+ ### Patch Changes
18
+
19
+ - Updated dependencies
20
+
3
21
  ## 2.3.1
4
22
 
5
23
  ### Patch Changes
@@ -9,6 +9,24 @@ Object.defineProperty(exports, "getRemixSlotValues", {
9
9
  return _remixSlotStore.getRemixSlotValues;
10
10
  }
11
11
  });
12
+ Object.defineProperty(exports, "getRemixVersionForRevision", {
13
+ enumerable: true,
14
+ get: function get() {
15
+ return _remixSlotStore.getRemixVersionForRevision;
16
+ }
17
+ });
18
+ Object.defineProperty(exports, "recordRemixRevisionEdit", {
19
+ enumerable: true,
20
+ get: function get() {
21
+ return _remixSlotStore.recordRemixRevisionEdit;
22
+ }
23
+ });
24
+ Object.defineProperty(exports, "recordRemixRevisionVersion", {
25
+ enumerable: true,
26
+ get: function get() {
27
+ return _remixSlotStore.recordRemixRevisionVersion;
28
+ }
29
+ });
12
30
  Object.defineProperty(exports, "recordRemixSlotValues", {
13
31
  enumerable: true,
14
32
  get: function get() {
@@ -21,4 +39,10 @@ Object.defineProperty(exports, "resetRemixSlotStore", {
21
39
  return _remixSlotStore.resetRemixSlotStore;
22
40
  }
23
41
  });
42
+ Object.defineProperty(exports, "seedRemixSlotValue", {
43
+ enumerable: true,
44
+ get: function get() {
45
+ return _remixSlotStore.seedRemixSlotValue;
46
+ }
47
+ });
24
48
  var _remixSlotStore = require("../utils/remix-slot-store");
@@ -21,6 +21,12 @@ Object.defineProperty(exports, "getParameters", {
21
21
  return _utils.getParameters;
22
22
  }
23
23
  });
24
+ Object.defineProperty(exports, "resolveRemixVersionId", {
25
+ enumerable: true,
26
+ get: function get() {
27
+ return _utils.resolveRemixVersionId;
28
+ }
29
+ });
24
30
  Object.defineProperty(exports, "setParameter", {
25
31
  enumerable: true,
26
32
  get: function get() {
@@ -11,8 +11,8 @@ require("./index.compiled.css");
11
11
  var _runtime = require("@compiled/react/runtime");
12
12
  var _react = _interopRequireWildcard(require("react"));
13
13
  var _reactIntl = require("react-intl");
14
- var _new = _interopRequireDefault(require("@atlaskit/button/new"));
15
- var _heading = _interopRequireDefault(require("@atlaskit/heading"));
14
+ var _button = _interopRequireDefault(require("@atlaskit/button/default/button"));
15
+ var _heading = _interopRequireDefault(require("@atlaskit/heading/heading"));
16
16
  var _refresh = _interopRequireDefault(require("@atlaskit/icon/core/refresh"));
17
17
  var _compiled = require("@atlaskit/primitives/compiled");
18
18
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
@@ -92,7 +92,7 @@ var NativeEmbedFallbackUI = exports.NativeEmbedFallbackUI = function NativeEmbed
92
92
  size: "small"
93
93
  }, formatMessage(messages.title)), /*#__PURE__*/_react.default.createElement(_compiled.Text, {
94
94
  color: "color.text.subtle"
95
- }, formatMessage(messages.description)), /*#__PURE__*/_react.default.createElement(_new.default, {
95
+ }, formatMessage(messages.description)), /*#__PURE__*/_react.default.createElement(_button.default, {
96
96
  iconBefore: _refresh.default,
97
97
  onClick: onConvert
98
98
  }, formatMessage(messages.refresh))));
@@ -4,21 +4,21 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.resetRemixSlotStore = exports.recordRemixSlotValues = exports.getRemixSlotValues = void 0;
7
+ exports.seedRemixSlotValue = exports.resetRemixSlotStore = exports.recordRemixSlotValues = exports.recordRemixRevisionVersion = exports.recordRemixRevisionEdit = exports.getRemixVersionForRevision = exports.getRemixSlotValues = void 0;
8
8
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
9
9
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
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
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) { (0, _defineProperty2.default)(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
12
  /**
13
- * Session-bound store for MAUI (remix) editable-text values, keyed by embed and
14
- * version. Part of the MAUI reload-free undo/redo (gate
13
+ * Session-bound store for MAUI (remix) editable-text values, keyed by embed,
14
+ * revision, and version. Part of the MAUI reload-free undo/redo (gate
15
15
  * `platform_editor_maui_remix_app_id`).
16
16
  *
17
17
  * Why this lives in `native-embeds-common` rather than the editor plugin: the
18
- * store is *managed by* the native-embeds editor plugin (it drives every write,
19
- * from the `native-embed-new-version` handler), but the value must also be
20
- * *read* by `native-embeds-editor-extension` when it renders the embed, to feed
21
- * the reload-free apply down to the child. The plugin already depends on the
18
+ * store is managed by the native-embeds editor plugin from edit and version
19
+ * events, but the value must also be read by `native-embeds-editor-extension`
20
+ * when it renders the embed, to feed the reload-free apply down to the child.
21
+ * The plugin already depends on the
22
22
  * extension, so a store physically inside the plugin package could not be read
23
23
  * by the extension without a dependency cycle. `native-embeds-common` is the
24
24
  * cycle-free package both sides already depend on.
@@ -31,14 +31,14 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
31
31
  */
32
32
 
33
33
  /**
34
- * `localId → (versionId → { slot: value })`.
34
+ * `localId → (versionId or revisionId → { slot: value })`.
35
35
  *
36
- * Each version holds a **full snapshot** of the edited slots as of that version
37
- * (built incrementally from single-slot edits), so applying `snapshot[target]`
38
- * on undo/redo fully restores that version's text. Slots that have never been
39
- * edited are absent and simply left untouched in the app (they never change).
36
+ * Each version and revision holds a full snapshot of the edited slots at that
37
+ * point, so undo and redo can restore its text. Unedited slots are absent.
40
38
  */
41
39
  var slotValuesByEmbed = new Map();
40
+ var slotValuesByRevisionByEmbed = new Map();
41
+ var versionByRevisionByEmbed = new Map();
42
42
  var getEmbedMap = function getEmbedMap(localId) {
43
43
  var perEmbed = slotValuesByEmbed.get(localId);
44
44
  if (!perEmbed) {
@@ -47,6 +47,56 @@ var getEmbedMap = function getEmbedMap(localId) {
47
47
  }
48
48
  return perEmbed;
49
49
  };
50
+ var getRevisionMap = function getRevisionMap(localId) {
51
+ var perEmbed = slotValuesByRevisionByEmbed.get(localId);
52
+ if (!perEmbed) {
53
+ perEmbed = new Map();
54
+ slotValuesByRevisionByEmbed.set(localId, perEmbed);
55
+ }
56
+ return perEmbed;
57
+ };
58
+ var saveRevisionSnapshot = function saveRevisionSnapshot(localId, revisionId, snapshot) {
59
+ var _versionByRevisionByE;
60
+ var savedSnapshot = _objectSpread({}, snapshot);
61
+ getRevisionMap(localId).set(revisionId, savedSnapshot);
62
+ var versionId = (_versionByRevisionByE = versionByRevisionByEmbed.get(localId)) === null || _versionByRevisionByE === void 0 ? void 0 : _versionByRevisionByE.get(revisionId);
63
+ if (versionId) {
64
+ getEmbedMap(localId).set(versionId, savedSnapshot);
65
+ }
66
+ };
67
+ var recordRemixRevisionEdit = exports.recordRemixRevisionEdit = function recordRemixRevisionEdit(_ref) {
68
+ var _ref2, _revisionSnapshots$ge;
69
+ var currentVersionId = _ref.currentVersionId,
70
+ localId = _ref.localId,
71
+ previousRevisionId = _ref.previousRevisionId,
72
+ previousValue = _ref.previousValue,
73
+ revisionId = _ref.revisionId,
74
+ slot = _ref.slot,
75
+ value = _ref.value;
76
+ if (!localId || !revisionId || !slot) {
77
+ return;
78
+ }
79
+ var versionSnapshots = getEmbedMap(localId);
80
+ var revisionSnapshots = getRevisionMap(localId);
81
+ var previousRevisionSnapshot = previousRevisionId ? revisionSnapshots.get(previousRevisionId) : undefined;
82
+ var currentVersionSnapshot = currentVersionId ? versionSnapshots.get(currentVersionId) : undefined;
83
+ var baseSnapshot = (_ref2 = previousRevisionSnapshot !== null && previousRevisionSnapshot !== void 0 ? previousRevisionSnapshot : currentVersionSnapshot) !== null && _ref2 !== void 0 ? _ref2 : {};
84
+ if (!(slot in baseSnapshot)) {
85
+ baseSnapshot = _objectSpread(_objectSpread({}, baseSnapshot), {}, (0, _defineProperty2.default)({}, slot, previousValue));
86
+ if (previousRevisionId && previousRevisionId !== revisionId) {
87
+ saveRevisionSnapshot(localId, previousRevisionId, baseSnapshot);
88
+ }
89
+ }
90
+ if (currentVersionId) {
91
+ var _versionSnapshots$get;
92
+ var snapshot = (_versionSnapshots$get = versionSnapshots.get(currentVersionId)) !== null && _versionSnapshots$get !== void 0 ? _versionSnapshots$get : {};
93
+ if (!(slot in snapshot)) {
94
+ versionSnapshots.set(currentVersionId, _objectSpread(_objectSpread({}, snapshot), {}, (0, _defineProperty2.default)({}, slot, previousValue)));
95
+ }
96
+ }
97
+ var revisionSnapshot = (_revisionSnapshots$ge = revisionSnapshots.get(revisionId)) !== null && _revisionSnapshots$ge !== void 0 ? _revisionSnapshots$ge : baseSnapshot;
98
+ saveRevisionSnapshot(localId, revisionId, _objectSpread(_objectSpread({}, revisionSnapshot), {}, (0, _defineProperty2.default)({}, slot, value)));
99
+ };
50
100
 
51
101
  /**
52
102
  * Record the single edit that produced a new version, extending the incremental
@@ -61,13 +111,13 @@ var getEmbedMap = function getEmbedMap(localId) {
61
111
  * new version simply inherits the previous snapshot; with no `prevVersionId`
62
112
  * (e.g. the embed had no stored version yet) the base snapshot is not seeded.
63
113
  */
64
- var recordRemixSlotValues = exports.recordRemixSlotValues = function recordRemixSlotValues(_ref) {
65
- var localId = _ref.localId,
66
- prevVersionId = _ref.prevVersionId,
67
- newVersionId = _ref.newVersionId,
68
- slot = _ref.slot,
69
- previousValue = _ref.previousValue,
70
- value = _ref.value;
114
+ var recordRemixSlotValues = exports.recordRemixSlotValues = function recordRemixSlotValues(_ref3) {
115
+ var localId = _ref3.localId,
116
+ prevVersionId = _ref3.prevVersionId,
117
+ newVersionId = _ref3.newVersionId,
118
+ slot = _ref3.slot,
119
+ previousValue = _ref3.previousValue,
120
+ value = _ref3.value;
71
121
  if (!localId || !newVersionId) {
72
122
  return;
73
123
  }
@@ -81,6 +131,18 @@ var recordRemixSlotValues = exports.recordRemixSlotValues = function recordRemix
81
131
  var newSnapshot = slot && value !== undefined ? _objectSpread(_objectSpread({}, prevSnapshot), {}, (0, _defineProperty2.default)({}, slot, value)) : _objectSpread({}, prevSnapshot);
82
132
  perEmbed.set(newVersionId, newSnapshot);
83
133
  };
134
+ var seedRemixSlotValue = exports.seedRemixSlotValue = function seedRemixSlotValue(localId, versionId, slot, value) {
135
+ var _perEmbed$get;
136
+ if (!localId || !versionId || !slot) {
137
+ return;
138
+ }
139
+ var perEmbed = getEmbedMap(localId);
140
+ var snapshot = (_perEmbed$get = perEmbed.get(versionId)) !== null && _perEmbed$get !== void 0 ? _perEmbed$get : {};
141
+ if (slot in snapshot) {
142
+ return;
143
+ }
144
+ perEmbed.set(versionId, _objectSpread(_objectSpread({}, snapshot), {}, (0, _defineProperty2.default)({}, slot, value)));
145
+ };
84
146
 
85
147
  /**
86
148
  * Return the full slot snapshot for a version as an array, or `undefined` when
@@ -96,18 +158,43 @@ var getRemixSlotValues = exports.getRemixSlotValues = function getRemixSlotValue
96
158
  if (!snapshot) {
97
159
  return undefined;
98
160
  }
99
- return Object.entries(snapshot).map(function (_ref2) {
100
- var _ref3 = (0, _slicedToArray2.default)(_ref2, 2),
101
- slot = _ref3[0],
102
- value = _ref3[1];
161
+ return Object.entries(snapshot).map(function (_ref4) {
162
+ var _ref5 = (0, _slicedToArray2.default)(_ref4, 2),
163
+ slot = _ref5[0],
164
+ value = _ref5[1];
103
165
  return {
104
166
  slot: slot,
105
167
  value: value
106
168
  };
107
169
  });
108
170
  };
171
+ var recordRemixRevisionVersion = exports.recordRemixRevisionVersion = function recordRemixRevisionVersion(localId, revisionId, versionId) {
172
+ var _slotValuesByRevision;
173
+ if (!localId || !revisionId || !versionId) {
174
+ return;
175
+ }
176
+ var versions = versionByRevisionByEmbed.get(localId);
177
+ if (!versions) {
178
+ versions = new Map();
179
+ versionByRevisionByEmbed.set(localId, versions);
180
+ }
181
+ versions.set(revisionId, versionId);
182
+ var snapshot = (_slotValuesByRevision = slotValuesByRevisionByEmbed.get(localId)) === null || _slotValuesByRevision === void 0 ? void 0 : _slotValuesByRevision.get(revisionId);
183
+ if (snapshot) {
184
+ getEmbedMap(localId).set(versionId, _objectSpread({}, snapshot));
185
+ }
186
+ };
187
+ var getRemixVersionForRevision = exports.getRemixVersionForRevision = function getRemixVersionForRevision(localId, revisionId) {
188
+ var _versionByRevisionByE2;
189
+ if (!localId || !revisionId) {
190
+ return undefined;
191
+ }
192
+ return (_versionByRevisionByE2 = versionByRevisionByEmbed.get(localId)) === null || _versionByRevisionByE2 === void 0 ? void 0 : _versionByRevisionByE2.get(revisionId);
193
+ };
109
194
 
110
195
  /** Test-only: clear the whole store. */
111
196
  var resetRemixSlotStore = exports.resetRemixSlotStore = function resetRemixSlotStore() {
112
197
  slotValuesByEmbed.clear();
198
+ slotValuesByRevisionByEmbed.clear();
199
+ versionByRevisionByEmbed.clear();
113
200
  };
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.getParameter = exports.createEditorToolbarActions = void 0;
8
8
  exports.getParameters = getParameters;
9
- exports.setParameters = exports.setParameter = void 0;
9
+ exports.setParameters = exports.setParameter = exports.resolveRemixVersionId = void 0;
10
10
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
11
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
12
12
  var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
@@ -104,6 +104,25 @@ var getParameter = exports.getParameter = function getParameter(parameters, key)
104
104
  return parsedValue === undefined ? _constants.NATIVE_EMBED_PARAMETER_DEFAULTS[key] : parsedValue;
105
105
  };
106
106
 
107
+ /** Matches the version id embedded in a legacy `/remix/ui/{id}` embed URL. */
108
+ var REMIX_UI_ID_RE = /\/remix\/ui\/([\w-]+)/;
109
+
110
+ /**
111
+ * Resolve the MAUI (remix) version pointer for an embed: the stored `remixAppId`
112
+ * parameter, falling back to the id embedded in a legacy `/remix/ui/{id}` URL.
113
+ *
114
+ * Every read *and* write of the pointer must go through this. A fresh embed carries no
115
+ * `remixAppId` parameter, so a caller that reads the parameter alone sees `undefined`
116
+ * while a caller that applies the fallback sees the URL id — and the pre-edit slot
117
+ * snapshot then gets recorded under a different key than undo later looks up.
118
+ */
119
+ var resolveRemixVersionId = exports.resolveRemixVersionId = function resolveRemixVersionId(_ref) {
120
+ var _url$match$, _url$match;
121
+ var storedRemixAppId = _ref.storedRemixAppId,
122
+ url = _ref.url;
123
+ return storedRemixAppId || (url ? (_url$match$ = (_url$match = url.match(REMIX_UI_ID_RE)) === null || _url$match === void 0 ? void 0 : _url$match[1]) !== null && _url$match$ !== void 0 ? _url$match$ : undefined : undefined);
124
+ };
125
+
107
126
  /**
108
127
  * Gets native-embed parameters as resolved values.
109
128
  * When key is provided, returns that single resolved value.
@@ -134,19 +153,19 @@ var setParameter = exports.setParameter = function setParameter(parameters, upda
134
153
  var setParameters = exports.setParameters = function setParameters(parameters, updates) {
135
154
  var currentParameters = parameters !== null && parameters !== void 0 ? parameters : {};
136
155
  var currentMacroParams = getMacroParamsRecord(parameters);
137
- var wrappedUpdates = Object.fromEntries(Object.entries(updates).map(function (_ref) {
138
- var _ref2 = (0, _slicedToArray2.default)(_ref, 2),
139
- key = _ref2[0],
140
- value = _ref2[1];
156
+ var wrappedUpdates = Object.fromEntries(Object.entries(updates).map(function (_ref2) {
157
+ var _ref3 = (0, _slicedToArray2.default)(_ref2, 2),
158
+ key = _ref3[0],
159
+ value = _ref3[1];
141
160
  return [key, serializeParameterValue(key, value)];
142
- }).filter(function (_ref3) {
143
- var _ref4 = (0, _slicedToArray2.default)(_ref3, 2),
144
- value = _ref4[1];
161
+ }).filter(function (_ref4) {
162
+ var _ref5 = (0, _slicedToArray2.default)(_ref4, 2),
163
+ value = _ref5[1];
145
164
  return value !== undefined;
146
- }).map(function (_ref5) {
147
- var _ref6 = (0, _slicedToArray2.default)(_ref5, 2),
148
- key = _ref6[0],
149
- value = _ref6[1];
165
+ }).map(function (_ref6) {
166
+ var _ref7 = (0, _slicedToArray2.default)(_ref6, 2),
167
+ key = _ref7[0],
168
+ value = _ref7[1];
150
169
  return [key, {
151
170
  value: value
152
171
  }];
@@ -1 +1 @@
1
- export { getRemixSlotValues, recordRemixSlotValues, resetRemixSlotStore } from '../utils/remix-slot-store';
1
+ export { getRemixSlotValues, getRemixVersionForRevision, recordRemixRevisionEdit, recordRemixSlotValues, recordRemixRevisionVersion, seedRemixSlotValue, resetRemixSlotStore } from '../utils/remix-slot-store';
@@ -1 +1 @@
1
- export { createEditorToolbarActions, getParameter, getParameters, setParameter, setParameters } from '../utils/utils';
1
+ export { createEditorToolbarActions, getParameter, getParameters, resolveRemixVersionId, setParameter, setParameters } from '../utils/utils';
@@ -3,8 +3,8 @@ import "./index.compiled.css";
3
3
  import { ax, ix } from "@compiled/react/runtime";
4
4
  import React, { useCallback } from 'react';
5
5
  import { defineMessages, useIntl } from 'react-intl';
6
- import Button from '@atlaskit/button/new';
7
- import Heading from '@atlaskit/heading';
6
+ import Button from '@atlaskit/button/default/button';
7
+ import Heading from '@atlaskit/heading/heading';
8
8
  import RefreshIcon from '@atlaskit/icon/core/refresh';
9
9
  import { Box, Stack, Text } from '@atlaskit/primitives/compiled';
10
10
  const messages = defineMessages({
@@ -1,13 +1,13 @@
1
1
  /**
2
- * Session-bound store for MAUI (remix) editable-text values, keyed by embed and
3
- * version. Part of the MAUI reload-free undo/redo (gate
2
+ * Session-bound store for MAUI (remix) editable-text values, keyed by embed,
3
+ * revision, and version. Part of the MAUI reload-free undo/redo (gate
4
4
  * `platform_editor_maui_remix_app_id`).
5
5
  *
6
6
  * Why this lives in `native-embeds-common` rather than the editor plugin: the
7
- * store is *managed by* the native-embeds editor plugin (it drives every write,
8
- * from the `native-embed-new-version` handler), but the value must also be
9
- * *read* by `native-embeds-editor-extension` when it renders the embed, to feed
10
- * the reload-free apply down to the child. The plugin already depends on the
7
+ * store is managed by the native-embeds editor plugin from edit and version
8
+ * events, but the value must also be read by `native-embeds-editor-extension`
9
+ * when it renders the embed, to feed the reload-free apply down to the child.
10
+ * The plugin already depends on the
11
11
  * extension, so a store physically inside the plugin package could not be read
12
12
  * by the extension without a dependency cycle. `native-embeds-common` is the
13
13
  * cycle-free package both sides already depend on.
@@ -20,14 +20,14 @@
20
20
  */
21
21
 
22
22
  /**
23
- * `localId → (versionId → { slot: value })`.
23
+ * `localId → (versionId or revisionId → { slot: value })`.
24
24
  *
25
- * Each version holds a **full snapshot** of the edited slots as of that version
26
- * (built incrementally from single-slot edits), so applying `snapshot[target]`
27
- * on undo/redo fully restores that version's text. Slots that have never been
28
- * edited are absent and simply left untouched in the app (they never change).
25
+ * Each version and revision holds a full snapshot of the edited slots at that
26
+ * point, so undo and redo can restore its text. Unedited slots are absent.
29
27
  */
30
28
  const slotValuesByEmbed = new Map();
29
+ const slotValuesByRevisionByEmbed = new Map();
30
+ const versionByRevisionByEmbed = new Map();
31
31
  const getEmbedMap = localId => {
32
32
  let perEmbed = slotValuesByEmbed.get(localId);
33
33
  if (!perEmbed) {
@@ -36,6 +36,68 @@ const getEmbedMap = localId => {
36
36
  }
37
37
  return perEmbed;
38
38
  };
39
+ const getRevisionMap = localId => {
40
+ let perEmbed = slotValuesByRevisionByEmbed.get(localId);
41
+ if (!perEmbed) {
42
+ perEmbed = new Map();
43
+ slotValuesByRevisionByEmbed.set(localId, perEmbed);
44
+ }
45
+ return perEmbed;
46
+ };
47
+ const saveRevisionSnapshot = (localId, revisionId, snapshot) => {
48
+ var _versionByRevisionByE;
49
+ const savedSnapshot = {
50
+ ...snapshot
51
+ };
52
+ getRevisionMap(localId).set(revisionId, savedSnapshot);
53
+ const versionId = (_versionByRevisionByE = versionByRevisionByEmbed.get(localId)) === null || _versionByRevisionByE === void 0 ? void 0 : _versionByRevisionByE.get(revisionId);
54
+ if (versionId) {
55
+ getEmbedMap(localId).set(versionId, savedSnapshot);
56
+ }
57
+ };
58
+ export const recordRemixRevisionEdit = ({
59
+ currentVersionId,
60
+ localId,
61
+ previousRevisionId,
62
+ previousValue,
63
+ revisionId,
64
+ slot,
65
+ value
66
+ }) => {
67
+ var _ref, _revisionSnapshots$ge;
68
+ if (!localId || !revisionId || !slot) {
69
+ return;
70
+ }
71
+ const versionSnapshots = getEmbedMap(localId);
72
+ const revisionSnapshots = getRevisionMap(localId);
73
+ const previousRevisionSnapshot = previousRevisionId ? revisionSnapshots.get(previousRevisionId) : undefined;
74
+ const currentVersionSnapshot = currentVersionId ? versionSnapshots.get(currentVersionId) : undefined;
75
+ let baseSnapshot = (_ref = previousRevisionSnapshot !== null && previousRevisionSnapshot !== void 0 ? previousRevisionSnapshot : currentVersionSnapshot) !== null && _ref !== void 0 ? _ref : {};
76
+ if (!(slot in baseSnapshot)) {
77
+ baseSnapshot = {
78
+ ...baseSnapshot,
79
+ [slot]: previousValue
80
+ };
81
+ if (previousRevisionId && previousRevisionId !== revisionId) {
82
+ saveRevisionSnapshot(localId, previousRevisionId, baseSnapshot);
83
+ }
84
+ }
85
+ if (currentVersionId) {
86
+ var _versionSnapshots$get;
87
+ const snapshot = (_versionSnapshots$get = versionSnapshots.get(currentVersionId)) !== null && _versionSnapshots$get !== void 0 ? _versionSnapshots$get : {};
88
+ if (!(slot in snapshot)) {
89
+ versionSnapshots.set(currentVersionId, {
90
+ ...snapshot,
91
+ [slot]: previousValue
92
+ });
93
+ }
94
+ }
95
+ const revisionSnapshot = (_revisionSnapshots$ge = revisionSnapshots.get(revisionId)) !== null && _revisionSnapshots$ge !== void 0 ? _revisionSnapshots$ge : baseSnapshot;
96
+ saveRevisionSnapshot(localId, revisionId, {
97
+ ...revisionSnapshot,
98
+ [slot]: value
99
+ });
100
+ };
39
101
 
40
102
  /**
41
103
  * Record the single edit that produced a new version, extending the incremental
@@ -79,6 +141,21 @@ export const recordRemixSlotValues = ({
79
141
  };
80
142
  perEmbed.set(newVersionId, newSnapshot);
81
143
  };
144
+ export const seedRemixSlotValue = (localId, versionId, slot, value) => {
145
+ var _perEmbed$get;
146
+ if (!localId || !versionId || !slot) {
147
+ return;
148
+ }
149
+ const perEmbed = getEmbedMap(localId);
150
+ const snapshot = (_perEmbed$get = perEmbed.get(versionId)) !== null && _perEmbed$get !== void 0 ? _perEmbed$get : {};
151
+ if (slot in snapshot) {
152
+ return;
153
+ }
154
+ perEmbed.set(versionId, {
155
+ ...snapshot,
156
+ [slot]: value
157
+ });
158
+ };
82
159
 
83
160
  /**
84
161
  * Return the full slot snapshot for a version as an array, or `undefined` when
@@ -99,8 +176,35 @@ export const getRemixSlotValues = (localId, versionId) => {
99
176
  value
100
177
  }));
101
178
  };
179
+ export const recordRemixRevisionVersion = (localId, revisionId, versionId) => {
180
+ var _slotValuesByRevision;
181
+ if (!localId || !revisionId || !versionId) {
182
+ return;
183
+ }
184
+ let versions = versionByRevisionByEmbed.get(localId);
185
+ if (!versions) {
186
+ versions = new Map();
187
+ versionByRevisionByEmbed.set(localId, versions);
188
+ }
189
+ versions.set(revisionId, versionId);
190
+ const snapshot = (_slotValuesByRevision = slotValuesByRevisionByEmbed.get(localId)) === null || _slotValuesByRevision === void 0 ? void 0 : _slotValuesByRevision.get(revisionId);
191
+ if (snapshot) {
192
+ getEmbedMap(localId).set(versionId, {
193
+ ...snapshot
194
+ });
195
+ }
196
+ };
197
+ export const getRemixVersionForRevision = (localId, revisionId) => {
198
+ var _versionByRevisionByE2;
199
+ if (!localId || !revisionId) {
200
+ return undefined;
201
+ }
202
+ return (_versionByRevisionByE2 = versionByRevisionByEmbed.get(localId)) === null || _versionByRevisionByE2 === void 0 ? void 0 : _versionByRevisionByE2.get(revisionId);
203
+ };
102
204
 
103
205
  /** Test-only: clear the whole store. */
104
206
  export const resetRemixSlotStore = () => {
105
207
  slotValuesByEmbed.clear();
208
+ slotValuesByRevisionByEmbed.clear();
209
+ versionByRevisionByEmbed.clear();
106
210
  };
@@ -88,6 +88,26 @@ export const getParameter = (parameters, key) => {
88
88
  return parsedValue === undefined ? NATIVE_EMBED_PARAMETER_DEFAULTS[key] : parsedValue;
89
89
  };
90
90
 
91
+ /** Matches the version id embedded in a legacy `/remix/ui/{id}` embed URL. */
92
+ const REMIX_UI_ID_RE = /\/remix\/ui\/([\w-]+)/;
93
+
94
+ /**
95
+ * Resolve the MAUI (remix) version pointer for an embed: the stored `remixAppId`
96
+ * parameter, falling back to the id embedded in a legacy `/remix/ui/{id}` URL.
97
+ *
98
+ * Every read *and* write of the pointer must go through this. A fresh embed carries no
99
+ * `remixAppId` parameter, so a caller that reads the parameter alone sees `undefined`
100
+ * while a caller that applies the fallback sees the URL id — and the pre-edit slot
101
+ * snapshot then gets recorded under a different key than undo later looks up.
102
+ */
103
+ export const resolveRemixVersionId = ({
104
+ storedRemixAppId,
105
+ url
106
+ }) => {
107
+ var _url$match$, _url$match;
108
+ return storedRemixAppId || (url ? (_url$match$ = (_url$match = url.match(REMIX_UI_ID_RE)) === null || _url$match === void 0 ? void 0 : _url$match[1]) !== null && _url$match$ !== void 0 ? _url$match$ : undefined : undefined);
109
+ };
110
+
91
111
  /**
92
112
  * Gets native-embed parameters as resolved values.
93
113
  * When key is provided, returns that single resolved value.
@@ -1 +1 @@
1
- export { getRemixSlotValues, recordRemixSlotValues, resetRemixSlotStore } from '../utils/remix-slot-store';
1
+ export { getRemixSlotValues, getRemixVersionForRevision, recordRemixRevisionEdit, recordRemixSlotValues, recordRemixRevisionVersion, seedRemixSlotValue, resetRemixSlotStore } from '../utils/remix-slot-store';
@@ -1 +1 @@
1
- export { createEditorToolbarActions, getParameter, getParameters, setParameter, setParameters } from '../utils/utils';
1
+ export { createEditorToolbarActions, getParameter, getParameters, resolveRemixVersionId, setParameter, setParameters } from '../utils/utils';
@@ -3,8 +3,8 @@ import "./index.compiled.css";
3
3
  import { ax, ix } from "@compiled/react/runtime";
4
4
  import React, { useCallback } from 'react';
5
5
  import { defineMessages, useIntl } from 'react-intl';
6
- import Button from '@atlaskit/button/new';
7
- import Heading from '@atlaskit/heading';
6
+ import Button from '@atlaskit/button/default/button';
7
+ import Heading from '@atlaskit/heading/heading';
8
8
  import RefreshIcon from '@atlaskit/icon/core/refresh';
9
9
  import { Box, Stack, Text } from '@atlaskit/primitives/compiled';
10
10
  var messages = defineMessages({
@@ -3,15 +3,15 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
3
  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; }
4
4
  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; }
5
5
  /**
6
- * Session-bound store for MAUI (remix) editable-text values, keyed by embed and
7
- * version. Part of the MAUI reload-free undo/redo (gate
6
+ * Session-bound store for MAUI (remix) editable-text values, keyed by embed,
7
+ * revision, and version. Part of the MAUI reload-free undo/redo (gate
8
8
  * `platform_editor_maui_remix_app_id`).
9
9
  *
10
10
  * Why this lives in `native-embeds-common` rather than the editor plugin: the
11
- * store is *managed by* the native-embeds editor plugin (it drives every write,
12
- * from the `native-embed-new-version` handler), but the value must also be
13
- * *read* by `native-embeds-editor-extension` when it renders the embed, to feed
14
- * the reload-free apply down to the child. The plugin already depends on the
11
+ * store is managed by the native-embeds editor plugin from edit and version
12
+ * events, but the value must also be read by `native-embeds-editor-extension`
13
+ * when it renders the embed, to feed the reload-free apply down to the child.
14
+ * The plugin already depends on the
15
15
  * extension, so a store physically inside the plugin package could not be read
16
16
  * by the extension without a dependency cycle. `native-embeds-common` is the
17
17
  * cycle-free package both sides already depend on.
@@ -24,14 +24,14 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
24
24
  */
25
25
 
26
26
  /**
27
- * `localId → (versionId → { slot: value })`.
27
+ * `localId → (versionId or revisionId → { slot: value })`.
28
28
  *
29
- * Each version holds a **full snapshot** of the edited slots as of that version
30
- * (built incrementally from single-slot edits), so applying `snapshot[target]`
31
- * on undo/redo fully restores that version's text. Slots that have never been
32
- * edited are absent and simply left untouched in the app (they never change).
29
+ * Each version and revision holds a full snapshot of the edited slots at that
30
+ * point, so undo and redo can restore its text. Unedited slots are absent.
33
31
  */
34
32
  var slotValuesByEmbed = new Map();
33
+ var slotValuesByRevisionByEmbed = new Map();
34
+ var versionByRevisionByEmbed = new Map();
35
35
  var getEmbedMap = function getEmbedMap(localId) {
36
36
  var perEmbed = slotValuesByEmbed.get(localId);
37
37
  if (!perEmbed) {
@@ -40,6 +40,56 @@ var getEmbedMap = function getEmbedMap(localId) {
40
40
  }
41
41
  return perEmbed;
42
42
  };
43
+ var getRevisionMap = function getRevisionMap(localId) {
44
+ var perEmbed = slotValuesByRevisionByEmbed.get(localId);
45
+ if (!perEmbed) {
46
+ perEmbed = new Map();
47
+ slotValuesByRevisionByEmbed.set(localId, perEmbed);
48
+ }
49
+ return perEmbed;
50
+ };
51
+ var saveRevisionSnapshot = function saveRevisionSnapshot(localId, revisionId, snapshot) {
52
+ var _versionByRevisionByE;
53
+ var savedSnapshot = _objectSpread({}, snapshot);
54
+ getRevisionMap(localId).set(revisionId, savedSnapshot);
55
+ var versionId = (_versionByRevisionByE = versionByRevisionByEmbed.get(localId)) === null || _versionByRevisionByE === void 0 ? void 0 : _versionByRevisionByE.get(revisionId);
56
+ if (versionId) {
57
+ getEmbedMap(localId).set(versionId, savedSnapshot);
58
+ }
59
+ };
60
+ export var recordRemixRevisionEdit = function recordRemixRevisionEdit(_ref) {
61
+ var _ref2, _revisionSnapshots$ge;
62
+ var currentVersionId = _ref.currentVersionId,
63
+ localId = _ref.localId,
64
+ previousRevisionId = _ref.previousRevisionId,
65
+ previousValue = _ref.previousValue,
66
+ revisionId = _ref.revisionId,
67
+ slot = _ref.slot,
68
+ value = _ref.value;
69
+ if (!localId || !revisionId || !slot) {
70
+ return;
71
+ }
72
+ var versionSnapshots = getEmbedMap(localId);
73
+ var revisionSnapshots = getRevisionMap(localId);
74
+ var previousRevisionSnapshot = previousRevisionId ? revisionSnapshots.get(previousRevisionId) : undefined;
75
+ var currentVersionSnapshot = currentVersionId ? versionSnapshots.get(currentVersionId) : undefined;
76
+ var baseSnapshot = (_ref2 = previousRevisionSnapshot !== null && previousRevisionSnapshot !== void 0 ? previousRevisionSnapshot : currentVersionSnapshot) !== null && _ref2 !== void 0 ? _ref2 : {};
77
+ if (!(slot in baseSnapshot)) {
78
+ baseSnapshot = _objectSpread(_objectSpread({}, baseSnapshot), {}, _defineProperty({}, slot, previousValue));
79
+ if (previousRevisionId && previousRevisionId !== revisionId) {
80
+ saveRevisionSnapshot(localId, previousRevisionId, baseSnapshot);
81
+ }
82
+ }
83
+ if (currentVersionId) {
84
+ var _versionSnapshots$get;
85
+ var snapshot = (_versionSnapshots$get = versionSnapshots.get(currentVersionId)) !== null && _versionSnapshots$get !== void 0 ? _versionSnapshots$get : {};
86
+ if (!(slot in snapshot)) {
87
+ versionSnapshots.set(currentVersionId, _objectSpread(_objectSpread({}, snapshot), {}, _defineProperty({}, slot, previousValue)));
88
+ }
89
+ }
90
+ var revisionSnapshot = (_revisionSnapshots$ge = revisionSnapshots.get(revisionId)) !== null && _revisionSnapshots$ge !== void 0 ? _revisionSnapshots$ge : baseSnapshot;
91
+ saveRevisionSnapshot(localId, revisionId, _objectSpread(_objectSpread({}, revisionSnapshot), {}, _defineProperty({}, slot, value)));
92
+ };
43
93
 
44
94
  /**
45
95
  * Record the single edit that produced a new version, extending the incremental
@@ -54,13 +104,13 @@ var getEmbedMap = function getEmbedMap(localId) {
54
104
  * new version simply inherits the previous snapshot; with no `prevVersionId`
55
105
  * (e.g. the embed had no stored version yet) the base snapshot is not seeded.
56
106
  */
57
- export var recordRemixSlotValues = function recordRemixSlotValues(_ref) {
58
- var localId = _ref.localId,
59
- prevVersionId = _ref.prevVersionId,
60
- newVersionId = _ref.newVersionId,
61
- slot = _ref.slot,
62
- previousValue = _ref.previousValue,
63
- value = _ref.value;
107
+ export var recordRemixSlotValues = function recordRemixSlotValues(_ref3) {
108
+ var localId = _ref3.localId,
109
+ prevVersionId = _ref3.prevVersionId,
110
+ newVersionId = _ref3.newVersionId,
111
+ slot = _ref3.slot,
112
+ previousValue = _ref3.previousValue,
113
+ value = _ref3.value;
64
114
  if (!localId || !newVersionId) {
65
115
  return;
66
116
  }
@@ -74,6 +124,18 @@ export var recordRemixSlotValues = function recordRemixSlotValues(_ref) {
74
124
  var newSnapshot = slot && value !== undefined ? _objectSpread(_objectSpread({}, prevSnapshot), {}, _defineProperty({}, slot, value)) : _objectSpread({}, prevSnapshot);
75
125
  perEmbed.set(newVersionId, newSnapshot);
76
126
  };
127
+ export var seedRemixSlotValue = function seedRemixSlotValue(localId, versionId, slot, value) {
128
+ var _perEmbed$get;
129
+ if (!localId || !versionId || !slot) {
130
+ return;
131
+ }
132
+ var perEmbed = getEmbedMap(localId);
133
+ var snapshot = (_perEmbed$get = perEmbed.get(versionId)) !== null && _perEmbed$get !== void 0 ? _perEmbed$get : {};
134
+ if (slot in snapshot) {
135
+ return;
136
+ }
137
+ perEmbed.set(versionId, _objectSpread(_objectSpread({}, snapshot), {}, _defineProperty({}, slot, value)));
138
+ };
77
139
 
78
140
  /**
79
141
  * Return the full slot snapshot for a version as an array, or `undefined` when
@@ -89,18 +151,43 @@ export var getRemixSlotValues = function getRemixSlotValues(localId, versionId)
89
151
  if (!snapshot) {
90
152
  return undefined;
91
153
  }
92
- return Object.entries(snapshot).map(function (_ref2) {
93
- var _ref3 = _slicedToArray(_ref2, 2),
94
- slot = _ref3[0],
95
- value = _ref3[1];
154
+ return Object.entries(snapshot).map(function (_ref4) {
155
+ var _ref5 = _slicedToArray(_ref4, 2),
156
+ slot = _ref5[0],
157
+ value = _ref5[1];
96
158
  return {
97
159
  slot: slot,
98
160
  value: value
99
161
  };
100
162
  });
101
163
  };
164
+ export var recordRemixRevisionVersion = function recordRemixRevisionVersion(localId, revisionId, versionId) {
165
+ var _slotValuesByRevision;
166
+ if (!localId || !revisionId || !versionId) {
167
+ return;
168
+ }
169
+ var versions = versionByRevisionByEmbed.get(localId);
170
+ if (!versions) {
171
+ versions = new Map();
172
+ versionByRevisionByEmbed.set(localId, versions);
173
+ }
174
+ versions.set(revisionId, versionId);
175
+ var snapshot = (_slotValuesByRevision = slotValuesByRevisionByEmbed.get(localId)) === null || _slotValuesByRevision === void 0 ? void 0 : _slotValuesByRevision.get(revisionId);
176
+ if (snapshot) {
177
+ getEmbedMap(localId).set(versionId, _objectSpread({}, snapshot));
178
+ }
179
+ };
180
+ export var getRemixVersionForRevision = function getRemixVersionForRevision(localId, revisionId) {
181
+ var _versionByRevisionByE2;
182
+ if (!localId || !revisionId) {
183
+ return undefined;
184
+ }
185
+ return (_versionByRevisionByE2 = versionByRevisionByEmbed.get(localId)) === null || _versionByRevisionByE2 === void 0 ? void 0 : _versionByRevisionByE2.get(revisionId);
186
+ };
102
187
 
103
188
  /** Test-only: clear the whole store. */
104
189
  export var resetRemixSlotStore = function resetRemixSlotStore() {
105
190
  slotValuesByEmbed.clear();
191
+ slotValuesByRevisionByEmbed.clear();
192
+ versionByRevisionByEmbed.clear();
106
193
  };
@@ -95,6 +95,25 @@ export var getParameter = function getParameter(parameters, key) {
95
95
  return parsedValue === undefined ? NATIVE_EMBED_PARAMETER_DEFAULTS[key] : parsedValue;
96
96
  };
97
97
 
98
+ /** Matches the version id embedded in a legacy `/remix/ui/{id}` embed URL. */
99
+ var REMIX_UI_ID_RE = /\/remix\/ui\/([\w-]+)/;
100
+
101
+ /**
102
+ * Resolve the MAUI (remix) version pointer for an embed: the stored `remixAppId`
103
+ * parameter, falling back to the id embedded in a legacy `/remix/ui/{id}` URL.
104
+ *
105
+ * Every read *and* write of the pointer must go through this. A fresh embed carries no
106
+ * `remixAppId` parameter, so a caller that reads the parameter alone sees `undefined`
107
+ * while a caller that applies the fallback sees the URL id — and the pre-edit slot
108
+ * snapshot then gets recorded under a different key than undo later looks up.
109
+ */
110
+ export var resolveRemixVersionId = function resolveRemixVersionId(_ref) {
111
+ var _url$match$, _url$match;
112
+ var storedRemixAppId = _ref.storedRemixAppId,
113
+ url = _ref.url;
114
+ return storedRemixAppId || (url ? (_url$match$ = (_url$match = url.match(REMIX_UI_ID_RE)) === null || _url$match === void 0 ? void 0 : _url$match[1]) !== null && _url$match$ !== void 0 ? _url$match$ : undefined : undefined);
115
+ };
116
+
98
117
  /**
99
118
  * Gets native-embed parameters as resolved values.
100
119
  * When key is provided, returns that single resolved value.
@@ -125,19 +144,19 @@ export var setParameter = function setParameter(parameters, update) {
125
144
  export var setParameters = function setParameters(parameters, updates) {
126
145
  var currentParameters = parameters !== null && parameters !== void 0 ? parameters : {};
127
146
  var currentMacroParams = getMacroParamsRecord(parameters);
128
- var wrappedUpdates = Object.fromEntries(Object.entries(updates).map(function (_ref) {
129
- var _ref2 = _slicedToArray(_ref, 2),
130
- key = _ref2[0],
131
- value = _ref2[1];
147
+ var wrappedUpdates = Object.fromEntries(Object.entries(updates).map(function (_ref2) {
148
+ var _ref3 = _slicedToArray(_ref2, 2),
149
+ key = _ref3[0],
150
+ value = _ref3[1];
132
151
  return [key, serializeParameterValue(key, value)];
133
- }).filter(function (_ref3) {
134
- var _ref4 = _slicedToArray(_ref3, 2),
135
- value = _ref4[1];
152
+ }).filter(function (_ref4) {
153
+ var _ref5 = _slicedToArray(_ref4, 2),
154
+ value = _ref5[1];
136
155
  return value !== undefined;
137
- }).map(function (_ref5) {
138
- var _ref6 = _slicedToArray(_ref5, 2),
139
- key = _ref6[0],
140
- value = _ref6[1];
156
+ }).map(function (_ref6) {
157
+ var _ref7 = _slicedToArray(_ref6, 2),
158
+ key = _ref7[0],
159
+ value = _ref7[1];
141
160
  return [key, {
142
161
  value: value
143
162
  }];
@@ -1 +1 @@
1
- export { getRemixSlotValues, recordRemixSlotValues, resetRemixSlotStore, type RemixSlotValue, } from '../utils/remix-slot-store';
1
+ export { getRemixSlotValues, getRemixVersionForRevision, recordRemixRevisionEdit, recordRemixSlotValues, recordRemixRevisionVersion, seedRemixSlotValue, resetRemixSlotStore, type RemixSlotValue, } from '../utils/remix-slot-store';
@@ -1 +1 @@
1
- export { createEditorToolbarActions, getParameter, getParameters, setParameter, setParameters, } from '../utils/utils';
1
+ export { createEditorToolbarActions, getParameter, getParameters, resolveRemixVersionId, setParameter, setParameters, } from '../utils/utils';
@@ -1,13 +1,13 @@
1
1
  /**
2
- * Session-bound store for MAUI (remix) editable-text values, keyed by embed and
3
- * version. Part of the MAUI reload-free undo/redo (gate
2
+ * Session-bound store for MAUI (remix) editable-text values, keyed by embed,
3
+ * revision, and version. Part of the MAUI reload-free undo/redo (gate
4
4
  * `platform_editor_maui_remix_app_id`).
5
5
  *
6
6
  * Why this lives in `native-embeds-common` rather than the editor plugin: the
7
- * store is *managed by* the native-embeds editor plugin (it drives every write,
8
- * from the `native-embed-new-version` handler), but the value must also be
9
- * *read* by `native-embeds-editor-extension` when it renders the embed, to feed
10
- * the reload-free apply down to the child. The plugin already depends on the
7
+ * store is managed by the native-embeds editor plugin from edit and version
8
+ * events, but the value must also be read by `native-embeds-editor-extension`
9
+ * when it renders the embed, to feed the reload-free apply down to the child.
10
+ * The plugin already depends on the
11
11
  * extension, so a store physically inside the plugin package could not be read
12
12
  * by the extension without a dependency cycle. `native-embeds-common` is the
13
13
  * cycle-free package both sides already depend on.
@@ -22,6 +22,15 @@ export interface RemixSlotValue {
22
22
  slot: string;
23
23
  value: string;
24
24
  }
25
+ export declare const recordRemixRevisionEdit: ({ currentVersionId, localId, previousRevisionId, previousValue, revisionId, slot, value, }: {
26
+ currentVersionId?: string;
27
+ localId: string;
28
+ previousRevisionId?: string;
29
+ previousValue: string;
30
+ revisionId: string;
31
+ slot: string;
32
+ value: string;
33
+ }) => void;
25
34
  /**
26
35
  * Record the single edit that produced a new version, extending the incremental
27
36
  * per-version snapshots.
@@ -43,11 +52,14 @@ export declare const recordRemixSlotValues: ({ localId, prevVersionId, newVersio
43
52
  slot?: string;
44
53
  value?: string;
45
54
  }) => void;
55
+ export declare const seedRemixSlotValue: (localId: string, versionId: string, slot: string, value: string) => void;
46
56
  /**
47
57
  * Return the full slot snapshot for a version as an array, or `undefined` when
48
58
  * nothing is recorded for that embed/version (e.g. the base version before any
49
59
  * edit, or a version created in another session).
50
60
  */
51
61
  export declare const getRemixSlotValues: (localId: string | undefined, versionId: string | undefined) => RemixSlotValue[] | undefined;
62
+ export declare const recordRemixRevisionVersion: (localId: string, revisionId: string, versionId: string) => void;
63
+ export declare const getRemixVersionForRevision: (localId: string | undefined, revisionId: string | undefined) => string | undefined;
52
64
  /** Test-only: clear the whole store. */
53
65
  export declare const resetRemixSlotStore: () => void;
@@ -1,6 +1,6 @@
1
1
  import type { ComponentType } from 'react';
2
2
  import type { PublicPluginAPI } from '@atlaskit/editor-common/types';
3
- import type { NewCoreIconProps } from '@atlaskit/icon';
3
+ import type { NewCoreIconProps } from '@atlaskit/icon/types';
4
4
  import type { BUILTIN_TOOLBAR_KEYS, EDITOR_TOOLBAR_HANDLER_KEYS } from './constants';
5
5
  export type AlignmentValue = 'left' | 'center' | 'right' | 'wrap-left' | 'wrap-right';
6
6
  export type NativeEmbedAppearance = 'url' | 'inline' | 'block' | 'embed';
@@ -4,6 +4,19 @@ import type { ManifestEditorToolbarActions, EditorToolbarAction, BuiltinToolbarK
4
4
  * Supports both wrapped ({ value }) and unwrapped values.
5
5
  */
6
6
  export declare const getParameter: <TKey extends NativeEmbedParameterKey>(parameters: NativeEmbedParameters | undefined, key: TKey) => NativeEmbedParameterValues[TKey];
7
+ /**
8
+ * Resolve the MAUI (remix) version pointer for an embed: the stored `remixAppId`
9
+ * parameter, falling back to the id embedded in a legacy `/remix/ui/{id}` URL.
10
+ *
11
+ * Every read *and* write of the pointer must go through this. A fresh embed carries no
12
+ * `remixAppId` parameter, so a caller that reads the parameter alone sees `undefined`
13
+ * while a caller that applies the fallback sees the URL id — and the pre-edit slot
14
+ * snapshot then gets recorded under a different key than undo later looks up.
15
+ */
16
+ export declare const resolveRemixVersionId: ({ storedRemixAppId, url, }: {
17
+ storedRemixAppId: string | undefined;
18
+ url: string | undefined;
19
+ }) => string | undefined;
7
20
  /**
8
21
  * Gets native-embed parameters as resolved values.
9
22
  * When key is provided, returns that single resolved value.
package/package.json CHANGED
@@ -16,14 +16,14 @@
16
16
  ],
17
17
  "atlaskit:src": "src/index.ts",
18
18
  "dependencies": {
19
- "@atlaskit/button": "^25.0.0",
20
- "@atlaskit/editor-common": "^119.0.0",
21
- "@atlaskit/editor-plugin-local-id": "^13.0.0",
19
+ "@atlaskit/button": "^25.2.0",
20
+ "@atlaskit/editor-common": "^120.4.0",
21
+ "@atlaskit/editor-plugin-local-id": "^14.0.0",
22
22
  "@atlaskit/editor-prosemirror": "^8.0.0",
23
- "@atlaskit/heading": "^7.0.0",
24
- "@atlaskit/icon": "^37.3.0",
25
- "@atlaskit/primitives": "^22.2.0",
26
- "@atlaskit/tokens": "^16.7.0",
23
+ "@atlaskit/heading": "^7.1.0",
24
+ "@atlaskit/icon": "^37.5.0",
25
+ "@atlaskit/primitives": "^22.4.0",
26
+ "@atlaskit/tokens": "^16.8.0",
27
27
  "@atlassian/afm-i18n-platform-native-embeds-native-embeds-common": "1.7.0",
28
28
  "@babel/runtime": "^7.0.0",
29
29
  "@compiled/react": "^1.0.2",
@@ -82,7 +82,7 @@
82
82
  }
83
83
  },
84
84
  "name": "@atlaskit/native-embeds-common",
85
- "version": "2.3.1",
85
+ "version": "2.4.0",
86
86
  "description": "A shared package for native embeds to be used across experiences and plugin",
87
87
  "author": "Atlassian Pty Ltd",
88
88
  "license": "Apache-2.0",