@atlaskit/editor-core 193.16.0 → 193.18.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 +21 -0
- package/dist/cjs/composable-editor/editor-internal.js +1 -6
- package/dist/cjs/use-preset.js +13 -4
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/es2019/composable-editor/editor-internal.js +1 -6
- package/dist/es2019/use-preset.js +9 -5
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/esm/composable-editor/editor-internal.js +1 -6
- package/dist/esm/use-preset.js +13 -5
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/types/create-editor/ReactEditorView.d.ts +3 -1
- package/dist/types/use-preset.d.ts +2 -2
- package/dist/types-ts4.5/create-editor/ReactEditorView.d.ts +3 -1
- package/dist/types-ts4.5/use-preset.d.ts +2 -2
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# @atlaskit/editor-core
|
|
2
2
|
|
|
3
|
+
## 193.18.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
|
|
9
|
+
## 193.17.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [#98727](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/98727)
|
|
14
|
+
[`057b3d93e3d4`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/057b3d93e3d4) -
|
|
15
|
+
The `usePreset` hook from editor-core previously required the EditorContext in order to have a
|
|
16
|
+
valid editorApi as a return value (otherwise it is undefined). This is confusing to developers
|
|
17
|
+
so this improvement allows the API value to be resolved without EditorContext - simplifying what
|
|
18
|
+
is required to setup the editor.
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- Updated dependencies
|
|
23
|
+
|
|
3
24
|
## 193.16.0
|
|
4
25
|
|
|
5
26
|
### Minor Changes
|
|
@@ -43,17 +43,12 @@ var EditorInternal = exports.EditorInternal = /*#__PURE__*/(0, _react.memo)(func
|
|
|
43
43
|
onEditorDestroyed = _ref.onEditorDestroyed,
|
|
44
44
|
preset = _ref.preset;
|
|
45
45
|
var Component = (0, _createEditor.getUiComponent)(props.appearance);
|
|
46
|
-
var _setInternalEditorApi = (0, _context.useSetPresetContext)();
|
|
47
46
|
var setEditorApi = (0, _react.useCallback)(function (api) {
|
|
48
|
-
if (_setInternalEditorApi) {
|
|
49
|
-
_setInternalEditorApi(api);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
47
|
// This is an workaround to unblock Editor Lego Decoupling project, if you have questions ping us #cc-editor-lego
|
|
53
48
|
// We may clean up this code when EditorActions deprecation process starts
|
|
54
49
|
// @ts-expect-error 2339: Property '__EDITOR_INTERNALS_DO_NOT_USE__API' does not exist on type 'EditorActions<any>'.
|
|
55
50
|
editorActions.__EDITOR_INTERNALS_DO_NOT_USE__API = api;
|
|
56
|
-
}, [
|
|
51
|
+
}, [editorActions]);
|
|
57
52
|
var overriddenEditorProps = _objectSpread(_objectSpread({}, props), {}, {
|
|
58
53
|
onSave: props.onSave ? handleSave : undefined,
|
|
59
54
|
// noop all analytic events, even if a handler is still passed.
|
package/dist/cjs/use-preset.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
7
|
exports.usePreset = usePreset;
|
|
8
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
7
9
|
var _react = require("react");
|
|
8
10
|
var _preset = require("@atlaskit/editor-common/preset");
|
|
9
|
-
var _context = require("./presets/context");
|
|
10
11
|
/**
|
|
11
12
|
* Creates a preset.
|
|
12
13
|
*
|
|
@@ -23,8 +24,8 @@ var _context = require("./presets/context");
|
|
|
23
24
|
* Example:
|
|
24
25
|
* ```ts
|
|
25
26
|
* function ExampleEditor() {
|
|
26
|
-
* const { preset, editorApi } = usePreset(() =>
|
|
27
|
-
*
|
|
27
|
+
* const { preset, editorApi } = usePreset((builder) =>
|
|
28
|
+
* builder.add(plugin1).add(plugin2)
|
|
28
29
|
* , []);
|
|
29
30
|
*
|
|
30
31
|
* // Can execute typesafe commands based on plugin1 or 2
|
|
@@ -42,12 +43,20 @@ var _context = require("./presets/context");
|
|
|
42
43
|
*/
|
|
43
44
|
function usePreset(createPreset) {
|
|
44
45
|
var dependencies = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
45
|
-
var
|
|
46
|
+
var _useState = (0, _react.useState)(undefined),
|
|
47
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
48
|
+
editorApi = _useState2[0],
|
|
49
|
+
setAPI = _useState2[1];
|
|
46
50
|
var preset = (0, _react.useMemo)(function () {
|
|
47
51
|
return createPreset(new _preset.EditorPresetBuilder());
|
|
48
52
|
},
|
|
49
53
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
50
54
|
dependencies);
|
|
55
|
+
(0, _react.useLayoutEffect)(function () {
|
|
56
|
+
preset.apiPromise.then(function (api) {
|
|
57
|
+
setAPI(api);
|
|
58
|
+
});
|
|
59
|
+
}, [preset.apiPromise]);
|
|
51
60
|
return {
|
|
52
61
|
editorApi: editorApi,
|
|
53
62
|
preset: preset
|
|
@@ -34,17 +34,12 @@ export const EditorInternal = /*#__PURE__*/memo(({
|
|
|
34
34
|
}) => {
|
|
35
35
|
var _props$performanceTra, _props$performanceTra2, _props$performanceTra3, _props$performanceTra4;
|
|
36
36
|
const Component = getUiComponent(props.appearance);
|
|
37
|
-
const _setInternalEditorApi = useSetPresetContext();
|
|
38
37
|
const setEditorApi = useCallback(api => {
|
|
39
|
-
if (_setInternalEditorApi) {
|
|
40
|
-
_setInternalEditorApi(api);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
38
|
// This is an workaround to unblock Editor Lego Decoupling project, if you have questions ping us #cc-editor-lego
|
|
44
39
|
// We may clean up this code when EditorActions deprecation process starts
|
|
45
40
|
// @ts-expect-error 2339: Property '__EDITOR_INTERNALS_DO_NOT_USE__API' does not exist on type 'EditorActions<any>'.
|
|
46
41
|
editorActions.__EDITOR_INTERNALS_DO_NOT_USE__API = api;
|
|
47
|
-
}, [
|
|
42
|
+
}, [editorActions]);
|
|
48
43
|
const overriddenEditorProps = {
|
|
49
44
|
...props,
|
|
50
45
|
onSave: props.onSave ? handleSave : undefined,
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { useMemo } from 'react';
|
|
1
|
+
import { useLayoutEffect, useMemo, useState } from 'react';
|
|
2
2
|
import { EditorPresetBuilder } from '@atlaskit/editor-common/preset';
|
|
3
|
-
import { usePresetContext } from './presets/context';
|
|
4
3
|
/**
|
|
5
4
|
* Creates a preset.
|
|
6
5
|
*
|
|
@@ -17,8 +16,8 @@ import { usePresetContext } from './presets/context';
|
|
|
17
16
|
* Example:
|
|
18
17
|
* ```ts
|
|
19
18
|
* function ExampleEditor() {
|
|
20
|
-
* const { preset, editorApi } = usePreset(() =>
|
|
21
|
-
*
|
|
19
|
+
* const { preset, editorApi } = usePreset((builder) =>
|
|
20
|
+
* builder.add(plugin1).add(plugin2)
|
|
22
21
|
* , []);
|
|
23
22
|
*
|
|
24
23
|
* // Can execute typesafe commands based on plugin1 or 2
|
|
@@ -35,10 +34,15 @@ import { usePresetContext } from './presets/context';
|
|
|
35
34
|
* ```
|
|
36
35
|
*/
|
|
37
36
|
export function usePreset(createPreset, dependencies = []) {
|
|
38
|
-
const editorApi =
|
|
37
|
+
const [editorApi, setAPI] = useState(undefined);
|
|
39
38
|
const preset = useMemo(() => createPreset(new EditorPresetBuilder()),
|
|
40
39
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
41
40
|
dependencies);
|
|
41
|
+
useLayoutEffect(() => {
|
|
42
|
+
preset.apiPromise.then(api => {
|
|
43
|
+
setAPI(api);
|
|
44
|
+
});
|
|
45
|
+
}, [preset.apiPromise]);
|
|
42
46
|
return {
|
|
43
47
|
editorApi,
|
|
44
48
|
preset
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export const name = "@atlaskit/editor-core";
|
|
2
|
-
export const version = "193.
|
|
2
|
+
export const version = "193.18.0";
|
|
@@ -37,17 +37,12 @@ export var EditorInternal = /*#__PURE__*/memo(function (_ref) {
|
|
|
37
37
|
onEditorDestroyed = _ref.onEditorDestroyed,
|
|
38
38
|
preset = _ref.preset;
|
|
39
39
|
var Component = getUiComponent(props.appearance);
|
|
40
|
-
var _setInternalEditorApi = useSetPresetContext();
|
|
41
40
|
var setEditorApi = useCallback(function (api) {
|
|
42
|
-
if (_setInternalEditorApi) {
|
|
43
|
-
_setInternalEditorApi(api);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
41
|
// This is an workaround to unblock Editor Lego Decoupling project, if you have questions ping us #cc-editor-lego
|
|
47
42
|
// We may clean up this code when EditorActions deprecation process starts
|
|
48
43
|
// @ts-expect-error 2339: Property '__EDITOR_INTERNALS_DO_NOT_USE__API' does not exist on type 'EditorActions<any>'.
|
|
49
44
|
editorActions.__EDITOR_INTERNALS_DO_NOT_USE__API = api;
|
|
50
|
-
}, [
|
|
45
|
+
}, [editorActions]);
|
|
51
46
|
var overriddenEditorProps = _objectSpread(_objectSpread({}, props), {}, {
|
|
52
47
|
onSave: props.onSave ? handleSave : undefined,
|
|
53
48
|
// noop all analytic events, even if a handler is still passed.
|
package/dist/esm/use-preset.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
+
import { useLayoutEffect, useMemo, useState } from 'react';
|
|
2
3
|
import { EditorPresetBuilder } from '@atlaskit/editor-common/preset';
|
|
3
|
-
import { usePresetContext } from './presets/context';
|
|
4
4
|
/**
|
|
5
5
|
* Creates a preset.
|
|
6
6
|
*
|
|
@@ -17,8 +17,8 @@ import { usePresetContext } from './presets/context';
|
|
|
17
17
|
* Example:
|
|
18
18
|
* ```ts
|
|
19
19
|
* function ExampleEditor() {
|
|
20
|
-
* const { preset, editorApi } = usePreset(() =>
|
|
21
|
-
*
|
|
20
|
+
* const { preset, editorApi } = usePreset((builder) =>
|
|
21
|
+
* builder.add(plugin1).add(plugin2)
|
|
22
22
|
* , []);
|
|
23
23
|
*
|
|
24
24
|
* // Can execute typesafe commands based on plugin1 or 2
|
|
@@ -36,12 +36,20 @@ import { usePresetContext } from './presets/context';
|
|
|
36
36
|
*/
|
|
37
37
|
export function usePreset(createPreset) {
|
|
38
38
|
var dependencies = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
39
|
-
var
|
|
39
|
+
var _useState = useState(undefined),
|
|
40
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
41
|
+
editorApi = _useState2[0],
|
|
42
|
+
setAPI = _useState2[1];
|
|
40
43
|
var preset = useMemo(function () {
|
|
41
44
|
return createPreset(new EditorPresetBuilder());
|
|
42
45
|
},
|
|
43
46
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
44
47
|
dependencies);
|
|
48
|
+
useLayoutEffect(function () {
|
|
49
|
+
preset.apiPromise.then(function (api) {
|
|
50
|
+
setAPI(api);
|
|
51
|
+
});
|
|
52
|
+
}, [preset.apiPromise]);
|
|
45
53
|
return {
|
|
46
54
|
editorApi: editorApi,
|
|
47
55
|
preset: preset
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export var name = "@atlaskit/editor-core";
|
|
2
|
-
export var version = "193.
|
|
2
|
+
export var version = "193.18.0";
|
|
@@ -22,7 +22,9 @@ import type { EditorAppearance, EditorConfig, EditorPlugin, EditorProps, EditorR
|
|
|
22
22
|
import type { EditorNextProps } from '../types/editor-props';
|
|
23
23
|
import { TransactionTracker } from '../utils/performance/track-transactions';
|
|
24
24
|
export interface EditorViewProps {
|
|
25
|
-
editorProps: EditorProps | EditorNextProps
|
|
25
|
+
editorProps: (EditorProps | EditorNextProps) & {
|
|
26
|
+
preset?: EditorNextProps['preset'];
|
|
27
|
+
};
|
|
26
28
|
createAnalyticsEvent?: CreateUIAnalyticsEvent;
|
|
27
29
|
providerFactory: ProviderFactory;
|
|
28
30
|
portalProviderAPI: LegacyPortalProviderAPI | PortalProviderAPI;
|
|
@@ -21,8 +21,8 @@ interface PresetAPI<PluginNames extends string[] = [], StackPlugins extends AllE
|
|
|
21
21
|
* Example:
|
|
22
22
|
* ```ts
|
|
23
23
|
* function ExampleEditor() {
|
|
24
|
-
* const { preset, editorApi } = usePreset(() =>
|
|
25
|
-
*
|
|
24
|
+
* const { preset, editorApi } = usePreset((builder) =>
|
|
25
|
+
* builder.add(plugin1).add(plugin2)
|
|
26
26
|
* , []);
|
|
27
27
|
*
|
|
28
28
|
* // Can execute typesafe commands based on plugin1 or 2
|
|
@@ -22,7 +22,9 @@ import type { EditorAppearance, EditorConfig, EditorPlugin, EditorProps, EditorR
|
|
|
22
22
|
import type { EditorNextProps } from '../types/editor-props';
|
|
23
23
|
import { TransactionTracker } from '../utils/performance/track-transactions';
|
|
24
24
|
export interface EditorViewProps {
|
|
25
|
-
editorProps: EditorProps | EditorNextProps
|
|
25
|
+
editorProps: (EditorProps | EditorNextProps) & {
|
|
26
|
+
preset?: EditorNextProps['preset'];
|
|
27
|
+
};
|
|
26
28
|
createAnalyticsEvent?: CreateUIAnalyticsEvent;
|
|
27
29
|
providerFactory: ProviderFactory;
|
|
28
30
|
portalProviderAPI: LegacyPortalProviderAPI | PortalProviderAPI;
|
|
@@ -23,8 +23,8 @@ interface PresetAPI<PluginNames extends string[] = [
|
|
|
23
23
|
* Example:
|
|
24
24
|
* ```ts
|
|
25
25
|
* function ExampleEditor() {
|
|
26
|
-
* const { preset, editorApi } = usePreset(() =>
|
|
27
|
-
*
|
|
26
|
+
* const { preset, editorApi } = usePreset((builder) =>
|
|
27
|
+
* builder.add(plugin1).add(plugin2)
|
|
28
28
|
* , []);
|
|
29
29
|
*
|
|
30
30
|
* // Can execute typesafe commands based on plugin1 or 2
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-core",
|
|
3
|
-
"version": "193.
|
|
3
|
+
"version": "193.18.0",
|
|
4
4
|
"description": "A package contains Atlassian editor core functionality",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"@atlaskit/analytics-next": "^9.3.0",
|
|
46
46
|
"@atlaskit/analytics-next-stable-react-context": "1.0.1",
|
|
47
47
|
"@atlaskit/button": "^17.14.0",
|
|
48
|
-
"@atlaskit/editor-common": "^
|
|
48
|
+
"@atlaskit/editor-common": "^80.0.0",
|
|
49
49
|
"@atlaskit/editor-json-transformer": "^8.12.0",
|
|
50
50
|
"@atlaskit/editor-plugins": "^2.5.0",
|
|
51
51
|
"@atlaskit/editor-prosemirror": "4.0.1",
|
|
@@ -87,9 +87,9 @@
|
|
|
87
87
|
"@atlaskit/adf-utils": "^19.1.0",
|
|
88
88
|
"@atlaskit/analytics-listeners": "^8.9.1",
|
|
89
89
|
"@atlaskit/checkbox": "^13.3.0",
|
|
90
|
-
"@atlaskit/collab-provider": "9.28.
|
|
90
|
+
"@atlaskit/collab-provider": "9.28.6",
|
|
91
91
|
"@atlaskit/dropdown-menu": "^12.10.0",
|
|
92
|
-
"@atlaskit/editor-plugin-annotation": "1.7.
|
|
92
|
+
"@atlaskit/editor-plugin-annotation": "1.7.4",
|
|
93
93
|
"@atlaskit/editor-plugin-card": "^1.11.0",
|
|
94
94
|
"@atlaskit/editor-plugin-editor-viewmode": "^1.1.0",
|
|
95
95
|
"@atlaskit/editor-plugin-list": "^3.2.0",
|
|
@@ -104,7 +104,7 @@
|
|
|
104
104
|
"@atlaskit/media-test-helpers": "^33.0.27",
|
|
105
105
|
"@atlaskit/modal-dialog": "^12.13.0",
|
|
106
106
|
"@atlaskit/primitives": "^6.1.0",
|
|
107
|
-
"@atlaskit/renderer": "^109.
|
|
107
|
+
"@atlaskit/renderer": "^109.26.0",
|
|
108
108
|
"@atlaskit/select": "^17.9.0",
|
|
109
109
|
"@atlaskit/smart-card": "^26.66.0",
|
|
110
110
|
"@atlaskit/synchrony-test-helpers": "^2.4.0",
|
|
@@ -113,7 +113,7 @@
|
|
|
113
113
|
"@atlassian/adf-schema-json": "^1.0.7",
|
|
114
114
|
"@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
|
|
115
115
|
"@atlassian/link-picker-plugins": "^24.0.0",
|
|
116
|
-
"@atlassian/search-provider": "2.4.
|
|
116
|
+
"@atlassian/search-provider": "2.4.65",
|
|
117
117
|
"@atlassian/ufo": "^0.2.0",
|
|
118
118
|
"@emotion/jest": "^11.8.0",
|
|
119
119
|
"@storybook/addon-knobs": "^5.3.18",
|