@atlaskit/editor-common 87.0.2 → 87.0.4
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 +22 -0
- package/code-block/package.json +15 -0
- package/dist/cjs/code-block/index.js +31 -0
- package/dist/cjs/lazy-node-view/index.js +19 -128
- package/dist/cjs/lazy-node-view/node-view.js +35 -0
- package/dist/cjs/lazy-node-view/replace-node-views.js +95 -0
- package/dist/cjs/lazy-node-view/types.js +5 -0
- package/dist/cjs/monitoring/error.js +1 -1
- package/dist/cjs/styles/shared/code-block.js +4 -3
- package/dist/cjs/ui/DropList/index.js +1 -1
- package/dist/es2019/code-block/index.js +25 -0
- package/dist/es2019/lazy-node-view/index.js +16 -124
- package/dist/es2019/lazy-node-view/node-view.js +27 -0
- package/dist/es2019/lazy-node-view/replace-node-views.js +91 -0
- package/dist/es2019/lazy-node-view/types.js +1 -0
- package/dist/es2019/monitoring/error.js +1 -1
- package/dist/es2019/styles/shared/code-block.js +9 -1
- package/dist/es2019/ui/DropList/index.js +1 -1
- package/dist/esm/code-block/index.js +25 -0
- package/dist/esm/lazy-node-view/index.js +16 -124
- package/dist/esm/lazy-node-view/node-view.js +28 -0
- package/dist/esm/lazy-node-view/replace-node-views.js +88 -0
- package/dist/esm/lazy-node-view/types.js +1 -0
- package/dist/esm/monitoring/error.js +1 -1
- package/dist/esm/styles/shared/code-block.js +4 -3
- package/dist/esm/ui/DropList/index.js +1 -1
- package/dist/types/code-block/index.d.ts +9 -0
- package/dist/types/lazy-node-view/index.d.ts +3 -49
- package/dist/types/lazy-node-view/node-view.d.ts +12 -0
- package/dist/types/lazy-node-view/replace-node-views.d.ts +44 -0
- package/dist/types/lazy-node-view/types.d.ts +14 -0
- package/dist/types/styles/shared/code-block.d.ts +1 -0
- package/dist/types-ts4.5/code-block/index.d.ts +9 -0
- package/dist/types-ts4.5/lazy-node-view/index.d.ts +3 -49
- package/dist/types-ts4.5/lazy-node-view/node-view.d.ts +12 -0
- package/dist/types-ts4.5/lazy-node-view/replace-node-views.d.ts +44 -0
- package/dist/types-ts4.5/lazy-node-view/types.d.ts +14 -0
- package/dist/types-ts4.5/styles/shared/code-block.d.ts +1 -0
- package/package.json +6 -2
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/// <reference types="lodash" />
|
|
2
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
3
|
+
import type { CacheLoadedReactNodeViews, NodeViewConstructor } from './types';
|
|
4
|
+
/**
|
|
5
|
+
* 🧱 Internal: Editor FE Platform
|
|
6
|
+
*
|
|
7
|
+
* Debounces and replaces the node views in a ProseMirror editor with lazy-loaded node views.
|
|
8
|
+
*
|
|
9
|
+
* This function is used to update the `nodeViews` property of the `EditorView` after lazy-loaded
|
|
10
|
+
* node views have been loaded. It uses a debounced approach to ensure that the replacement does
|
|
11
|
+
* not happen too frequently, which can be performance-intensive.
|
|
12
|
+
*
|
|
13
|
+
* The function checks if there are any loaded node views in the cache associated with the given
|
|
14
|
+
* `EditorView`. If there are, it replaces the current `nodeViews` in the `EditorView` with the
|
|
15
|
+
* loaded node views. The replacement is scheduled using `requestIdleCallback` or
|
|
16
|
+
* `requestAnimationFrame` to avoid blocking the main thread, especially in Firefox where
|
|
17
|
+
* `requestIdleCallback` may not be supported.
|
|
18
|
+
*
|
|
19
|
+
* @param {WeakMap<EditorView, Record<string, NodeViewConstructor>>} cache - A WeakMap that stores
|
|
20
|
+
* the loaded node views for each `EditorView`. The key is the `EditorView`, and the value
|
|
21
|
+
* is a record of node type names to their corresponding `NodeViewConstructor`.
|
|
22
|
+
* @param {EditorView} view - The ProseMirror `EditorView` instance whose `nodeViews` property
|
|
23
|
+
* needs to be updated.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* const cache = new WeakMap();
|
|
27
|
+
* const view = new EditorView(...);
|
|
28
|
+
*
|
|
29
|
+
* // Assume some node views have been loaded and stored in the cache
|
|
30
|
+
* cache.set(view, {
|
|
31
|
+
* 'table': TableViewConstructor,
|
|
32
|
+
* 'tableCell': TableCellViewConstructor,
|
|
33
|
+
* });
|
|
34
|
+
*
|
|
35
|
+
* debouncedReplaceNodeviews(cache, view);
|
|
36
|
+
*/
|
|
37
|
+
export declare const debouncedReplaceNodeviews: import("lodash").DebouncedFunc<(cache: CacheLoadedReactNodeViews, view: EditorView) => void>;
|
|
38
|
+
/**
|
|
39
|
+
* 🧱 Internal: Editor FE Platform
|
|
40
|
+
*/
|
|
41
|
+
export declare const queueReplaceNodeViews: (view: EditorView, { nodeName, nodeViewFunc }: {
|
|
42
|
+
nodeName: string;
|
|
43
|
+
nodeViewFunc: NodeViewConstructor;
|
|
44
|
+
}) => void;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
+
import type { Decoration, DecorationSource, EditorView, NodeView } from '@atlaskit/editor-prosemirror/view';
|
|
3
|
+
/**
|
|
4
|
+
* 🧱 Internal: Editor FE Platform
|
|
5
|
+
*/
|
|
6
|
+
export type NodeViewConstructor = (node: PMNode, view: EditorView, getPos: () => number | undefined, decorations: readonly Decoration[], innerDecorations: DecorationSource) => NodeView;
|
|
7
|
+
/**
|
|
8
|
+
* 🧱 Internal: Editor FE Platform
|
|
9
|
+
*/
|
|
10
|
+
export type LoadedReactNodeViews = Record<string, NodeViewConstructor>;
|
|
11
|
+
/**
|
|
12
|
+
* 🧱 Internal: Editor FE Platform
|
|
13
|
+
*/
|
|
14
|
+
export type CacheLoadedReactNodeViews = WeakMap<EditorView, LoadedReactNodeViews>;
|
|
@@ -6,6 +6,7 @@ export declare const CodeBlockSharedCssClassName: {
|
|
|
6
6
|
CODEBLOCK_LINE_NUMBER_GUTTER: string;
|
|
7
7
|
CODEBLOCK_CONTENT: string;
|
|
8
8
|
DS_CODEBLOCK: string;
|
|
9
|
+
CODEBLOCK_CONTENT_WRAPPED: string;
|
|
9
10
|
};
|
|
10
11
|
export declare const codeBlockSharedStyles: () => import("@emotion/react").SerializedStyles;
|
|
11
12
|
export declare const codeBlockInListSafariFix: import("@emotion/react").SerializedStyles;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Node as PmNode } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
+
export declare const defaultWordWrapState = false;
|
|
3
|
+
export declare const codeBlockWrappedStates: WeakMap<PmNode, boolean | undefined>;
|
|
4
|
+
export declare const isCodeBlockWordWrapEnabled: (codeBlockNode: PmNode) => boolean;
|
|
5
|
+
/**
|
|
6
|
+
* As the code block node is used as the key, there is instances where the node will be destroyed & recreated and is no longer a valid key.
|
|
7
|
+
* In these instances, we must get the value from that old node and set it to the value of the new node.
|
|
8
|
+
*/
|
|
9
|
+
export declare const transferCodeBlockWrappedValue: (oldCodeBlockNode: PmNode, newCodeBlockNode: PmNode) => void;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
/// <reference types="lodash" />
|
|
2
1
|
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
3
|
-
import type { Decoration,
|
|
2
|
+
import type { Decoration, EditorView, NodeView } from '@atlaskit/editor-prosemirror/view';
|
|
4
3
|
import type { DispatchAnalyticsEvent } from '../analytics';
|
|
4
|
+
import type { NodeViewConstructor } from './types';
|
|
5
|
+
export type { NodeViewConstructor };
|
|
5
6
|
/**
|
|
6
7
|
* 📢 Public Type
|
|
7
8
|
*
|
|
@@ -19,52 +20,6 @@ export type LazyLoadingProps<NodeViewOptions> = {
|
|
|
19
20
|
getNodeViewOptions: () => NodeViewOptions;
|
|
20
21
|
dispatchAnalyticsEvent?: DispatchAnalyticsEvent;
|
|
21
22
|
};
|
|
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
23
|
/**
|
|
69
24
|
* 📢 Public: Any EditorPlugin can use this function
|
|
70
25
|
*
|
|
@@ -106,4 +61,3 @@ export declare const debouncedReplaceNodeviews: import("lodash").DebouncedFunc<(
|
|
|
106
61
|
* // Then, use `lazyTableView` in ProseMirror editor setup to enhance 'table' nodes with lazy loading
|
|
107
62
|
*/
|
|
108
63
|
export declare const withLazyLoading: <Options>({ nodeName, loader, getNodeViewOptions, dispatchAnalyticsEvent, }: LazyLoadingProps<Options>) => NodeViewConstructor;
|
|
109
|
-
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
+
import type { EditorView, NodeView } from '@atlaskit/editor-prosemirror/view';
|
|
3
|
+
/**
|
|
4
|
+
* 🧱 Internal: Editor FE Platform
|
|
5
|
+
*
|
|
6
|
+
* A NodeView that serves as a placeholder until the actual NodeView is loaded.
|
|
7
|
+
*/
|
|
8
|
+
export declare class LazyNodeView implements NodeView {
|
|
9
|
+
dom: Node;
|
|
10
|
+
contentDOM?: HTMLElement;
|
|
11
|
+
constructor(node: PMNode, view: EditorView, getPos: () => number | undefined);
|
|
12
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/// <reference types="lodash" />
|
|
2
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
3
|
+
import type { CacheLoadedReactNodeViews, NodeViewConstructor } from './types';
|
|
4
|
+
/**
|
|
5
|
+
* 🧱 Internal: Editor FE Platform
|
|
6
|
+
*
|
|
7
|
+
* Debounces and replaces the node views in a ProseMirror editor with lazy-loaded node views.
|
|
8
|
+
*
|
|
9
|
+
* This function is used to update the `nodeViews` property of the `EditorView` after lazy-loaded
|
|
10
|
+
* node views have been loaded. It uses a debounced approach to ensure that the replacement does
|
|
11
|
+
* not happen too frequently, which can be performance-intensive.
|
|
12
|
+
*
|
|
13
|
+
* The function checks if there are any loaded node views in the cache associated with the given
|
|
14
|
+
* `EditorView`. If there are, it replaces the current `nodeViews` in the `EditorView` with the
|
|
15
|
+
* loaded node views. The replacement is scheduled using `requestIdleCallback` or
|
|
16
|
+
* `requestAnimationFrame` to avoid blocking the main thread, especially in Firefox where
|
|
17
|
+
* `requestIdleCallback` may not be supported.
|
|
18
|
+
*
|
|
19
|
+
* @param {WeakMap<EditorView, Record<string, NodeViewConstructor>>} cache - A WeakMap that stores
|
|
20
|
+
* the loaded node views for each `EditorView`. The key is the `EditorView`, and the value
|
|
21
|
+
* is a record of node type names to their corresponding `NodeViewConstructor`.
|
|
22
|
+
* @param {EditorView} view - The ProseMirror `EditorView` instance whose `nodeViews` property
|
|
23
|
+
* needs to be updated.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* const cache = new WeakMap();
|
|
27
|
+
* const view = new EditorView(...);
|
|
28
|
+
*
|
|
29
|
+
* // Assume some node views have been loaded and stored in the cache
|
|
30
|
+
* cache.set(view, {
|
|
31
|
+
* 'table': TableViewConstructor,
|
|
32
|
+
* 'tableCell': TableCellViewConstructor,
|
|
33
|
+
* });
|
|
34
|
+
*
|
|
35
|
+
* debouncedReplaceNodeviews(cache, view);
|
|
36
|
+
*/
|
|
37
|
+
export declare const debouncedReplaceNodeviews: import("lodash").DebouncedFunc<(cache: CacheLoadedReactNodeViews, view: EditorView) => void>;
|
|
38
|
+
/**
|
|
39
|
+
* 🧱 Internal: Editor FE Platform
|
|
40
|
+
*/
|
|
41
|
+
export declare const queueReplaceNodeViews: (view: EditorView, { nodeName, nodeViewFunc }: {
|
|
42
|
+
nodeName: string;
|
|
43
|
+
nodeViewFunc: NodeViewConstructor;
|
|
44
|
+
}) => void;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
+
import type { Decoration, DecorationSource, EditorView, NodeView } from '@atlaskit/editor-prosemirror/view';
|
|
3
|
+
/**
|
|
4
|
+
* 🧱 Internal: Editor FE Platform
|
|
5
|
+
*/
|
|
6
|
+
export type NodeViewConstructor = (node: PMNode, view: EditorView, getPos: () => number | undefined, decorations: readonly Decoration[], innerDecorations: DecorationSource) => NodeView;
|
|
7
|
+
/**
|
|
8
|
+
* 🧱 Internal: Editor FE Platform
|
|
9
|
+
*/
|
|
10
|
+
export type LoadedReactNodeViews = Record<string, NodeViewConstructor>;
|
|
11
|
+
/**
|
|
12
|
+
* 🧱 Internal: Editor FE Platform
|
|
13
|
+
*/
|
|
14
|
+
export type CacheLoadedReactNodeViews = WeakMap<EditorView, LoadedReactNodeViews>;
|
|
@@ -6,6 +6,7 @@ export declare const CodeBlockSharedCssClassName: {
|
|
|
6
6
|
CODEBLOCK_LINE_NUMBER_GUTTER: string;
|
|
7
7
|
CODEBLOCK_CONTENT: string;
|
|
8
8
|
DS_CODEBLOCK: string;
|
|
9
|
+
CODEBLOCK_CONTENT_WRAPPED: string;
|
|
9
10
|
};
|
|
10
11
|
export declare const codeBlockSharedStyles: () => import("@emotion/react").SerializedStyles;
|
|
11
12
|
export declare const codeBlockInListSafariFix: import("@emotion/react").SerializedStyles;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-common",
|
|
3
|
-
"version": "87.0.
|
|
3
|
+
"version": "87.0.4",
|
|
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/"
|
|
@@ -93,6 +93,7 @@
|
|
|
93
93
|
"./constants": "./src/link/constants.ts",
|
|
94
94
|
"./doc-utils": "./src/doc-utils/index.ts",
|
|
95
95
|
"./expand": "./src/expand/index.ts",
|
|
96
|
+
"./code-block": "./src/code-block/index.ts",
|
|
96
97
|
"./table": "./src/table/index.ts",
|
|
97
98
|
"./lazy-node-view": "./src/lazy-node-view/index.ts"
|
|
98
99
|
},
|
|
@@ -115,7 +116,7 @@
|
|
|
115
116
|
"@atlaskit/editor-shared-styles": "^2.13.0",
|
|
116
117
|
"@atlaskit/editor-tables": "^2.8.0",
|
|
117
118
|
"@atlaskit/emoji": "^67.6.0",
|
|
118
|
-
"@atlaskit/icon": "^22.
|
|
119
|
+
"@atlaskit/icon": "^22.8.0",
|
|
119
120
|
"@atlaskit/icon-object": "^6.4.0",
|
|
120
121
|
"@atlaskit/link-datasource": "^2.9.0",
|
|
121
122
|
"@atlaskit/link-picker": "^1.41.0",
|
|
@@ -264,6 +265,9 @@
|
|
|
264
265
|
},
|
|
265
266
|
"editor_inline_comments_paste_insert_nodes": {
|
|
266
267
|
"type": "boolean"
|
|
268
|
+
},
|
|
269
|
+
"editor_support_code_block_wrapping": {
|
|
270
|
+
"type": "boolean"
|
|
267
271
|
}
|
|
268
272
|
}
|
|
269
273
|
}
|