@atlaskit/editor-common 86.0.0 → 86.1.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 +19 -0
- package/dist/cjs/lazy-node-view/index.js +217 -0
- package/dist/cjs/link/ConfigureLinkOverlay/Dropdown.js +19 -4
- package/dist/cjs/link/ConfigureLinkOverlay/index.js +2 -1
- package/dist/cjs/messages/help-dialog.js +5 -0
- package/dist/cjs/monitoring/error.js +1 -1
- package/dist/cjs/ui/DropList/index.js +1 -1
- package/dist/cjs/ui-menu/DropdownMenu/index.js +4 -4
- package/dist/cjs/ui-menu/ToolbarButton/index.js +7 -1
- package/dist/es2019/lazy-node-view/index.js +212 -0
- package/dist/es2019/link/ConfigureLinkOverlay/Dropdown.js +17 -4
- package/dist/es2019/link/ConfigureLinkOverlay/index.js +2 -1
- package/dist/es2019/messages/help-dialog.js +5 -0
- package/dist/es2019/monitoring/error.js +1 -1
- package/dist/es2019/ui/DropList/index.js +1 -1
- package/dist/es2019/ui-menu/DropdownMenu/index.js +4 -4
- package/dist/es2019/ui-menu/ToolbarButton/index.js +7 -1
- package/dist/esm/lazy-node-view/index.js +211 -0
- package/dist/esm/link/ConfigureLinkOverlay/Dropdown.js +19 -4
- package/dist/esm/link/ConfigureLinkOverlay/index.js +2 -1
- package/dist/esm/messages/help-dialog.js +5 -0
- package/dist/esm/monitoring/error.js +1 -1
- package/dist/esm/ui/DropList/index.js +1 -1
- package/dist/esm/ui-menu/DropdownMenu/index.js +4 -4
- package/dist/esm/ui-menu/ToolbarButton/index.js +7 -1
- package/dist/types/lazy-node-view/index.d.ts +109 -0
- package/dist/types/link/ConfigureLinkOverlay/Dropdown.d.ts +2 -0
- package/dist/types/messages/help-dialog.d.ts +5 -0
- package/dist/types/ui-menu/ToolbarButton/index.d.ts +3 -0
- package/dist/types-ts4.5/lazy-node-view/index.d.ts +109 -0
- package/dist/types-ts4.5/link/ConfigureLinkOverlay/Dropdown.d.ts +2 -0
- package/dist/types-ts4.5/messages/help-dialog.d.ts +5 -0
- package/dist/types-ts4.5/ui-menu/ToolbarButton/index.d.ts +3 -0
- package/lazy-node-view/package.json +15 -0
- package/package.json +4 -3
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/// <reference types="lodash" />
|
|
2
|
+
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
3
|
+
import type { Decoration, DecorationSource, EditorView, NodeView } from '@atlaskit/editor-prosemirror/view';
|
|
4
|
+
import type { DispatchAnalyticsEvent } from '../analytics';
|
|
5
|
+
/**
|
|
6
|
+
* 📢 Public Type
|
|
7
|
+
*
|
|
8
|
+
* @see {withLazyLoading}
|
|
9
|
+
*/
|
|
10
|
+
export type CreateReactNodeViewProps<NodeViewOptions> = (node: PMNode, view: EditorView, getPos: () => number | undefined, decorations: readonly Decoration[], getNodeViewOptions: () => NodeViewOptions) => NodeView;
|
|
11
|
+
/**
|
|
12
|
+
* 📢 Public Type
|
|
13
|
+
*
|
|
14
|
+
* @see {withLazyLoading}
|
|
15
|
+
*/
|
|
16
|
+
export type LazyLoadingProps<NodeViewOptions> = {
|
|
17
|
+
nodeName: string;
|
|
18
|
+
loader: () => Promise<CreateReactNodeViewProps<NodeViewOptions>>;
|
|
19
|
+
getNodeViewOptions: () => NodeViewOptions;
|
|
20
|
+
dispatchAnalyticsEvent?: DispatchAnalyticsEvent;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* 🧱 Internal: Editor FE Platform
|
|
24
|
+
*/
|
|
25
|
+
export type NodeViewConstructor = (node: PMNode, view: EditorView, getPos: () => number | undefined, decorations: readonly Decoration[], innerDecorations: DecorationSource) => NodeView;
|
|
26
|
+
/**
|
|
27
|
+
* 🧱 Internal: Editor FE Platform
|
|
28
|
+
*/
|
|
29
|
+
type LoadedReactNodeViews = Record<string, NodeViewConstructor>;
|
|
30
|
+
/**
|
|
31
|
+
* 🧱 Internal: Editor FE Platform
|
|
32
|
+
*/
|
|
33
|
+
type CacheType = WeakMap<EditorView, LoadedReactNodeViews>;
|
|
34
|
+
/**
|
|
35
|
+
* 🧱 Internal: Editor FE Platform
|
|
36
|
+
*
|
|
37
|
+
* Debounces and replaces the node views in a ProseMirror editor with lazy-loaded node views.
|
|
38
|
+
*
|
|
39
|
+
* This function is used to update the `nodeViews` property of the `EditorView` after lazy-loaded
|
|
40
|
+
* node views have been loaded. It uses a debounced approach to ensure that the replacement does
|
|
41
|
+
* not happen too frequently, which can be performance-intensive.
|
|
42
|
+
*
|
|
43
|
+
* The function checks if there are any loaded node views in the cache associated with the given
|
|
44
|
+
* `EditorView`. If there are, it replaces the current `nodeViews` in the `EditorView` with the
|
|
45
|
+
* loaded node views. The replacement is scheduled using `requestIdleCallback` or
|
|
46
|
+
* `requestAnimationFrame` to avoid blocking the main thread, especially in Firefox where
|
|
47
|
+
* `requestIdleCallback` may not be supported.
|
|
48
|
+
*
|
|
49
|
+
* @param {WeakMap<EditorView, Record<string, NodeViewConstructor>>} cache - A WeakMap that stores
|
|
50
|
+
* the loaded node views for each `EditorView`. The key is the `EditorView`, and the value
|
|
51
|
+
* is a record of node type names to their corresponding `NodeViewConstructor`.
|
|
52
|
+
* @param {EditorView} view - The ProseMirror `EditorView` instance whose `nodeViews` property
|
|
53
|
+
* needs to be updated.
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* const cache = new WeakMap();
|
|
57
|
+
* const view = new EditorView(...);
|
|
58
|
+
*
|
|
59
|
+
* // Assume some node views have been loaded and stored in the cache
|
|
60
|
+
* cache.set(view, {
|
|
61
|
+
* 'table': TableViewConstructor,
|
|
62
|
+
* 'tableCell': TableCellViewConstructor,
|
|
63
|
+
* });
|
|
64
|
+
*
|
|
65
|
+
* debouncedReplaceNodeviews(cache, view);
|
|
66
|
+
*/
|
|
67
|
+
export declare const debouncedReplaceNodeviews: import("lodash").DebouncedFunc<(cache: CacheType, view: EditorView) => void>;
|
|
68
|
+
/**
|
|
69
|
+
* 📢 Public: Any EditorPlugin can use this function
|
|
70
|
+
*
|
|
71
|
+
* Wraps a NodeView constructor with laziness, allowing the NodeView to be loaded only when required.
|
|
72
|
+
*
|
|
73
|
+
* This higher-order function is designed to optimize the loading and rendering performance
|
|
74
|
+
* of ProseMirror editor nodes by deferring the loading of their associated NodeViews until they are actually needed.
|
|
75
|
+
* This is particularly useful for complex or heavy NodeViews, such as tables, table cells, rows, and headers within
|
|
76
|
+
* the ProseMirror editor. By using dynamic imports (with promises), the initial load time of the editor can be significantly
|
|
77
|
+
* reduced, leading to a smoother and faster user experience.
|
|
78
|
+
*
|
|
79
|
+
* The function accepts configuration parameters including the node name, a loader function that dynamically imports
|
|
80
|
+
* the NodeView, and a function to retrieve NodeView options. It returns a NodeViewConstructor that ProseMirror
|
|
81
|
+
* can use when rendering nodes of the specified type.
|
|
82
|
+
*
|
|
83
|
+
* @template NodeViewOptions - The type parameter that describes the shape of the options object for the NodeView.
|
|
84
|
+
* @param {LazyLoadingProps<NodeViewOptions>} params - Configuration parameters for lazy loading.
|
|
85
|
+
* @param {string} params.nodeName - The name of the node (e.g., 'table', 'tableCell', 'tableHeader', 'tableRow') for which the lazy-loaded NodeView is intended.
|
|
86
|
+
* @param {() => Promise<CreateReactNodeViewProps<NodeViewOptions>>} params.loader - A function that, when called, returns a promise that resolves to the actual NodeView constructor. This function typically uses dynamic `import()` to load the NodeView code.
|
|
87
|
+
* @param {() => NodeViewOptions} params.getNodeViewOptions - A function that returns the options to be passed to the NodeView constructor. These options can include dependencies like `portalProviderAPI`, `eventDispatcher`, and others, which are necessary for the NodeView's operation.
|
|
88
|
+
* @param {DispatchAnalyticsEvent} [params.dispatchAnalyticsEvent] - An optional function for dispatching analytics events, which can be used to monitor the performance and usage of the lazy-loaded NodeViews.
|
|
89
|
+
* @returns {NodeViewConstructor} A constructor function for creating a NodeView that ProseMirror can instantiate when it encounters a node of the specified type. This constructor is a lightweight placeholder until the actual NodeView is loaded.
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* // Lazy load a table NodeView with specific options
|
|
93
|
+
* const lazyTableView = withLazyLoading({
|
|
94
|
+
* nodeName: 'table',
|
|
95
|
+
* loader: () => import('./table').then(module => module.createTableView),
|
|
96
|
+
* getNodeViewOptions: () => ({
|
|
97
|
+
* portalProviderAPI,
|
|
98
|
+
* eventDispatcher,
|
|
99
|
+
* getEditorContainerWidth,
|
|
100
|
+
* getEditorFeatureFlags,
|
|
101
|
+
* dispatchAnalyticsEvent,
|
|
102
|
+
* pluginInjectionApi,
|
|
103
|
+
* }),
|
|
104
|
+
* });
|
|
105
|
+
*
|
|
106
|
+
* // Then, use `lazyTableView` in ProseMirror editor setup to enhance 'table' nodes with lazy loading
|
|
107
|
+
*/
|
|
108
|
+
export declare const withLazyLoading: <Options>({ nodeName, loader, getNodeViewOptions, dispatchAnalyticsEvent, }: LazyLoadingProps<Options>) => NodeViewConstructor;
|
|
109
|
+
export {};
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
+
import { type EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
2
3
|
export type OnDropdownChange = (isOpen: boolean) => void;
|
|
3
4
|
export type DropdownProps = {
|
|
4
5
|
/** Callback fired when the Configure dropdown item is clicked */
|
|
5
6
|
onConfigureClick: () => void;
|
|
6
7
|
/** Callback fired when the dropdown is open or close */
|
|
7
8
|
onDropdownChange?: OnDropdownChange;
|
|
9
|
+
editorView: EditorView;
|
|
8
10
|
testId: string;
|
|
9
11
|
};
|
|
10
12
|
declare const _default: import("react").ForwardRefExoticComponent<DropdownProps & import("@atlaskit/analytics-next").WithContextProps & import("react").RefAttributes<any>>;
|
|
@@ -69,6 +69,11 @@ export declare const helpDialogMessages: {
|
|
|
69
69
|
defaultMessage: string;
|
|
70
70
|
description: string;
|
|
71
71
|
};
|
|
72
|
+
openCellOptions: {
|
|
73
|
+
id: string;
|
|
74
|
+
defaultMessage: string;
|
|
75
|
+
description: string;
|
|
76
|
+
};
|
|
72
77
|
focusTableResizeHandle: {
|
|
73
78
|
id: string;
|
|
74
79
|
defaultMessage: string;
|
|
@@ -3,6 +3,7 @@ import React from 'react';
|
|
|
3
3
|
import type { ButtonProps } from '@atlaskit/button/types';
|
|
4
4
|
import type { PositionType } from '@atlaskit/tooltip';
|
|
5
5
|
import { TOOLBAR_ACTION_SUBJECT_ID } from '../../analytics';
|
|
6
|
+
import { type Keymap } from '../../keymaps';
|
|
6
7
|
import type { MenuItem } from '../DropdownMenu';
|
|
7
8
|
export declare const TOOLBAR_BUTTON: typeof TOOLBAR_ACTION_SUBJECT_ID;
|
|
8
9
|
export type Props = {
|
|
@@ -23,6 +24,7 @@ export type Props = {
|
|
|
23
24
|
titlePosition?: PositionType;
|
|
24
25
|
item?: MenuItem;
|
|
25
26
|
testId?: string;
|
|
27
|
+
keymap?: Keymap;
|
|
26
28
|
'aria-label'?: React.AriaAttributes['aria-label'];
|
|
27
29
|
'aria-expanded'?: React.AriaAttributes['aria-expanded'];
|
|
28
30
|
'aria-haspopup'?: React.AriaAttributes['aria-haspopup'];
|
|
@@ -48,6 +50,7 @@ declare const ToolbarButton: React.ForwardRefExoticComponent<{
|
|
|
48
50
|
titlePosition?: PositionType | undefined;
|
|
49
51
|
item?: MenuItem | undefined;
|
|
50
52
|
testId?: string | undefined;
|
|
53
|
+
keymap?: Keymap | undefined;
|
|
51
54
|
'aria-label'?: React.AriaAttributes['aria-label'];
|
|
52
55
|
'aria-expanded'?: React.AriaAttributes['aria-expanded'];
|
|
53
56
|
'aria-haspopup'?: React.AriaAttributes['aria-haspopup'];
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@atlaskit/editor-common/lazy-node-view",
|
|
3
|
+
"main": "../dist/cjs/lazy-node-view/index.js",
|
|
4
|
+
"module": "../dist/esm/lazy-node-view/index.js",
|
|
5
|
+
"module:es2019": "../dist/es2019/lazy-node-view/index.js",
|
|
6
|
+
"sideEffects": false,
|
|
7
|
+
"types": "../dist/types/lazy-node-view/index.d.ts",
|
|
8
|
+
"typesVersions": {
|
|
9
|
+
">=4.5 <5.4": {
|
|
10
|
+
"*": [
|
|
11
|
+
"../dist/types-ts4.5/lazy-node-view/index.d.ts"
|
|
12
|
+
]
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-common",
|
|
3
|
-
"version": "86.
|
|
3
|
+
"version": "86.1.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/"
|
|
@@ -92,7 +92,8 @@
|
|
|
92
92
|
"./constants": "./src/link/constants.ts",
|
|
93
93
|
"./doc-utils": "./src/doc-utils/index.ts",
|
|
94
94
|
"./expand": "./src/expand/index.ts",
|
|
95
|
-
"./table": "./src/table/index.ts"
|
|
95
|
+
"./table": "./src/table/index.ts",
|
|
96
|
+
"./lazy-node-view": "./src/lazy-node-view/index.ts"
|
|
96
97
|
},
|
|
97
98
|
"dependencies": {
|
|
98
99
|
"@atlaskit/activity-provider": "^2.4.0",
|
|
@@ -246,7 +247,7 @@
|
|
|
246
247
|
"platform-editor-a11y-image-border-options-dropdown": {
|
|
247
248
|
"type": "boolean"
|
|
248
249
|
},
|
|
249
|
-
"
|
|
250
|
+
"platform_editor_a11y_table_context_menu": {
|
|
250
251
|
"type": "boolean"
|
|
251
252
|
},
|
|
252
253
|
"platform.editor.a11y-main-toolbar-navigation_osrty": {
|