@blocklet/editor 2.1.129 → 2.1.131
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/lib/ext/nodes/GithubNode.js +26 -12
- package/package.json +2 -2
|
@@ -3,11 +3,19 @@ import { DecoratorNode } from 'lexical';
|
|
|
3
3
|
import { Suspense } from 'react';
|
|
4
4
|
import GithubComponent from './GithubComp';
|
|
5
5
|
function convertGithubElement(domNode) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
const githubStr = domNode.getAttribute('data-lexical-github');
|
|
7
|
+
if (!githubStr) {
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
try {
|
|
11
|
+
const parsed = JSON.parse(githubStr);
|
|
12
|
+
if (parsed && typeof parsed === 'object') {
|
|
13
|
+
const node = $createGithubNode({ title: parsed.title, image: parsed.image, link: parsed.link });
|
|
14
|
+
return { node };
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
catch (e) {
|
|
18
|
+
console.warn(`Failed to parse: ${githubStr}`, e);
|
|
11
19
|
}
|
|
12
20
|
return null;
|
|
13
21
|
}
|
|
@@ -31,17 +39,22 @@ export class GithubNode extends DecoratorNode {
|
|
|
31
39
|
return node;
|
|
32
40
|
}
|
|
33
41
|
exportDOM() {
|
|
34
|
-
const element = document.createElement('
|
|
35
|
-
element.
|
|
36
|
-
element.setAttribute('
|
|
42
|
+
const element = document.createElement('span');
|
|
43
|
+
element.className = 'github-node-container';
|
|
44
|
+
element.setAttribute('data-lexical-github', JSON.stringify({ title: this.__title, image: this.__image, link: this.__link }));
|
|
37
45
|
return { element };
|
|
38
46
|
}
|
|
39
47
|
static importDOM() {
|
|
40
48
|
return {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
49
|
+
span: (domNode) => {
|
|
50
|
+
if (!domNode.hasAttribute('data-lexical-github')) {
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
conversion: convertGithubElement,
|
|
55
|
+
priority: 4,
|
|
56
|
+
};
|
|
57
|
+
},
|
|
45
58
|
};
|
|
46
59
|
}
|
|
47
60
|
constructor(title, image, link) {
|
|
@@ -63,6 +76,7 @@ export class GithubNode extends DecoratorNode {
|
|
|
63
76
|
createDOM(config) {
|
|
64
77
|
const span = document.createElement('span');
|
|
65
78
|
span.className = 'github-node-container';
|
|
79
|
+
span.setAttribute('data-lexical-github', JSON.stringify({ title: this.__title, image: this.__image, link: this.__link }));
|
|
66
80
|
return span;
|
|
67
81
|
}
|
|
68
82
|
updateDOM() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/editor",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.131",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"ufo": "^1.5.4",
|
|
67
67
|
"url-join": "^4.0.1",
|
|
68
68
|
"zustand": "^4.5.5",
|
|
69
|
-
"@blocklet/pdf": "^2.1.
|
|
69
|
+
"@blocklet/pdf": "^2.1.131"
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
72
|
"@babel/core": "^7.25.2",
|