@atlaskit/editor-plugin-block-controls 20.1.2 → 20.1.3
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,13 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-block-controls
|
|
2
2
|
|
|
3
|
+
## 20.1.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`2a3bb6864b8fe`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/2a3bb6864b8fe) -
|
|
8
|
+
Clean up the `platform_editor_fix_selection_text_color_change` experiment.
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
|
|
3
11
|
## 20.1.2
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
|
@@ -10,7 +10,6 @@ var _bindEventListener = require("bind-event-listener");
|
|
|
10
10
|
var _browserApis = require("@atlaskit/browser-apis");
|
|
11
11
|
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
12
12
|
var _styles = require("@atlaskit/editor-common/styles");
|
|
13
|
-
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
14
13
|
var _main = require("../main");
|
|
15
14
|
var _selection = require("../utils/selection");
|
|
16
15
|
var _editorCommands = require("./editor-commands");
|
|
@@ -54,37 +53,25 @@ var createSelectionPreservationPlugin = exports.createSelectionPreservationPlugi
|
|
|
54
53
|
key: _pluginKey.selectionPreservationPluginKey,
|
|
55
54
|
state: {
|
|
56
55
|
init: function init() {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
};
|
|
62
|
-
} else {
|
|
63
|
-
return {
|
|
64
|
-
preservedSelection: undefined
|
|
65
|
-
};
|
|
66
|
-
}
|
|
56
|
+
return {
|
|
57
|
+
preservedSelection: undefined,
|
|
58
|
+
syncDomSelectionForDoc: undefined
|
|
59
|
+
};
|
|
67
60
|
},
|
|
68
61
|
apply: function apply(tr, pluginState) {
|
|
69
62
|
var meta = (0, _utils.getSelectionPreservationMeta)(tr);
|
|
70
63
|
var newState = _objectSpread({}, pluginState);
|
|
71
64
|
if ((meta === null || meta === void 0 ? void 0 : meta.type) === 'startPreserving') {
|
|
72
65
|
newState.preservedSelection = (0, _selection.createPreservedSelection)(tr.doc.resolve(tr.selection.from), tr.doc.resolve(tr.selection.to));
|
|
73
|
-
|
|
74
|
-
newState.syncDomSelectionForDoc = undefined;
|
|
75
|
-
}
|
|
66
|
+
newState.syncDomSelectionForDoc = undefined;
|
|
76
67
|
} else if ((meta === null || meta === void 0 ? void 0 : meta.type) === 'stopPreserving') {
|
|
77
68
|
newState.preservedSelection = undefined;
|
|
78
|
-
|
|
79
|
-
newState.syncDomSelectionForDoc = undefined;
|
|
80
|
-
}
|
|
69
|
+
newState.syncDomSelectionForDoc = undefined;
|
|
81
70
|
} else if (tr.docChanged) {
|
|
82
71
|
if (newState.preservedSelection) {
|
|
83
72
|
newState.preservedSelection = (0, _selection.mapPreservedSelection)(newState.preservedSelection, tr);
|
|
84
73
|
}
|
|
85
|
-
|
|
86
|
-
newState.syncDomSelectionForDoc = (0, _utils.hasFormatSelectionSyncMeta)(tr) ? tr.doc : undefined;
|
|
87
|
-
}
|
|
74
|
+
newState.syncDomSelectionForDoc = (0, _utils.hasFormatSelectionSyncMeta)(tr) ? tr.doc : undefined;
|
|
88
75
|
}
|
|
89
76
|
if (!(0, _utils.compareSelections)(newState.preservedSelection, pluginState.preservedSelection)) {
|
|
90
77
|
if (newState.preservedSelection) {
|
|
@@ -194,23 +181,19 @@ var createSelectionPreservationPlugin = exports.createSelectionPreservationPlugi
|
|
|
194
181
|
var activeNodeChanged = prevActiveNode !== currActiveNode;
|
|
195
182
|
var docChanged = prevState.doc !== view.state.doc;
|
|
196
183
|
var hasFormatSyncRequestForCurrentDoc = (currPluginState === null || currPluginState === void 0 ? void 0 : currPluginState.syncDomSelectionForDoc) === view.state.doc;
|
|
197
|
-
var shouldSyncDOMSelection = (hasPreservedSelection && (preservedSelectionChanged || activeNodeChanged) ||
|
|
184
|
+
var shouldSyncDOMSelection = (hasPreservedSelection && (preservedSelectionChanged || activeNodeChanged) || hasFormatSyncRequestForCurrentDoc) && docChanged;
|
|
198
185
|
if (shouldSyncDOMSelection) {
|
|
199
186
|
var syncSelection = view.state.selection;
|
|
200
|
-
if (
|
|
201
|
-
if (
|
|
202
|
-
|
|
203
|
-
cancelAnimationFrame(pendingFormatSelectionSyncFrame);
|
|
204
|
-
}
|
|
205
|
-
pendingFormatSelectionSyncFrame = requestAnimationFrame(function () {
|
|
206
|
-
pendingFormatSelectionSyncFrame = undefined;
|
|
207
|
-
(0, _utils.syncDOMSelection)(syncSelection, view, {
|
|
208
|
-
focusEditor: true
|
|
209
|
-
});
|
|
210
|
-
});
|
|
211
|
-
} else {
|
|
212
|
-
(0, _utils.syncDOMSelection)(syncSelection, view);
|
|
187
|
+
if (hasFormatSyncRequestForCurrentDoc) {
|
|
188
|
+
if (pendingFormatSelectionSyncFrame !== undefined) {
|
|
189
|
+
cancelAnimationFrame(pendingFormatSelectionSyncFrame);
|
|
213
190
|
}
|
|
191
|
+
pendingFormatSelectionSyncFrame = requestAnimationFrame(function () {
|
|
192
|
+
pendingFormatSelectionSyncFrame = undefined;
|
|
193
|
+
(0, _utils.syncDOMSelection)(syncSelection, view, {
|
|
194
|
+
focusEditor: true
|
|
195
|
+
});
|
|
196
|
+
});
|
|
214
197
|
} else {
|
|
215
198
|
(0, _utils.syncDOMSelection)(syncSelection, view);
|
|
216
199
|
}
|
|
@@ -2,7 +2,6 @@ import { bind } from 'bind-event-listener';
|
|
|
2
2
|
import { getDocument } from '@atlaskit/browser-apis';
|
|
3
3
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
4
4
|
import { DRAG_HANDLE_SELECTOR } from '@atlaskit/editor-common/styles';
|
|
5
|
-
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
6
5
|
import { key } from '../main';
|
|
7
6
|
import { createPreservedSelection, mapPreservedSelection } from '../utils/selection';
|
|
8
7
|
import { stopPreservingSelection } from './editor-commands';
|
|
@@ -44,16 +43,10 @@ export const createSelectionPreservationPlugin = api => () => {
|
|
|
44
43
|
key: selectionPreservationPluginKey,
|
|
45
44
|
state: {
|
|
46
45
|
init() {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
};
|
|
52
|
-
} else {
|
|
53
|
-
return {
|
|
54
|
-
preservedSelection: undefined
|
|
55
|
-
};
|
|
56
|
-
}
|
|
46
|
+
return {
|
|
47
|
+
preservedSelection: undefined,
|
|
48
|
+
syncDomSelectionForDoc: undefined
|
|
49
|
+
};
|
|
57
50
|
},
|
|
58
51
|
apply(tr, pluginState) {
|
|
59
52
|
const meta = getSelectionPreservationMeta(tr);
|
|
@@ -62,21 +55,15 @@ export const createSelectionPreservationPlugin = api => () => {
|
|
|
62
55
|
};
|
|
63
56
|
if ((meta === null || meta === void 0 ? void 0 : meta.type) === 'startPreserving') {
|
|
64
57
|
newState.preservedSelection = createPreservedSelection(tr.doc.resolve(tr.selection.from), tr.doc.resolve(tr.selection.to));
|
|
65
|
-
|
|
66
|
-
newState.syncDomSelectionForDoc = undefined;
|
|
67
|
-
}
|
|
58
|
+
newState.syncDomSelectionForDoc = undefined;
|
|
68
59
|
} else if ((meta === null || meta === void 0 ? void 0 : meta.type) === 'stopPreserving') {
|
|
69
60
|
newState.preservedSelection = undefined;
|
|
70
|
-
|
|
71
|
-
newState.syncDomSelectionForDoc = undefined;
|
|
72
|
-
}
|
|
61
|
+
newState.syncDomSelectionForDoc = undefined;
|
|
73
62
|
} else if (tr.docChanged) {
|
|
74
63
|
if (newState.preservedSelection) {
|
|
75
64
|
newState.preservedSelection = mapPreservedSelection(newState.preservedSelection, tr);
|
|
76
65
|
}
|
|
77
|
-
|
|
78
|
-
newState.syncDomSelectionForDoc = hasFormatSelectionSyncMeta(tr) ? tr.doc : undefined;
|
|
79
|
-
}
|
|
66
|
+
newState.syncDomSelectionForDoc = hasFormatSelectionSyncMeta(tr) ? tr.doc : undefined;
|
|
80
67
|
}
|
|
81
68
|
if (!compareSelections(newState.preservedSelection, pluginState.preservedSelection)) {
|
|
82
69
|
if (newState.preservedSelection) {
|
|
@@ -187,23 +174,19 @@ export const createSelectionPreservationPlugin = api => () => {
|
|
|
187
174
|
const activeNodeChanged = prevActiveNode !== currActiveNode;
|
|
188
175
|
const docChanged = prevState.doc !== view.state.doc;
|
|
189
176
|
const hasFormatSyncRequestForCurrentDoc = (currPluginState === null || currPluginState === void 0 ? void 0 : currPluginState.syncDomSelectionForDoc) === view.state.doc;
|
|
190
|
-
const shouldSyncDOMSelection = (hasPreservedSelection && (preservedSelectionChanged || activeNodeChanged) ||
|
|
177
|
+
const shouldSyncDOMSelection = (hasPreservedSelection && (preservedSelectionChanged || activeNodeChanged) || hasFormatSyncRequestForCurrentDoc) && docChanged;
|
|
191
178
|
if (shouldSyncDOMSelection) {
|
|
192
179
|
const syncSelection = view.state.selection;
|
|
193
|
-
if (
|
|
194
|
-
if (
|
|
195
|
-
|
|
196
|
-
cancelAnimationFrame(pendingFormatSelectionSyncFrame);
|
|
197
|
-
}
|
|
198
|
-
pendingFormatSelectionSyncFrame = requestAnimationFrame(() => {
|
|
199
|
-
pendingFormatSelectionSyncFrame = undefined;
|
|
200
|
-
syncDOMSelection(syncSelection, view, {
|
|
201
|
-
focusEditor: true
|
|
202
|
-
});
|
|
203
|
-
});
|
|
204
|
-
} else {
|
|
205
|
-
syncDOMSelection(syncSelection, view);
|
|
180
|
+
if (hasFormatSyncRequestForCurrentDoc) {
|
|
181
|
+
if (pendingFormatSelectionSyncFrame !== undefined) {
|
|
182
|
+
cancelAnimationFrame(pendingFormatSelectionSyncFrame);
|
|
206
183
|
}
|
|
184
|
+
pendingFormatSelectionSyncFrame = requestAnimationFrame(() => {
|
|
185
|
+
pendingFormatSelectionSyncFrame = undefined;
|
|
186
|
+
syncDOMSelection(syncSelection, view, {
|
|
187
|
+
focusEditor: true
|
|
188
|
+
});
|
|
189
|
+
});
|
|
207
190
|
} else {
|
|
208
191
|
syncDOMSelection(syncSelection, view);
|
|
209
192
|
}
|
|
@@ -5,7 +5,6 @@ import { bind } from 'bind-event-listener';
|
|
|
5
5
|
import { getDocument } from '@atlaskit/browser-apis';
|
|
6
6
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
7
7
|
import { DRAG_HANDLE_SELECTOR } from '@atlaskit/editor-common/styles';
|
|
8
|
-
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
9
8
|
import { key } from '../main';
|
|
10
9
|
import { createPreservedSelection, mapPreservedSelection } from '../utils/selection';
|
|
11
10
|
import { stopPreservingSelection } from './editor-commands';
|
|
@@ -48,37 +47,25 @@ export var createSelectionPreservationPlugin = function createSelectionPreservat
|
|
|
48
47
|
key: selectionPreservationPluginKey,
|
|
49
48
|
state: {
|
|
50
49
|
init: function init() {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
};
|
|
56
|
-
} else {
|
|
57
|
-
return {
|
|
58
|
-
preservedSelection: undefined
|
|
59
|
-
};
|
|
60
|
-
}
|
|
50
|
+
return {
|
|
51
|
+
preservedSelection: undefined,
|
|
52
|
+
syncDomSelectionForDoc: undefined
|
|
53
|
+
};
|
|
61
54
|
},
|
|
62
55
|
apply: function apply(tr, pluginState) {
|
|
63
56
|
var meta = getSelectionPreservationMeta(tr);
|
|
64
57
|
var newState = _objectSpread({}, pluginState);
|
|
65
58
|
if ((meta === null || meta === void 0 ? void 0 : meta.type) === 'startPreserving') {
|
|
66
59
|
newState.preservedSelection = createPreservedSelection(tr.doc.resolve(tr.selection.from), tr.doc.resolve(tr.selection.to));
|
|
67
|
-
|
|
68
|
-
newState.syncDomSelectionForDoc = undefined;
|
|
69
|
-
}
|
|
60
|
+
newState.syncDomSelectionForDoc = undefined;
|
|
70
61
|
} else if ((meta === null || meta === void 0 ? void 0 : meta.type) === 'stopPreserving') {
|
|
71
62
|
newState.preservedSelection = undefined;
|
|
72
|
-
|
|
73
|
-
newState.syncDomSelectionForDoc = undefined;
|
|
74
|
-
}
|
|
63
|
+
newState.syncDomSelectionForDoc = undefined;
|
|
75
64
|
} else if (tr.docChanged) {
|
|
76
65
|
if (newState.preservedSelection) {
|
|
77
66
|
newState.preservedSelection = mapPreservedSelection(newState.preservedSelection, tr);
|
|
78
67
|
}
|
|
79
|
-
|
|
80
|
-
newState.syncDomSelectionForDoc = hasFormatSelectionSyncMeta(tr) ? tr.doc : undefined;
|
|
81
|
-
}
|
|
68
|
+
newState.syncDomSelectionForDoc = hasFormatSelectionSyncMeta(tr) ? tr.doc : undefined;
|
|
82
69
|
}
|
|
83
70
|
if (!compareSelections(newState.preservedSelection, pluginState.preservedSelection)) {
|
|
84
71
|
if (newState.preservedSelection) {
|
|
@@ -188,23 +175,19 @@ export var createSelectionPreservationPlugin = function createSelectionPreservat
|
|
|
188
175
|
var activeNodeChanged = prevActiveNode !== currActiveNode;
|
|
189
176
|
var docChanged = prevState.doc !== view.state.doc;
|
|
190
177
|
var hasFormatSyncRequestForCurrentDoc = (currPluginState === null || currPluginState === void 0 ? void 0 : currPluginState.syncDomSelectionForDoc) === view.state.doc;
|
|
191
|
-
var shouldSyncDOMSelection = (hasPreservedSelection && (preservedSelectionChanged || activeNodeChanged) ||
|
|
178
|
+
var shouldSyncDOMSelection = (hasPreservedSelection && (preservedSelectionChanged || activeNodeChanged) || hasFormatSyncRequestForCurrentDoc) && docChanged;
|
|
192
179
|
if (shouldSyncDOMSelection) {
|
|
193
180
|
var syncSelection = view.state.selection;
|
|
194
|
-
if (
|
|
195
|
-
if (
|
|
196
|
-
|
|
197
|
-
cancelAnimationFrame(pendingFormatSelectionSyncFrame);
|
|
198
|
-
}
|
|
199
|
-
pendingFormatSelectionSyncFrame = requestAnimationFrame(function () {
|
|
200
|
-
pendingFormatSelectionSyncFrame = undefined;
|
|
201
|
-
syncDOMSelection(syncSelection, view, {
|
|
202
|
-
focusEditor: true
|
|
203
|
-
});
|
|
204
|
-
});
|
|
205
|
-
} else {
|
|
206
|
-
syncDOMSelection(syncSelection, view);
|
|
181
|
+
if (hasFormatSyncRequestForCurrentDoc) {
|
|
182
|
+
if (pendingFormatSelectionSyncFrame !== undefined) {
|
|
183
|
+
cancelAnimationFrame(pendingFormatSelectionSyncFrame);
|
|
207
184
|
}
|
|
185
|
+
pendingFormatSelectionSyncFrame = requestAnimationFrame(function () {
|
|
186
|
+
pendingFormatSelectionSyncFrame = undefined;
|
|
187
|
+
syncDOMSelection(syncSelection, view, {
|
|
188
|
+
focusEditor: true
|
|
189
|
+
});
|
|
190
|
+
});
|
|
208
191
|
} else {
|
|
209
192
|
syncDOMSelection(syncSelection, view);
|
|
210
193
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-block-controls",
|
|
3
|
-
"version": "20.1.
|
|
3
|
+
"version": "20.1.3",
|
|
4
4
|
"description": "Block controls plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"@atlaskit/primitives": "^22.5.0",
|
|
62
62
|
"@atlaskit/section-message": "^10.2.0",
|
|
63
63
|
"@atlaskit/theme": "^28.2.0",
|
|
64
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
64
|
+
"@atlaskit/tmp-editor-statsig": "^203.0.0",
|
|
65
65
|
"@atlaskit/tokens": "^19.0.0",
|
|
66
66
|
"@atlaskit/tooltip": "^24.3.0",
|
|
67
67
|
"@babel/runtime": "^7.0.0",
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
"uuid": "^11.1.1"
|
|
74
74
|
},
|
|
75
75
|
"peerDependencies": {
|
|
76
|
-
"@atlaskit/editor-common": "^123.
|
|
76
|
+
"@atlaskit/editor-common": "^123.8.0",
|
|
77
77
|
"react": "^18.2.0 || ^19.2.0",
|
|
78
78
|
"react-dom": "^18.2.0 || ^19.2.0",
|
|
79
79
|
"react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"
|