@flozy/editor 1.0.0 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (105) hide show
  1. package/package.json +6 -2
  2. package/.eslintignore +0 -4
  3. package/.eslintrc.json +0 -6
  4. package/.github/workflows/npm-publish.yml +0 -33
  5. package/.husky/pre-commit +0 -1
  6. package/.storybook/main.js +0 -20
  7. package/.storybook/preview.js +0 -14
  8. package/.vscode/extensions.json +0 -7
  9. package/.vscode/launch.json +0 -15
  10. package/.vscode/settings.json +0 -22
  11. package/craco.config.js +0 -16
  12. package/public/favicon.ico +0 -0
  13. package/public/index.html +0 -43
  14. package/public/logo192.png +0 -0
  15. package/public/logo512.png +0 -0
  16. package/public/manifest.json +0 -25
  17. package/public/robots.txt +0 -3
  18. package/src/components/Editor/CollaborativeEditor.js +0 -119
  19. package/src/components/Editor/CommonEditor.js +0 -549
  20. package/src/components/Editor/Editor.css +0 -115
  21. package/src/components/Editor/Elements/CodeToText/CodeToText.css +0 -57
  22. package/src/components/Editor/Elements/CodeToText/CodeToText.jsx +0 -115
  23. package/src/components/Editor/Elements/CodeToText/CodeToTextButton.jsx +0 -16
  24. package/src/components/Editor/Elements/CodeToText/HtmlCode.jsx +0 -59
  25. package/src/components/Editor/Elements/CodeToText/HtmlContextMenu.jsx +0 -39
  26. package/src/components/Editor/Elements/Color Picker/ColorPicker.css +0 -38
  27. package/src/components/Editor/Elements/Color Picker/ColorPicker.jsx +0 -110
  28. package/src/components/Editor/Elements/Color Picker/defaultColors.js +0 -34
  29. package/src/components/Editor/Elements/Embed/Embed.css +0 -14
  30. package/src/components/Editor/Elements/Embed/Embed.jsx +0 -74
  31. package/src/components/Editor/Elements/Embed/Image.jsx +0 -82
  32. package/src/components/Editor/Elements/Embed/Video.jsx +0 -65
  33. package/src/components/Editor/Elements/Equation/Equation.jsx +0 -19
  34. package/src/components/Editor/Elements/Equation/EquationButton.jsx +0 -59
  35. package/src/components/Editor/Elements/Equation/styles.css +0 -4
  36. package/src/components/Editor/Elements/Grid/Grid.js +0 -48
  37. package/src/components/Editor/Elements/Grid/GridButton.js +0 -21
  38. package/src/components/Editor/Elements/Grid/GridItem.js +0 -57
  39. package/src/components/Editor/Elements/ID/Id.jsx +0 -56
  40. package/src/components/Editor/Elements/Link/Link.jsx +0 -24
  41. package/src/components/Editor/Elements/Link/LinkButton.jsx +0 -71
  42. package/src/components/Editor/Elements/Link/styles.css +0 -20
  43. package/src/components/Editor/Elements/Mentions/Mentions.jsx +0 -37
  44. package/src/components/Editor/Elements/NewLine/NewLineButton.js +0 -29
  45. package/src/components/Editor/Elements/Table/Table.jsx +0 -13
  46. package/src/components/Editor/Elements/Table/TableSelector.css +0 -18
  47. package/src/components/Editor/Elements/Table/TableSelector.jsx +0 -76
  48. package/src/components/Editor/Elements/TableContextMenu/TableContextMenu.jsx +0 -97
  49. package/src/components/Editor/Elements/TableContextMenu/styles.css +0 -18
  50. package/src/components/Editor/RemoteCursorOverlay/Overlay.js +0 -78
  51. package/src/components/Editor/Toolbar/Toolbar.jsx +0 -167
  52. package/src/components/Editor/Toolbar/styles.css +0 -28
  53. package/src/components/Editor/Toolbar/toolbarGroups.js +0 -167
  54. package/src/components/Editor/Toolbar/toolbarIcons/align-center.svg +0 -1
  55. package/src/components/Editor/Toolbar/toolbarIcons/align-left.svg +0 -1
  56. package/src/components/Editor/Toolbar/toolbarIcons/align-right.svg +0 -1
  57. package/src/components/Editor/Toolbar/toolbarIcons/blockquote.svg +0 -1
  58. package/src/components/Editor/Toolbar/toolbarIcons/bold.png +0 -0
  59. package/src/components/Editor/Toolbar/toolbarIcons/fontColor.svg +0 -4
  60. package/src/components/Editor/Toolbar/toolbarIcons/headingOne.svg +0 -3
  61. package/src/components/Editor/Toolbar/toolbarIcons/headingTwo.svg +0 -3
  62. package/src/components/Editor/Toolbar/toolbarIcons/italic.png +0 -0
  63. package/src/components/Editor/Toolbar/toolbarIcons/link.svg +0 -1
  64. package/src/components/Editor/Toolbar/toolbarIcons/orderedList.svg +0 -1
  65. package/src/components/Editor/Toolbar/toolbarIcons/strikethrough.png +0 -0
  66. package/src/components/Editor/Toolbar/toolbarIcons/subscript.svg +0 -1
  67. package/src/components/Editor/Toolbar/toolbarIcons/superscript.svg +0 -1
  68. package/src/components/Editor/Toolbar/toolbarIcons/textColor.png +0 -0
  69. package/src/components/Editor/Toolbar/toolbarIcons/underline.png +0 -0
  70. package/src/components/Editor/Toolbar/toolbarIcons/unlink.svg +0 -1
  71. package/src/components/Editor/Toolbar/toolbarIcons/unorderedList.svg +0 -1
  72. package/src/components/Editor/YjsProvider.js +0 -11
  73. package/src/components/Editor/common/Button.jsx +0 -12
  74. package/src/components/Editor/common/Icon.jsx +0 -82
  75. package/src/components/Editor/common/MentionsPopup.jsx +0 -56
  76. package/src/components/Editor/hooks/useMentions.js +0 -44
  77. package/src/components/Editor/hooks/withCollaborative.js +0 -15
  78. package/src/components/Editor/hooks/withCommon.js +0 -17
  79. package/src/components/Editor/plugins/withEmbeds.js +0 -36
  80. package/src/components/Editor/plugins/withEquation.js +0 -8
  81. package/src/components/Editor/plugins/withLinks.js +0 -9
  82. package/src/components/Editor/plugins/withMentions.js +0 -19
  83. package/src/components/Editor/plugins/withTable.js +0 -74
  84. package/src/components/Editor/utils/SlateUtilityFunctions.js +0 -273
  85. package/src/components/Editor/utils/customHooks/useContextMenu.js +0 -42
  86. package/src/components/Editor/utils/customHooks/useFormat.js +0 -26
  87. package/src/components/Editor/utils/customHooks/usePopup.jsx +0 -26
  88. package/src/components/Editor/utils/customHooks/useResize.js +0 -41
  89. package/src/components/Editor/utils/draftToSlate.js +0 -104
  90. package/src/components/Editor/utils/embed.js +0 -18
  91. package/src/components/Editor/utils/equation.js +0 -22
  92. package/src/components/Editor/utils/events.js +0 -56
  93. package/src/components/Editor/utils/grid.js +0 -12
  94. package/src/components/Editor/utils/gridItem.js +0 -19
  95. package/src/components/Editor/utils/link.js +0 -53
  96. package/src/components/Editor/utils/mentions.js +0 -11
  97. package/src/components/Editor/utils/paragraph.js +0 -4
  98. package/src/components/Editor/utils/serializer.js +0 -32
  99. package/src/components/Editor/utils/table.js +0 -151
  100. package/src/components/index.js +0 -5
  101. package/src/index.js +0 -1
  102. package/src/stories/CollaborativeEditor.stories.js +0 -30
  103. package/src/stories/Editor.stories.js +0 -24
  104. package/src/stories/EditorSampleProps/ChatSample.js +0 -43
  105. package/src/stories/EditorSampleProps/LayoutOne.js +0 -551
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flozy/editor",
3
- "version": "1.0.0",
3
+ "version": "1.0.5",
4
4
  "description": "An Editor for flozy app brain",
