@yoopta/exports 4.5.2-rc.3 → 4.6.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/README.md +66 -40
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -23,29 +23,25 @@ import { html } from '@yoopta/exports';
|
|
|
23
23
|
const Editor = () => {
|
|
24
24
|
const editor = useMemo(() => createYooptaEditor(), []);
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
// from html to @yoopta content
|
|
27
|
+
const deserializeHTML = () => {
|
|
28
|
+
const htmlString = '<h1>First title</h1>';
|
|
29
|
+
const content = html.deserialize(editor, htmlString);
|
|
30
|
+
|
|
31
|
+
editor.setEditorValue(content);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
// from @yoopta content to html string
|
|
35
|
+
const serializeHTML = () => {
|
|
36
|
+
const data = editor.getEditorValue();
|
|
37
|
+
const htmlString = html.serialize(editor, data);
|
|
38
|
+
console.log('html string', htmlString);
|
|
39
|
+
};
|
|
27
40
|
|
|
28
41
|
return (
|
|
29
42
|
<div>
|
|
30
|
-
<button
|
|
31
|
-
|
|
32
|
-
const htmlString = '<h1>First title</h1>';
|
|
33
|
-
const value = html.deserialize(editor, htmlString);
|
|
34
|
-
|
|
35
|
-
editor.setEditorValue(value);
|
|
36
|
-
}}
|
|
37
|
-
>
|
|
38
|
-
Deserialize from html to content
|
|
39
|
-
</button>
|
|
40
|
-
|
|
41
|
-
<button
|
|
42
|
-
onClick={() => {
|
|
43
|
-
const data = editor.getEditorValue();
|
|
44
|
-
const htmlString = html.serialize(editor, data);
|
|
45
|
-
}}
|
|
46
|
-
>
|
|
47
|
-
Serialize from content to html
|
|
48
|
-
</button>
|
|
43
|
+
<button onClick={deserializeHTML}>Deserialize from html to content</button>
|
|
44
|
+
<button onClick={serializeHTML}>Serialize from content to html</button>
|
|
49
45
|
|
|
50
46
|
<YooptaEditor editor={editor} plugins={plugins} />
|
|
51
47
|
</div>
|
|
@@ -63,29 +59,59 @@ import { markdown } from '@yoopta/exports';
|
|
|
63
59
|
const Editor = () => {
|
|
64
60
|
const editor = useMemo(() => createYooptaEditor(), []);
|
|
65
61
|
|
|
66
|
-
|
|
62
|
+
// from markdown to @yoopta content
|
|
63
|
+
const deserializeMarkdown = () => {
|
|
64
|
+
const markdownString = '# First title';
|
|
65
|
+
const value = markdown.deserialize(editor, markdownString);
|
|
66
|
+
|
|
67
|
+
editor.setEditorValue(value);
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
// from @yoopta content to markdown string
|
|
71
|
+
const serializeMarkdown = () => {
|
|
72
|
+
const data = editor.getEditorValue();
|
|
73
|
+
const markdownString = markdown.serialize(editor, data);
|
|
74
|
+
console.log('markdown string', markdownString);
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
return (
|
|
78
|
+
<div>
|
|
79
|
+
<button onClick={deserializeMarkdown}>Deserialize from markdown to content</button>
|
|
80
|
+
<button onClick={serializeMarkdown}>Serialize from content to markdown</button>
|
|
81
|
+
|
|
82
|
+
<YooptaEditor editor={editor} plugins={plugins} />
|
|
83
|
+
</div>
|
|
84
|
+
);
|
|
85
|
+
};
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Plain text exports/imports example
|
|
89
|
+
|
|
90
|
+
```jsx
|
|
91
|
+
import { plainText } from '@yoopta/exports';
|
|
92
|
+
|
|
93
|
+
const Editor = () => {
|
|
94
|
+
const editor = useMemo(() => createYooptaEditor(), []);
|
|
95
|
+
|
|
96
|
+
// from plain text to @yoopta content
|
|
97
|
+
const deserializeText = () => {
|
|
98
|
+
const textString = '# First title';
|
|
99
|
+
const value = plainText.deserialize(editor, textString);
|
|
100
|
+
|
|
101
|
+
editor.setEditorValue(value);
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
// from @yoopta content to plain text string
|
|
105
|
+
const serializeText = () => {
|
|
106
|
+
const data = editor.getEditorValue();
|
|
107
|
+
const textString = plainText.serialize(editor, data);
|
|
108
|
+
console.log('plain text string', textString);
|
|
109
|
+
};
|
|
67
110
|
|
|
68
111
|
return (
|
|
69
112
|
<div>
|
|
70
|
-
<button
|
|
71
|
-
|
|
72
|
-
const markdownString = '# First title';
|
|
73
|
-
const value = markdown.deserialize(editor, markdownString);
|
|
74
|
-
|
|
75
|
-
editor.setEditorValue(value);
|
|
76
|
-
}}
|
|
77
|
-
>
|
|
78
|
-
Deserialize from markdown to content
|
|
79
|
-
</button>
|
|
80
|
-
|
|
81
|
-
<buttonw
|
|
82
|
-
onClick={() => {
|
|
83
|
-
const data = editor.getEditorValue();
|
|
84
|
-
const markdownString = markdown.serialize(editor, data);
|
|
85
|
-
}}
|
|
86
|
-
>
|
|
87
|
-
Serialize from content to markdown
|
|
88
|
-
</button>
|
|
113
|
+
<button onClick={deserializeText}>Deserialize from plain text to content</button>
|
|
114
|
+
<button onClick={serializeText}>Serialize from content to plain text</button>
|
|
89
115
|
|
|
90
116
|
<YooptaEditor editor={editor} plugins={plugins} />
|
|
91
117
|
</div>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yoopta/exports",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.6.0",
|
|
4
4
|
"description": "Serialize/deserialize exports in different formats for Yoopta-Editor",
|
|
5
5
|
"author": "Darginec05 <devopsbanda@gmail.com>",
|
|
6
6
|
"homepage": "https://github.com/Darginec05/Editor-Yoopta#readme",
|
|
@@ -36,5 +36,5 @@
|
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"marked": "^13.0.0"
|
|
38
38
|
},
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "6aa0efc351d0e71c53e60a452c13023febc31235"
|
|
40
40
|
}
|