Skip to content

Commit

Permalink
update example with custom examples
Browse files Browse the repository at this point in the history
  • Loading branch information
Darginec05 committed Jun 5, 2024
1 parent e655c06 commit c156322
Show file tree
Hide file tree
Showing 2 changed files with 512 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,10 @@ const MARKS = [Bold, Italic, CodeMark, Underline, Strike, Highlight];
function WithCustomPluginExample() {
const editor = useMemo(() => createYooptaEditor(), []);
const selectionRef = useRef(null);
const [value] = useState(() => {
const localData = localStorage.getItem('WithCustomPluginExample');
if (localData) return JSON.parse(localData);
return WITH_CUSTOM_PLUGIN_VALUE;
});

useEffect(() => {
function handleChange(data: any) {
localStorage.setItem('WithCustomPluginExample', JSON.stringify(data));
console.log('WithCustomPluginExample value', data);
}
editor.on('change', handleChange);
return () => {
Expand All @@ -121,16 +116,14 @@ function WithCustomPluginExample() {
className="md:py-[100px] md:pl-[200px] md:pr-[80px] px-[20px] pt-[80px] pb-[40px] flex justify-center"
ref={selectionRef}
>
{value && (
<YooptaEditor
editor={editor}
plugins={plugins}
tools={TOOLS}
marks={MARKS}
value={value}
selectionBoxRoot={selectionRef}
/>
)}
<YooptaEditor
editor={editor}
plugins={plugins}
tools={TOOLS}
marks={MARKS}
value={WITH_CUSTOM_PLUGIN_VALUE}
selectionBoxRoot={selectionRef}
/>
</div>
);
}
Expand Down
538 changes: 503 additions & 35 deletions web/next-example/src/components/examples/withCustomPlugin/initValue.ts

Large diffs are not rendered by default.

0 comments on commit c156322

Please sign in to comment.