@lobehub/editor 4.24.0 → 4.24.1

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.
@@ -1,7 +1,7 @@
1
1
  import { getListClassName, getTableWrapperClassName } from "../style.js";
2
2
  import { parseCSSText } from "./utils.js";
3
3
  import { createElement } from "react";
4
- import { jsx } from "react/jsx-runtime";
4
+ import { jsx, jsxs } from "react/jsx-runtime";
5
5
  //#region src/renderer/engine/render-builtin-node.tsx
6
6
  const SAFE_URL_PROTOCOLS = /* @__PURE__ */ new Set([
7
7
  "http:",
@@ -31,6 +31,11 @@ function formatLinkHighlightUrl(url) {
31
31
  function textToSlug(text) {
32
32
  return text.toLowerCase().trim().replaceAll(/[^\s\w\u3000-\u9FFF\uAC00-\uD7AF\uFF00-\uFFEF-]/g, "").replaceAll(/[\s_]+/g, "-").replaceAll(/^-+|-+$/g, "");
33
33
  }
34
+ const FLUID_TABLE_STYLE = { width: "100%" };
35
+ function toTableColWidths(value) {
36
+ if (!Array.isArray(value) || value.length === 0) return null;
37
+ return value.every((width) => Number.isFinite(width) && width > 0) ? value : null;
38
+ }
34
39
  const DIFF_ROOT_STYLE = { position: "relative" };
35
40
  const DIFF_LIST_ITEM_ROOT_STYLE = {
36
41
  display: "inline-block",
@@ -157,13 +162,17 @@ function renderBuiltinNode(node, key, children, headingSlugs, textContent) {
157
162
  children
158
163
  }, key);
159
164
  }
160
- case "table": return /* @__PURE__ */ jsx("div", {
161
- className: getTableWrapperClassName(),
162
- children: /* @__PURE__ */ jsx("table", {
163
- className: "editor_table",
164
- children: /* @__PURE__ */ jsx("tbody", { children })
165
- })
166
- }, key);
165
+ case "table": {
166
+ const colWidths = toTableColWidths(node.colWidths);
167
+ return /* @__PURE__ */ jsx("div", {
168
+ className: getTableWrapperClassName(),
169
+ children: /* @__PURE__ */ jsxs("table", {
170
+ className: "editor_table",
171
+ style: colWidths ? void 0 : FLUID_TABLE_STYLE,
172
+ children: [colWidths && /* @__PURE__ */ jsx("colgroup", { children: colWidths.map((width, index) => /* @__PURE__ */ jsx("col", { style: { width } }, index)) }), /* @__PURE__ */ jsx("tbody", { children })]
173
+ })
174
+ }, key);
175
+ }
167
176
  case "tablerow": return /* @__PURE__ */ jsx("tr", { children }, key);
168
177
  case "tablecell": {
169
178
  const isHeader = !!node.headerState;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/editor",
3
- "version": "4.24.0",
3
+ "version": "4.24.1",
4
4
  "description": "A powerful and extensible rich text editor built on Meta's Lexical framework, providing a modern editing experience with React integration.",
5
5
  "keywords": [
6
6
  "lobehub",