@springmicro/rte 0.1.3 → 0.1.10
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/README.md +50 -5
- package/dist/index.js +7361 -7279
- package/package.json +7 -3
- package/.eslintrc.cjs +0 -18
- package/dist/index.d.ts +0 -10
- package/dist/index.umd.cjs +0 -469
- package/index.html +0 -13
- package/src/App.css +0 -42
- package/src/App.tsx +0 -10
- package/src/contexts/color-context.tsx +0 -53
- package/src/hooks/useSimpleFormik.tsx +0 -74
- package/src/index.css +0 -68
- package/src/index.tsx +0 -3
- package/src/main.tsx +0 -10
- package/src/slate/base-editor.stories.tsx +0 -16
- package/src/slate/base-editor.tsx +0 -116
- package/src/slate/blog-rte.stories.tsx +0 -16
- package/src/slate/blog-rte.tsx +0 -126
- package/src/slate/common/button.tsx +0 -35
- package/src/slate/common/element.tsx +0 -13
- package/src/slate/common/icon.jsx +0 -97
- package/src/slate/components/code-to-text/CodeToTextButton.jsx +0 -19
- package/src/slate/components/code-to-text/HtmlCode.jsx +0 -64
- package/src/slate/components/code-to-text/HtmlContextMenu.jsx +0 -39
- package/src/slate/components/code-to-text/index.jsx +0 -111
- package/src/slate/components/color-picker/color-cursor.stories.tsx +0 -16
- package/src/slate/components/color-picker/color-cursor.tsx +0 -34
- package/src/slate/components/color-picker/color-formats-view.stories.tsx +0 -25
- package/src/slate/components/color-picker/color-formats-view.tsx +0 -115
- package/src/slate/components/color-picker/color-gradient.stories.tsx +0 -48
- package/src/slate/components/color-picker/color-gradient.tsx +0 -128
- package/src/slate/components/color-picker/color-hue.stories.tsx +0 -41
- package/src/slate/components/color-picker/color-hue.tsx +0 -110
- package/src/slate/components/color-picker/color-picker.stories.tsx +0 -25
- package/src/slate/components/color-picker/color-picker.tsx +0 -41
- package/src/slate/components/color-picker/color-popover.stories.tsx +0 -26
- package/src/slate/components/color-picker/color-popover.tsx +0 -58
- package/src/slate/components/color-picker/color-swatch.stories.tsx +0 -16
- package/src/slate/components/color-picker/color-swatch.tsx +0 -76
- package/src/slate/components/color-picker/default-colors.ts +0 -38
- package/src/slate/components/color-picker/slate-color-button.tsx +0 -128
- package/src/slate/components/embed/Embed.jsx +0 -96
- package/src/slate/components/embed/Image.jsx +0 -45
- package/src/slate/components/embed/Video.jsx +0 -65
- package/src/slate/components/equation/Equation.jsx +0 -19
- package/src/slate/components/equation/EquationButton.jsx +0 -68
- package/src/slate/components/id/Id.jsx +0 -57
- package/src/slate/components/image/image.stories.tsx +0 -17
- package/src/slate/components/image/image.tsx +0 -62
- package/src/slate/components/image/insert-image-button.stories.tsx +0 -83
- package/src/slate/components/image/insert-image-button.tsx +0 -132
- package/src/slate/components/image/types.ts +0 -9
- package/src/slate/components/link/Link.jsx +0 -56
- package/src/slate/components/link/LinkButton.tsx +0 -106
- package/src/slate/components/table/Table.jsx +0 -11
- package/src/slate/components/table/TableSelector.jsx +0 -97
- package/src/slate/components/table-context-menu/TableContextMenu.tsx +0 -106
- package/src/slate/custom-types.d.ts +0 -152
- package/src/slate/editor.module.css +0 -226
- package/src/slate/paper-rte.stories.tsx +0 -16
- package/src/slate/paper-rte.tsx +0 -47
- package/src/slate/plugins/withEmbeds.js +0 -33
- package/src/slate/plugins/withEquation.js +0 -8
- package/src/slate/plugins/withImages.ts +0 -69
- package/src/slate/plugins/withLinks.js +0 -9
- package/src/slate/plugins/withTable.js +0 -74
- package/src/slate/serializers/generic.ts +0 -44
- package/src/slate/serializers/types.ts +0 -20
- package/src/slate/toolbar/index.tsx +0 -186
- package/src/slate/toolbar/paper-toolbar.tsx +0 -494
- package/src/slate/toolbar/shortcuts.tsx +0 -77
- package/src/slate/toolbar/toolbar-groups.ts +0 -213
- package/src/slate/types/index.ts +0 -0
- package/src/slate/utils/customHooks/useContextMenu.js +0 -42
- package/src/slate/utils/customHooks/useFormat.js +0 -26
- package/src/slate/utils/customHooks/usePopup.jsx +0 -26
- package/src/slate/utils/customHooks/useResize.js +0 -27
- package/src/slate/utils/embed.js +0 -18
- package/src/slate/utils/equation.js +0 -22
- package/src/slate/utils/index.jsx +0 -267
- package/src/slate/utils/link.js +0 -44
- package/src/slate/utils/p.js +0 -4
- package/src/slate/utils/table.js +0 -131
- package/src/vite-env.d.ts +0 -1
- package/tsconfig.json +0 -32
- package/tsconfig.node.json +0 -10
- package/vite.config.ts +0 -41
package/src/slate/utils/table.js
DELETED
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
import { Transforms, Editor, Range, Element, Path } from "slate"
|
|
2
|
-
|
|
3
|
-
export class TableUtil {
|
|
4
|
-
constructor(editor) {
|
|
5
|
-
this.editor = editor
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
insertTable = (rows, columns) => {
|
|
9
|
-
const [tableNode] = Editor.nodes(this.editor, {
|
|
10
|
-
match: (n) => !Editor.isEditor(n) && Element.isElement(n) && n.type === "table",
|
|
11
|
-
mode: "highest",
|
|
12
|
-
})
|
|
13
|
-
|
|
14
|
-
if (tableNode) return
|
|
15
|
-
if (!rows || !columns) {
|
|
16
|
-
return
|
|
17
|
-
}
|
|
18
|
-
//Creating a 2-d array of blank string as default text for the table
|
|
19
|
-
const cellText = Array.from({ length: rows }, () => Array.from({ length: columns }, () => ""))
|
|
20
|
-
const newTable = createTableNode(cellText, rows, columns)
|
|
21
|
-
|
|
22
|
-
Transforms.insertNodes(this.editor, newTable, {
|
|
23
|
-
mode: "highest",
|
|
24
|
-
})
|
|
25
|
-
Transforms.insertNodes(
|
|
26
|
-
this.editor,
|
|
27
|
-
{ type: "p", children: [{ text: "" }] },
|
|
28
|
-
{ mode: "highest" }
|
|
29
|
-
)
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
removeTable = () => {
|
|
33
|
-
Transforms.removeNodes(this.editor, {
|
|
34
|
-
match: (n) => !Editor.isEditor(n) && Element.isElement(n) && n.type === "table",
|
|
35
|
-
// mode:'highest'
|
|
36
|
-
})
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
insertRow = (action) => {
|
|
40
|
-
const { selection } = this.editor
|
|
41
|
-
|
|
42
|
-
if (!!selection && Range.isCollapsed(selection)) {
|
|
43
|
-
const [tableNode] = Editor.nodes(this.editor, {
|
|
44
|
-
match: (n) => !Editor.isEditor(n) && Element.isElement(n) && n.type === "table-row",
|
|
45
|
-
})
|
|
46
|
-
if (tableNode) {
|
|
47
|
-
const [[table, tablePath]] = Editor.nodes(this.editor, {
|
|
48
|
-
match: (n) => !Editor.isEditor(n) && Element.isElement(n) && n.type === "table",
|
|
49
|
-
})
|
|
50
|
-
const [, currentRow] = tableNode
|
|
51
|
-
|
|
52
|
-
const path = action === "after" ? Path.next(currentRow) : currentRow
|
|
53
|
-
|
|
54
|
-
Transforms.insertNodes(this.editor, createRow(Array(table.columns).fill("")), {
|
|
55
|
-
at: path,
|
|
56
|
-
})
|
|
57
|
-
Transforms.setNodes(
|
|
58
|
-
this.editor,
|
|
59
|
-
{ rows: table.rows + 1 },
|
|
60
|
-
{
|
|
61
|
-
at: tablePath,
|
|
62
|
-
}
|
|
63
|
-
)
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
insertColumn = (action) => {
|
|
69
|
-
const { selection } = this.editor
|
|
70
|
-
if (!!selection && Range.isCollapsed(selection)) {
|
|
71
|
-
const [tableNode] = Editor.nodes(this.editor, {
|
|
72
|
-
match: (n) => !Editor.isEditor(n) && Element.isElement(n) && n.type === "table-cell",
|
|
73
|
-
})
|
|
74
|
-
if (tableNode) {
|
|
75
|
-
const [[table, tablePath]] = Editor.nodes(this.editor, {
|
|
76
|
-
match: (n) => !Editor.isEditor(n) && Element.isElement(n) && n.type === "table",
|
|
77
|
-
})
|
|
78
|
-
const [, currentCell] = tableNode
|
|
79
|
-
const startPath = action === "after" ? Path.next(currentCell) : currentCell
|
|
80
|
-
|
|
81
|
-
// The last two indices of the path represents the row and column. We need to add one cell to each row starting from the first row
|
|
82
|
-
startPath[startPath.length - 2] = 0
|
|
83
|
-
for (let row = 0; row < table.rows; row++) {
|
|
84
|
-
Transforms.insertNodes(this.editor, createTableCell(""), {
|
|
85
|
-
at: startPath,
|
|
86
|
-
})
|
|
87
|
-
startPath[startPath.length - 2]++
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
Transforms.setNodes(
|
|
91
|
-
this.editor,
|
|
92
|
-
{ columns: table.columns + 1 },
|
|
93
|
-
{
|
|
94
|
-
at: tablePath,
|
|
95
|
-
}
|
|
96
|
-
)
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
const createRow = (cellText) => {
|
|
103
|
-
const newRow = Array.from(cellText, (value) => createTableCell(value))
|
|
104
|
-
return {
|
|
105
|
-
type: "table-row",
|
|
106
|
-
children: newRow,
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
export const createTableCell = (text) => {
|
|
111
|
-
return {
|
|
112
|
-
type: "table-cell",
|
|
113
|
-
children: [
|
|
114
|
-
{
|
|
115
|
-
type: "p",
|
|
116
|
-
children: [{ text }],
|
|
117
|
-
},
|
|
118
|
-
],
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
const createTableNode = (cellText, rows, columns) => {
|
|
123
|
-
const tableChildren = Array.from(cellText, (value) => createRow(value))
|
|
124
|
-
let tableNode = {
|
|
125
|
-
type: "table",
|
|
126
|
-
children: tableChildren,
|
|
127
|
-
rows,
|
|
128
|
-
columns,
|
|
129
|
-
}
|
|
130
|
-
return tableNode
|
|
131
|
-
}
|
package/src/vite-env.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
/// <reference types="vite/client" />
|
package/tsconfig.json
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES2020",
|
|
4
|
-
"useDefineForClassFields": true,
|
|
5
|
-
"lib": ["ES2020", "DOM", "DOM.Iterable"],
|
|
6
|
-
"module": "ESNext",
|
|
7
|
-
"skipLibCheck": true,
|
|
8
|
-
|
|
9
|
-
/* Bundler mode */
|
|
10
|
-
"moduleResolution": "bundler",
|
|
11
|
-
"allowImportingTsExtensions": true,
|
|
12
|
-
"resolveJsonModule": true,
|
|
13
|
-
"isolatedModules": true,
|
|
14
|
-
"noEmit": true,
|
|
15
|
-
"jsx": "react-jsx",
|
|
16
|
-
|
|
17
|
-
/* Linting */
|
|
18
|
-
"strict": false,
|
|
19
|
-
"noFallthroughCasesInSwitch": true,
|
|
20
|
-
|
|
21
|
-
"paths": {
|
|
22
|
-
"@mui/material": ["../../node_modules/@mui/material"],
|
|
23
|
-
"@springmicro/utils": ["../../node_modules/@springmicro/utils"],
|
|
24
|
-
"react": ["../../node_modules/react"],
|
|
25
|
-
"react-dom": ["../../node_modules/react-dom"],
|
|
26
|
-
"react-icons": ["../../node_modules/react-icons"]
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
|
-
"include": ["src"],
|
|
30
|
-
"exclude": ["src/main.tsx", "**/*.stories.tsx"],
|
|
31
|
-
"references": [{ "path": "./tsconfig.node.json" }]
|
|
32
|
-
}
|
package/tsconfig.node.json
DELETED
package/vite.config.ts
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import react from "@vitejs/plugin-react";
|
|
2
|
-
import { resolve } from "path";
|
|
3
|
-
import { defineConfig } from "vite";
|
|
4
|
-
import dts from "vite-plugin-dts";
|
|
5
|
-
|
|
6
|
-
export default defineConfig({
|
|
7
|
-
plugins: [react(), dts({ rollupTypes: true })],
|
|
8
|
-
build: {
|
|
9
|
-
lib: {
|
|
10
|
-
entry: resolve(__dirname, "src/index.tsx"),
|
|
11
|
-
name: "@springmicro/rte",
|
|
12
|
-
fileName: "index",
|
|
13
|
-
},
|
|
14
|
-
rollupOptions: {
|
|
15
|
-
external: [
|
|
16
|
-
"react",
|
|
17
|
-
"react-dom",
|
|
18
|
-
"react-icons",
|
|
19
|
-
"@mui/material",
|
|
20
|
-
"@springmicro/utils",
|
|
21
|
-
],
|
|
22
|
-
output: {
|
|
23
|
-
globals: {
|
|
24
|
-
react: "React",
|
|
25
|
-
"react-dom": "React-dom",
|
|
26
|
-
"react-icons": "React-icons",
|
|
27
|
-
"@mui/material": "MuiMaterial",
|
|
28
|
-
"@springmicro/utils": "SpringMicroUtils",
|
|
29
|
-
},
|
|
30
|
-
// manualChunks(id: string) {
|
|
31
|
-
// if (id.includes("domhandler")) {
|
|
32
|
-
// return "domhandler";
|
|
33
|
-
// }
|
|
34
|
-
// if (id.includes("escape-html")) {
|
|
35
|
-
// return "escape-html";
|
|
36
|
-
// }
|
|
37
|
-
// },
|
|
38
|
-
},
|
|
39
|
-
},
|
|
40
|
-
},
|
|
41
|
-
});
|