@atlaskit/editor-common 76.41.0 → 77.0.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 +80 -0
- package/dist/cjs/media-inline/styles.js +2 -1
- package/dist/cjs/monitoring/error.js +1 -1
- package/dist/cjs/preset/builder.js +18 -59
- package/dist/cjs/ui/DropList/index.js +1 -1
- package/dist/es2019/media-inline/styles.js +2 -1
- package/dist/es2019/monitoring/error.js +1 -1
- package/dist/es2019/preset/builder.js +18 -60
- package/dist/es2019/ui/DropList/index.js +1 -1
- package/dist/esm/media-inline/styles.js +2 -1
- package/dist/esm/monitoring/error.js +1 -1
- package/dist/esm/preset/builder.js +18 -59
- package/dist/esm/ui/DropList/index.js +1 -1
- package/dist/types/preset/builder.d.ts +14 -6
- package/dist/types/types/index.d.ts +1 -1
- package/dist/types/types/next-editor-plugin.d.ts +10 -7
- package/dist/types-ts4.5/preset/builder.d.ts +14 -6
- package/dist/types-ts4.5/types/index.d.ts +1 -1
- package/dist/types-ts4.5/types/next-editor-plugin.d.ts +14 -9
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,85 @@
|
|
|
1
1
|
# @atlaskit/editor-common
|
|
2
2
|
|
|
3
|
+
## 77.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- [#67576](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/67576) [`ebaeefd6ab17`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/ebaeefd6ab17) - [ED-21835] Change EditorAPI type to always union with undefined
|
|
8
|
+
|
|
9
|
+
# Breaking change
|
|
10
|
+
|
|
11
|
+
## What
|
|
12
|
+
|
|
13
|
+
EditorAPI nows set all plugins as possible `undefined` as default
|
|
14
|
+
|
|
15
|
+
## Why
|
|
16
|
+
|
|
17
|
+
That is too guarantee safe-null on runtime, since the EditorBuilderPreset does not guarantee the plugin required is on bundle anymore.
|
|
18
|
+
|
|
19
|
+
## How
|
|
20
|
+
|
|
21
|
+
If you have anycode doing usign the editorAPI like this:
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
editorAPI.core.commands
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
You will need to safe-null it like this:
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
editorAPI.core?.commands
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
- [#67576](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/67576) [`0c7a7fae2055`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/0c7a7fae2055) - [ED-21835] EditorPresetBuilder.maybeAdd changed to keep the typesafety
|
|
34
|
+
|
|
35
|
+
warn This Changeset includes a major change and we STRONGLY recommend adding more information to the changeset:
|
|
36
|
+
warn WHAT the breaking change is
|
|
37
|
+
warn WHY the change was made
|
|
38
|
+
warn HOW a consumer should update their code
|
|
39
|
+
|
|
40
|
+
# WHAT the breaking change is
|
|
41
|
+
|
|
42
|
+
The Editor Preset creation process. When you need to add a plugin based on some condition, you used to do this:
|
|
43
|
+
|
|
44
|
+
```
|
|
45
|
+
// BEFORE
|
|
46
|
+
const preset = new EditorPresetBuilder()
|
|
47
|
+
.add(pluginOne)
|
|
48
|
+
.maybeAdd(tablePlugin, (plugin, builder) => {
|
|
49
|
+
|
|
50
|
+
if (featureFlag.addTablePlugin) {
|
|
51
|
+
return builder.add(tablePlugin)
|
|
52
|
+
}
|
|
53
|
+
return builder;
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
# WHY the change was made
|
|
59
|
+
|
|
60
|
+
The `maybeAdd` was breaking the whole typesystem always returning a `EditorPresetBuilder<any, any>`.
|
|
61
|
+
|
|
62
|
+
# HOW a consumer should update their code
|
|
63
|
+
|
|
64
|
+
You need to do a similar change like this below:
|
|
65
|
+
|
|
66
|
+
```
|
|
67
|
+
// AFTER
|
|
68
|
+
|
|
69
|
+
const preset = new EditorPresetBuilder()
|
|
70
|
+
.add(pluginOne)
|
|
71
|
+
.maybeAdd(tablePlugin, featureFlag.addTablePlugin);
|
|
72
|
+
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Now, the `maybeAdd` type is `maybeAdd: (plugin, boolean) => EditorPresetBuilder`
|
|
76
|
+
|
|
77
|
+
## 76.41.1
|
|
78
|
+
|
|
79
|
+
### Patch Changes
|
|
80
|
+
|
|
81
|
+
- [#68067](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/68067) [`5b13ed605a1b`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/5b13ed605a1b) - ED-21828 -fix layouts for wide inline images
|
|
82
|
+
|
|
3
83
|
## 76.41.0
|
|
4
84
|
|
|
5
85
|
### Minor Changes
|
|
@@ -35,7 +35,8 @@ var wrapperStyle = exports.wrapperStyle = (0, _react.css)({
|
|
|
35
35
|
verticalAlign: 'middle',
|
|
36
36
|
overflow: 'hidden',
|
|
37
37
|
borderRadius: "var(--ds-border-radius, 3px)",
|
|
38
|
-
aspectRatio: "var(".concat(INLINE_IMAGE_ASPECT_RATIO_CSS_VAR_KEY, ", ").concat(_constants.DEFAULT_INLINE_IMAGE_ASPECT_RATIO, ")")
|
|
38
|
+
aspectRatio: "var(".concat(INLINE_IMAGE_ASPECT_RATIO_CSS_VAR_KEY, ", ").concat(_constants.DEFAULT_INLINE_IMAGE_ASPECT_RATIO, ")"),
|
|
39
|
+
maxWidth: '100%'
|
|
39
40
|
});
|
|
40
41
|
var selectedStyle = exports.selectedStyle = (0, _react.css)({
|
|
41
42
|
cursor: 'pointer',
|
|
@@ -16,7 +16,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
16
16
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
17
17
|
var SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
|
|
18
18
|
var packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
|
|
19
|
-
var packageVersion = "
|
|
19
|
+
var packageVersion = "77.0.0";
|
|
20
20
|
var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
|
|
21
21
|
// Remove URL as it has UGC
|
|
22
22
|
// TODO: Sanitise the URL instead of just removing it
|
|
@@ -33,28 +33,24 @@ var EditorPresetBuilder = exports.EditorPresetBuilder = /*#__PURE__*/function ()
|
|
|
33
33
|
*/
|
|
34
34
|
nextOrTuple].concat((0, _toConsumableArray2.default)(this.data)));
|
|
35
35
|
}
|
|
36
|
-
|
|
37
|
-
// hasPlugin<Plugin extends NextEditorPlugin<any, any>>(
|
|
38
|
-
// pluginToAdd: Plugin,
|
|
39
|
-
// ): this is TryCastEditorPresetBuilderByCheckingPlugins<this, Plugin> {
|
|
40
|
-
// const hasPluginQueryExists = this.data.find((pluginEntry) => {
|
|
41
|
-
// const pluginFunction: NextEditorPlugin<any, any> = !Array.isArray(
|
|
42
|
-
// pluginEntry,
|
|
43
|
-
// )
|
|
44
|
-
// ? pluginEntry
|
|
45
|
-
// : pluginEntry[0];
|
|
46
|
-
|
|
47
|
-
// return pluginFunction === pluginToAdd;
|
|
48
|
-
// });
|
|
49
|
-
|
|
50
|
-
// return Boolean(hasPluginQueryExists);
|
|
51
|
-
// }
|
|
52
36
|
}, {
|
|
53
37
|
key: "maybeAdd",
|
|
54
|
-
value: function maybeAdd(pluginToAdd,
|
|
55
|
-
|
|
56
|
-
//
|
|
57
|
-
this);
|
|
38
|
+
value: function maybeAdd(pluginToAdd, shouldAdd) {
|
|
39
|
+
var pluginOrBuilder = typeof shouldAdd === 'function' ?
|
|
40
|
+
// @ts-expect-error Argument of type 'SafePresetCheck<ToAddPlugin, StackPlugins>' is not assignable to parameter of type 'ToAddPlugin'.
|
|
41
|
+
shouldAdd(pluginToAdd, this) : shouldAdd;
|
|
42
|
+
if (pluginOrBuilder instanceof EditorPresetBuilder) {
|
|
43
|
+
return pluginOrBuilder;
|
|
44
|
+
}
|
|
45
|
+
var nextPluginStack = [
|
|
46
|
+
/**
|
|
47
|
+
* re-cast this to NewPlugin as we've done all the type
|
|
48
|
+
* safety, dependency checking, narrowing, during
|
|
49
|
+
* `SafePresetCheck & VerifyPluginDependencies`
|
|
50
|
+
*/
|
|
51
|
+
pluginOrBuilder ? pluginToAdd : undefined].concat((0, _toConsumableArray2.default)(this.data));
|
|
52
|
+
var nextEditorPresetBuilder = (0, _construct2.default)(EditorPresetBuilder, (0, _toConsumableArray2.default)(nextPluginStack));
|
|
53
|
+
return nextEditorPresetBuilder;
|
|
58
54
|
}
|
|
59
55
|
}, {
|
|
60
56
|
key: "has",
|
|
@@ -83,7 +79,7 @@ var EditorPresetBuilder = exports.EditorPresetBuilder = /*#__PURE__*/function ()
|
|
|
83
79
|
key: "verifyDuplicatedPlugins",
|
|
84
80
|
value: function verifyDuplicatedPlugins() {
|
|
85
81
|
var cache = new Set();
|
|
86
|
-
this.data.forEach(function (pluginEntry) {
|
|
82
|
+
this.data.filter(Boolean).forEach(function (pluginEntry) {
|
|
87
83
|
var _ref2 = Array.isArray(pluginEntry) ? pluginEntry : [pluginEntry, undefined],
|
|
88
84
|
_ref3 = (0, _slicedToArray2.default)(_ref2, 2),
|
|
89
85
|
pluginFn = _ref3[0],
|
|
@@ -104,7 +100,7 @@ var EditorPresetBuilder = exports.EditorPresetBuilder = /*#__PURE__*/function ()
|
|
|
104
100
|
this.verifyDuplicatedPlugins();
|
|
105
101
|
var seen = new Set();
|
|
106
102
|
var pluginsDataCopy = this.data.slice();
|
|
107
|
-
var plugins = pluginsDataCopy.reverse().map(function (entry) {
|
|
103
|
+
var plugins = pluginsDataCopy.reverse().filter(Boolean).map(function (entry) {
|
|
108
104
|
var _this$safeEntry = _this.safeEntry(entry),
|
|
109
105
|
_this$safeEntry2 = (0, _slicedToArray2.default)(_this$safeEntry, 2),
|
|
110
106
|
fn = _this$safeEntry2[0],
|
|
@@ -143,43 +139,6 @@ var EditorPresetBuilder = exports.EditorPresetBuilder = /*#__PURE__*/function ()
|
|
|
143
139
|
}
|
|
144
140
|
return plugins;
|
|
145
141
|
}
|
|
146
|
-
|
|
147
|
-
// TODO: ED-17023 - Bring back type safety to the EditorPresetBuilder.add preset
|
|
148
|
-
// import type {
|
|
149
|
-
// ExtractPluginDependencies,
|
|
150
|
-
// } from '../types/next-editor-plugin';
|
|
151
|
-
// type TryCastEditorPresetBuilderByCheckingDependencies<MaybeEditorPresetBuilder, Plugin> =
|
|
152
|
-
// MaybeEditorPresetBuilder extends EditorPresetBuilder<any, infer StackPlugins>
|
|
153
|
-
// ? Plugin extends NextEditorPlugin<any, any>
|
|
154
|
-
// ? ExtractPluginDependencies<Plugin>[number] extends StackPlugins[number]
|
|
155
|
-
// ? MaybeEditorPresetBuilder
|
|
156
|
-
// : never
|
|
157
|
-
// : never
|
|
158
|
-
// : never;
|
|
159
|
-
// Because how our plugins are added in the preset, we can't use the type safe system
|
|
160
|
-
// in the EditorPresetBuilder.
|
|
161
|
-
// TODO: ED-17023 - Bring back type safety to the EditorPresetBuilder.add preset
|
|
162
|
-
// maybeAdd<
|
|
163
|
-
// MaybePlugin extends NextEditorPlugin<any, any>,
|
|
164
|
-
// MaybePluginNames extends string[],
|
|
165
|
-
// MaybeStackPlugins extends AllEditorPresetPluginTypes[],
|
|
166
|
-
// MaybeEditorPresetBuilder extends EditorPresetBuilder<
|
|
167
|
-
// MaybePluginNames,
|
|
168
|
-
// MaybeStackPlugins
|
|
169
|
-
// >,
|
|
170
|
-
// >(
|
|
171
|
-
// pluginToAdd: MaybePlugin,
|
|
172
|
-
// add: (
|
|
173
|
-
// pluginToAdd: MaybePlugin,
|
|
174
|
-
// maybeEditorPresetBuilder: TryCastEditorPresetBuilderByCheckingDependencies<this, MaybePlugin>,
|
|
175
|
-
// ) => MaybeEditorPresetBuilder,
|
|
176
|
-
// ): MaybeEditorPresetBuilder | this {
|
|
177
|
-
// return add(
|
|
178
|
-
// pluginToAdd,
|
|
179
|
-
// // @ts-ignore
|
|
180
|
-
// this as any,
|
|
181
|
-
// );
|
|
182
|
-
// }
|
|
183
142
|
}]);
|
|
184
143
|
return EditorPresetBuilder;
|
|
185
144
|
}();
|
|
@@ -22,7 +22,7 @@ var _templateObject, _templateObject2, _templateObject3;
|
|
|
22
22
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
23
23
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } /** @jsx jsx */
|
|
24
24
|
var packageName = "@atlaskit/editor-common";
|
|
25
|
-
var packageVersion = "
|
|
25
|
+
var packageVersion = "77.0.0";
|
|
26
26
|
var halfFocusRing = 1;
|
|
27
27
|
var dropOffset = '0, 8';
|
|
28
28
|
var DropList = /*#__PURE__*/function (_Component) {
|
|
@@ -63,7 +63,8 @@ export const wrapperStyle = css({
|
|
|
63
63
|
verticalAlign: 'middle',
|
|
64
64
|
overflow: 'hidden',
|
|
65
65
|
borderRadius: `${"var(--ds-border-radius, 3px)"}`,
|
|
66
|
-
aspectRatio: `var(${INLINE_IMAGE_ASPECT_RATIO_CSS_VAR_KEY}, ${DEFAULT_INLINE_IMAGE_ASPECT_RATIO})
|
|
66
|
+
aspectRatio: `var(${INLINE_IMAGE_ASPECT_RATIO_CSS_VAR_KEY}, ${DEFAULT_INLINE_IMAGE_ASPECT_RATIO})`,
|
|
67
|
+
maxWidth: '100%'
|
|
67
68
|
});
|
|
68
69
|
export const selectedStyle = css({
|
|
69
70
|
cursor: 'pointer',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
|
|
2
2
|
const packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
|
|
3
|
-
const packageVersion = "
|
|
3
|
+
const packageVersion = "77.0.0";
|
|
4
4
|
const sanitiseSentryEvents = (data, _hint) => {
|
|
5
5
|
// Remove URL as it has UGC
|
|
6
6
|
// TODO: Sanitise the URL instead of just removing it
|
|
@@ -13,27 +13,22 @@ export class EditorPresetBuilder {
|
|
|
13
13
|
*/
|
|
14
14
|
nextOrTuple, ...this.data);
|
|
15
15
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
maybeAdd(pluginToAdd, add) {
|
|
34
|
-
return add(pluginToAdd,
|
|
35
|
-
// @ts-ignore
|
|
36
|
-
this);
|
|
16
|
+
maybeAdd(pluginToAdd, shouldAdd) {
|
|
17
|
+
const pluginOrBuilder = typeof shouldAdd === 'function' ?
|
|
18
|
+
// @ts-expect-error Argument of type 'SafePresetCheck<ToAddPlugin, StackPlugins>' is not assignable to parameter of type 'ToAddPlugin'.
|
|
19
|
+
shouldAdd(pluginToAdd, this) : shouldAdd;
|
|
20
|
+
if (pluginOrBuilder instanceof EditorPresetBuilder) {
|
|
21
|
+
return pluginOrBuilder;
|
|
22
|
+
}
|
|
23
|
+
const nextPluginStack = [
|
|
24
|
+
/**
|
|
25
|
+
* re-cast this to NewPlugin as we've done all the type
|
|
26
|
+
* safety, dependency checking, narrowing, during
|
|
27
|
+
* `SafePresetCheck & VerifyPluginDependencies`
|
|
28
|
+
*/
|
|
29
|
+
pluginOrBuilder ? pluginToAdd : undefined, ...this.data];
|
|
30
|
+
const nextEditorPresetBuilder = new EditorPresetBuilder(...nextPluginStack);
|
|
31
|
+
return nextEditorPresetBuilder;
|
|
37
32
|
}
|
|
38
33
|
has(plugin) {
|
|
39
34
|
return this.data.some(pluginPreset => {
|
|
@@ -56,7 +51,7 @@ export class EditorPresetBuilder {
|
|
|
56
51
|
}
|
|
57
52
|
verifyDuplicatedPlugins() {
|
|
58
53
|
const cache = new Set();
|
|
59
|
-
this.data.forEach(pluginEntry => {
|
|
54
|
+
this.data.filter(Boolean).forEach(pluginEntry => {
|
|
60
55
|
const [pluginFn, _] = Array.isArray(pluginEntry) ? pluginEntry : [pluginEntry, undefined];
|
|
61
56
|
if (cache.has(pluginFn)) {
|
|
62
57
|
throw new Error(`${pluginFn} is already included!`);
|
|
@@ -72,7 +67,7 @@ export class EditorPresetBuilder {
|
|
|
72
67
|
this.verifyDuplicatedPlugins();
|
|
73
68
|
const seen = new Set();
|
|
74
69
|
const pluginsDataCopy = this.data.slice();
|
|
75
|
-
const plugins = pluginsDataCopy.reverse().map(entry => {
|
|
70
|
+
const plugins = pluginsDataCopy.reverse().filter(Boolean).map(entry => {
|
|
76
71
|
const [fn, config] = this.safeEntry(entry);
|
|
77
72
|
if (seen.has(fn)) {
|
|
78
73
|
return null;
|
|
@@ -104,41 +99,4 @@ export class EditorPresetBuilder {
|
|
|
104
99
|
}
|
|
105
100
|
return plugins;
|
|
106
101
|
}
|
|
107
|
-
|
|
108
|
-
// TODO: ED-17023 - Bring back type safety to the EditorPresetBuilder.add preset
|
|
109
|
-
// import type {
|
|
110
|
-
// ExtractPluginDependencies,
|
|
111
|
-
// } from '../types/next-editor-plugin';
|
|
112
|
-
// type TryCastEditorPresetBuilderByCheckingDependencies<MaybeEditorPresetBuilder, Plugin> =
|
|
113
|
-
// MaybeEditorPresetBuilder extends EditorPresetBuilder<any, infer StackPlugins>
|
|
114
|
-
// ? Plugin extends NextEditorPlugin<any, any>
|
|
115
|
-
// ? ExtractPluginDependencies<Plugin>[number] extends StackPlugins[number]
|
|
116
|
-
// ? MaybeEditorPresetBuilder
|
|
117
|
-
// : never
|
|
118
|
-
// : never
|
|
119
|
-
// : never;
|
|
120
|
-
// Because how our plugins are added in the preset, we can't use the type safe system
|
|
121
|
-
// in the EditorPresetBuilder.
|
|
122
|
-
// TODO: ED-17023 - Bring back type safety to the EditorPresetBuilder.add preset
|
|
123
|
-
// maybeAdd<
|
|
124
|
-
// MaybePlugin extends NextEditorPlugin<any, any>,
|
|
125
|
-
// MaybePluginNames extends string[],
|
|
126
|
-
// MaybeStackPlugins extends AllEditorPresetPluginTypes[],
|
|
127
|
-
// MaybeEditorPresetBuilder extends EditorPresetBuilder<
|
|
128
|
-
// MaybePluginNames,
|
|
129
|
-
// MaybeStackPlugins
|
|
130
|
-
// >,
|
|
131
|
-
// >(
|
|
132
|
-
// pluginToAdd: MaybePlugin,
|
|
133
|
-
// add: (
|
|
134
|
-
// pluginToAdd: MaybePlugin,
|
|
135
|
-
// maybeEditorPresetBuilder: TryCastEditorPresetBuilderByCheckingDependencies<this, MaybePlugin>,
|
|
136
|
-
// ) => MaybeEditorPresetBuilder,
|
|
137
|
-
// ): MaybeEditorPresetBuilder | this {
|
|
138
|
-
// return add(
|
|
139
|
-
// pluginToAdd,
|
|
140
|
-
// // @ts-ignore
|
|
141
|
-
// this as any,
|
|
142
|
-
// );
|
|
143
|
-
// }
|
|
144
102
|
}
|
|
@@ -7,7 +7,7 @@ import { createAndFireEvent, withAnalyticsContext, withAnalyticsEvents } from '@
|
|
|
7
7
|
import { N0, N50A, N60A, N900 } from '@atlaskit/theme/colors';
|
|
8
8
|
import Layer from '../Layer';
|
|
9
9
|
const packageName = "@atlaskit/editor-common";
|
|
10
|
-
const packageVersion = "
|
|
10
|
+
const packageVersion = "77.0.0";
|
|
11
11
|
const halfFocusRing = 1;
|
|
12
12
|
const dropOffset = '0, 8';
|
|
13
13
|
class DropList extends Component {
|
|
@@ -28,7 +28,8 @@ export var wrapperStyle = css({
|
|
|
28
28
|
verticalAlign: 'middle',
|
|
29
29
|
overflow: 'hidden',
|
|
30
30
|
borderRadius: "var(--ds-border-radius, 3px)",
|
|
31
|
-
aspectRatio: "var(".concat(INLINE_IMAGE_ASPECT_RATIO_CSS_VAR_KEY, ", ").concat(DEFAULT_INLINE_IMAGE_ASPECT_RATIO, ")")
|
|
31
|
+
aspectRatio: "var(".concat(INLINE_IMAGE_ASPECT_RATIO_CSS_VAR_KEY, ", ").concat(DEFAULT_INLINE_IMAGE_ASPECT_RATIO, ")"),
|
|
32
|
+
maxWidth: '100%'
|
|
32
33
|
});
|
|
33
34
|
export var selectedStyle = css({
|
|
34
35
|
cursor: 'pointer',
|
|
@@ -6,7 +6,7 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
|
|
|
6
6
|
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; }
|
|
7
7
|
var SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
|
|
8
8
|
var packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
|
|
9
|
-
var packageVersion = "
|
|
9
|
+
var packageVersion = "77.0.0";
|
|
10
10
|
var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
|
|
11
11
|
// Remove URL as it has UGC
|
|
12
12
|
// TODO: Sanitise the URL instead of just removing it
|
|
@@ -26,28 +26,24 @@ export var EditorPresetBuilder = /*#__PURE__*/function () {
|
|
|
26
26
|
*/
|
|
27
27
|
nextOrTuple].concat(_toConsumableArray(this.data)));
|
|
28
28
|
}
|
|
29
|
-
|
|
30
|
-
// hasPlugin<Plugin extends NextEditorPlugin<any, any>>(
|
|
31
|
-
// pluginToAdd: Plugin,
|
|
32
|
-
// ): this is TryCastEditorPresetBuilderByCheckingPlugins<this, Plugin> {
|
|
33
|
-
// const hasPluginQueryExists = this.data.find((pluginEntry) => {
|
|
34
|
-
// const pluginFunction: NextEditorPlugin<any, any> = !Array.isArray(
|
|
35
|
-
// pluginEntry,
|
|
36
|
-
// )
|
|
37
|
-
// ? pluginEntry
|
|
38
|
-
// : pluginEntry[0];
|
|
39
|
-
|
|
40
|
-
// return pluginFunction === pluginToAdd;
|
|
41
|
-
// });
|
|
42
|
-
|
|
43
|
-
// return Boolean(hasPluginQueryExists);
|
|
44
|
-
// }
|
|
45
29
|
}, {
|
|
46
30
|
key: "maybeAdd",
|
|
47
|
-
value: function maybeAdd(pluginToAdd,
|
|
48
|
-
|
|
49
|
-
//
|
|
50
|
-
this);
|
|
31
|
+
value: function maybeAdd(pluginToAdd, shouldAdd) {
|
|
32
|
+
var pluginOrBuilder = typeof shouldAdd === 'function' ?
|
|
33
|
+
// @ts-expect-error Argument of type 'SafePresetCheck<ToAddPlugin, StackPlugins>' is not assignable to parameter of type 'ToAddPlugin'.
|
|
34
|
+
shouldAdd(pluginToAdd, this) : shouldAdd;
|
|
35
|
+
if (pluginOrBuilder instanceof EditorPresetBuilder) {
|
|
36
|
+
return pluginOrBuilder;
|
|
37
|
+
}
|
|
38
|
+
var nextPluginStack = [
|
|
39
|
+
/**
|
|
40
|
+
* re-cast this to NewPlugin as we've done all the type
|
|
41
|
+
* safety, dependency checking, narrowing, during
|
|
42
|
+
* `SafePresetCheck & VerifyPluginDependencies`
|
|
43
|
+
*/
|
|
44
|
+
pluginOrBuilder ? pluginToAdd : undefined].concat(_toConsumableArray(this.data));
|
|
45
|
+
var nextEditorPresetBuilder = _construct(EditorPresetBuilder, _toConsumableArray(nextPluginStack));
|
|
46
|
+
return nextEditorPresetBuilder;
|
|
51
47
|
}
|
|
52
48
|
}, {
|
|
53
49
|
key: "has",
|
|
@@ -76,7 +72,7 @@ export var EditorPresetBuilder = /*#__PURE__*/function () {
|
|
|
76
72
|
key: "verifyDuplicatedPlugins",
|
|
77
73
|
value: function verifyDuplicatedPlugins() {
|
|
78
74
|
var cache = new Set();
|
|
79
|
-
this.data.forEach(function (pluginEntry) {
|
|
75
|
+
this.data.filter(Boolean).forEach(function (pluginEntry) {
|
|
80
76
|
var _ref2 = Array.isArray(pluginEntry) ? pluginEntry : [pluginEntry, undefined],
|
|
81
77
|
_ref3 = _slicedToArray(_ref2, 2),
|
|
82
78
|
pluginFn = _ref3[0],
|
|
@@ -97,7 +93,7 @@ export var EditorPresetBuilder = /*#__PURE__*/function () {
|
|
|
97
93
|
this.verifyDuplicatedPlugins();
|
|
98
94
|
var seen = new Set();
|
|
99
95
|
var pluginsDataCopy = this.data.slice();
|
|
100
|
-
var plugins = pluginsDataCopy.reverse().map(function (entry) {
|
|
96
|
+
var plugins = pluginsDataCopy.reverse().filter(Boolean).map(function (entry) {
|
|
101
97
|
var _this$safeEntry = _this.safeEntry(entry),
|
|
102
98
|
_this$safeEntry2 = _slicedToArray(_this$safeEntry, 2),
|
|
103
99
|
fn = _this$safeEntry2[0],
|
|
@@ -136,43 +132,6 @@ export var EditorPresetBuilder = /*#__PURE__*/function () {
|
|
|
136
132
|
}
|
|
137
133
|
return plugins;
|
|
138
134
|
}
|
|
139
|
-
|
|
140
|
-
// TODO: ED-17023 - Bring back type safety to the EditorPresetBuilder.add preset
|
|
141
|
-
// import type {
|
|
142
|
-
// ExtractPluginDependencies,
|
|
143
|
-
// } from '../types/next-editor-plugin';
|
|
144
|
-
// type TryCastEditorPresetBuilderByCheckingDependencies<MaybeEditorPresetBuilder, Plugin> =
|
|
145
|
-
// MaybeEditorPresetBuilder extends EditorPresetBuilder<any, infer StackPlugins>
|
|
146
|
-
// ? Plugin extends NextEditorPlugin<any, any>
|
|
147
|
-
// ? ExtractPluginDependencies<Plugin>[number] extends StackPlugins[number]
|
|
148
|
-
// ? MaybeEditorPresetBuilder
|
|
149
|
-
// : never
|
|
150
|
-
// : never
|
|
151
|
-
// : never;
|
|
152
|
-
// Because how our plugins are added in the preset, we can't use the type safe system
|
|
153
|
-
// in the EditorPresetBuilder.
|
|
154
|
-
// TODO: ED-17023 - Bring back type safety to the EditorPresetBuilder.add preset
|
|
155
|
-
// maybeAdd<
|
|
156
|
-
// MaybePlugin extends NextEditorPlugin<any, any>,
|
|
157
|
-
// MaybePluginNames extends string[],
|
|
158
|
-
// MaybeStackPlugins extends AllEditorPresetPluginTypes[],
|
|
159
|
-
// MaybeEditorPresetBuilder extends EditorPresetBuilder<
|
|
160
|
-
// MaybePluginNames,
|
|
161
|
-
// MaybeStackPlugins
|
|
162
|
-
// >,
|
|
163
|
-
// >(
|
|
164
|
-
// pluginToAdd: MaybePlugin,
|
|
165
|
-
// add: (
|
|
166
|
-
// pluginToAdd: MaybePlugin,
|
|
167
|
-
// maybeEditorPresetBuilder: TryCastEditorPresetBuilderByCheckingDependencies<this, MaybePlugin>,
|
|
168
|
-
// ) => MaybeEditorPresetBuilder,
|
|
169
|
-
// ): MaybeEditorPresetBuilder | this {
|
|
170
|
-
// return add(
|
|
171
|
-
// pluginToAdd,
|
|
172
|
-
// // @ts-ignore
|
|
173
|
-
// this as any,
|
|
174
|
-
// );
|
|
175
|
-
// }
|
|
176
135
|
}]);
|
|
177
136
|
return EditorPresetBuilder;
|
|
178
137
|
}();
|
|
@@ -17,7 +17,7 @@ import { createAndFireEvent, withAnalyticsContext, withAnalyticsEvents } from '@
|
|
|
17
17
|
import { N0, N50A, N60A, N900 } from '@atlaskit/theme/colors';
|
|
18
18
|
import Layer from '../Layer';
|
|
19
19
|
var packageName = "@atlaskit/editor-common";
|
|
20
|
-
var packageVersion = "
|
|
20
|
+
var packageVersion = "77.0.0";
|
|
21
21
|
var halfFocusRing = 1;
|
|
22
22
|
var dropOffset = '0, 8';
|
|
23
23
|
var DropList = /*#__PURE__*/function (_Component) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AllEditorPresetPluginTypes, ExtractPluginNameFromAllBuilderPlugins,
|
|
1
|
+
import type { AllEditorPresetPluginTypes, ExtractPluginNameFromAllBuilderPlugins, MaybePlugin, MaybePluginName, PresetPlugin, SafePresetCheck } from '../types';
|
|
2
2
|
import type { EditorPlugin } from '../types/editor-plugin';
|
|
3
3
|
import type { EditorPluginInjectionAPI } from './plugin-injection-api';
|
|
4
4
|
interface ProcessProps {
|
|
@@ -9,17 +9,25 @@ interface BuildProps extends ProcessProps {
|
|
|
9
9
|
excludePlugins?: Set<string>;
|
|
10
10
|
pluginInjectionAPI?: EditorPluginInjectionAPI;
|
|
11
11
|
}
|
|
12
|
-
|
|
12
|
+
type OldAndDeprecatedAddFunction<T> = (pluginToAdd: T, builder: EditorPresetBuilder<any, any>) => EditorPresetBuilder<any, any>;
|
|
13
|
+
type AllPluginNames = string | MaybePluginName<string>;
|
|
14
|
+
export declare class EditorPresetBuilder<PluginNames extends AllPluginNames[] = [], StackPlugins extends AllEditorPresetPluginTypes[] = []> {
|
|
13
15
|
private readonly data;
|
|
14
16
|
constructor(...more: [...StackPlugins]);
|
|
15
|
-
add<NewPlugin extends
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
add<NewPlugin extends PresetPlugin>(nextOrTuple: SafePresetCheck<NewPlugin, StackPlugins>): EditorPresetBuilder<[
|
|
18
|
+
ExtractPluginNameFromAllBuilderPlugins<NewPlugin>,
|
|
19
|
+
...PluginNames
|
|
18
20
|
], [
|
|
19
21
|
...[NewPlugin],
|
|
20
22
|
...StackPlugins
|
|
21
23
|
]>;
|
|
22
|
-
maybeAdd<
|
|
24
|
+
maybeAdd<ToAddPlugin extends PresetPlugin>(pluginToAdd: SafePresetCheck<ToAddPlugin, StackPlugins>, shouldAdd: boolean | (() => boolean) | OldAndDeprecatedAddFunction<ToAddPlugin>): EditorPresetBuilder<[
|
|
25
|
+
MaybePluginName<ExtractPluginNameFromAllBuilderPlugins<ToAddPlugin>>,
|
|
26
|
+
...PluginNames
|
|
27
|
+
], [
|
|
28
|
+
MaybePlugin<ToAddPlugin>,
|
|
29
|
+
...StackPlugins
|
|
30
|
+
]>;
|
|
23
31
|
has(plugin: AllEditorPresetPluginTypes): boolean;
|
|
24
32
|
build({ pluginInjectionAPI, excludePlugins: maybeExcludePlugins, }?: BuildProps): EditorPlugin[];
|
|
25
33
|
private verifyDuplicatedPlugins;
|
|
@@ -28,7 +28,7 @@ export type { EditorReactContext } from './editor-react-context';
|
|
|
28
28
|
export type { PMPluginFactoryParams, PMPluginFactory, PMPlugin, } from './plugin-factory';
|
|
29
29
|
export type { NodeConfig, MarkConfig, NodeViewConfig, } from './prosemirror-config';
|
|
30
30
|
export type { PluginsOptions, EditorPlugin, getPosHandler, getPosHandlerNode, } from './editor-plugin';
|
|
31
|
-
export type { NextEditorPlugin, AllEditorPresetPluginTypes, PluginDependenciesAPI, ExtractPluginNameFromAllBuilderPlugins, SafePresetCheck, DefaultEditorPlugin, OptionalPlugin, PluginInjectionAPI, CreatePluginDependenciesAPI, NextEditorPluginMetadata, ExtractInjectionAPI, ExtractPluginActions, PluginInjectionAPIWithDependencies, PublicPluginAPI, NextEditorPluginFunctionOptionalConfigDefinition, ExtractNextEditorPlugins, } from './next-editor-plugin';
|
|
31
|
+
export type { NextEditorPlugin, AllEditorPresetPluginTypes, PluginDependenciesAPI, ExtractPluginNameFromAllBuilderPlugins, SafePresetCheck, DefaultEditorPlugin, OptionalPlugin, PluginInjectionAPI, CreatePluginDependenciesAPI, NextEditorPluginMetadata, ExtractInjectionAPI, ExtractPluginActions, PluginInjectionAPIWithDependencies, PublicPluginAPI, NextEditorPluginFunctionOptionalConfigDefinition, ExtractNextEditorPlugins, MaybePlugin, MaybePluginName, PresetPlugin, } from './next-editor-plugin';
|
|
32
32
|
export type { ExtractPublicEditorAPI } from './editor-public-api';
|
|
33
33
|
export type { EditorCommand, EditorCommandWithMetadata, } from './editor-command';
|
|
34
34
|
export type IconProps = {
|
|
@@ -97,12 +97,15 @@ export type PluginDependenciesAPI<Plugin extends NextEditorPlugin<any, any>> = {
|
|
|
97
97
|
commands: Plugin extends NextEditorPlugin<any, infer Metadata> ? ExtractCommandsFromMetadata<Metadata> : never;
|
|
98
98
|
};
|
|
99
99
|
export type CreatePluginDependenciesAPI<PluginList extends NextEditorPlugin<any, any>[]> = {
|
|
100
|
-
[Plugin in PluginList[number] as `${ExtractPluginName<Plugin>}`]: Plugin extends OptionalPlugin<NextEditorPlugin<any, any>> ? PluginDependenciesAPI<Plugin> | undefined : Plugin extends NextEditorPlugin<any, any> ? PluginDependenciesAPI<Plugin> : never;
|
|
100
|
+
[Plugin in PluginList[number] as `${ExtractPluginName<Plugin>}`]: Plugin extends OptionalPlugin<NextEditorPlugin<any, any>> ? PluginDependenciesAPI<Plugin> | undefined : Plugin extends NextEditorPlugin<any, any> ? PluginDependenciesAPI<Plugin> | undefined : never;
|
|
101
101
|
};
|
|
102
|
-
export type
|
|
103
|
-
export type
|
|
104
|
-
type
|
|
105
|
-
export type
|
|
102
|
+
export type PluginWithConfiguration<Plugin> = undefined extends ExtractPluginConfiguration<Plugin> ? [Plugin, ExtractPluginConfiguration<Plugin>?] : [Plugin, ExtractPluginConfiguration<Plugin>];
|
|
103
|
+
export type MaybePluginName<T extends string> = [T];
|
|
104
|
+
export type PresetPlugin = PluginWithConfiguration<any> | NextEditorPlugin<any, any>;
|
|
105
|
+
export type MaybePlugin<T extends PresetPlugin> = T | undefined;
|
|
106
|
+
export type AllEditorPresetPluginTypes = PresetPlugin | MaybePlugin<NextEditorPlugin<any, any>>;
|
|
107
|
+
type ExtractNextEditorPlugin<Plugin> = Plugin extends PluginWithConfiguration<any> ? Plugin[0] : never;
|
|
108
|
+
export type VerifyPluginDependencies<Plugin, PluginsStack extends AllEditorPresetPluginTypes[]> = ExtractPluginDependencies<Plugin> extends [] ? Plugin extends PluginWithConfiguration<any> | NextEditorPlugin<any, any> ? Plugin : never :
|
|
106
109
|
/**
|
|
107
110
|
* case 1: We're looking for its dependent plugins indexed on `AllEditorPresetPluginTypes`
|
|
108
111
|
*/
|
|
@@ -120,8 +123,8 @@ export type SafePresetCheck<Plugin, StackPlugins extends AllEditorPresetPluginTy
|
|
|
120
123
|
type CheckTupleRequirements<Plugin, Config, ArrayType> = unknown extends Config ? Plugin | ArrayType : undefined extends Config ? Plugin | ArrayType : [
|
|
121
124
|
Config
|
|
122
125
|
] extends [never] ? Plugin : ArrayType;
|
|
123
|
-
type CheckBasicPlugin<Plugin> = Plugin extends (args: any, api: any) => EditorPlugin ? CheckTupleRequirements<Plugin, ExtractPluginConfiguration<Plugin>,
|
|
124
|
-
export type ExtractPluginNameFromAllBuilderPlugins<Plugin extends
|
|
126
|
+
type CheckBasicPlugin<Plugin> = Plugin extends (args: any, api: any) => EditorPlugin ? CheckTupleRequirements<Plugin, ExtractPluginConfiguration<Plugin>, PluginWithConfiguration<Plugin>> : never;
|
|
127
|
+
export type ExtractPluginNameFromAllBuilderPlugins<Plugin extends PresetPlugin> = Plugin extends Array<any> ? Plugin extends [infer MPlugin, ...any] ? MPlugin extends NextEditorPlugin<any, any> ? ExtractPluginName<MPlugin> : never : never : Plugin extends NextEditorPlugin<any, any> ? ExtractPluginName<Plugin> : never;
|
|
125
128
|
export type ExtractInjectionAPI<Plugin> = Plugin extends NextEditorPlugin<infer Name, infer Metadata> ? PluginInjectionAPI<Name, Metadata>['dependencies'] : never;
|
|
126
129
|
export type PublicPluginAPI<PluginList extends NextEditorPlugin<any, any>[]> = CreatePluginDependenciesAPI<[...PluginList, CorePlugin]>;
|
|
127
130
|
export type ExtractNextEditorPlugins<Plugins extends AllEditorPresetPluginTypes[]> = {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AllEditorPresetPluginTypes, ExtractPluginNameFromAllBuilderPlugins,
|
|
1
|
+
import type { AllEditorPresetPluginTypes, ExtractPluginNameFromAllBuilderPlugins, MaybePlugin, MaybePluginName, PresetPlugin, SafePresetCheck } from '../types';
|
|
2
2
|
import type { EditorPlugin } from '../types/editor-plugin';
|
|
3
3
|
import type { EditorPluginInjectionAPI } from './plugin-injection-api';
|
|
4
4
|
interface ProcessProps {
|
|
@@ -9,23 +9,31 @@ interface BuildProps extends ProcessProps {
|
|
|
9
9
|
excludePlugins?: Set<string>;
|
|
10
10
|
pluginInjectionAPI?: EditorPluginInjectionAPI;
|
|
11
11
|
}
|
|
12
|
-
|
|
12
|
+
type OldAndDeprecatedAddFunction<T> = (pluginToAdd: T, builder: EditorPresetBuilder<any, any>) => EditorPresetBuilder<any, any>;
|
|
13
|
+
type AllPluginNames = string | MaybePluginName<string>;
|
|
14
|
+
export declare class EditorPresetBuilder<PluginNames extends AllPluginNames[] = [
|
|
13
15
|
], StackPlugins extends AllEditorPresetPluginTypes[] = [
|
|
14
16
|
]> {
|
|
15
17
|
private readonly data;
|
|
16
18
|
constructor(...more: [
|
|
17
19
|
...StackPlugins
|
|
18
20
|
]);
|
|
19
|
-
add<NewPlugin extends
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
add<NewPlugin extends PresetPlugin>(nextOrTuple: SafePresetCheck<NewPlugin, StackPlugins>): EditorPresetBuilder<[
|
|
22
|
+
ExtractPluginNameFromAllBuilderPlugins<NewPlugin>,
|
|
23
|
+
...PluginNames
|
|
22
24
|
], [
|
|
23
25
|
...[
|
|
24
26
|
NewPlugin
|
|
25
27
|
],
|
|
26
28
|
...StackPlugins
|
|
27
29
|
]>;
|
|
28
|
-
maybeAdd<
|
|
30
|
+
maybeAdd<ToAddPlugin extends PresetPlugin>(pluginToAdd: SafePresetCheck<ToAddPlugin, StackPlugins>, shouldAdd: boolean | (() => boolean) | OldAndDeprecatedAddFunction<ToAddPlugin>): EditorPresetBuilder<[
|
|
31
|
+
MaybePluginName<ExtractPluginNameFromAllBuilderPlugins<ToAddPlugin>>,
|
|
32
|
+
...PluginNames
|
|
33
|
+
], [
|
|
34
|
+
MaybePlugin<ToAddPlugin>,
|
|
35
|
+
...StackPlugins
|
|
36
|
+
]>;
|
|
29
37
|
has(plugin: AllEditorPresetPluginTypes): boolean;
|
|
30
38
|
build({ pluginInjectionAPI, excludePlugins: maybeExcludePlugins, }?: BuildProps): EditorPlugin[];
|
|
31
39
|
private verifyDuplicatedPlugins;
|
|
@@ -28,7 +28,7 @@ export type { EditorReactContext } from './editor-react-context';
|
|
|
28
28
|
export type { PMPluginFactoryParams, PMPluginFactory, PMPlugin, } from './plugin-factory';
|
|
29
29
|
export type { NodeConfig, MarkConfig, NodeViewConfig, } from './prosemirror-config';
|
|
30
30
|
export type { PluginsOptions, EditorPlugin, getPosHandler, getPosHandlerNode, } from './editor-plugin';
|
|
31
|
-
export type { NextEditorPlugin, AllEditorPresetPluginTypes, PluginDependenciesAPI, ExtractPluginNameFromAllBuilderPlugins, SafePresetCheck, DefaultEditorPlugin, OptionalPlugin, PluginInjectionAPI, CreatePluginDependenciesAPI, NextEditorPluginMetadata, ExtractInjectionAPI, ExtractPluginActions, PluginInjectionAPIWithDependencies, PublicPluginAPI, NextEditorPluginFunctionOptionalConfigDefinition, ExtractNextEditorPlugins, } from './next-editor-plugin';
|
|
31
|
+
export type { NextEditorPlugin, AllEditorPresetPluginTypes, PluginDependenciesAPI, ExtractPluginNameFromAllBuilderPlugins, SafePresetCheck, DefaultEditorPlugin, OptionalPlugin, PluginInjectionAPI, CreatePluginDependenciesAPI, NextEditorPluginMetadata, ExtractInjectionAPI, ExtractPluginActions, PluginInjectionAPIWithDependencies, PublicPluginAPI, NextEditorPluginFunctionOptionalConfigDefinition, ExtractNextEditorPlugins, MaybePlugin, MaybePluginName, PresetPlugin, } from './next-editor-plugin';
|
|
32
32
|
export type { ExtractPublicEditorAPI } from './editor-public-api';
|
|
33
33
|
export type { EditorCommand, EditorCommandWithMetadata, } from './editor-command';
|
|
34
34
|
export type IconProps = {
|
|
@@ -103,19 +103,24 @@ export type PluginDependenciesAPI<Plugin extends NextEditorPlugin<any, any>> = {
|
|
|
103
103
|
commands: Plugin extends NextEditorPlugin<any, infer Metadata> ? ExtractCommandsFromMetadata<Metadata> : never;
|
|
104
104
|
};
|
|
105
105
|
export type CreatePluginDependenciesAPI<PluginList extends NextEditorPlugin<any, any>[]> = {
|
|
106
|
-
[Plugin in PluginList[number] as `${ExtractPluginName<Plugin>}`]: Plugin extends OptionalPlugin<NextEditorPlugin<any, any>> ? PluginDependenciesAPI<Plugin> | undefined : Plugin extends NextEditorPlugin<any, any> ? PluginDependenciesAPI<Plugin> : never;
|
|
106
|
+
[Plugin in PluginList[number] as `${ExtractPluginName<Plugin>}`]: Plugin extends OptionalPlugin<NextEditorPlugin<any, any>> ? PluginDependenciesAPI<Plugin> | undefined : Plugin extends NextEditorPlugin<any, any> ? PluginDependenciesAPI<Plugin> | undefined : never;
|
|
107
107
|
};
|
|
108
|
-
export type
|
|
108
|
+
export type PluginWithConfiguration<Plugin> = undefined extends ExtractPluginConfiguration<Plugin> ? [
|
|
109
109
|
Plugin,
|
|
110
110
|
ExtractPluginConfiguration<Plugin>?
|
|
111
111
|
] : [
|
|
112
112
|
Plugin,
|
|
113
113
|
ExtractPluginConfiguration<Plugin>
|
|
114
114
|
];
|
|
115
|
-
export type
|
|
116
|
-
|
|
115
|
+
export type MaybePluginName<T extends string> = [
|
|
116
|
+
T
|
|
117
|
+
];
|
|
118
|
+
export type PresetPlugin = PluginWithConfiguration<any> | NextEditorPlugin<any, any>;
|
|
119
|
+
export type MaybePlugin<T extends PresetPlugin> = T | undefined;
|
|
120
|
+
export type AllEditorPresetPluginTypes = PresetPlugin | MaybePlugin<NextEditorPlugin<any, any>>;
|
|
121
|
+
type ExtractNextEditorPlugin<Plugin> = Plugin extends PluginWithConfiguration<any> ? Plugin[0] : never;
|
|
117
122
|
export type VerifyPluginDependencies<Plugin, PluginsStack extends AllEditorPresetPluginTypes[]> = ExtractPluginDependencies<Plugin> extends [
|
|
118
|
-
] ? Plugin extends
|
|
123
|
+
] ? Plugin extends PluginWithConfiguration<any> | NextEditorPlugin<any, any> ? Plugin : never :
|
|
119
124
|
/**
|
|
120
125
|
* case 1: We're looking for its dependent plugins indexed on `AllEditorPresetPluginTypes`
|
|
121
126
|
*/
|
|
@@ -135,11 +140,11 @@ type CheckTupleRequirements<Plugin, Config, ArrayType> = unknown extends Config
|
|
|
135
140
|
] extends [
|
|
136
141
|
never
|
|
137
142
|
] ? Plugin : ArrayType;
|
|
138
|
-
type CheckBasicPlugin<Plugin> = Plugin extends (args: any, api: any) => EditorPlugin ? CheckTupleRequirements<Plugin, ExtractPluginConfiguration<Plugin>,
|
|
139
|
-
export type ExtractPluginNameFromAllBuilderPlugins<Plugin extends
|
|
140
|
-
infer
|
|
143
|
+
type CheckBasicPlugin<Plugin> = Plugin extends (args: any, api: any) => EditorPlugin ? CheckTupleRequirements<Plugin, ExtractPluginConfiguration<Plugin>, PluginWithConfiguration<Plugin>> : never;
|
|
144
|
+
export type ExtractPluginNameFromAllBuilderPlugins<Plugin extends PresetPlugin> = Plugin extends Array<any> ? Plugin extends [
|
|
145
|
+
infer MPlugin,
|
|
141
146
|
...any
|
|
142
|
-
] ?
|
|
147
|
+
] ? MPlugin extends NextEditorPlugin<any, any> ? ExtractPluginName<MPlugin> : never : never : Plugin extends NextEditorPlugin<any, any> ? ExtractPluginName<Plugin> : never;
|
|
143
148
|
export type ExtractInjectionAPI<Plugin> = Plugin extends NextEditorPlugin<infer Name, infer Metadata> ? PluginInjectionAPI<Name, Metadata>['dependencies'] : never;
|
|
144
149
|
export type PublicPluginAPI<PluginList extends NextEditorPlugin<any, any>[]> = CreatePluginDependenciesAPI<[
|
|
145
150
|
...PluginList,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-common",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "77.0.0",
|
|
4
4
|
"description": "A package that contains common classes and components for editor and renderer",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -105,7 +105,7 @@
|
|
|
105
105
|
"@atlaskit/editor-palette": "1.5.2",
|
|
106
106
|
"@atlaskit/editor-prosemirror": "1.1.0",
|
|
107
107
|
"@atlaskit/editor-shared-styles": "^2.9.0",
|
|
108
|
-
"@atlaskit/editor-tables": "^2.
|
|
108
|
+
"@atlaskit/editor-tables": "^2.4.0",
|
|
109
109
|
"@atlaskit/emoji": "^67.6.0",
|
|
110
110
|
"@atlaskit/icon": "^22.0.0",
|
|
111
111
|
"@atlaskit/icon-object": "^6.3.0",
|
|
@@ -119,13 +119,13 @@
|
|
|
119
119
|
"@atlaskit/menu": "^2.1.0",
|
|
120
120
|
"@atlaskit/platform-feature-flags": "^0.2.0",
|
|
121
121
|
"@atlaskit/profilecard": "^19.7.0",
|
|
122
|
-
"@atlaskit/smart-card": "^26.
|
|
122
|
+
"@atlaskit/smart-card": "^26.45.0",
|
|
123
123
|
"@atlaskit/smart-user-picker": "^6.4.0",
|
|
124
124
|
"@atlaskit/spinner": "^16.0.0",
|
|
125
125
|
"@atlaskit/task-decision": "^17.9.0",
|
|
126
126
|
"@atlaskit/textfield": "^6.0.0",
|
|
127
127
|
"@atlaskit/theme": "^12.6.0",
|
|
128
|
-
"@atlaskit/tokens": "^1.
|
|
128
|
+
"@atlaskit/tokens": "^1.34.0",
|
|
129
129
|
"@atlaskit/tooltip": "^18.1.0",
|
|
130
130
|
"@atlaskit/ufo": "^0.2.0",
|
|
131
131
|
"@atlaskit/width-detector": "^4.1.0",
|