wendang-react 0.5.5 → 0.5.6

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 CHANGED
@@ -15,6 +15,15 @@ npm install wendang wendang-react yjs y-protocols
15
15
  项目需已有 `react` 和 `react-dom`。使用 TypeScript 时安装对应的 `@types/react` 和 `@types/react-dom`。
16
16
  构建环境使用 Node.js **20.19+**,页面在现代浏览器中运行。应用入口引入一次 `wendang-react/styles.css`。
17
17
 
18
+ ### 版本兼容
19
+
20
+ 版本号采用 `主版本.次版本.修订版本`。`wendang-react` 与 `wendang` 的主版本号、
21
+ 次版本号应保持一致;升级这两位版本时,请同步升级应用中使用的相关包。
22
+ 修订版本用于兼容性修复,修订号可以不同,可按需单独升级。
23
+
24
+ 例如,`wendang-react@0.5.6` 可搭配 `wendang@0.5.5`。
25
+ 核心包的具体版本要求以 `wendang-react` 声明的依赖为准。
26
+
18
27
  ## 先运行:编辑、预览和本地保存
19
28
 
20
29
  把下面内容放入 `App.tsx`。不需要后端或额外 UI 组件库:可以输入文字、切换预览、保存到本机,刷新后恢复。
@@ -1241,7 +1241,7 @@ ${JSON.stringify(copied.current)}`).catch(() => {
1241
1241
  setDragPreview(null);
1242
1242
  }
1243
1243
  function pointerDown(event, id) {
1244
- var _a2, _b2, _c2;
1244
+ var _a2, _b2;
1245
1245
  if (!((_a2 = stage.current) == null ? void 0 : _a2.contains(event.target))) return;
1246
1246
  if (event.target.closest("button,input,textarea,a")) return;
1247
1247
  setFollowing(null);
@@ -1258,8 +1258,8 @@ ${JSON.stringify(copied.current)}`).catch(() => {
1258
1258
  gesture.current = { ...base, kind: "box", additive: event.shiftKey || event.metaKey || event.ctrlKey };
1259
1259
  if (!gesture.current.additive) setSelected(/* @__PURE__ */ new Set());
1260
1260
  } else return;
1261
- (_b2 = stage.current) == null ? void 0 : _b2.setPointerCapture(event.pointerId);
1262
- (_c2 = stage.current) == null ? void 0 : _c2.focus();
1261
+ event.currentTarget.setPointerCapture(event.pointerId);
1262
+ (_b2 = stage.current) == null ? void 0 : _b2.focus();
1263
1263
  event.preventDefault();
1264
1264
  }
