@lexical/react 0.2.6 → 0.2.9
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/LexicalAutoScrollPlugin.d.ts +1 -2
- package/LexicalBlockWithAlignableContents.d.ts +18 -0
- package/LexicalCheckListPlugin.d.ts +9 -0
- package/LexicalCollaborationPlugin.d.ts +2 -20
- package/LexicalDecoratorBlockNode.d.ts +23 -0
- package/LexicalMarkdownShortcutPlugin.d.ts +5 -1
- package/LexicalMarkdownShortcutPlugin.dev.js +98 -3
- package/LexicalMarkdownShortcutPlugin.prod.js +3 -1
- package/LexicalNestedComposer.d.ts +1 -1
- package/package.json +19 -19
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @flow strict
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import type {ElementFormatType, NodeKey} from 'lexical';
|
|
11
|
+
|
|
12
|
+
type Props = Readonly<{
|
|
13
|
+
children: JSX.Element | string | (JSX.Element | string)[];
|
|
14
|
+
format: ElementFormatType | null;
|
|
15
|
+
nodeKey: NodeKey;
|
|
16
|
+
}>;
|
|
17
|
+
|
|
18
|
+
declare function BlockWithAlignableContents(Props): JSX.Element;
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
+
import {WebsocketProvider} from 'y-websocket';
|
|
9
10
|
import type {Doc, RelativePosition} from 'yjs';
|
|
10
11
|
export type UserState = {
|
|
11
12
|
anchorPos: null | RelativePosition;
|
|
@@ -21,34 +22,15 @@ export type ProviderAwareness = {
|
|
|
21
22
|
on: (type: 'update', cb: () => void) => void;
|
|
22
23
|
off: (type: 'update', cb: () => void) => void;
|
|
23
24
|
};
|
|
24
|
-
export interface Provider {
|
|
25
|
-
connect(): void | Promise<void>;
|
|
26
|
-
disconnect(): void;
|
|
27
|
-
awareness: ProviderAwareness;
|
|
28
|
-
on(type: 'sync', cb: (isSynced: boolean) => void): void;
|
|
29
|
-
on(type: 'status', cb: (arg0: {status: string}) => void): void;
|
|
30
|
-
// $FlowFixMe: temp
|
|
31
|
-
on(type: 'update', cb: (arg0: any) => void): void;
|
|
32
|
-
on(type: 'reload', cb: (doc: Doc) => boolean): void;
|
|
33
|
-
off(type: 'sync', cb: (isSynced: boolean) => void): void;
|
|
34
|
-
// $FlowFixMe: temp
|
|
35
|
-
off(type: 'update', cb: (arg0: any) => void): void;
|
|
36
|
-
off(type: 'status', cb: (arg0: {status: string}) => void): void;
|
|
37
|
-
off(type: 'reload', cb: (doc: Doc) => boolean): void;
|
|
38
|
-
}
|
|
39
25
|
type CollaborationContextType = {
|
|
40
26
|
clientID: number;
|
|
41
27
|
color: string;
|
|
42
28
|
name: string;
|
|
43
29
|
yjsDocMap: Map<string, Doc>;
|
|
44
30
|
};
|
|
45
|
-
export type ProviderFactory = (
|
|
46
|
-
id: string,
|
|
47
|
-
yjsDocMap: Map<string, Doc>,
|
|
48
|
-
) => Provider;
|
|
49
31
|
export function CollaborationPlugin(arg0: {
|
|
50
32
|
id: string;
|
|
51
|
-
providerFactory:
|
|
33
|
+
providerFactory(id: string, yjsDocMap: Map<string, Doc>): WebsocketProvider;
|
|
52
34
|
shouldBootstrap: boolean;
|
|
53
35
|
username?: string;
|
|
54
36
|
}): JSX.Element | null;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @flow strict
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import type {ElementFormatType, LexicalNode, NodeKey} from 'lexical';
|
|
11
|
+
|
|
12
|
+
import {DecoratorNode} from 'lexical';
|
|
13
|
+
|
|
14
|
+
declare class DecoratorBlockNode<T> extends DecoratorNode<T> {
|
|
15
|
+
__format: ElementFormatType;
|
|
16
|
+
constructor(format?: ElementFormatType | null, key?: NodeKey);
|
|
17
|
+
createDOM(): HTMLElement;
|
|
18
|
+
setFormat(format: ElementFormatType): void;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
declare function $isDecoratorBlockNode<T>(
|
|
22
|
+
node: LexicalNode,
|
|
23
|
+
): node is DecoratorBlockNode<T>;
|
|
@@ -6,4 +6,8 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
import type {Transformer} from '@lexical/markdown';
|
|
10
|
+
|
|
11
|
+
export default function LexicalMarkdownShortcutPlugin(arg0: {
|
|
12
|
+
transformers: Array<Transformer>;
|
|
13
|
+
}): JSX.Element | null;
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
|
|
9
9
|
var markdown = require('@lexical/markdown');
|
|
10
10
|
var LexicalComposerContext = require('@lexical/react/LexicalComposerContext');
|
|
11
|
-
var
|
|
11
|
+
var React = require('react');
|
|
12
|
+
var lexical = require('lexical');
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
@@ -18,11 +19,105 @@ var react = require('react');
|
|
|
18
19
|
*
|
|
19
20
|
*
|
|
20
21
|
*/
|
|
22
|
+
lexical.createCommand();
|
|
23
|
+
|
|
24
|
+
function HorizontalRuleComponent() {
|
|
25
|
+
return /*#__PURE__*/React.createElement("hr", null);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
class HorizontalRuleNode extends lexical.DecoratorNode {
|
|
29
|
+
static getType() {
|
|
30
|
+
return 'horizontalrule';
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
static clone(node) {
|
|
34
|
+
return new HorizontalRuleNode(node.__key);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
static importDOM() {
|
|
38
|
+
return {
|
|
39
|
+
hr: node => ({
|
|
40
|
+
conversion: convertHorizontalRuleElement,
|
|
41
|
+
priority: 0
|
|
42
|
+
})
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
exportDOM() {
|
|
47
|
+
return {
|
|
48
|
+
element: document.createElement('hr')
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
createDOM() {
|
|
53
|
+
const div = document.createElement('div');
|
|
54
|
+
div.style.display = 'contents';
|
|
55
|
+
return div;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
getTextContent() {
|
|
59
|
+
return '\n';
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
isTopLevel() {
|
|
63
|
+
return true;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
updateDOM() {
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
decorate() {
|
|
71
|
+
return /*#__PURE__*/React.createElement(HorizontalRuleComponent, null);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function convertHorizontalRuleElement() {
|
|
77
|
+
return {
|
|
78
|
+
node: $createHorizontalRuleNode()
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function $createHorizontalRuleNode() {
|
|
83
|
+
return new HorizontalRuleNode();
|
|
84
|
+
}
|
|
85
|
+
function $isHorizontalRuleNode(node) {
|
|
86
|
+
return node instanceof HorizontalRuleNode;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
91
|
+
*
|
|
92
|
+
* This source code is licensed under the MIT license found in the
|
|
93
|
+
* LICENSE file in the root directory of this source tree.
|
|
94
|
+
*
|
|
95
|
+
*
|
|
96
|
+
*/
|
|
97
|
+
const HR = {
|
|
98
|
+
export: node => {
|
|
99
|
+
return $isHorizontalRuleNode(node) ? '***' : null;
|
|
100
|
+
},
|
|
101
|
+
regExp: /^(---|\*\*\*|___)\s?$/,
|
|
102
|
+
replace: (parentNode, _1, _2, isImport) => {
|
|
103
|
+
const line = $createHorizontalRuleNode(); // TODO: Get rid of isImport flag
|
|
104
|
+
|
|
105
|
+
if (isImport || parentNode.getNextSibling() != null) {
|
|
106
|
+
parentNode.replace(line);
|
|
107
|
+
} else {
|
|
108
|
+
parentNode.insertBefore(line);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
line.selectNext();
|
|
112
|
+
},
|
|
113
|
+
type: 'element'
|
|
114
|
+
};
|
|
115
|
+
const DEFAULT_TRANSFORMERS = [HR, ...markdown.TRANSFORMERS];
|
|
21
116
|
function LexicalMarkdownShortcutPlugin({
|
|
22
|
-
transformers
|
|
117
|
+
transformers = DEFAULT_TRANSFORMERS
|
|
23
118
|
}) {
|
|
24
119
|
const [editor] = LexicalComposerContext.useLexicalComposerContext();
|
|
25
|
-
|
|
120
|
+
React.useEffect(() => {
|
|
26
121
|
return markdown.registerMarkdownShortcuts(editor, transformers);
|
|
27
122
|
}, [editor, transformers]);
|
|
28
123
|
return null;
|
|
@@ -4,4 +4,6 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
var c=require("@lexical/markdown"),d=require("@lexical/react/LexicalComposerContext"),e=require("react")
|
|
7
|
+
var c=require("@lexical/markdown"),d=require("@lexical/react/LexicalComposerContext"),e=require("react"),f=require("lexical");f.createCommand();function g(){return e.createElement("hr",null)}
|
|
8
|
+
class h extends f.DecoratorNode{static getType(){return"horizontalrule"}static clone(a){return new h(a.__key)}static importDOM(){return{hr:()=>({conversion:k,priority:0})}}exportDOM(){return{element:document.createElement("hr")}}createDOM(){const a=document.createElement("div");a.style.display="contents";return a}getTextContent(){return"\n"}isTopLevel(){return!0}updateDOM(){return!1}decorate(){return e.createElement(g,null)}}function k(){return{node:new h}}
|
|
9
|
+
const m=[{export:a=>a instanceof h?"***":null,regExp:/^(---|\*\*\*|___)\s?$/,replace:(a,b,n,l)=>{b=new h;l||null!=a.getNextSibling()?a.replace(b):a.insertBefore(b);b.selectNext()},type:"element"},...c.TRANSFORMERS];module.exports=function({transformers:a=m}){const [b]=d.useLexicalComposerContext();e.useEffect(()=>c.registerMarkdownShortcuts(b,a),[b,a]);return null};
|
|
@@ -11,5 +11,5 @@ import type {LexicalEditor, EditorThemeClasses} from 'lexical';
|
|
|
11
11
|
export default function LexicalNestedComposer(arg0: {
|
|
12
12
|
initialEditor: LexicalEditor;
|
|
13
13
|
initialTheme?: EditorThemeClasses;
|
|
14
|
-
children: JSX.Element | JSX.Element[] | null;
|
|
14
|
+
children: JSX.Element | (JSX.Element | string | null)[] | null;
|
|
15
15
|
}): JSX.Element | null;
|
package/package.json
CHANGED
|
@@ -8,28 +8,28 @@
|
|
|
8
8
|
"rich-text"
|
|
9
9
|
],
|
|
10
10
|
"license": "MIT",
|
|
11
|
-
"version": "0.2.
|
|
11
|
+
"version": "0.2.9",
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@lexical/clipboard": "0.2.
|
|
14
|
-
"@lexical/list": "0.2.
|
|
15
|
-
"@lexical/table": "0.2.
|
|
16
|
-
"@lexical/yjs": "0.2.
|
|
17
|
-
"@lexical/hashtag": "0.2.
|
|
18
|
-
"@lexical/selection": "0.2.
|
|
19
|
-
"@lexical/utils": "0.2.
|
|
20
|
-
"@lexical/dragon": "0.2.
|
|
21
|
-
"@lexical/plain-text": "0.2.
|
|
22
|
-
"@lexical/rich-text": "0.2.
|
|
23
|
-
"@lexical/code": "0.2.
|
|
24
|
-
"@lexical/text": "0.2.
|
|
25
|
-
"@lexical/link": "0.2.
|
|
26
|
-
"@lexical/overflow": "0.2.
|
|
27
|
-
"@lexical/history": "0.2.
|
|
28
|
-
"@lexical/markdown": "0.2.
|
|
29
|
-
"@lexical/mark": "0.2.
|
|
13
|
+
"@lexical/clipboard": "0.2.9",
|
|
14
|
+
"@lexical/list": "0.2.9",
|
|
15
|
+
"@lexical/table": "0.2.9",
|
|
16
|
+
"@lexical/yjs": "0.2.9",
|
|
17
|
+
"@lexical/hashtag": "0.2.9",
|
|
18
|
+
"@lexical/selection": "0.2.9",
|
|
19
|
+
"@lexical/utils": "0.2.9",
|
|
20
|
+
"@lexical/dragon": "0.2.9",
|
|
21
|
+
"@lexical/plain-text": "0.2.9",
|
|
22
|
+
"@lexical/rich-text": "0.2.9",
|
|
23
|
+
"@lexical/code": "0.2.9",
|
|
24
|
+
"@lexical/text": "0.2.9",
|
|
25
|
+
"@lexical/link": "0.2.9",
|
|
26
|
+
"@lexical/overflow": "0.2.9",
|
|
27
|
+
"@lexical/history": "0.2.9",
|
|
28
|
+
"@lexical/markdown": "0.2.9",
|
|
29
|
+
"@lexical/mark": "0.2.9"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
|
-
"lexical": "0.2.
|
|
32
|
+
"lexical": "0.2.9",
|
|
33
33
|
"react": ">=17.x",
|
|
34
34
|
"react-dom": ">=17.x"
|
|
35
35
|
},
|