import * as React from "react"; import { withKnobs, text, object, boolean, select, } from "@storybook/addon-knobs"; import { Editor, EditorContext } from "./Editor"; import { ComponentTypes } from "@sc/plugins/webcomponents/v2/types"; import { EditorObject, LoadComponent, RichEditor, ItemLegend, ComponentSelector, } from "./components"; import { EditorActions, CURSOR_ID } from "./types"; import { EditorObjectState } from "./components/EditorObject/types"; import { AddTypes } from "./components/EditorObject/EditorObject"; export default { title: "Modules|Editor", component: Editor, subcomponents: { EditorObject, LoadComponent, RichEditor, ItemLegend, ComponentSelector, }, parameters: { componentSubtitle: "This is the editor module", }, excludeStories: /.*Data$/, decorators: [withKnobs], }; export const sampleContentData = [ { id: "body", type: ComponentTypes.BODY, parent: false, style: { // backgroundColor: `rgb(255,255,0,0.3)`, padding: 30, }, canHaveChildren: true, }, { id: "testing1", type: ComponentTypes.HEADLINE, style: { color: "green", fontSize: "18pt" }, children: "1 [HEADLINE] - This is a test", parent: "body", }, { id: "container", type: ComponentTypes.CONTAINER, parent: "body", style: { backgroundColor: "#f1f1f1", padding: 20 }, canHaveChildren: true, }, { id: "testing2", type: ComponentTypes.TEXT, style: { fontSize: "12pt" }, children: "2 [TEXT] - This is a test", parent: "container", }, { id: "testing3", type: ComponentTypes.HEADLINE, style: { color: "green", fontSize: "18pt" }, children: "3 [HEADLINE] - This is a test", parent: "container", state: EditorObjectState.ACTIVE, }, { id: "testing4", type: ComponentTypes.TEXT, style: { fontSize: "12pt" }, children: "4 [TEXT] - This is a test", parent: "container", }, { id: "testing5", type: ComponentTypes.TEXT, style: { fontSize: "12pt" }, children: "5 [TEXT] - This is a test", parent: "body", }, { id: "testing6", type: ComponentTypes.TEXT, style: { fontSize: "12pt" }, children: "6 [TEXT] - This is a test", parent: "body", }, ]; export const Default = () => { const components = Object.keys(ComponentTypes); const SampleToolbar = () => { const btnStyle = { margin: 5 }; const editor = React.useContext(EditorContext); const { content, dispatch } = editor; return (