@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.
Files changed (77) hide show
  1. package/.babelrc +44 -0
  2. package/README.md +5 -0
  3. package/componentLoader.js +52 -0
  4. package/dist/BlockEditor.css +93 -0
  5. package/dist/BlockEditor.js +2 -0
  6. package/dist/BlockEditor.js.LICENSE.txt +61 -0
  7. package/dist/Renderer.js +2 -0
  8. package/dist/Renderer.js.LICENSE.txt +15 -0
  9. package/dist/fromHTML.js +1 -0
  10. package/dist/index.css +93 -0
  11. package/dist/index.js +2 -0
  12. package/dist/index.js.LICENSE.txt +69 -0
  13. package/dist/toHTML.js +2 -0
  14. package/dist/toHTML.js.LICENSE.txt +23 -0
  15. package/dist/toText.js +2 -0
  16. package/dist/toText.js.LICENSE.txt +23 -0
  17. package/package.json +79 -0
  18. package/postcss.config.js +7 -0
  19. package/scss/demo.scss +142 -0
  20. package/scss/editor.scss +394 -0
  21. package/scss/storybook.scss +66 -0
  22. package/scss/toolbar.scss +160 -0
  23. package/src/BlockEditor.js +252 -0
  24. package/src/Blocks/EmptyBlock.js +12 -0
  25. package/src/Blocks/EmptyWrapper.js +5 -0
  26. package/src/Blocks/ErrorBoundary.js +41 -0
  27. package/src/Blocks/LayoutBlock.js +179 -0
  28. package/src/Blocks/LayoutSlot.js +61 -0
  29. package/src/Context/StorybookContext.js +7 -0
  30. package/src/Nodes/Default.js +151 -0
  31. package/src/Nodes/Element.js +72 -0
  32. package/src/Nodes/Leaf.js +40 -0
  33. package/src/Nodes/Storybook.js +170 -0
  34. package/src/Nodes/StorybookDisplay.js +118 -0
  35. package/src/Nodes/Text.js +67 -0
  36. package/src/Renderer.js +41 -0
  37. package/src/Serializer/Html.js +43 -0
  38. package/src/Serializer/Serializer.js +318 -0
  39. package/src/Serializer/Text.js +18 -0
  40. package/src/Serializer/ads.js +175 -0
  41. package/src/Serializer/index.js +4 -0
  42. package/src/SidebarEditor/SidebarEditorField.js +249 -0
  43. package/src/SidebarEditor.css +90 -0
  44. package/src/SidebarEditor.js +236 -0
  45. package/src/Storybook.js +152 -0
  46. package/src/Toolbar/Align.js +65 -0
  47. package/src/Toolbar/Block.js +121 -0
  48. package/src/Toolbar/Element.js +49 -0
  49. package/src/Toolbar/Formats.js +60 -0
  50. package/src/Toolbar/Insert.js +29 -0
  51. package/src/Toolbar/Layout.js +333 -0
  52. package/src/Toolbar/Link.js +165 -0
  53. package/src/Toolbar/Toolbar.js +164 -0
  54. package/src/Tools/Margin.js +52 -0
  55. package/src/dev/App.js +61 -0
  56. package/src/dev/draftToSlate.json +3148 -0
  57. package/src/dev/index.css +3 -0
  58. package/src/dev/index.html +11 -0
  59. package/src/dev/index.js +5 -0
  60. package/src/dev/sampleValue1.json +4295 -0
  61. package/src/dev/sampleValue2.json +0 -0
  62. package/src/dev/sampleValueValid.json +411 -0
  63. package/src/dev/testComponents/TestStory.js +9 -0
  64. package/src/dev/testComponents/TestStory.stories.js +172 -0
  65. package/src/dev/testSampleValue.json +747 -0
  66. package/src/fromHTML.js +5 -0
  67. package/src/index.js +9 -0
  68. package/src/plugins/ListItem.js +49 -0
  69. package/src/plugins/SoftBreak.js +24 -0
  70. package/src/toHTML.js +7 -0
  71. package/src/toText.js +7 -0
  72. package/src/util.js +20 -0
  73. package/storyLoader.js +46 -0
  74. package/tailwind.config.js +5 -0
  75. package/webpack.config.build.js +53 -0
  76. package/webpack.config.dev.js +61 -0
  77. 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;