@atlaskit/editor-core 203.13.1 → 203.14.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 +8 -0
- package/dist/cjs/create-editor/ReactEditorViewNext.js +10 -10
- package/dist/cjs/create-editor/create-editor.js +1 -1
- package/dist/cjs/create-editor/editorStateNotificationPlugin.js +29 -1
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/es2019/create-editor/ReactEditorViewNext.js +10 -10
- package/dist/es2019/create-editor/create-editor.js +1 -1
- package/dist/es2019/create-editor/editorStateNotificationPlugin.js +29 -1
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/esm/create-editor/ReactEditorViewNext.js +10 -10
- package/dist/esm/create-editor/create-editor.js +1 -1
- package/dist/esm/create-editor/editorStateNotificationPlugin.js +29 -1
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/types/create-editor/editorStateNotificationPlugin.d.ts +9 -2
- package/dist/types-ts4.5/create-editor/editorStateNotificationPlugin.d.ts +9 -2
- package/package.json +5 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @atlaskit/editor-core
|
|
2
2
|
|
|
3
|
+
## 203.14.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#106350](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/106350)
|
|
8
|
+
[`ab9819f908779`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/ab9819f908779) -
|
|
9
|
+
Migrated onEditorViewStateUpdatedCallbacks calls to createEditorStateNotificationPlugin
|
|
10
|
+
|
|
3
11
|
## 203.13.1
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
|
@@ -346,7 +346,6 @@ function ReactEditorView(props) {
|
|
|
346
346
|
}));
|
|
347
347
|
}, [blur, dispatchAnalyticsEvent, eventDispatcher, dispatch, errorReporter, featureFlags]);
|
|
348
348
|
var onEditorViewUpdated = (0, _react.useCallback)(function (_ref2) {
|
|
349
|
-
var _config$current;
|
|
350
349
|
var originalTransaction = _ref2.originalTransaction,
|
|
351
350
|
transactions = _ref2.transactions,
|
|
352
351
|
oldEditorState = _ref2.oldEditorState,
|
|
@@ -357,16 +356,17 @@ function ReactEditorView(props) {
|
|
|
357
356
|
oldEditorState: oldEditorState
|
|
358
357
|
});
|
|
359
358
|
}
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
359
|
+
if (!(0, _platformFeatureFlags.fg)('platform_editor_migrate_state_updates')) {
|
|
360
|
+
var _config$current;
|
|
361
|
+
(_config$current = config.current) === null || _config$current === void 0 || _config$current.onEditorViewStateUpdatedCallbacks.forEach(function (entry) {
|
|
362
|
+
entry.callback({
|
|
363
|
+
originalTransaction: originalTransaction,
|
|
364
|
+
transactions: transactions,
|
|
365
|
+
oldEditorState: oldEditorState,
|
|
366
|
+
newEditorState: newEditorState
|
|
367
|
+
});
|
|
368
368
|
});
|
|
369
|
-
}
|
|
369
|
+
}
|
|
370
370
|
}, []);
|
|
371
371
|
var _dispatchTransaction = (0, _useDispatchTransaction.useDispatchTransaction)({
|
|
372
372
|
onChange: props.editorProps.onChange,
|
|
@@ -115,7 +115,7 @@ function createPMPlugins(config) {
|
|
|
115
115
|
return typeof plugin !== 'undefined';
|
|
116
116
|
});
|
|
117
117
|
if (config.onEditorStateUpdated !== undefined) {
|
|
118
|
-
return [(0, _editorStateNotificationPlugin.createEditorStateNotificationPlugin)(config.onEditorStateUpdated)].concat((0, _toConsumableArray2.default)(pmPlugins));
|
|
118
|
+
return [(0, _editorStateNotificationPlugin.createEditorStateNotificationPlugin)(config.onEditorStateUpdated, config.editorConfig.onEditorViewStateUpdatedCallbacks)].concat((0, _toConsumableArray2.default)(pmPlugins));
|
|
119
119
|
}
|
|
120
120
|
return pmPlugins;
|
|
121
121
|
}
|
|
@@ -5,11 +5,39 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.createEditorStateNotificationPlugin = void 0;
|
|
7
7
|
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
8
|
-
var
|
|
8
|
+
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
9
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
10
|
+
var key = new _state.PluginKey('editorStateNotificationPlugin');
|
|
11
|
+
var createEditorStateNotificationPlugin = exports.createEditorStateNotificationPlugin = function createEditorStateNotificationPlugin(onEditorStateUpdated, onEditorViewStateUpdatedCallbacks) {
|
|
9
12
|
return new _safePlugin.SafePlugin({
|
|
13
|
+
key: key,
|
|
14
|
+
state: {
|
|
15
|
+
init: function init() {
|
|
16
|
+
return {
|
|
17
|
+
latestTransaction: undefined
|
|
18
|
+
};
|
|
19
|
+
},
|
|
20
|
+
apply: function apply(tr) {
|
|
21
|
+
return {
|
|
22
|
+
latestTransaction: tr
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
},
|
|
10
26
|
view: function view() {
|
|
11
27
|
return {
|
|
12
28
|
update: function update(view, oldEditorState) {
|
|
29
|
+
var _key$getState;
|
|
30
|
+
var originalTransaction = (_key$getState = key.getState(view.state)) === null || _key$getState === void 0 ? void 0 : _key$getState.latestTransaction;
|
|
31
|
+
if (originalTransaction && (0, _platformFeatureFlags.fg)('platform_editor_migrate_state_updates')) {
|
|
32
|
+
onEditorViewStateUpdatedCallbacks.forEach(function (entry) {
|
|
33
|
+
entry.callback({
|
|
34
|
+
originalTransaction: originalTransaction,
|
|
35
|
+
transactions: [originalTransaction],
|
|
36
|
+
oldEditorState: oldEditorState,
|
|
37
|
+
newEditorState: view.state
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
}
|
|
13
41
|
onEditorStateUpdated({
|
|
14
42
|
oldEditorState: oldEditorState,
|
|
15
43
|
newEditorState: view.state
|
|
@@ -324,23 +324,23 @@ export function ReactEditorView(props) {
|
|
|
324
324
|
oldEditorState,
|
|
325
325
|
newEditorState
|
|
326
326
|
}) => {
|
|
327
|
-
var _config$current;
|
|
328
327
|
if (!fg('platform_editor_catch_missing_injection_states')) {
|
|
329
328
|
pluginInjectionAPI.current.onEditorViewUpdated({
|
|
330
329
|
newEditorState,
|
|
331
330
|
oldEditorState
|
|
332
331
|
});
|
|
333
332
|
}
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
333
|
+
if (!fg('platform_editor_migrate_state_updates')) {
|
|
334
|
+
var _config$current;
|
|
335
|
+
(_config$current = config.current) === null || _config$current === void 0 ? void 0 : _config$current.onEditorViewStateUpdatedCallbacks.forEach(entry => {
|
|
336
|
+
entry.callback({
|
|
337
|
+
originalTransaction,
|
|
338
|
+
transactions,
|
|
339
|
+
oldEditorState,
|
|
340
|
+
newEditorState
|
|
341
|
+
});
|
|
342
342
|
});
|
|
343
|
-
}
|
|
343
|
+
}
|
|
344
344
|
}, []);
|
|
345
345
|
const dispatchTransaction = useDispatchTransaction({
|
|
346
346
|
onChange: props.editorProps.onChange,
|
|
@@ -95,7 +95,7 @@ export function createPMPlugins(config) {
|
|
|
95
95
|
getIntl: config.getIntl
|
|
96
96
|
})).filter(plugin => typeof plugin !== 'undefined');
|
|
97
97
|
if (config.onEditorStateUpdated !== undefined) {
|
|
98
|
-
return [createEditorStateNotificationPlugin(config.onEditorStateUpdated), ...pmPlugins];
|
|
98
|
+
return [createEditorStateNotificationPlugin(config.onEditorStateUpdated, config.editorConfig.onEditorViewStateUpdatedCallbacks), ...pmPlugins];
|
|
99
99
|
}
|
|
100
100
|
return pmPlugins;
|
|
101
101
|
}
|
|
@@ -1,8 +1,36 @@
|
|
|
1
1
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
|
-
|
|
2
|
+
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
4
|
+
const key = new PluginKey('editorStateNotificationPlugin');
|
|
5
|
+
export const createEditorStateNotificationPlugin = (onEditorStateUpdated, onEditorViewStateUpdatedCallbacks) => new SafePlugin({
|
|
6
|
+
key: key,
|
|
7
|
+
state: {
|
|
8
|
+
init() {
|
|
9
|
+
return {
|
|
10
|
+
latestTransaction: undefined
|
|
11
|
+
};
|
|
12
|
+
},
|
|
13
|
+
apply(tr) {
|
|
14
|
+
return {
|
|
15
|
+
latestTransaction: tr
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
},
|
|
3
19
|
view: () => {
|
|
4
20
|
return {
|
|
5
21
|
update: (view, oldEditorState) => {
|
|
22
|
+
var _key$getState;
|
|
23
|
+
const originalTransaction = (_key$getState = key.getState(view.state)) === null || _key$getState === void 0 ? void 0 : _key$getState.latestTransaction;
|
|
24
|
+
if (originalTransaction && fg('platform_editor_migrate_state_updates')) {
|
|
25
|
+
onEditorViewStateUpdatedCallbacks.forEach(entry => {
|
|
26
|
+
entry.callback({
|
|
27
|
+
originalTransaction,
|
|
28
|
+
transactions: [originalTransaction],
|
|
29
|
+
oldEditorState,
|
|
30
|
+
newEditorState: view.state
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
}
|
|
6
34
|
onEditorStateUpdated({
|
|
7
35
|
oldEditorState,
|
|
8
36
|
newEditorState: view.state
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export const name = "@atlaskit/editor-core";
|
|
2
|
-
export const version = "203.
|
|
2
|
+
export const version = "203.14.0";
|
|
@@ -335,7 +335,6 @@ export function ReactEditorView(props) {
|
|
|
335
335
|
}));
|
|
336
336
|
}, [blur, dispatchAnalyticsEvent, eventDispatcher, dispatch, errorReporter, featureFlags]);
|
|
337
337
|
var onEditorViewUpdated = useCallback(function (_ref2) {
|
|
338
|
-
var _config$current;
|
|
339
338
|
var originalTransaction = _ref2.originalTransaction,
|
|
340
339
|
transactions = _ref2.transactions,
|
|
341
340
|
oldEditorState = _ref2.oldEditorState,
|
|
@@ -346,16 +345,17 @@ export function ReactEditorView(props) {
|
|
|
346
345
|
oldEditorState: oldEditorState
|
|
347
346
|
});
|
|
348
347
|
}
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
348
|
+
if (!fg('platform_editor_migrate_state_updates')) {
|
|
349
|
+
var _config$current;
|
|
350
|
+
(_config$current = config.current) === null || _config$current === void 0 || _config$current.onEditorViewStateUpdatedCallbacks.forEach(function (entry) {
|
|
351
|
+
entry.callback({
|
|
352
|
+
originalTransaction: originalTransaction,
|
|
353
|
+
transactions: transactions,
|
|
354
|
+
oldEditorState: oldEditorState,
|
|
355
|
+
newEditorState: newEditorState
|
|
356
|
+
});
|
|
357
357
|
});
|
|
358
|
-
}
|
|
358
|
+
}
|
|
359
359
|
}, []);
|
|
360
360
|
var _dispatchTransaction = useDispatchTransaction({
|
|
361
361
|
onChange: props.editorProps.onChange,
|
|
@@ -104,7 +104,7 @@ export function createPMPlugins(config) {
|
|
|
104
104
|
return typeof plugin !== 'undefined';
|
|
105
105
|
});
|
|
106
106
|
if (config.onEditorStateUpdated !== undefined) {
|
|
107
|
-
return [createEditorStateNotificationPlugin(config.onEditorStateUpdated)].concat(_toConsumableArray(pmPlugins));
|
|
107
|
+
return [createEditorStateNotificationPlugin(config.onEditorStateUpdated, config.editorConfig.onEditorViewStateUpdatedCallbacks)].concat(_toConsumableArray(pmPlugins));
|
|
108
108
|
}
|
|
109
109
|
return pmPlugins;
|
|
110
110
|
}
|
|
@@ -1,9 +1,37 @@
|
|
|
1
1
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
|
-
|
|
2
|
+
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
4
|
+
var key = new PluginKey('editorStateNotificationPlugin');
|
|
5
|
+
export var createEditorStateNotificationPlugin = function createEditorStateNotificationPlugin(onEditorStateUpdated, onEditorViewStateUpdatedCallbacks) {
|
|
3
6
|
return new SafePlugin({
|
|
7
|
+
key: key,
|
|
8
|
+
state: {
|
|
9
|
+
init: function init() {
|
|
10
|
+
return {
|
|
11
|
+
latestTransaction: undefined
|
|
12
|
+
};
|
|
13
|
+
},
|
|
14
|
+
apply: function apply(tr) {
|
|
15
|
+
return {
|
|
16
|
+
latestTransaction: tr
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
},
|
|
4
20
|
view: function view() {
|
|
5
21
|
return {
|
|
6
22
|
update: function update(view, oldEditorState) {
|
|
23
|
+
var _key$getState;
|
|
24
|
+
var originalTransaction = (_key$getState = key.getState(view.state)) === null || _key$getState === void 0 ? void 0 : _key$getState.latestTransaction;
|
|
25
|
+
if (originalTransaction && fg('platform_editor_migrate_state_updates')) {
|
|
26
|
+
onEditorViewStateUpdatedCallbacks.forEach(function (entry) {
|
|
27
|
+
entry.callback({
|
|
28
|
+
originalTransaction: originalTransaction,
|
|
29
|
+
transactions: [originalTransaction],
|
|
30
|
+
oldEditorState: oldEditorState,
|
|
31
|
+
newEditorState: view.state
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
}
|
|
7
35
|
onEditorStateUpdated({
|
|
8
36
|
oldEditorState: oldEditorState,
|
|
9
37
|
newEditorState: view.state
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export var name = "@atlaskit/editor-core";
|
|
2
|
-
export var version = "203.
|
|
2
|
+
export var version = "203.14.0";
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
|
-
import type
|
|
2
|
+
import { type ReadonlyTransaction, type EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
+
import { type EditorViewStateUpdatedCallbackProps } from '../types/editor-config';
|
|
4
|
+
export type EditorStateNotificationPluginState = {
|
|
5
|
+
latestTransaction: ReadonlyTransaction | undefined;
|
|
6
|
+
};
|
|
3
7
|
export declare const createEditorStateNotificationPlugin: (onEditorStateUpdated: (props: {
|
|
4
8
|
oldEditorState: EditorState;
|
|
5
9
|
newEditorState: EditorState;
|
|
6
|
-
}) => void
|
|
10
|
+
}) => void, onEditorViewStateUpdatedCallbacks: {
|
|
11
|
+
pluginName: string;
|
|
12
|
+
callback: (props: EditorViewStateUpdatedCallbackProps) => void;
|
|
13
|
+
}[]) => SafePlugin<EditorStateNotificationPluginState>;
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
|
-
import type
|
|
2
|
+
import { type ReadonlyTransaction, type EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
+
import { type EditorViewStateUpdatedCallbackProps } from '../types/editor-config';
|
|
4
|
+
export type EditorStateNotificationPluginState = {
|
|
5
|
+
latestTransaction: ReadonlyTransaction | undefined;
|
|
6
|
+
};
|
|
3
7
|
export declare const createEditorStateNotificationPlugin: (onEditorStateUpdated: (props: {
|
|
4
8
|
oldEditorState: EditorState;
|
|
5
9
|
newEditorState: EditorState;
|
|
6
|
-
}) => void
|
|
10
|
+
}) => void, onEditorViewStateUpdatedCallbacks: {
|
|
11
|
+
pluginName: string;
|
|
12
|
+
callback: (props: EditorViewStateUpdatedCallbackProps) => void;
|
|
13
|
+
}[]) => SafePlugin<EditorStateNotificationPluginState>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-core",
|
|
3
|
-
"version": "203.
|
|
3
|
+
"version": "203.14.0",
|
|
4
4
|
"description": "A package contains Atlassian editor core functionality",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"@atlaskit/editor-prosemirror": "6.2.1",
|
|
51
51
|
"@atlaskit/editor-shared-styles": "^3.2.0",
|
|
52
52
|
"@atlaskit/emoji": "^67.13.0",
|
|
53
|
-
"@atlaskit/icon": "^23.
|
|
53
|
+
"@atlaskit/icon": "^23.6.0",
|
|
54
54
|
"@atlaskit/media-card": "^78.19.0",
|
|
55
55
|
"@atlaskit/mention": "^23.11.0",
|
|
56
56
|
"@atlaskit/platform-feature-flags": "^0.3.0",
|
|
@@ -265,6 +265,9 @@
|
|
|
265
265
|
"platform_editor_catch_missing_injection_states": {
|
|
266
266
|
"type": "boolean"
|
|
267
267
|
},
|
|
268
|
+
"platform_editor_migrate_state_updates": {
|
|
269
|
+
"type": "boolean"
|
|
270
|
+
},
|
|
268
271
|
"platform_editor_typography_ugc": {
|
|
269
272
|
"type": "boolean",
|
|
270
273
|
"referenceOnly": true
|