@vonaffenfels/slate-editor 1.0.1
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/.babelrc +44 -0
- package/README.md +5 -0
- package/componentLoader.js +52 -0
- package/dist/BlockEditor.css +93 -0
- package/dist/BlockEditor.js +2 -0
- package/dist/BlockEditor.js.LICENSE.txt +61 -0
- package/dist/Renderer.js +2 -0
- package/dist/Renderer.js.LICENSE.txt +15 -0
- package/dist/fromHTML.js +1 -0
- package/dist/index.css +93 -0
- package/dist/index.js +2 -0
- package/dist/index.js.LICENSE.txt +69 -0
- package/dist/toHTML.js +2 -0
- package/dist/toHTML.js.LICENSE.txt +23 -0
- package/dist/toText.js +2 -0
- package/dist/toText.js.LICENSE.txt +23 -0
- package/package.json +79 -0
- package/postcss.config.js +7 -0
- package/scss/demo.scss +142 -0
- package/scss/editor.scss +394 -0
- package/scss/storybook.scss +66 -0
- package/scss/toolbar.scss +160 -0
- package/src/BlockEditor.js +252 -0
- package/src/Blocks/EmptyBlock.js +12 -0
- package/src/Blocks/EmptyWrapper.js +5 -0
- package/src/Blocks/ErrorBoundary.js +41 -0
- package/src/Blocks/LayoutBlock.js +179 -0
- package/src/Blocks/LayoutSlot.js +61 -0
- package/src/Context/StorybookContext.js +7 -0
- package/src/Nodes/Default.js +151 -0
- package/src/Nodes/Element.js +72 -0
- package/src/Nodes/Leaf.js +40 -0
- package/src/Nodes/Storybook.js +170 -0
- package/src/Nodes/StorybookDisplay.js +118 -0
- package/src/Nodes/Text.js +67 -0
- package/src/Renderer.js +41 -0
- package/src/Serializer/Html.js +43 -0
- package/src/Serializer/Serializer.js +318 -0
- package/src/Serializer/Text.js +18 -0
- package/src/Serializer/ads.js +175 -0
- package/src/Serializer/index.js +4 -0
- package/src/SidebarEditor/SidebarEditorField.js +249 -0
- package/src/SidebarEditor.css +90 -0
- package/src/SidebarEditor.js +236 -0
- package/src/Storybook.js +152 -0
- package/src/Toolbar/Align.js +65 -0
- package/src/Toolbar/Block.js +121 -0
- package/src/Toolbar/Element.js +49 -0
- package/src/Toolbar/Formats.js +60 -0
- package/src/Toolbar/Insert.js +29 -0
- package/src/Toolbar/Layout.js +333 -0
- package/src/Toolbar/Link.js +165 -0
- package/src/Toolbar/Toolbar.js +164 -0
- package/src/Tools/Margin.js +52 -0
- package/src/dev/App.js +61 -0
- package/src/dev/draftToSlate.json +3148 -0
- package/src/dev/index.css +3 -0
- package/src/dev/index.html +11 -0
- package/src/dev/index.js +5 -0
- package/src/dev/sampleValue1.json +4295 -0
- package/src/dev/sampleValue2.json +0 -0
- package/src/dev/sampleValueValid.json +411 -0
- package/src/dev/testComponents/TestStory.js +9 -0
- package/src/dev/testComponents/TestStory.stories.js +172 -0
- package/src/dev/testSampleValue.json +747 -0
- package/src/fromHTML.js +5 -0
- package/src/index.js +9 -0
- package/src/plugins/ListItem.js +49 -0
- package/src/plugins/SoftBreak.js +24 -0
- package/src/toHTML.js +7 -0
- package/src/toText.js +7 -0
- package/src/util.js +20 -0
- package/storyLoader.js +46 -0
- package/tailwind.config.js +5 -0
- package/webpack.config.build.js +53 -0
- package/webpack.config.dev.js +61 -0
- package/webpack.config.js +117 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import classNames from "classnames";
|
|
2
|
+
|
|
3
|
+
export const ToolMargin = ({
|
|
4
|
+
margin,
|
|
5
|
+
onChange,
|
|
6
|
+
}) => {
|
|
7
|
+
const onMarginClick = (e, direction) => {
|
|
8
|
+
onChange({
|
|
9
|
+
...(margin || {}),
|
|
10
|
+
[direction]: !margin?.[direction],
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
return <span className="layout-slot-option-padding">
|
|
15
|
+
<span
|
|
16
|
+
className={classNames({
|
|
17
|
+
"layout-slot-option-padding-item layout-slot-option-padding-top": true,
|
|
18
|
+
"active": margin?.top,
|
|
19
|
+
})}
|
|
20
|
+
contentEditable={false}
|
|
21
|
+
onClick={(e) => {
|
|
22
|
+
onMarginClick(e, "top");
|
|
23
|
+
}} />
|
|
24
|
+
<span
|
|
25
|
+
className={classNames({
|
|
26
|
+
"layout-slot-option-padding-item layout-slot-option-padding-right": true,
|
|
27
|
+
"active": margin?.right,
|
|
28
|
+
})}
|
|
29
|
+
contentEditable={false}
|
|
30
|
+
onClick={(e) => {
|
|
31
|
+
onMarginClick(e, "right");
|
|
32
|
+
}} />
|
|
33
|
+
<span
|
|
34
|
+
className={classNames({
|
|
35
|
+
"layout-slot-option-padding-item layout-slot-option-padding-bottom": true,
|
|
36
|
+
"active": margin?.bottom,
|
|
37
|
+
})}
|
|
38
|
+
contentEditable={false}
|
|
39
|
+
onClick={(e) => {
|
|
40
|
+
onMarginClick(e, "bottom");
|
|
41
|
+
}} />
|
|
42
|
+
<span
|
|
43
|
+
className={classNames({
|
|
44
|
+
"layout-slot-option-padding-item layout-slot-option-padding-left": true,
|
|
45
|
+
"active": margin?.left,
|
|
46
|
+
})}
|
|
47
|
+
contentEditable={false}
|
|
48
|
+
onClick={(e) => {
|
|
49
|
+
onMarginClick(e, "left");
|
|
50
|
+
}} />
|
|
51
|
+
</span>;
|
|
52
|
+
};
|
package/src/dev/App.js
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import React, {useEffect} from 'react';
|
|
2
|
+
import BlockEditor from "../BlockEditor";
|
|
3
|
+
// eslint-disable-next-line import/no-unresolved
|
|
4
|
+
import "scss/demo.scss";
|
|
5
|
+
import "./index.css";
|
|
6
|
+
import {
|
|
7
|
+
useState, useContext,
|
|
8
|
+
} from "react";
|
|
9
|
+
import SampleValue from "./testSampleValue.json";
|
|
10
|
+
// eslint-disable-next-line
|
|
11
|
+
import storybookStories from "storybookStories";
|
|
12
|
+
import componentLoader from "@vonaffenfels/slate-editor/componentLoader.js";
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
function App() {
|
|
16
|
+
const defaultValue = [
|
|
17
|
+
{
|
|
18
|
+
type: "paragraph",
|
|
19
|
+
children: [
|
|
20
|
+
{text: ""},
|
|
21
|
+
],
|
|
22
|
+
},
|
|
23
|
+
];
|
|
24
|
+
const [value, setValue] = useState(SampleValue);
|
|
25
|
+
const [loadedStorybookStories, setLoadedStorybookStories] = useState([]);
|
|
26
|
+
|
|
27
|
+
const loadStories = async () => {
|
|
28
|
+
setLoadedStorybookStories(await storybookStories());
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
loadStories();
|
|
33
|
+
}, []);
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<div className="editor-demo-wrapper">
|
|
37
|
+
<div className="editor-demo block-editor-content">
|
|
38
|
+
<div className="editor-demo-editor container">
|
|
39
|
+
<BlockEditor
|
|
40
|
+
storybookStories={loadedStorybookStories}
|
|
41
|
+
onChange={setValue}
|
|
42
|
+
elementPropsMap={{}}
|
|
43
|
+
value={value}
|
|
44
|
+
storybookUrl={"http://localhost:3000/"}
|
|
45
|
+
storybookComponentLoader={(block) => {
|
|
46
|
+
return componentLoader(block);
|
|
47
|
+
}}
|
|
48
|
+
storybookComponentDataLoader={async (block, attributes) => {
|
|
49
|
+
return {};
|
|
50
|
+
}}
|
|
51
|
+
/>
|
|
52
|
+
</div>
|
|
53
|
+
</div>
|
|
54
|
+
<div className="editor-demo-output">
|
|
55
|
+
<textarea value={JSON.stringify(value)}/>
|
|
56
|
+
</div>
|
|
57
|
+
</div>
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export default App;
|