Skip to content

Commit

Permalink
update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Darginec05 committed Jun 25, 2024
1 parent 298a53f commit d4bab54
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 42 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

[![RepoRater](https://repo-rater.eddiehub.io/api/badge?owner=Darginec05&name=Yoopta-Editor)](https://repo-rater.eddiehub.io/rate?owner=Darginec05&name=Yoopta-Editor)
![npm](https://img.shields.io/npm/v/@yoopta/editor)
![license](https://img.shields.io/npm/l/@yoopta/editor)
![downloads](https://img.shields.io/npm/dm/@yoopta/editor)
[![](https://img.shields.io/static/v1?label=Sponsor&message=%E2%9D%A4&logo=GitHub&color=%23fe8e86)](https://github.com/sponsors/Darginec05)

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
],
"private": true,
"scripts": {
"start": "yarn lerna run start --scope @yoopta/editor --scope @yoopta/exports --scope @yoopta/link --scope @yoopta/file --scope @yoopta/image --parallel --ignore development",
"start": "yarn lerna run start --scope @yoopta/editor --scope @yoopta/exports --scope @yoopta/link --scope @yoopta/marks --scope @yoopta/file --scope @yoopta/image --parallel --ignore development",
"build": "yarn clean && yarn lerna run build --parallel --ignore development",
"clean": "find ./packages -type d -name dist ! -path './packages/development/*' -exec rm -rf {} +",
"serve": "yarn lerna run dev --scope=development",
Expand Down
106 changes: 66 additions & 40 deletions packages/core/exports/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,29 +23,25 @@ import { html } from '@yoopta/exports';
const Editor = () => {
const editor = useMemo(() => createYooptaEditor(), []);

const deserializeHTML = () => {};
// from html to @yoopta content
const deserializeHTML = () => {
const htmlString = '<h1>First title</h1>';
const content = html.deserialize(editor, htmlString);

editor.setEditorValue(content);
};

// from @yoopta content to html string
const serializeHTML = () => {
const data = editor.getEditorValue();
const htmlString = html.serialize(editor, data);
console.log('html string', htmlString);
};

return (
<div>
<button
onClick={() => {
const htmlString = '<h1>First title</h1>';
const value = html.deserialize(editor, htmlString);

editor.setEditorValue(value);
}}
>
Deserialize from html to content
</button>

<button
onClick={() => {
const data = editor.getEditorValue();
const htmlString = html.serialize(editor, data);
}}
>
Serialize from content to html
</button>
<button onClick={deserializeHTML}>Deserialize from html to content</button>
<button onClick={serializeHTML}>Serialize from content to html</button>

<YooptaEditor editor={editor} plugins={plugins} />
</div>
Expand All @@ -63,29 +59,59 @@ import { markdown } from '@yoopta/exports';
const Editor = () => {
const editor = useMemo(() => createYooptaEditor(), []);

const deserializeHTML = () => {};
// from markdown to @yoopta content
const deserializeMarkdown = () => {
const markdownString = '# First title';
const value = markdown.deserialize(editor, markdownString);

editor.setEditorValue(value);
};

// from @yoopta content to markdown string
const serializeMarkdown = () => {
const data = editor.getEditorValue();
const markdownString = markdown.serialize(editor, data);
console.log('markdown string', markdownString);
};

return (
<div>
<button onClick={deserializeMarkdown}>Deserialize from markdown to content</button>
<button onClick={serializeMarkdown}>Serialize from content to markdown</button>

<YooptaEditor editor={editor} plugins={plugins} />
</div>
);
};
```

Plain text exports/imports example

```jsx
import { plainText } from '@yoopta/exports';

const Editor = () => {
const editor = useMemo(() => createYooptaEditor(), []);

// from plain text to @yoopta content
const deserializeText = () => {
const textString = '# First title';
const value = plainText.deserialize(editor, textString);

editor.setEditorValue(value);
};

// from @yoopta content to plain text string
const serializeText = () => {
const data = editor.getEditorValue();
const textString = plainText.serialize(editor, data);
console.log('plain text string', textString);
};

return (
<div>
<button
onClick={() => {
const markdownString = '# First title';
const value = markdown.deserialize(editor, markdownString);

editor.setEditorValue(value);
}}
>
Deserialize from markdown to content
</button>

<buttonw
onClick={() => {
const data = editor.getEditorValue();
const markdownString = markdown.serialize(editor, data);
}}
>
Serialize from content to markdown
</button>
<button onClick={deserializeText}>Deserialize from plain text to content</button>
<button onClick={serializeText}>Serialize from content to plain text</button>

<YooptaEditor editor={editor} plugins={plugins} />
</div>
Expand Down

0 comments on commit d4bab54

Please sign in to comment.