5
5
  "dependencies": {
6
6
  "@emotion/react": "^11.11.1",
@@ -103,5 +103,9 @@
103
103
  "license": "ISC",
104
104
  "bugs": {
105
105
  "url": "https://github.com/Flozy-App/editor/issues"
106
- }
106
+ },
107
+ "files": [
108
+ "dist"
109
+ ],
110
+ "main": "dist/index.js"
107
111
  }
package/.eslintignore DELETED
@@ -1,4 +0,0 @@
1
- .storybook/*.js
2
- .husky
3
- .vscode
4
- node_modules
package/.eslintrc.json DELETED
@@ -1,6 +0,0 @@
1
- {
2
- "extends": [ "react-app" ],
3
- "rules": {
4
- "react-hooks/exhaustive-deps": "off"
5
- }
6
- }
@@ -1,33 +0,0 @@
1
- # This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
2
- # For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages
3
-
4
- name: FLOZY APP - EDITOR - Semantic Release
5
-
6
- on:
7
- release:
8
- types: [created]
9
-
10
- jobs:
11
- build:
12
- runs-on: ubuntu-latest
13
- steps:
14
- - uses: actions/checkout@v3
15
- - uses: actions/setup-node@v3
16
- with:
17
- node-version: 16
18
- - run: npm ci
19
- - run: npm test
20
-
21
- publish-npm:
22
- needs: build
23
- runs-on: ubuntu-latest
24
- steps:
25
- - uses: actions/checkout@v3
26
- - uses: actions/setup-node@v3
27
- with:
28
- node-version: 16
29
- registry-url: https://registry.npmjs.org/
30
- - run: npm ci
31
- - run: npm publish --access public
32
- env:
33
- NODE_AUTH_TOKEN: ${{secrets.NPM_PUBLISH_TOKEN}}
package/.husky/pre-commit DELETED
@@ -1 +0,0 @@
1
- npx lint-staged
@@ -1,20 +0,0 @@
1
- /** @type { import('@storybook/react-webpack5').StorybookConfig } */
2
- const config = {
3
- stories: ["../src/**/*.mdx", "../src/**/*.stories.@(js|jsx|mjs|ts|tsx)"],
4
- addons: [
5
- "@storybook/addon-links",
6
- "@storybook/addon-essentials",
7
- "@storybook/preset-create-react-app",
8
- "@storybook/addon-onboarding",
9
- "@storybook/addon-interactions",
10
- ],
11
- framework: {
12
- name: "@storybook/react-webpack5",
13
- options: {},
14
- },
15
- docs: {
16
- autodocs: "tag",
17
- },
18
- staticDirs: ["../public"],
19
- };
20
- export default config;
@@ -1,14 +0,0 @@
1
- /** @type { import('@storybook/react').Preview } */
2
- const preview = {
3
- parameters: {
4
- actions: { argTypesRegex: "^on[A-Z].*" },
5
- controls: {
6
- matchers: {
7
- color: /(background|color)$/i,
8
- date: /Date$/,
9
- },
10
- },
11
- },
12
- };
13
-
14
- export default preview;
@@ -1,7 +0,0 @@
1
- {
2
- "recommendations": [
3
- "dbaeumer.vscode-eslint",
4
- "esbenp.prettier-vscode",
5
- "mikoz.black-py"
6
- ]
7
- }
@@ -1,15 +0,0 @@
1
- {
2
- "version": "0.2.0",
3
- "configurations": [
4
- {
5
- "name": "Chrome",
6
- "type": "chrome",
7
- "request": "launch",
8
- "url": "http://localhost:3000",
9
- "webRoot": "${workspaceFolder}/client/src",
10
- "sourceMapPathOverrides": {
11
- "webpack:///src/*": "${webRoot}/*"
12
- }
13
- }
14
- ]
15
- }
@@ -1,22 +0,0 @@
1
- {
2
- "[javascript]": {
3
- "editor.defaultFormatter": "esbenp.prettier-vscode",
4
- "editor.formatOnSave": true
5
- },
6
- "[javascriptreact]": {
7
- "editor.formatOnSave": true,
8
- "editor.defaultFormatter": "esbenp.prettier-vscode"
9
- },
10
- "[json]": {
11
- "editor.formatOnSave": true,
12
- "editor.defaultFormatter": "esbenp.prettier-vscode"
13
- },
14
- "[python]": {
15
- "editor.defaultFormatter": "ms-python.black-formatter",
16
- "editor.formatOnSave": true
17
- },
18
- "[markdown]": {
19
- "editor.formatOnSave": true,
20
- "editor.formatOnPaste": true
21
- }
22
- }
package/craco.config.js DELETED
@@ -1,16 +0,0 @@
1
- module.exports = {
2
- webpack: {
3
- configure: {
4
- module: {
5
- rules: [
6
- {
7
- test: /\.m?js$/,
8
- resolve: {
9
- fullySpecified: false,
10
- },
11
- },
12
- ],
13
- },
14
- },
15
- },
16
- };
Binary file
package/public/index.html DELETED
@@ -1,43 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="utf-8" />
5
- <link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
6
- <meta name="viewport" content="width=device-width, initial-scale=1" />
7
- <meta name="theme-color" content="#000000" />
8
- <meta
9
- name="description"
10
- content="Web site created using create-react-app"
11
- />
12
- <link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
13
- <!--
14
- manifest.json provides metadata used when your web app is installed on a
15
- user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
16
- -->
17
- <link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
18
- <!--
19
- Notice the use of %PUBLIC_URL% in the tags above.
20
- It will be replaced with the URL of the `public` folder during the build.
21
- Only files inside the `public` folder can be referenced from the HTML.
22
-
23
- Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
24
- work correctly both with client-side routing and a non-root public URL.
25
- Learn how to configure a non-root public URL by running `npm run build`.
26
- -->
27
- <title>FLOZY APP - Editor</title>
28
- </head>
29
- <body>
30
- <noscript>You need to enable JavaScript to run this app.</noscript>
31
- <div id="root"></div>
32
- <!--
33
- This HTML file is a template.
34
- If you open it directly in the browser, you will see an empty page.
35
-
36
- You can add webfonts, meta tags, or analytics to this file.
37
- The build step will place the bundled scripts into the <body> tag.
38
-
39
- To begin the development, run `npm start` or `yarn start`.
40
- To create a production bundle, use `npm run build` or `yarn build`.
41
- -->
42
- </body>
43
- </html>
Binary file
Binary file
@@ -1,25 +0,0 @@
1
- {
2
- "short_name": "React App",
3
- "name": "Create React App Sample",
4
- "icons": [
5
- {
6
- "src": "favicon.ico",
7
- "sizes": "64x64 32x32 24x24 16x16",
8
- "type": "image/x-icon"
9
- },
10
- {
11
- "src": "logo192.png",
12
- "type": "image/png",
13
- "sizes": "192x192"
14
- },
15
- {
16
- "src": "logo512.png",
17
- "type": "image/png",
18
- "sizes": "512x512"
19
- }
20
- ],
21
- "start_url": ".",
22
- "display": "standalone",
23
- "theme_color": "#000000",
24
- "background_color": "#ffffff"
25
- }
package/public/robots.txt DELETED
@@ -1,3 +0,0 @@
1
- # https://www.robotstxt.org/robotstxt.html
2
- User-agent: *
3
- Disallow:
@@ -1,119 +0,0 @@
1
- import React, { useEffect, useMemo, useState } from "react";
2
- import * as Y from "yjs";
3
- import { HocuspocusProvider } from "@hocuspocus/provider";
4
- import { Editor, Transforms } from "slate";
5
- import { YjsEditor } from "@slate-yjs/core";
6
- import "./Editor.css";
7
- import { draftToSlate } from "./utils/draftToSlate";
8
- import withCommon from "./hooks/withCommon";
9
- import withCollaborative from "./hooks/withCollaborative";
10
- import CommonEditor from "./CommonEditor";
11
-
12
- const CollaborativeEditor = (props) => {
13
- const { id, content, onSave, user, socketURL } = props;
14
- const convertedContent = draftToSlate({ data: content });
15
- const [value] = useState(convertedContent);
16
- const [connected, setConnected] = useState(null);
17
- const [authenticated, setAuthenticated] = useState({
18
- status: null,
19
- scope: null,
20
- });
21
-
22
- const provider = useMemo(() => {
23
- return new HocuspocusProvider({
24
- url: socketURL,
25
- name: `document-${id}`,
26
- connect: false,
27
- token: user?.token,
28
- });
29
- }, []);
30
-
31
- // setup changes for Yjs
32
- const editor = useMemo(() => {
33
- if (!connected) return null;
34
- const sharedType = provider.document.get("content", Y.XmlText);
35
- const e = withCommon(
36
- withCollaborative({
37
- provider,
38
- sharedType,
39
- data: user,
40
- })
41
- );
42
-
43
- // Ensure editor always has at least 1 valid child
44
- const { normalizeNode } = e;
45
- e.normalizeNode = (entry) => {
46
- const [node] = entry;
47
-
48
- if (!Editor.isEditor(node) || node.children.length > 0) {
49
- return normalizeNode(entry);
50
- }
51
-
52
- Transforms.insertNodes(editor, value, { at: [0] });
53
- };
54
-
55
- return e;
56
- }, [provider.document, provider.awareness, connected]);
57
-
58
- // connect Yjs
59
- useEffect(() => {
60
- provider.connect();
61
- return () => {
62
- provider.disconnect(editor);
63
- };
64
- }, [provider]);
65
-
66
- // connect to editor
67
- useEffect(() => {
68
- if (editor) {
69
- YjsEditor.connect(editor);
70
- }
71
- return () => {
72
- if (editor) {
73
- YjsEditor.disconnect(editor);
74
- }
75
- };
76
- }, [editor]);
77
-
78
- provider.on("authenticated", () => {
79
- setAuthenticated({
80
- status: true,
81
- scope: provider.authorizedScope,
82
- });
83
- });
84
-
85
- provider.on("authenticationFailed", () => {
86
- setAuthenticated({
87
- status: false,
88
- scope: null,
89
- });
90
- });
91
-
92
- provider.on("synced", () => {
93
- setConnected(true);
94
- });
95
-
96
- provider.on("disconnect", () => {
97
- setConnected(false);
98
- });
99
-
100
- provider.on("close", () => {
101
- setConnected(false);
102
- });
103
-
104
- if (authenticated.status === null || !connected === null || !editor) {
105
- return <h1 data-status={connected}>Loading...</h1>;
106
- }
107
-
108
- return (
109
- <CommonEditor
110
- editor={editor}
111
- id={id}
112
- content={[]}
113
- onSave={onSave}
114
- readOnly={authenticated.scope}
115
- />
116
- );
117
- };
118
-
119
- export default CollaborativeEditor;