@atlaskit/native-embeds-common 2.2.11 → 2.3.1
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 +20 -0
- package/dist/cjs/entry-points/remix-slot-store.js +24 -0
- package/dist/cjs/utils/constants.js +1 -0
- package/dist/cjs/utils/remix-slot-store.js +113 -0
- package/dist/cjs/utils/utils.js +1 -0
- package/dist/es2019/entry-points/remix-slot-store.js +1 -0
- package/dist/es2019/utils/constants.js +1 -0
- package/dist/es2019/utils/remix-slot-store.js +106 -0
- package/dist/es2019/utils/utils.js +1 -0
- package/dist/esm/entry-points/remix-slot-store.js +1 -0
- package/dist/esm/utils/constants.js +1 -0
- package/dist/esm/utils/remix-slot-store.js +106 -0
- package/dist/esm/utils/utils.js +1 -0
- package/dist/types/entry-points/remix-slot-store.d.ts +1 -0
- package/dist/types/utils/remix-slot-store.d.ts +53 -0
- package/dist/types/utils/types.d.ts +8 -0
- package/package.json +5 -5
- package/remix-slot-store/package.json +10 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @atlaskit/native-embeds-common
|
|
2
2
|
|
|
3
|
+
## 2.3.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
|
|
9
|
+
## 2.3.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [`f63012e42f000`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/f63012e42f000) -
|
|
14
|
+
Add a `remixAppId` node parameter and a session-scoped slot-value store (`recordRemixSlotValues` /
|
|
15
|
+
`getRemixSlotValues`, exposed via the new `@atlaskit/native-embeds-common/remix-slot-store`
|
|
16
|
+
subpath) used to support reload-free undo/redo for MAUI native embeds. Behind gate
|
|
17
|
+
`platform_editor_maui_remix_app_id`; no behavioural change when the gate is off.
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- Updated dependencies
|
|
22
|
+
|
|
3
23
|
## 2.2.11
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "getRemixSlotValues", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function get() {
|
|
9
|
+
return _remixSlotStore.getRemixSlotValues;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "recordRemixSlotValues", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function get() {
|
|
15
|
+
return _remixSlotStore.recordRemixSlotValues;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "resetRemixSlotStore", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function get() {
|
|
21
|
+
return _remixSlotStore.resetRemixSlotStore;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
var _remixSlotStore = require("../utils/remix-slot-store");
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.resetRemixSlotStore = exports.recordRemixSlotValues = exports.getRemixSlotValues = void 0;
|
|
8
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
9
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
11
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (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
|
+
/**
|
|
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
|
|
15
|
+
* `platform_editor_maui_remix_app_id`).
|
|
16
|
+
*
|
|
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
|
|
22
|
+
* extension, so a store physically inside the plugin package could not be read
|
|
23
|
+
* by the extension without a dependency cycle. `native-embeds-common` is the
|
|
24
|
+
* cycle-free package both sides already depend on.
|
|
25
|
+
*
|
|
26
|
+
* The map is a plain module-level singleton: session-lifetime, never serialized
|
|
27
|
+
* to ADF, and intentionally not part of any ProseMirror plugin state (so it
|
|
28
|
+
* carries no undo/redo baggage of its own — undo/redo of the *version pointer*
|
|
29
|
+
* lives in editor history; this map only answers "what were the slot values at
|
|
30
|
+
* version X?").
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* `localId → (versionId → { slot: value })`.
|
|
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).
|
|
40
|
+
*/
|
|
41
|
+
var slotValuesByEmbed = new Map();
|
|
42
|
+
var getEmbedMap = function getEmbedMap(localId) {
|
|
43
|
+
var perEmbed = slotValuesByEmbed.get(localId);
|
|
44
|
+
if (!perEmbed) {
|
|
45
|
+
perEmbed = new Map();
|
|
46
|
+
slotValuesByEmbed.set(localId, perEmbed);
|
|
47
|
+
}
|
|
48
|
+
return perEmbed;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Record the single edit that produced a new version, extending the incremental
|
|
53
|
+
* per-version snapshots.
|
|
54
|
+
*
|
|
55
|
+
* - `prevVersionId` snapshot is seeded with the slot's `previousValue` (once, if
|
|
56
|
+
* not already known) so that undoing back to it restores the pre-edit text.
|
|
57
|
+
* - `newVersionId` snapshot = the previous snapshot with the edited slot set to
|
|
58
|
+
* its new `value`.
|
|
59
|
+
*
|
|
60
|
+
* All fields except `newVersionId` are best-effort: with no `slot`/`value` the
|
|
61
|
+
* new version simply inherits the previous snapshot; with no `prevVersionId`
|
|
62
|
+
* (e.g. the embed had no stored version yet) the base snapshot is not seeded.
|
|
63
|
+
*/
|
|
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;
|
|
71
|
+
if (!localId || !newVersionId) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
var perEmbed = getEmbedMap(localId);
|
|
75
|
+
var prevSnapshot = prevVersionId && perEmbed.get(prevVersionId) || {};
|
|
76
|
+
if (prevVersionId && slot && previousValue !== undefined && !(slot in prevSnapshot)) {
|
|
77
|
+
// Seed the pre-edit value on the previous version once, so undo restores it.
|
|
78
|
+
prevSnapshot = _objectSpread(_objectSpread({}, prevSnapshot), {}, (0, _defineProperty2.default)({}, slot, previousValue));
|
|
79
|
+
perEmbed.set(prevVersionId, prevSnapshot);
|
|
80
|
+
}
|
|
81
|
+
var newSnapshot = slot && value !== undefined ? _objectSpread(_objectSpread({}, prevSnapshot), {}, (0, _defineProperty2.default)({}, slot, value)) : _objectSpread({}, prevSnapshot);
|
|
82
|
+
perEmbed.set(newVersionId, newSnapshot);
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Return the full slot snapshot for a version as an array, or `undefined` when
|
|
87
|
+
* nothing is recorded for that embed/version (e.g. the base version before any
|
|
88
|
+
* edit, or a version created in another session).
|
|
89
|
+
*/
|
|
90
|
+
var getRemixSlotValues = exports.getRemixSlotValues = function getRemixSlotValues(localId, versionId) {
|
|
91
|
+
var _slotValuesByEmbed$ge;
|
|
92
|
+
if (!localId || !versionId) {
|
|
93
|
+
return undefined;
|
|
94
|
+
}
|
|
95
|
+
var snapshot = (_slotValuesByEmbed$ge = slotValuesByEmbed.get(localId)) === null || _slotValuesByEmbed$ge === void 0 ? void 0 : _slotValuesByEmbed$ge.get(versionId);
|
|
96
|
+
if (!snapshot) {
|
|
97
|
+
return undefined;
|
|
98
|
+
}
|
|
99
|
+
return Object.entries(snapshot).map(function (_ref2) {
|
|
100
|
+
var _ref3 = (0, _slicedToArray2.default)(_ref2, 2),
|
|
101
|
+
slot = _ref3[0],
|
|
102
|
+
value = _ref3[1];
|
|
103
|
+
return {
|
|
104
|
+
slot: slot,
|
|
105
|
+
value: value
|
|
106
|
+
};
|
|
107
|
+
});
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
/** Test-only: clear the whole store. */
|
|
111
|
+
var resetRemixSlotStore = exports.resetRemixSlotStore = function resetRemixSlotStore() {
|
|
112
|
+
slotValuesByEmbed.clear();
|
|
113
|
+
};
|
package/dist/cjs/utils/utils.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { getRemixSlotValues, recordRemixSlotValues, resetRemixSlotStore } from '../utils/remix-slot-store';
|
|
@@ -0,0 +1,106 @@
|
|
|
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
|
|
4
|
+
* `platform_editor_maui_remix_app_id`).
|
|
5
|
+
*
|
|
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
|
|
11
|
+
* extension, so a store physically inside the plugin package could not be read
|
|
12
|
+
* by the extension without a dependency cycle. `native-embeds-common` is the
|
|
13
|
+
* cycle-free package both sides already depend on.
|
|
14
|
+
*
|
|
15
|
+
* The map is a plain module-level singleton: session-lifetime, never serialized
|
|
16
|
+
* to ADF, and intentionally not part of any ProseMirror plugin state (so it
|
|
17
|
+
* carries no undo/redo baggage of its own — undo/redo of the *version pointer*
|
|
18
|
+
* lives in editor history; this map only answers "what were the slot values at
|
|
19
|
+
* version X?").
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* `localId → (versionId → { slot: value })`.
|
|
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).
|
|
29
|
+
*/
|
|
30
|
+
const slotValuesByEmbed = new Map();
|
|
31
|
+
const getEmbedMap = localId => {
|
|
32
|
+
let perEmbed = slotValuesByEmbed.get(localId);
|
|
33
|
+
if (!perEmbed) {
|
|
34
|
+
perEmbed = new Map();
|
|
35
|
+
slotValuesByEmbed.set(localId, perEmbed);
|
|
36
|
+
}
|
|
37
|
+
return perEmbed;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Record the single edit that produced a new version, extending the incremental
|
|
42
|
+
* per-version snapshots.
|
|
43
|
+
*
|
|
44
|
+
* - `prevVersionId` snapshot is seeded with the slot's `previousValue` (once, if
|
|
45
|
+
* not already known) so that undoing back to it restores the pre-edit text.
|
|
46
|
+
* - `newVersionId` snapshot = the previous snapshot with the edited slot set to
|
|
47
|
+
* its new `value`.
|
|
48
|
+
*
|
|
49
|
+
* All fields except `newVersionId` are best-effort: with no `slot`/`value` the
|
|
50
|
+
* new version simply inherits the previous snapshot; with no `prevVersionId`
|
|
51
|
+
* (e.g. the embed had no stored version yet) the base snapshot is not seeded.
|
|
52
|
+
*/
|
|
53
|
+
export const recordRemixSlotValues = ({
|
|
54
|
+
localId,
|
|
55
|
+
prevVersionId,
|
|
56
|
+
newVersionId,
|
|
57
|
+
slot,
|
|
58
|
+
previousValue,
|
|
59
|
+
value
|
|
60
|
+
}) => {
|
|
61
|
+
if (!localId || !newVersionId) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
const perEmbed = getEmbedMap(localId);
|
|
65
|
+
let prevSnapshot = prevVersionId && perEmbed.get(prevVersionId) || {};
|
|
66
|
+
if (prevVersionId && slot && previousValue !== undefined && !(slot in prevSnapshot)) {
|
|
67
|
+
// Seed the pre-edit value on the previous version once, so undo restores it.
|
|
68
|
+
prevSnapshot = {
|
|
69
|
+
...prevSnapshot,
|
|
70
|
+
[slot]: previousValue
|
|
71
|
+
};
|
|
72
|
+
perEmbed.set(prevVersionId, prevSnapshot);
|
|
73
|
+
}
|
|
74
|
+
const newSnapshot = slot && value !== undefined ? {
|
|
75
|
+
...prevSnapshot,
|
|
76
|
+
[slot]: value
|
|
77
|
+
} : {
|
|
78
|
+
...prevSnapshot
|
|
79
|
+
};
|
|
80
|
+
perEmbed.set(newVersionId, newSnapshot);
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Return the full slot snapshot for a version as an array, or `undefined` when
|
|
85
|
+
* nothing is recorded for that embed/version (e.g. the base version before any
|
|
86
|
+
* edit, or a version created in another session).
|
|
87
|
+
*/
|
|
88
|
+
export const getRemixSlotValues = (localId, versionId) => {
|
|
89
|
+
var _slotValuesByEmbed$ge;
|
|
90
|
+
if (!localId || !versionId) {
|
|
91
|
+
return undefined;
|
|
92
|
+
}
|
|
93
|
+
const snapshot = (_slotValuesByEmbed$ge = slotValuesByEmbed.get(localId)) === null || _slotValuesByEmbed$ge === void 0 ? void 0 : _slotValuesByEmbed$ge.get(versionId);
|
|
94
|
+
if (!snapshot) {
|
|
95
|
+
return undefined;
|
|
96
|
+
}
|
|
97
|
+
return Object.entries(snapshot).map(([slot, value]) => ({
|
|
98
|
+
slot,
|
|
99
|
+
value
|
|
100
|
+
}));
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
/** Test-only: clear the whole store. */
|
|
104
|
+
export const resetRemixSlotStore = () => {
|
|
105
|
+
slotValuesByEmbed.clear();
|
|
106
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { getRemixSlotValues, recordRemixSlotValues, resetRemixSlotStore } from '../utils/remix-slot-store';
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
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
|
+
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
|
+
/**
|
|
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
|
|
8
|
+
* `platform_editor_maui_remix_app_id`).
|
|
9
|
+
*
|
|
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
|
|
15
|
+
* extension, so a store physically inside the plugin package could not be read
|
|
16
|
+
* by the extension without a dependency cycle. `native-embeds-common` is the
|
|
17
|
+
* cycle-free package both sides already depend on.
|
|
18
|
+
*
|
|
19
|
+
* The map is a plain module-level singleton: session-lifetime, never serialized
|
|
20
|
+
* to ADF, and intentionally not part of any ProseMirror plugin state (so it
|
|
21
|
+
* carries no undo/redo baggage of its own — undo/redo of the *version pointer*
|
|
22
|
+
* lives in editor history; this map only answers "what were the slot values at
|
|
23
|
+
* version X?").
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* `localId → (versionId → { slot: value })`.
|
|
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).
|
|
33
|
+
*/
|
|
34
|
+
var slotValuesByEmbed = new Map();
|
|
35
|
+
var getEmbedMap = function getEmbedMap(localId) {
|
|
36
|
+
var perEmbed = slotValuesByEmbed.get(localId);
|
|
37
|
+
if (!perEmbed) {
|
|
38
|
+
perEmbed = new Map();
|
|
39
|
+
slotValuesByEmbed.set(localId, perEmbed);
|
|
40
|
+
}
|
|
41
|
+
return perEmbed;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Record the single edit that produced a new version, extending the incremental
|
|
46
|
+
* per-version snapshots.
|
|
47
|
+
*
|
|
48
|
+
* - `prevVersionId` snapshot is seeded with the slot's `previousValue` (once, if
|
|
49
|
+
* not already known) so that undoing back to it restores the pre-edit text.
|
|
50
|
+
* - `newVersionId` snapshot = the previous snapshot with the edited slot set to
|
|
51
|
+
* its new `value`.
|
|
52
|
+
*
|
|
53
|
+
* All fields except `newVersionId` are best-effort: with no `slot`/`value` the
|
|
54
|
+
* new version simply inherits the previous snapshot; with no `prevVersionId`
|
|
55
|
+
* (e.g. the embed had no stored version yet) the base snapshot is not seeded.
|
|
56
|
+
*/
|
|
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;
|
|
64
|
+
if (!localId || !newVersionId) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
var perEmbed = getEmbedMap(localId);
|
|
68
|
+
var prevSnapshot = prevVersionId && perEmbed.get(prevVersionId) || {};
|
|
69
|
+
if (prevVersionId && slot && previousValue !== undefined && !(slot in prevSnapshot)) {
|
|
70
|
+
// Seed the pre-edit value on the previous version once, so undo restores it.
|
|
71
|
+
prevSnapshot = _objectSpread(_objectSpread({}, prevSnapshot), {}, _defineProperty({}, slot, previousValue));
|
|
72
|
+
perEmbed.set(prevVersionId, prevSnapshot);
|
|
73
|
+
}
|
|
74
|
+
var newSnapshot = slot && value !== undefined ? _objectSpread(_objectSpread({}, prevSnapshot), {}, _defineProperty({}, slot, value)) : _objectSpread({}, prevSnapshot);
|
|
75
|
+
perEmbed.set(newVersionId, newSnapshot);
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Return the full slot snapshot for a version as an array, or `undefined` when
|
|
80
|
+
* nothing is recorded for that embed/version (e.g. the base version before any
|
|
81
|
+
* edit, or a version created in another session).
|
|
82
|
+
*/
|
|
83
|
+
export var getRemixSlotValues = function getRemixSlotValues(localId, versionId) {
|
|
84
|
+
var _slotValuesByEmbed$ge;
|
|
85
|
+
if (!localId || !versionId) {
|
|
86
|
+
return undefined;
|
|
87
|
+
}
|
|
88
|
+
var snapshot = (_slotValuesByEmbed$ge = slotValuesByEmbed.get(localId)) === null || _slotValuesByEmbed$ge === void 0 ? void 0 : _slotValuesByEmbed$ge.get(versionId);
|
|
89
|
+
if (!snapshot) {
|
|
90
|
+
return undefined;
|
|
91
|
+
}
|
|
92
|
+
return Object.entries(snapshot).map(function (_ref2) {
|
|
93
|
+
var _ref3 = _slicedToArray(_ref2, 2),
|
|
94
|
+
slot = _ref3[0],
|
|
95
|
+
value = _ref3[1];
|
|
96
|
+
return {
|
|
97
|
+
slot: slot,
|
|
98
|
+
value: value
|
|
99
|
+
};
|
|
100
|
+
});
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
/** Test-only: clear the whole store. */
|
|
104
|
+
export var resetRemixSlotStore = function resetRemixSlotStore() {
|
|
105
|
+
slotValuesByEmbed.clear();
|
|
106
|
+
};
|
package/dist/esm/utils/utils.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { getRemixSlotValues, recordRemixSlotValues, resetRemixSlotStore, type RemixSlotValue, } from '../utils/remix-slot-store';
|
|
@@ -0,0 +1,53 @@
|
|
|
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
|
|
4
|
+
* `platform_editor_maui_remix_app_id`).
|
|
5
|
+
*
|
|
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
|
|
11
|
+
* extension, so a store physically inside the plugin package could not be read
|
|
12
|
+
* by the extension without a dependency cycle. `native-embeds-common` is the
|
|
13
|
+
* cycle-free package both sides already depend on.
|
|
14
|
+
*
|
|
15
|
+
* The map is a plain module-level singleton: session-lifetime, never serialized
|
|
16
|
+
* to ADF, and intentionally not part of any ProseMirror plugin state (so it
|
|
17
|
+
* carries no undo/redo baggage of its own — undo/redo of the *version pointer*
|
|
18
|
+
* lives in editor history; this map only answers "what were the slot values at
|
|
19
|
+
* version X?").
|
|
20
|
+
*/
|
|
21
|
+
export interface RemixSlotValue {
|
|
22
|
+
slot: string;
|
|
23
|
+
value: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Record the single edit that produced a new version, extending the incremental
|
|
27
|
+
* per-version snapshots.
|
|
28
|
+
*
|
|
29
|
+
* - `prevVersionId` snapshot is seeded with the slot's `previousValue` (once, if
|
|
30
|
+
* not already known) so that undoing back to it restores the pre-edit text.
|
|
31
|
+
* - `newVersionId` snapshot = the previous snapshot with the edited slot set to
|
|
32
|
+
* its new `value`.
|
|
33
|
+
*
|
|
34
|
+
* All fields except `newVersionId` are best-effort: with no `slot`/`value` the
|
|
35
|
+
* new version simply inherits the previous snapshot; with no `prevVersionId`
|
|
36
|
+
* (e.g. the embed had no stored version yet) the base snapshot is not seeded.
|
|
37
|
+
*/
|
|
38
|
+
export declare const recordRemixSlotValues: ({ localId, prevVersionId, newVersionId, slot, previousValue, value, }: {
|
|
39
|
+
localId: string;
|
|
40
|
+
newVersionId: string;
|
|
41
|
+
previousValue?: string;
|
|
42
|
+
prevVersionId?: string;
|
|
43
|
+
slot?: string;
|
|
44
|
+
value?: string;
|
|
45
|
+
}) => void;
|
|
46
|
+
/**
|
|
47
|
+
* Return the full slot snapshot for a version as an array, or `undefined` when
|
|
48
|
+
* nothing is recorded for that embed/version (e.g. the base version before any
|
|
49
|
+
* edit, or a version created in another session).
|
|
50
|
+
*/
|
|
51
|
+
export declare const getRemixSlotValues: (localId: string | undefined, versionId: string | undefined) => RemixSlotValue[] | undefined;
|
|
52
|
+
/** Test-only: clear the whole store. */
|
|
53
|
+
export declare const resetRemixSlotStore: () => void;
|
|
@@ -26,6 +26,13 @@ export type NativeEmbedParameterValues = {
|
|
|
26
26
|
* Omitted for existing embeds; parameter resolution treats an omitted value as `false`.
|
|
27
27
|
*/
|
|
28
28
|
isMaxWidth?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* MAUI (remix) app/version identifier carried as a `data-remix-app-id` attribute on the
|
|
31
|
+
* managed iframe rather than in the iframe URL path. Storing it as a node parameter (instead
|
|
32
|
+
* of encoding it in `url`) keeps the iframe `src` stable, so undo/redo of a version change is
|
|
33
|
+
* an ordinary ProseMirror node-attribute transaction that never reloads the iframe.
|
|
34
|
+
*/
|
|
35
|
+
remixAppId?: string;
|
|
29
36
|
url?: string;
|
|
30
37
|
width?: number;
|
|
31
38
|
};
|
|
@@ -42,6 +49,7 @@ export type NativeEmbedParameters = {
|
|
|
42
49
|
displayText?: NativeEmbedParameterValue;
|
|
43
50
|
height?: NativeEmbedParameterValue;
|
|
44
51
|
isMaxWidth?: NativeEmbedParameterValue;
|
|
52
|
+
remixAppId?: NativeEmbedParameterValue;
|
|
45
53
|
url?: NativeEmbedParameterValue;
|
|
46
54
|
width?: NativeEmbedParameterValue;
|
|
47
55
|
};
|
package/package.json
CHANGED
|
@@ -17,16 +17,16 @@
|
|
|
17
17
|
"atlaskit:src": "src/index.ts",
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"@atlaskit/button": "^25.0.0",
|
|
20
|
-
"@atlaskit/editor-common": "^
|
|
21
|
-
"@atlaskit/editor-plugin-local-id": "^
|
|
20
|
+
"@atlaskit/editor-common": "^119.0.0",
|
|
21
|
+
"@atlaskit/editor-plugin-local-id": "^13.0.0",
|
|
22
22
|
"@atlaskit/editor-prosemirror": "^8.0.0",
|
|
23
23
|
"@atlaskit/heading": "^7.0.0",
|
|
24
24
|
"@atlaskit/icon": "^37.3.0",
|
|
25
25
|
"@atlaskit/primitives": "^22.2.0",
|
|
26
|
-
"@atlaskit/tokens": "^16.
|
|
26
|
+
"@atlaskit/tokens": "^16.7.0",
|
|
27
27
|
"@atlassian/afm-i18n-platform-native-embeds-native-embeds-common": "1.7.0",
|
|
28
28
|
"@babel/runtime": "^7.0.0",
|
|
29
|
-
"@compiled/react": "^1.0.
|
|
29
|
+
"@compiled/react": "^1.0.2",
|
|
30
30
|
"@emotion/react": "^11.7.1"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
}
|
|
83
83
|
},
|
|
84
84
|
"name": "@atlaskit/native-embeds-common",
|
|
85
|
-
"version": "2.
|
|
85
|
+
"version": "2.3.1",
|
|
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",
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@atlaskit/native-embeds-common/remix-slot-store",
|
|
3
|
+
"main": "../dist/cjs/entry-points/remix-slot-store.js",
|
|
4
|
+
"module": "../dist/esm/entry-points/remix-slot-store.js",
|
|
5
|
+
"module:es2019": "../dist/es2019/entry-points/remix-slot-store.js",
|
|
6
|
+
"sideEffects": [
|
|
7
|
+
"*.compiled.css"
|
|
8
|
+
],
|
|
9
|
+
"types": "../dist/types/entry-points/remix-slot-store.d.ts"
|
|
10
|
+
}
|