@cyberyozh/text-editor 0.1.8 → 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/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
  },
@@ -2187,22 +2246,36 @@ var PromptContent = ({ children, isEmpty, placeholder }) => /* @__PURE__ */ jsx6
2187
2246
  ) });
2188
2247
 
2189
2248
  // src/extensions/views/components/table.tsx
2249
+ import { useEffect, useRef, useState } from "react";
2190
2250
  import { jsx as jsx67, jsxs as jsxs21 } from "react/jsx-runtime";
2191
2251
  function Table({ children }) {
2252
+ const wrapperRef = useRef(null);
2253
+ const [undefinedColWidth, setUndefinedColWidth] = useState(void 0);
2192
2254
  let colWidths = [];
2193
2255
  if (Array.isArray(children) && children.length > 0) {
2194
2256
  const firstRow = children[0];
2195
2257
  if (firstRow?.props?.children) {
2196
2258
  const cells = Array.isArray(firstRow.props.children) ? firstRow.props.children : [firstRow.props.children];
2197
- colWidths = cells.map((cell) => cell?.props?.node?.attrs?.colwidth?.[0]).filter((width) => width !== void 0);
2259
+ colWidths = cells.map((cell) => cell?.props?.node?.attrs?.colwidth?.[0]);
2198
2260
  }
2199
2261
  }
2200
- const tableWidth = colWidths.length > 0 ? colWidths.reduce((total, width) => total + width, 0) : null;
2201
- return /* @__PURE__ */ jsx67("div", { className: "tableWrapper", children: /* @__PURE__ */ jsxs21("table", { style: tableWidth ? { width: `${tableWidth}px` } : void 0, children: [
2262
+ const definedWidths = colWidths.filter((w) => w !== void 0);
2263
+ const totalDefinedWidth = definedWidths.reduce((total, width) => total + width, 0);
2264
+ const undefinedCount = colWidths.filter((w) => w === void 0).length;
2265
+ useEffect(() => {
2266
+ if (wrapperRef.current && undefinedCount > 0) {
2267
+ const containerWidth = wrapperRef.current.clientWidth;
2268
+ const remainingSpace = containerWidth - totalDefinedWidth;
2269
+ const calculatedWidth = Math.floor(remainingSpace / undefinedCount);
2270
+ setUndefinedColWidth(calculatedWidth > 0 ? calculatedWidth : void 0);
2271
+ }
2272
+ }, [totalDefinedWidth, undefinedCount]);
2273
+ const tableWidth = undefinedCount > 0 && undefinedColWidth ? totalDefinedWidth + undefinedColWidth * undefinedCount : totalDefinedWidth > 0 ? totalDefinedWidth : void 0;
2274
+ return /* @__PURE__ */ jsx67("div", { ref: wrapperRef, className: "tableWrapper", children: /* @__PURE__ */ jsxs21("table", { style: tableWidth ? { width: `${tableWidth}px` } : void 0, children: [
2202
2275
  colWidths.length > 0 && /* @__PURE__ */ jsx67("colgroup", { children: colWidths.map((width, index) => /* @__PURE__ */ jsx67(
2203
2276
  "col",
2204
2277
  {
2205
- style: { width: `${width}px` }
2278
+ style: width ? { width: `${width}px` } : undefinedColWidth ? { width: `${undefinedColWidth}px` } : void 0
2206
2279
  },
2207
2280
  index
2208
2281
  )) }),