@flozy/editor 5.7.8 → 5.7.9
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/dist/Editor/Editor.css
CHANGED
@@ -1329,3 +1329,12 @@ blockquote {
|
|
1329
1329
|
background: linear-gradient(112.61deg, #2C63ED 19.3%, #8360FD 88.14%) !important;
|
1330
1330
|
text-transform: math-auto !important;
|
1331
1331
|
}
|
1332
|
+
|
1333
|
+
code.markcode {
|
1334
|
+
border-radius: 4px;
|
1335
|
+
padding: 6px 8px;
|
1336
|
+
margin: 8px 0px;
|
1337
|
+
display: block;
|
1338
|
+
background-color: #f3f3f3;
|
1339
|
+
font-family: 'Source Code Pro' !important;
|
1340
|
+
}
|
@@ -90,9 +90,18 @@ const ELEMENT_TAGS = {
|
|
90
90
|
type: "image",
|
91
91
|
url: el.getAttribute("src")
|
92
92
|
}),
|
93
|
-
LI:
|
94
|
-
|
95
|
-
|
93
|
+
LI: el => {
|
94
|
+
const checkListItem = el.querySelector(".check-list-item");
|
95
|
+
if (checkListItem) {
|
96
|
+
return {
|
97
|
+
type: "check-list-item",
|
98
|
+
checked: checkListItem?.dataset?.checked === "true"
|
99
|
+
};
|
100
|
+
}
|
101
|
+
return {
|
102
|
+
type: "list-item"
|
103
|
+
};
|
104
|
+
},
|
96
105
|
UL: () => ({
|
97
106
|
type: "unorderedList"
|
98
107
|
}),
|
@@ -109,7 +118,7 @@ const ELEMENT_TAGS = {
|
|
109
118
|
"GOOGLE-SHEETS-HTML-ORIGIN": paragraphType,
|
110
119
|
TABLE: (el, children = []) => {
|
111
120
|
try {
|
112
|
-
const bodyChild = children || [];
|
121
|
+
const bodyChild = (children || [])?.filter(f => f !== null);
|
113
122
|
const firstRowChildren = bodyChild[0]?.children || [];
|
114
123
|
return {
|
115
124
|
type: "table",
|
@@ -129,7 +138,11 @@ const ELEMENT_TAGS = {
|
|
129
138
|
}),
|
130
139
|
TD: handleTableCell,
|
131
140
|
COLGROUP: paragraphType,
|
132
|
-
COL: paragraphType
|
141
|
+
COL: paragraphType,
|
142
|
+
HR: () => ({
|
143
|
+
type: "divider",
|
144
|
+
borderColor: "#CCC"
|
145
|
+
})
|
133
146
|
};
|
134
147
|
|
135
148
|
// COMPAT: `B` is omitted here because Google Docs uses `<b>` in weird ways.
|
@@ -0,0 +1,45 @@
|
|
1
|
+
import MarkdownIt from "markdown-it";
|
2
|
+
const md = new MarkdownIt();
|
3
|
+
function markdownItCheckbox(md) {
|
4
|
+
md.core.ruler.push("checkbox_lists", function (state) {
|
5
|
+
const tokens = state.tokens;
|
6
|
+
for (let i = 0; i < tokens.length; i++) {
|
7
|
+
const token = tokens[i];
|
8
|
+
if (token.type === "inline" && token.content) {
|
9
|
+
const taskListRegex = /^\s*(-\s*)?\[\s*([xX\s]?)\s*\]\s+(.*)/;
|
10
|
+
const match = taskListRegex.exec(token.content);
|
11
|
+
if (match) {
|
12
|
+
token.attrJoin("class", "check-list-item");
|
13
|
+
const isChecked = match[2].toLowerCase() === "x"; // Check if checked
|
14
|
+
const content = match[3].trim(); // Extract text after checkbox
|
15
|
+
|
16
|
+
// Create new tokens for the task list item
|
17
|
+
const listItemOpenToken = new state.Token("html_inline", "", 0);
|
18
|
+
listItemOpenToken.content = `<li class="check-list-item" data-checked="${isChecked}">`;
|
19
|
+
const checkboxToken = new state.Token("html_inline", "", 0);
|
20
|
+
checkboxToken.content = `<span class='check-list-item' data-checked="${isChecked}" />`;
|
21
|
+
const textToken = new state.Token("text", "", 0);
|
22
|
+
textToken.content = content;
|
23
|
+
const listItemCloseToken = new state.Token("html_inline", "", 0);
|
24
|
+
listItemCloseToken.content = `</li>`;
|
25
|
+
|
26
|
+
// Replace the original token with the new tokens
|
27
|
+
tokens.splice(i, 1, checkboxToken, textToken);
|
28
|
+
}
|
29
|
+
}
|
30
|
+
}
|
31
|
+
});
|
32
|
+
}
|
33
|
+
|
34
|
+
// init plugin
|
35
|
+
md.use(markdownItCheckbox);
|
36
|
+
function convertMDToHTML(data) {
|
37
|
+
try {
|
38
|
+
const html = md.render(data);
|
39
|
+
return html;
|
40
|
+
} catch (err) {
|
41
|
+
console.log(err);
|
42
|
+
return data;
|
43
|
+
}
|
44
|
+
}
|
45
|
+
export default convertMDToHTML;
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import { Transforms, Editor, Element, Node, Path } from "slate";
|
2
2
|
import deserialize from "../helper/deserialize";
|
3
3
|
import { decodeAndParseBase64 } from "../utils/helper";
|
4
|
+
import convertMDToHTML from "../helper/markdown";
|
4
5
|
const avoidDefaultInsert = ["table", "grid"];
|
5
6
|
const NON_TEXT_TAGS = ["ol", "ul", "img", "table", "video", "a", "button", "GOOGLE-SHEETS-HTML-ORIGIN"];
|
6
7
|
const ALLOWED_TEXT_NODES = ["paragraph", "title", "headingOne", "headingTwo", "headingThree"];
|
@@ -274,9 +275,15 @@ const withHtml = editor => {
|
|
274
275
|
Transforms.insertFragment(editor, formattedFragment);
|
275
276
|
return;
|
276
277
|
} else {
|
277
|
-
|
278
|
+
const html = convertMDToHTML(data.getData("text/plain"));
|
279
|
+
let parsed = new DOMParser().parseFromString(html, "text/html");
|
280
|
+
parsed = parseCopiedHTML(html);
|
281
|
+
const fragment = deserialize(parsed.body);
|
282
|
+
Transforms.insertFragment(editor, fragment);
|
283
|
+
// insertData(data);
|
278
284
|
}
|
279
285
|
};
|
286
|
+
|
280
287
|
return editor;
|
281
288
|
};
|
282
289
|
export default withHtml;
|
@@ -301,6 +301,30 @@ export const getBlock = props => {
|
|
301
301
|
placeholder: "Heading 3",
|
302
302
|
children: children
|
303
303
|
});
|
304
|
+
case "headingFour":
|
305
|
+
return /*#__PURE__*/_jsx("h4", {
|
306
|
+
...attributes,
|
307
|
+
...element.attr,
|
308
|
+
className: `edt-headings content-editable ${isEmpty ? "empty" : ""}`,
|
309
|
+
placeholder: "Heading 4",
|
310
|
+
children: children
|
311
|
+
});
|
312
|
+
case "headingFive":
|
313
|
+
return /*#__PURE__*/_jsx("h5", {
|
314
|
+
...attributes,
|
315
|
+
...element.attr,
|
316
|
+
className: `edt-headings content-editable ${isEmpty ? "empty" : ""}`,
|
317
|
+
placeholder: "Heading 5",
|
318
|
+
children: children
|
319
|
+
});
|
320
|
+
case "headingSix":
|
321
|
+
return /*#__PURE__*/_jsx("h6", {
|
322
|
+
...attributes,
|
323
|
+
...element.attr,
|
324
|
+
className: `edt-headings content-editable ${isEmpty ? "empty" : ""}`,
|
325
|
+
placeholder: "Heading 6",
|
326
|
+
children: children
|
327
|
+
});
|
304
328
|
case "blockquote":
|
305
329
|
return /*#__PURE__*/_jsx("blockquote", {
|
306
330
|
...attributes,
|
@@ -588,6 +612,13 @@ export const getBlock = props => {
|
|
588
612
|
return /*#__PURE__*/_jsx(ColumnView, {
|
589
613
|
...props
|
590
614
|
});
|
615
|
+
case "code":
|
616
|
+
return /*#__PURE__*/_jsx("code", {
|
617
|
+
...attributes,
|
618
|
+
...element.attr,
|
619
|
+
className: "markcode",
|
620
|
+
children: children
|
621
|
+
});
|
591
622
|
default:
|
592
623
|
return /*#__PURE__*/_jsx(SimpleText, {
|
593
624
|
...props,
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@flozy/editor",
|
3
|
-
"version": "5.7.
|
3
|
+
"version": "5.7.9",
|
4
4
|
"description": "An Editor for flozy app brain",
|
5
5
|
"files": [
|
6
6
|
"dist"
|
@@ -30,6 +30,7 @@
|
|
30
30
|
"husky": "^8.0.3",
|
31
31
|
"interweave": "^13.1.0",
|
32
32
|
"lint-staged": "^13.2.3",
|
33
|
+
"markdown-it": "^14.1.0",
|
33
34
|
"prettier": "^3.0.1",
|
34
35
|
"react-best-gradient-color-picker": "^2.2.23",
|
35
36
|
"react-datepicker": "^4.18.0",
|