mirror of
https://github.com/webstudio-is/webstudio.git
synced 2026-10-27 15:16:53 +09:00
52 lines
1015 B
TypeScript
52 lines
1015 B
TypeScript
import { useState } from "react";
|
|
import { StorySection } from "@webstudio-is/design-system";
|
|
import { CodeEditor as CodeEditorComponent } from "./code-editor";
|
|
|
|
export default {
|
|
title: "Code editor",
|
|
component: CodeEditorComponent,
|
|
};
|
|
|
|
const initialHtml = `
|
|
<div>
|
|
<a href="#">Click me</a>
|
|
</div>
|
|
<script>
|
|
runMyJavascript()
|
|
</script>
|
|
`.trim();
|
|
|
|
const BaseEditorDemo = () => {
|
|
const [value, setValue] = useState(initialHtml);
|
|
return (
|
|
<CodeEditorComponent
|
|
value={value}
|
|
onChange={setValue}
|
|
onChangeComplete={setValue}
|
|
/>
|
|
);
|
|
};
|
|
|
|
const HtmlEditorDemo = () => {
|
|
const [value, setValue] = useState(initialHtml);
|
|
return (
|
|
<CodeEditorComponent
|
|
value={value}
|
|
onChange={setValue}
|
|
onChangeComplete={setValue}
|
|
lang="html"
|
|
/>
|
|
);
|
|
};
|
|
|
|
export const CodeEditor = () => (
|
|
<>
|
|
<StorySection title="Base editor">
|
|
<BaseEditorDemo />
|
|
</StorySection>
|
|
<StorySection title="HTML editor">
|
|
<HtmlEditorDemo />
|
|
</StorySection>
|
|
</>
|
|
);
|