@cyberyozh/text-editor 0.1.7 → 0.1.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.css +12 -2
- package/dist/editor.css.map +1 -1
- package/dist/editor.d.mts +1 -0
- package/dist/editor.d.ts +1 -0
- package/dist/editor.js +202 -139
- package/dist/editor.js.map +1 -1
- package/dist/editor.mjs +200 -137
- package/dist/editor.mjs.map +1 -1
- package/dist/render.js +76 -11
- package/dist/render.js.map +1 -1
- package/dist/render.mjs +76 -11
- package/dist/render.mjs.map +1 -1
- package/dist/styles/index.css +12 -2
- package/package.json +2 -4
- package/src/editor/controls/bubble-menu-content.tsx +4 -8
- package/src/editor/controls/callout-menu.tsx +2 -0
- package/src/editor/controls/drag-handle.tsx +6 -1
- package/src/editor/dialogs/add-link-dialog/add-link-dialog.css +12 -4
- package/src/editor/dialogs/add-link-dialog/add-link-dialog.tsx +65 -28
- package/src/editor/dialogs/image-dialog/image-dialog.tsx +1 -1
- package/src/editor/editor.tsx +19 -12
- package/src/editor/handlers/dialog-handlers.ts +87 -156
- package/src/editor/handlers/index.ts +1 -2
- package/src/extensions/base/compatibility.ts +52 -0
- package/src/extensions/base/figure.ts +7 -0
- package/src/extensions/base/link.ts +3 -3
- package/src/extensions/views/components/table.tsx +23 -4
- package/src/extensions/views/node-views/figure.tsx +1 -1
- package/src/render/static-renderer-config.tsx +1 -17
- package/src/styles/editor/base.css +1 -1
- package/src/styles/extensions/callout.css +1 -1
- package/src/translations/en.json +5 -1
- package/src/translations/ru.json +5 -1
- package/src/types/image-handler.ts +2 -0
- package/src/types/link.ts +9 -0
- package/src/editor/handlers/create-image-upload-handler.ts +0 -24
package/dist/render.mjs
CHANGED
|
@@ -651,6 +651,13 @@ var BaseFigure = Image.extend({
|
|
|
651
651
|
caption: {
|
|
652
652
|
default: null,
|
|
653
653
|
parseHTML: (element) => element.querySelector("figcaption")?.textContent || null
|
|
654
|
+
},
|
|
655
|
+
storageKey: {
|
|
656
|
+
default: null,
|
|
657
|
+
parseHTML: (element) => element.getAttribute("data-storage-key"),
|
|
658
|
+
renderHTML: (attributes) => ({
|
|
659
|
+
"data-storage-key": attributes.storageKey
|
|
660
|
+
})
|
|
654
661
|
}
|
|
655
662
|
};
|
|
656
663
|
},
|
|
@@ -1092,6 +1099,32 @@ var BaseLegacyBookAlert = Node6.create({
|
|
|
1092
1099
|
return {
|
|
1093
1100
|
type: {
|
|
1094
1101
|
default: "error"
|
|
1102
|
+
},
|
|
1103
|
+
bgColor: {
|
|
1104
|
+
default: null,
|
|
1105
|
+
parseHTML: (element) => {
|
|
1106
|
+
if (typeof element === "string") return null;
|
|
1107
|
+
return element.getAttribute("data-bg-color");
|
|
1108
|
+
},
|
|
1109
|
+
renderHTML: (attributes) => {
|
|
1110
|
+
if (!attributes.bgColor) return {};
|
|
1111
|
+
return {
|
|
1112
|
+
"data-bg-color": attributes.bgColor
|
|
1113
|
+
};
|
|
1114
|
+
}
|
|
1115
|
+
},
|
|
1116
|
+
emoji: {
|
|
1117
|
+
default: null,
|
|
1118
|
+
parseHTML: (element) => {
|
|
1119
|
+
if (typeof element === "string") return null;
|
|
1120
|
+
return element.getAttribute("data-emoji");
|
|
1121
|
+
},
|
|
1122
|
+
renderHTML: (attributes) => {
|
|
1123
|
+
if (!attributes.emoji) return {};
|
|
1124
|
+
return {
|
|
1125
|
+
"data-emoji": attributes.emoji
|
|
1126
|
+
};
|
|
1127
|
+
}
|
|
1095
1128
|
}
|
|
1096
1129
|
};
|
|
1097
1130
|
},
|
|
@@ -1121,6 +1154,32 @@ var BaseLegacyBookTip = Node6.create({
|
|
|
1121
1154
|
return {
|
|
1122
1155
|
type: {
|
|
1123
1156
|
default: "info"
|
|
1157
|
+
},
|
|
1158
|
+
bgColor: {
|
|
1159
|
+
default: null,
|
|
1160
|
+
parseHTML: (element) => {
|
|
1161
|
+
if (typeof element === "string") return null;
|
|
1162
|
+
return element.getAttribute("data-bg-color");
|
|
1163
|
+
},
|
|
1164
|
+
renderHTML: (attributes) => {
|
|
1165
|
+
if (!attributes.bgColor) return {};
|
|
1166
|
+
return {
|
|
1167
|
+
"data-bg-color": attributes.bgColor
|
|
1168
|
+
};
|
|
1169
|
+
}
|
|
1170
|
+
},
|
|
1171
|
+
emoji: {
|
|
1172
|
+
default: null,
|
|
1173
|
+
parseHTML: (element) => {
|
|
1174
|
+
if (typeof element === "string") return null;
|
|
1175
|
+
return element.getAttribute("data-emoji");
|
|
1176
|
+
},
|
|
1177
|
+
renderHTML: (attributes) => {
|
|
1178
|
+
if (!attributes.emoji) return {};
|
|
1179
|
+
return {
|
|
1180
|
+
"data-emoji": attributes.emoji
|
|
1181
|
+
};
|
|
1182
|
+
}
|
|
1124
1183
|
}
|
|
1125
1184
|
};
|
|
1126
1185
|
},
|
|
@@ -2188,10 +2247,24 @@ var PromptContent = ({ children, isEmpty, placeholder }) => /* @__PURE__ */ jsx6
|
|
|
2188
2247
|
|
|
2189
2248
|
// src/extensions/views/components/table.tsx
|
|
2190
2249
|
import { jsx as jsx67, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
2191
|
-
function Table({ children
|
|
2250
|
+
function Table({ children }) {
|
|
2251
|
+
let colWidths = [];
|
|
2252
|
+
if (Array.isArray(children) && children.length > 0) {
|
|
2253
|
+
const firstRow = children[0];
|
|
2254
|
+
if (firstRow?.props?.children) {
|
|
2255
|
+
const cells = Array.isArray(firstRow.props.children) ? firstRow.props.children : [firstRow.props.children];
|
|
2256
|
+
colWidths = cells.map((cell) => cell?.props?.node?.attrs?.colwidth?.[0]).filter((width) => width !== void 0);
|
|
2257
|
+
}
|
|
2258
|
+
}
|
|
2192
2259
|
const tableWidth = colWidths.length > 0 ? colWidths.reduce((total, width) => total + width, 0) : null;
|
|
2193
2260
|
return /* @__PURE__ */ jsx67("div", { className: "tableWrapper", children: /* @__PURE__ */ jsxs21("table", { style: tableWidth ? { width: `${tableWidth}px` } : void 0, children: [
|
|
2194
|
-
colWidths.length > 0 && /* @__PURE__ */ jsx67("colgroup", { children: colWidths.map((width, index) => /* @__PURE__ */ jsx67(
|
|
2261
|
+
colWidths.length > 0 && /* @__PURE__ */ jsx67("colgroup", { children: colWidths.map((width, index) => /* @__PURE__ */ jsx67(
|
|
2262
|
+
"col",
|
|
2263
|
+
{
|
|
2264
|
+
style: { width: `${width}px` }
|
|
2265
|
+
},
|
|
2266
|
+
index
|
|
2267
|
+
)) }),
|
|
2195
2268
|
/* @__PURE__ */ jsx67("tbody", { children })
|
|
2196
2269
|
] }) });
|
|
2197
2270
|
}
|
|
@@ -2358,15 +2431,7 @@ var getNodeMapping = (getImageById) => ({
|
|
|
2358
2431
|
return /* @__PURE__ */ jsx69(Video, { src: node.attrs.src });
|
|
2359
2432
|
},
|
|
2360
2433
|
table({ children }) {
|
|
2361
|
-
|
|
2362
|
-
if (Array.isArray(children) && children.length > 0) {
|
|
2363
|
-
const firstRow = children[0];
|
|
2364
|
-
if (firstRow?.props?.children) {
|
|
2365
|
-
const cells = Array.isArray(firstRow.props.children) ? firstRow.props.children : [firstRow.props.children];
|
|
2366
|
-
colWidths = cells.map((cell) => cell?.props?.node?.attrs?.colwidth?.[0]).filter((width) => width !== void 0);
|
|
2367
|
-
}
|
|
2368
|
-
}
|
|
2369
|
-
return /* @__PURE__ */ jsx69(Table, { colWidths, children });
|
|
2434
|
+
return /* @__PURE__ */ jsx69(Table, { children });
|
|
2370
2435
|
},
|
|
2371
2436
|
figure({ node }) {
|
|
2372
2437
|
return /* @__PURE__ */ jsx69(
|