1265
1265
  function pointerMove(event) {
@@ -1269,8 +1269,10 @@ ${JSON.stringify(copied.current)}`).catch(() => {
1269
1269
  cancelGesture();
1270
1270
  return;
1271
1271
  }
1272
- if (g.kind === "pan") setPan((previous) => ({ x: previous.x + event.clientX - g.lastX, y: previous.y + event.clientY - g.lastY }));
1273
- else if (g.kind === "box") {
1272
+ if (g.kind === "pan") {
1273
+ const dx = event.clientX - g.lastX, dy = event.clientY - g.lastY;
1274
+ setPan((previous) => ({ x: previous.x + dx, y: previous.y + dy }));
1275
+ } else if (g.kind === "box") {
1274
1276
  const from = point(g.x, g.y), to = point(event.clientX, event.clientY);
1275
1277
  g.box = { x: Math.min(from.x, to.x), y: Math.min(from.y, to.y), w: Math.abs(to.x - from.x), h: Math.abs(to.y - from.y) };
1276
1278
  setBox(g.box);
@@ -6,7 +6,7 @@ import { MIND_TOPIC_FONT, mindTopicLineHeight, readableTextColor } from "wendang
6
6
  import { b as useContentHost } from "./host-C-V688Rq.js";
7
7
  import { W as WButton } from "./index-Ii536CFG.js";
8
8
  import { T as TopicLabel, A as AttachmentImage } from "./mind-topic-text-BBNTbFSe.js";
9
- const Canvas = lazy(() => import("./MindMapCanvas-VWrxTy5Q.js").then((module) => ({ default: module.MindMapCanvas })));
9
+ const Canvas = lazy(() => import("./MindMapCanvas-D5XwjVH1.js").then((module) => ({ default: module.MindMapCanvas })));
10
10
  function MindMapViewer({ value, modelValue, height, fetchAttachment }) {
11
11
  var _a;
12
12
  const model = value ?? modelValue;
@@ -6,7 +6,7 @@ import { readMindMap } from "wendang/mindmap";
6
6
  import { isWorkbookDocument } from "wendang/spreadsheet";
7
7
  import { b as useContentHost } from "../chunks/host-C-V688Rq.js";
8
8
  import { M as MathView, V as VideoView, F as FileView, A as AttachmentImage } from "../chunks/mind-topic-text-BBNTbFSe.js";
9
- import { M as MindMapBlock } from "../chunks/MindMapViewer-DqKu_Kuz.js";
9
+ import { M as MindMapBlock } from "../chunks/MindMapViewer-CQTQAgNq.js";
10
10
  import { S as SpreadsheetViewer } from "../chunks/SpreadsheetViewer-DN_QQGud.js";
11
11
  import { e as ensureCodeHighlight, c as codeTokens } from "../chunks/code-highlight-BmaqTe1m.js";
12
12
  import { h as hideCommentHint, s as showCommentHint, C as CodeToolbar } from "../chunks/comment-hint-DN7LKJAn.js";
package/dist/document.js CHANGED
@@ -10,7 +10,7 @@ import { b as buildColumnsJson, d as dismissSlash, u as unwrapCallout, h as high
10
10
  import { C } from "./chunks/extensions-B-CVVQhp.js";
11
11
  import { a as useContentContext, p as primeAttachment, u as unavailableAttachment } from "./chunks/host-C-V688Rq.js";
12
12
  import { c as createMindMapController } from "./chunks/mind-map-controller-B6SxK3GZ.js";
13
- import { M as MindMapBlock } from "./chunks/MindMapViewer-DqKu_Kuz.js";
13
+ import { M as MindMapBlock } from "./chunks/MindMapViewer-CQTQAgNq.js";
14
14
  import { p as previewItemsFrom, I as ImagePreview, V as VideoView } from "./chunks/mind-topic-text-BBNTbFSe.js";
15
15
  import { u as useLatest, a as useReady, b as asError } from "./chunks/hooks-C53Dp0pr.js";
16
16
  import { W as WButton, b as WIcon, l as lockScroll, t as trapTab, c as WDialog } from "./chunks/index-Ii536CFG.js";
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import { M, a } from "../chunks/MindMapViewer-DqKu_Kuz.js";
2
+ import { M, a } from "../chunks/MindMapViewer-CQTQAgNq.js";
3
3
  export {
4
4
  M as MindMapBlock,
5
5
  a as MindMapViewer
package/dist/mindmap.js CHANGED
@@ -8,7 +8,7 @@ import { T as TextStyle, H as Highlight, M as MindMap, a as MindMapTopic, b as M
8
8
  import { c as createMindMapController } from "./chunks/mind-map-controller-B6SxK3GZ.js";
9
9
  import { b as useContentHost, u as unavailableAttachment } from "./chunks/host-C-V688Rq.js";
10
10
  import { u as useLatest, a as useReady } from "./chunks/hooks-C53Dp0pr.js";
11
- import { MindMapCanvas } from "./chunks/MindMapCanvas-VWrxTy5Q.js";
11
+ import { MindMapCanvas } from "./chunks/MindMapCanvas-D5XwjVH1.js";
12
12
  const MindMapEditor = forwardRef(function MindMapEditor2(props, ref) {
13
13
  var _a, _b, _c;
14
14
  const latest = useLatest(props), host = useContentHost(), hostRef = useLatest(host), mount = useRef(null);
@@ -67,7 +67,7 @@
67
67
  .mind-search { display:flex;align-items:center;flex-wrap:wrap;gap:8px;padding:6px 0 10px;font-size:12px; }
68
68
  .mind-search input {width:180px;font-size:12px;}
69
69
  .mind-outline-row {display:flex;align-items:center;margin:3px 0;}.mind-outline-row input {min-width:0;width:100%;border:0;background:transparent;font:12px/22px inherit;color:var(--color-text);padding:5px;}.mind-outline-row.current {background:var(--color-surface-subtle);}.mind-outline-row>button:last-child {width:24px;flex-shrink:0;padding:2px;}
70
- .mind-outline-row textarea{min-width:0;width:100%;border:0;background:transparent;font-size:12px;line-height:22px;color:var(--color-text);padding:5px;resize:none;border-radius:4px;}
70
+ .mind-canvas-outline .mind-outline-row textarea{min-width:0;width:100%;border:0;background:transparent;font-size:12px;line-height:22px;color:var(--color-text);padding:5px;resize:none;border-radius:4px;}
71
71
  .mind-inline { height:100%; min-height:380px; }
72
72
  .mind-inline .mind-map-workspace { height:100%; }.mind-settings-menu{width:310px;display:flex;flex-wrap:wrap;align-items:center;gap:8px;padding:8px;font-size:12px;}.mind-settings-menu label{width:100%;display:flex;gap:8px;align-items:center;}.mind-settings-menu input{width:auto;}
73
73
  .mind-canvas-fullscreen {
@@ -3,7 +3,7 @@
3
3
  .mind-topic.root { background: var(--mind-color); border-color: var(--mind-color); color: white; font-weight: 600; }
4
4
  .mind-topic.active { box-shadow: 0 0 0 3px color-mix(in srgb, var(--mind-color) 22%, transparent); }
5
5
  .mind-topic-label { width:100%;min-width:0;white-space:pre-wrap;overflow-wrap:anywhere;word-break:break-all;text-align:center;line-height:var(--mind-topic-line-height,22px); }
6
- .mind-topic-input { box-sizing:border-box;display:block;border:0;border-radius:4px;outline:0;padding:0;margin:0;width:100%;min-width:0;min-height:var(--mind-topic-line-height,22px);max-width:none;resize:none;overflow:hidden;white-space:pre-wrap;word-break:break-all;overflow-wrap:anywhere;background:transparent;color:inherit;font:inherit;line-height:var(--mind-topic-line-height,22px);text-align:center; }
6
+ .mind-topic-input { box-sizing:border-box;display:block;border:0;border-radius:4px;outline:0;padding:0;margin:0;width:100%;min-width:0;min-height:var(--mind-topic-line-height,22px);max-width:none;resize:none;overflow:hidden;white-space:pre-wrap;word-break:break-all;overflow-wrap:anywhere;background:transparent;color:inherit;font:inherit;line-height:var(--mind-topic-line-height,22px);text-align:inherit; }
7
7
  .mind-topic-input:focus { box-shadow: none; outline: 0; }
8
8
  .mind-topic-fold {
9
9
  position:absolute;left:calc(100% + 20px);top:calc(50% - 12px);width:24px;min-width:24px;height:24px;padding:0;
@@ -89,12 +89,13 @@
89
89
  * 默认样式、`.muted`/`.small`/`.error-banner` 全部失效。用 `:is()` 让两处共用
90
90
  * 同一组声明,避免再复制一遍。
91
91
  */
92
- :is(.wendang, .wendang-popup-scope) :where(button, input, textarea) { font: inherit; box-sizing: border-box; }
92
+ /* Inline topic editors own their font metrics and appearance in both canvas hosts. */
93
+ :is(.wendang, .wendang-popup-scope) :where(button, input, textarea):not(:where(.mind-topic-input)) { font: inherit; box-sizing: border-box; }
93
94
  :is(.wendang, .wendang-popup-scope) :where(a) { color: var(--color-accent); }
94
95
  :is(.wendang, .wendang-popup-scope) :where(button) { cursor: pointer; }
95
96
  :is(.wendang, .wendang-popup-scope) .muted { color: var(--color-text-muted); }
96
97
  :is(.wendang, .wendang-popup-scope) .small { font-size: 12px; }
97
- :is(.wendang, .wendang-popup-scope) :where(input:not([type=checkbox]):not([type=radio]), textarea):not(.worksheet-grid *) {
98
+ :is(.wendang, .wendang-popup-scope) :where(input:not([type=checkbox]):not([type=radio]), textarea):not(.worksheet-grid *):not(:where(.mind-topic-input)) {
98
99
  background: var(--color-surface); color: var(--color-text); border: 1px solid var(--color-border);
99
100
  border-radius: 6px; padding: 6px 8px;
100
101
  }
package/dist/styles.css CHANGED
@@ -89,12 +89,13 @@
89
89
  * 默认样式、`.muted`/`.small`/`.error-banner` 全部失效。用 `:is()` 让两处共用
90
90
  * 同一组声明,避免再复制一遍。
91
91
  */
92
- :is(.wendang, .wendang-popup-scope) :where(button, input, textarea) { font: inherit; box-sizing: border-box; }
92
+ /* Inline topic editors own their font metrics and appearance in both canvas hosts. */
93
+ :is(.wendang, .wendang-popup-scope) :where(button, input, textarea):not(:where(.mind-topic-input)) { font: inherit; box-sizing: border-box; }
93
94
  :is(.wendang, .wendang-popup-scope) :where(a) { color: var(--color-accent); }
94
95
  :is(.wendang, .wendang-popup-scope) :where(button) { cursor: pointer; }
95
96
  :is(.wendang, .wendang-popup-scope) .muted { color: var(--color-text-muted); }
96
97
  :is(.wendang, .wendang-popup-scope) .small { font-size: 12px; }
97
- :is(.wendang, .wendang-popup-scope) :where(input:not([type=checkbox]):not([type=radio]), textarea):not(.worksheet-grid *) {
98
+ :is(.wendang, .wendang-popup-scope) :where(input:not([type=checkbox]):not([type=radio]), textarea):not(.worksheet-grid *):not(:where(.mind-topic-input)) {
98
99
  background: var(--color-surface); color: var(--color-text); border: 1px solid var(--color-border);
99
100
  border-radius: 6px; padding: 6px 8px;
100
101
  }
@@ -1924,7 +1925,7 @@
1924
1925
  .mind-search { display:flex;align-items:center;flex-wrap:wrap;gap:8px;padding:6px 0 10px;font-size:12px; }
1925
1926
  .mind-search input {width:180px;font-size:12px;}
1926
1927
  .mind-outline-row {display:flex;align-items:center;margin:3px 0;}.mind-outline-row input {min-width:0;width:100%;border:0;background:transparent;font:12px/22px inherit;color:var(--color-text);padding:5px;}.mind-outline-row.current {background:var(--color-surface-subtle);}.mind-outline-row>button:last-child {width:24px;flex-shrink:0;padding:2px;}
1927
- .mind-outline-row textarea{min-width:0;width:100%;border:0;background:transparent;font-size:12px;line-height:22px;color:var(--color-text);padding:5px;resize:none;border-radius:4px;}
1928
+ .mind-canvas-outline .mind-outline-row textarea{min-width:0;width:100%;border:0;background:transparent;font-size:12px;line-height:22px;color:var(--color-text);padding:5px;resize:none;border-radius:4px;}
1928
1929
  .mind-inline { height:100%; min-height:380px; }
1929
1930
  .mind-inline .mind-map-workspace { height:100%; }.mind-settings-menu{width:310px;display:flex;flex-wrap:wrap;align-items:center;gap:8px;padding:8px;font-size:12px;}.mind-settings-menu label{width:100%;display:flex;gap:8px;align-items:center;}.mind-settings-menu input{width:auto;}
1930
1931
  .mind-canvas-fullscreen {
@@ -1940,7 +1941,7 @@
1940
1941
  .mind-topic.root { background: var(--mind-color); border-color: var(--mind-color); color: white; font-weight: 600; }
1941
1942
  .mind-topic.active { box-shadow: 0 0 0 3px color-mix(in srgb, var(--mind-color) 22%, transparent); }
1942
1943
  .mind-topic-label { width:100%;min-width:0;white-space:pre-wrap;overflow-wrap:anywhere;word-break:break-all;text-align:center;line-height:var(--mind-topic-line-height,22px); }
1943
- .mind-topic-input { box-sizing:border-box;display:block;border:0;border-radius:4px;outline:0;padding:0;margin:0;width:100%;min-width:0;min-height:var(--mind-topic-line-height,22px);max-width:none;resize:none;overflow:hidden;white-space:pre-wrap;word-break:break-all;overflow-wrap:anywhere;background:transparent;color:inherit;font:inherit;line-height:var(--mind-topic-line-height,22px);text-align:center; }
1944
+ .mind-topic-input { box-sizing:border-box;display:block;border:0;border-radius:4px;outline:0;padding:0;margin:0;width:100%;min-width:0;min-height:var(--mind-topic-line-height,22px);max-width:none;resize:none;overflow:hidden;white-space:pre-wrap;word-break:break-all;overflow-wrap:anywhere;background:transparent;color:inherit;font:inherit;line-height:var(--mind-topic-line-height,22px);text-align:inherit; }
1944
1945
  .mind-topic-input:focus { box-shadow: none; outline: 0; }
1945
1946
  .mind-topic-fold {
1946
1947
  position:absolute;left:calc(100% + 20px);top:calc(50% - 12px);width:24px;min-width:24px;height:24px;padding:0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wendang-react",
3
- "version": "0.5.5",
3
+ "version": "0.5.6",
4
4
  "description": "Wendang 原生 React 文档、工作表和思维导图编辑与展示组件。",
5
5
  "type": "module",
6
6
  "license": "MIT",