@yudaocode/univer-boards 1.6.218 → 1.6.219
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 +6 -1
- package/lib/cjs/facade/index.js +45 -0
- package/lib/cjs/facade/index.js.map +1 -1
- package/lib/cjs/index.js +1352 -83
- package/lib/cjs/index.js.map +1 -1
- package/lib/es/facade/index.js +53 -0
- package/lib/es/facade/index.js.map +1 -1
- package/lib/es/index.js +1310 -46
- package/lib/es/index.js.map +1 -1
- package/lib/types/facade/index.d.ts +21 -1
- package/lib/types/index.d.ts +187 -2
- package/package.json +1 -1
package/lib/cjs/index.js
CHANGED
|
@@ -39,17 +39,24 @@ __export(src_exports, {
|
|
|
39
39
|
BoardIoService: () => BoardIoService,
|
|
40
40
|
BoardSelectionService: () => BoardSelectionService,
|
|
41
41
|
BoardUnitModel: () => BoardUnitModel,
|
|
42
|
+
CastBoardSessionVoteCommand: () => CastBoardSessionVoteCommand,
|
|
42
43
|
DeleteBoardElementsCommand: () => DeleteBoardElementsCommand,
|
|
44
|
+
EndBoardVotingSessionCommand: () => EndBoardVotingSessionCommand,
|
|
43
45
|
GroupBoardElementsInFrameCommand: () => GroupBoardElementsInFrameCommand,
|
|
44
46
|
IBoardIoService: () => IBoardIoService,
|
|
45
47
|
IBoardSelectionService: () => IBoardSelectionService,
|
|
48
|
+
ImportDocumentPagesToBoardCommand: () => ImportDocumentPagesToBoardCommand,
|
|
46
49
|
ImportMermaidToBoardCommand: () => ImportMermaidToBoardCommand,
|
|
47
50
|
LayoutBoardMindmapCommand: () => LayoutBoardMindmapCommand,
|
|
48
51
|
MERMAID_PRESET_TEMPLATES: () => MERMAID_PRESET_TEMPLATES,
|
|
49
52
|
MINDMAP_BRANCH_PALETTE: () => MINDMAP_BRANCH_PALETTE,
|
|
50
53
|
ReplaceBoardSnapshotCommand: () => ReplaceBoardSnapshotCommand,
|
|
54
|
+
RevealPrivateBrainstormCommand: () => RevealPrivateBrainstormCommand,
|
|
51
55
|
SetBoardViewportCommand: () => SetBoardViewportCommand,
|
|
52
56
|
SetBoardViewportMutation: () => SetBoardViewportMutation,
|
|
57
|
+
StartBoardVotingSessionCommand: () => StartBoardVotingSessionCommand,
|
|
58
|
+
StartPrivateBrainstormCommand: () => StartPrivateBrainstormCommand,
|
|
59
|
+
StopPrivateBrainstormCommand: () => StopPrivateBrainstormCommand,
|
|
53
60
|
UNIVER_BOARDS_PLUGIN_NAME: () => UNIVER_BOARDS_PLUGIN_NAME,
|
|
54
61
|
UniverBoardsPlugin: () => UniverBoardsPlugin,
|
|
55
62
|
UpdateBoardElementsCommand: () => UpdateBoardElementsCommand,
|
|
@@ -59,6 +66,7 @@ __export(src_exports, {
|
|
|
59
66
|
buildShapeSvgPath: () => buildShapeSvgPath,
|
|
60
67
|
computeBoardBounds: () => computeBoardBounds,
|
|
61
68
|
computeBoardConnectorPath: () => computeBoardConnectorPath,
|
|
69
|
+
computeBoardVotingLeaderboard: () => computeBoardVotingLeaderboard,
|
|
62
70
|
createDefaultBoardElement: () => createDefaultBoardElement,
|
|
63
71
|
createDefaultBoardUnitData: () => createDefaultBoardUnitData,
|
|
64
72
|
createSampleArchitectureBoardData: () => createSampleArchitectureBoardData,
|
|
@@ -73,7 +81,11 @@ __export(src_exports, {
|
|
|
73
81
|
getElementPortPoint: () => getElementPortPoint,
|
|
74
82
|
getMindmapDescendantIds: () => getMindmapDescendantIds,
|
|
75
83
|
importCsvToBoardStickies: () => importCsvToBoardStickies,
|
|
84
|
+
importDeckOrPdfToBoardFrames: () => importDeckOrPdfToBoardFrames,
|
|
85
|
+
importPdfBytesToBoardElements: () => importPdfBytesToBoardElements,
|
|
86
|
+
importPptxBytesToBoardElements: () => importPptxBytesToBoardElements,
|
|
76
87
|
isMindmapNodeCollapsedHidden: () => isMindmapNodeCollapsedHidden,
|
|
88
|
+
isStickyMaskedForViewer: () => isStickyMaskedForViewer,
|
|
77
89
|
layoutBoardMindmap: () => layoutBoardMindmap,
|
|
78
90
|
parseMermaidToBoardElements: () => parseMermaidToBoardElements,
|
|
79
91
|
parseRfc4180Csv: () => parseRfc4180Csv,
|
|
@@ -83,10 +95,10 @@ __export(src_exports, {
|
|
|
83
95
|
module.exports = __toCommonJS(src_exports);
|
|
84
96
|
|
|
85
97
|
// src/plugin.ts
|
|
86
|
-
var
|
|
98
|
+
var import_core12 = require("@univerjs/core");
|
|
87
99
|
|
|
88
100
|
// src/commands/commands/board.command.ts
|
|
89
|
-
var
|
|
101
|
+
var import_core7 = require("@univerjs/core");
|
|
90
102
|
|
|
91
103
|
// src/engine/mindmap-layout.ts
|
|
92
104
|
var import_core2 = require("@univerjs/core");
|
|
@@ -117,6 +129,81 @@ function resolveStickyPalette(color) {
|
|
|
117
129
|
}
|
|
118
130
|
return BOARD_STICKY_PALETTE.yellow;
|
|
119
131
|
}
|
|
132
|
+
function isStickyMaskedForViewer(sticky, brainstorm, viewerUserId) {
|
|
133
|
+
if (!brainstorm?.active || brainstorm.revealed) {
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
136
|
+
if (sticky.authorId && sticky.authorId !== viewerUserId) {
|
|
137
|
+
return true;
|
|
138
|
+
}
|
|
139
|
+
return false;
|
|
140
|
+
}
|
|
141
|
+
function findContainingFrame(el, snapshot) {
|
|
142
|
+
if (el.frameId) {
|
|
143
|
+
const direct = snapshot.elements[el.frameId];
|
|
144
|
+
if (direct && direct.type === "frame") {
|
|
145
|
+
return direct;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
const cx = el.x + el.width / 2;
|
|
149
|
+
const cy = el.y + el.height / 2;
|
|
150
|
+
const frameIds = snapshot.frameOrder.length ? snapshot.frameOrder : Object.keys(snapshot.elements).filter((id) => snapshot.elements[id]?.type === "frame");
|
|
151
|
+
for (const fid of frameIds) {
|
|
152
|
+
const frame = snapshot.elements[fid];
|
|
153
|
+
if (frame && frame.type === "frame" && cx >= frame.x && cx <= frame.x + frame.width && cy >= frame.y && cy <= frame.y + frame.height) {
|
|
154
|
+
return frame;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
return void 0;
|
|
158
|
+
}
|
|
159
|
+
function computeBoardVotingLeaderboard(snapshot, options) {
|
|
160
|
+
const orderIds = snapshot.elementOrder.length ? [...snapshot.elementOrder] : Object.keys(snapshot.elements);
|
|
161
|
+
const seen = new Set(orderIds);
|
|
162
|
+
for (const key of Object.keys(snapshot.elements)) {
|
|
163
|
+
if (!seen.has(key)) {
|
|
164
|
+
orderIds.push(key);
|
|
165
|
+
seen.add(key);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
const effectiveFrameId = options?.targetFrameId ?? snapshot.votingSession?.targetFrameId;
|
|
169
|
+
const sessionTally = /* @__PURE__ */ new Map();
|
|
170
|
+
if (snapshot.votingSession) {
|
|
171
|
+
for (const votedIds of Object.values(snapshot.votingSession.votesByUser)) {
|
|
172
|
+
for (const sid of votedIds) {
|
|
173
|
+
sessionTally.set(sid, (sessionTally.get(sid) ?? 0) + 1);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
const candidates = [];
|
|
178
|
+
orderIds.forEach((id, orderIndex) => {
|
|
179
|
+
const el = snapshot.elements[id];
|
|
180
|
+
if (!el || el.type !== "sticky" || el.hidden) return;
|
|
181
|
+
const frame = findContainingFrame(el, snapshot);
|
|
182
|
+
if (effectiveFrameId && snapshot.elements[effectiveFrameId]?.type === "frame") {
|
|
183
|
+
if (frame?.id !== effectiveFrameId) return;
|
|
184
|
+
}
|
|
185
|
+
const voteCount = snapshot.votingSession ? sessionTally.get(el.id) ?? 0 : el.votes.length;
|
|
186
|
+
candidates.push({
|
|
187
|
+
sticky: el,
|
|
188
|
+
voteCount,
|
|
189
|
+
frameTitle: frame?.title ?? "",
|
|
190
|
+
orderIndex
|
|
191
|
+
});
|
|
192
|
+
});
|
|
193
|
+
candidates.sort((a, b) => {
|
|
194
|
+
if (b.voteCount !== a.voteCount) return b.voteCount - a.voteCount;
|
|
195
|
+
return a.orderIndex - b.orderIndex;
|
|
196
|
+
});
|
|
197
|
+
return candidates.map((item, idx) => ({
|
|
198
|
+
rank: idx + 1,
|
|
199
|
+
elementId: item.sticky.id,
|
|
200
|
+
text: item.sticky.text,
|
|
201
|
+
voteCount: item.voteCount,
|
|
202
|
+
frameTitle: item.frameTitle,
|
|
203
|
+
color: item.sticky.color,
|
|
204
|
+
...item.sticky.author ? { author: item.sticky.author } : {}
|
|
205
|
+
}));
|
|
206
|
+
}
|
|
120
207
|
var MINDMAP_BRANCH_PALETTE = [
|
|
121
208
|
"#2563EB",
|
|
122
209
|
"#7C3AED",
|
|
@@ -178,6 +265,7 @@ function createDefaultBoardElement(type, partial) {
|
|
|
178
265
|
text: partial?.text ?? "\u53CC\u51FB\u8F93\u5165\u4FBF\u7B7E\u60F3\u6CD5...",
|
|
179
266
|
color: partial?.color ?? "yellow",
|
|
180
267
|
author: partial?.author ?? "\u534F\u4F5C\u6210\u5458",
|
|
268
|
+
...typeof partial?.authorId === "string" && partial.authorId ? { authorId: partial.authorId } : {},
|
|
181
269
|
votes: Array.isArray(partial?.votes) ? [...partial.votes] : [],
|
|
182
270
|
tags: Array.isArray(partial?.tags) ? [...partial.tags] : [],
|
|
183
271
|
x,
|
|
@@ -617,8 +705,781 @@ function layoutBoardMindmap(elements, rootId, options) {
|
|
|
617
705
|
return fullMap;
|
|
618
706
|
}
|
|
619
707
|
|
|
620
|
-
// src/
|
|
708
|
+
// src/exporter/board-doc-tiler.ts
|
|
621
709
|
var import_core3 = require("@univerjs/core");
|
|
710
|
+
var import_pdf_lib = require("pdf-lib");
|
|
711
|
+
var BASE64_ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
712
|
+
function uint8ToBase64(bytes) {
|
|
713
|
+
let out = "";
|
|
714
|
+
const len = bytes.length;
|
|
715
|
+
for (let i = 0; i < len; i += 3) {
|
|
716
|
+
const b0 = bytes[i];
|
|
717
|
+
const b1 = i + 1 < len ? bytes[i + 1] : 0;
|
|
718
|
+
const b2 = i + 2 < len ? bytes[i + 2] : 0;
|
|
719
|
+
const triplet = b0 << 16 | b1 << 8 | b2;
|
|
720
|
+
out += BASE64_ALPHABET[triplet >>> 18 & 63];
|
|
721
|
+
out += BASE64_ALPHABET[triplet >>> 12 & 63];
|
|
722
|
+
out += i + 1 < len ? BASE64_ALPHABET[triplet >>> 6 & 63] : "=";
|
|
723
|
+
out += i + 2 < len ? BASE64_ALPHABET[triplet & 63] : "=";
|
|
724
|
+
}
|
|
725
|
+
return out;
|
|
726
|
+
}
|
|
727
|
+
function unescapeXml(raw) {
|
|
728
|
+
return raw.replace(/</g, "<").replace(/>/g, ">").replace(/"/g, '"').replace(/'/g, "'").replace(/&#(\d+);/g, (_, code) => String.fromCharCode(Number(code))).replace(/&#x([0-9a-fA-F]+);/g, (_, hex) => String.fromCharCode(parseInt(hex, 16))).replace(/&/g, "&");
|
|
729
|
+
}
|
|
730
|
+
async function decompressBytesIfSupported(compressed, format) {
|
|
731
|
+
const DecompCtor = globalThis.DecompressionStream;
|
|
732
|
+
if (typeof DecompCtor !== "function") {
|
|
733
|
+
return null;
|
|
734
|
+
}
|
|
735
|
+
try {
|
|
736
|
+
const copy = compressed.slice().buffer;
|
|
737
|
+
const stream = new Blob([copy]).stream().pipeThrough(new DecompCtor(format));
|
|
738
|
+
const ab = await new Response(stream).arrayBuffer();
|
|
739
|
+
return new Uint8Array(ab);
|
|
740
|
+
} catch {
|
|
741
|
+
return null;
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
async function readZipArchiveEntries(zipBytes) {
|
|
745
|
+
const entries = /* @__PURE__ */ new Map();
|
|
746
|
+
if (zipBytes.length < 22) return entries;
|
|
747
|
+
const view = new DataView(zipBytes.buffer, zipBytes.byteOffset, zipBytes.byteLength);
|
|
748
|
+
const decoder = new TextDecoder("utf-8", { fatal: false });
|
|
749
|
+
let eocdOffset = -1;
|
|
750
|
+
const minSearch = Math.max(0, zipBytes.length - 65557);
|
|
751
|
+
for (let pos = zipBytes.length - 22; pos >= minSearch; pos -= 1) {
|
|
752
|
+
if (view.getUint32(pos, true) === 101010256) {
|
|
753
|
+
eocdOffset = pos;
|
|
754
|
+
break;
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
if (eocdOffset >= 0) {
|
|
758
|
+
const totalRecords = view.getUint16(eocdOffset + 10, true);
|
|
759
|
+
const centralDirOffset = view.getUint32(eocdOffset + 16, true);
|
|
760
|
+
let cursor = centralDirOffset;
|
|
761
|
+
for (let i = 0; i < totalRecords && cursor + 46 <= zipBytes.length; i += 1) {
|
|
762
|
+
if (view.getUint32(cursor, true) !== 33639248) break;
|
|
763
|
+
const compressionMethod = view.getUint16(cursor + 10, true);
|
|
764
|
+
const compressedSize = view.getUint32(cursor + 20, true);
|
|
765
|
+
const fileNameLen = view.getUint16(cursor + 28, true);
|
|
766
|
+
const extraLen = view.getUint16(cursor + 30, true);
|
|
767
|
+
const commentLen = view.getUint16(cursor + 32, true);
|
|
768
|
+
const localHeaderOffset = view.getUint32(cursor + 42, true);
|
|
769
|
+
const rawName = decoder.decode(zipBytes.subarray(cursor + 46, cursor + 46 + fileNameLen));
|
|
770
|
+
const cleanName = rawName.replace(/^\/+/, "");
|
|
771
|
+
cursor += 46 + fileNameLen + extraLen + commentLen;
|
|
772
|
+
if (!cleanName || cleanName.endsWith("/") || localHeaderOffset + 30 > zipBytes.length || view.getUint32(localHeaderOffset, true) !== 67324752) {
|
|
773
|
+
continue;
|
|
774
|
+
}
|
|
775
|
+
const localNameLen = view.getUint16(localHeaderOffset + 26, true);
|
|
776
|
+
const localExtraLen = view.getUint16(localHeaderOffset + 28, true);
|
|
777
|
+
const dataStart = localHeaderOffset + 30 + localNameLen + localExtraLen;
|
|
778
|
+
if (dataStart + compressedSize > zipBytes.length) continue;
|
|
779
|
+
const rawSlice = zipBytes.subarray(dataStart, dataStart + compressedSize);
|
|
780
|
+
if (compressionMethod === 0) {
|
|
781
|
+
entries.set(cleanName, rawSlice);
|
|
782
|
+
} else if (compressionMethod === 8) {
|
|
783
|
+
const inflated = await decompressBytesIfSupported(rawSlice, "deflate-raw");
|
|
784
|
+
if (inflated) {
|
|
785
|
+
entries.set(cleanName, inflated);
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
return entries;
|
|
790
|
+
}
|
|
791
|
+
let offset = 0;
|
|
792
|
+
while (offset + 30 <= zipBytes.length) {
|
|
793
|
+
if (view.getUint32(offset, true) !== 67324752) break;
|
|
794
|
+
const method = view.getUint16(offset + 8, true);
|
|
795
|
+
const compSize = view.getUint32(offset + 18, true);
|
|
796
|
+
const nameLen = view.getUint16(offset + 26, true);
|
|
797
|
+
const extraLen = view.getUint16(offset + 28, true);
|
|
798
|
+
const name = decoder.decode(zipBytes.subarray(offset + 30, offset + 30 + nameLen)).replace(/^\/+/, "");
|
|
799
|
+
const dataStart = offset + 30 + nameLen + extraLen;
|
|
800
|
+
if (dataStart + compSize > zipBytes.length) break;
|
|
801
|
+
const slice = zipBytes.subarray(dataStart, dataStart + compSize);
|
|
802
|
+
if (name && !name.endsWith("/")) {
|
|
803
|
+
if (method === 0) {
|
|
804
|
+
entries.set(name, slice);
|
|
805
|
+
} else if (method === 8) {
|
|
806
|
+
const inflated = await decompressBytesIfSupported(slice, "deflate-raw");
|
|
807
|
+
if (inflated) entries.set(name, inflated);
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
offset = dataStart + compSize;
|
|
811
|
+
}
|
|
812
|
+
return entries;
|
|
813
|
+
}
|
|
814
|
+
function findXmlBlocks(xml, tagName) {
|
|
815
|
+
const results = [];
|
|
816
|
+
const openToken = `<${tagName}`;
|
|
817
|
+
const closeToken = `</${tagName}>`;
|
|
818
|
+
let searchFrom = 0;
|
|
819
|
+
while (searchFrom < xml.length) {
|
|
820
|
+
const idx = xml.indexOf(openToken, searchFrom);
|
|
821
|
+
if (idx === -1) break;
|
|
822
|
+
const nextCh = xml[idx + openToken.length];
|
|
823
|
+
const isTagBoundary = nextCh === ">" || nextCh === "/" || nextCh === " " || nextCh === " " || nextCh === "\r" || nextCh === "\n";
|
|
824
|
+
if (!isTagBoundary) {
|
|
825
|
+
searchFrom = idx + openToken.length;
|
|
826
|
+
continue;
|
|
827
|
+
}
|
|
828
|
+
const openTagEnd = xml.indexOf(">", idx + openToken.length);
|
|
829
|
+
if (openTagEnd === -1) break;
|
|
830
|
+
if (xml[openTagEnd - 1] === "/") {
|
|
831
|
+
results.push(xml.slice(idx, openTagEnd + 1));
|
|
832
|
+
searchFrom = openTagEnd + 1;
|
|
833
|
+
continue;
|
|
834
|
+
}
|
|
835
|
+
let depth = 1;
|
|
836
|
+
let cursor = openTagEnd + 1;
|
|
837
|
+
while (depth > 0 && cursor < xml.length) {
|
|
838
|
+
const nextOpen = xml.indexOf(openToken, cursor);
|
|
839
|
+
const nextClose = xml.indexOf(closeToken, cursor);
|
|
840
|
+
if (nextClose === -1) {
|
|
841
|
+
cursor = xml.length;
|
|
842
|
+
break;
|
|
843
|
+
}
|
|
844
|
+
if (nextOpen !== -1 && nextOpen < nextClose) {
|
|
845
|
+
const ch = xml[nextOpen + openToken.length];
|
|
846
|
+
if (ch === ">" || ch === "/" || ch === " " || ch === " " || ch === "\r" || ch === "\n") {
|
|
847
|
+
const subEnd = xml.indexOf(">", nextOpen + openToken.length);
|
|
848
|
+
if (subEnd !== -1 && xml[subEnd - 1] !== "/") {
|
|
849
|
+
depth += 1;
|
|
850
|
+
}
|
|
851
|
+
cursor = subEnd !== -1 ? subEnd + 1 : nextOpen + openToken.length;
|
|
852
|
+
continue;
|
|
853
|
+
}
|
|
854
|
+
cursor = nextOpen + openToken.length;
|
|
855
|
+
continue;
|
|
856
|
+
}
|
|
857
|
+
depth -= 1;
|
|
858
|
+
cursor = nextClose + closeToken.length;
|
|
859
|
+
}
|
|
860
|
+
results.push(xml.slice(idx, cursor));
|
|
861
|
+
searchFrom = cursor;
|
|
862
|
+
}
|
|
863
|
+
return results;
|
|
864
|
+
}
|
|
865
|
+
function resolveOpcPath(baseDir, target) {
|
|
866
|
+
const clean = target.trim();
|
|
867
|
+
if (clean.startsWith("/")) {
|
|
868
|
+
return clean.replace(/^\/+/, "");
|
|
869
|
+
}
|
|
870
|
+
const parts = [...baseDir.split("/").filter(Boolean), ...clean.split("/").filter(Boolean)];
|
|
871
|
+
const stack = [];
|
|
872
|
+
for (const seg of parts) {
|
|
873
|
+
if (seg === ".") continue;
|
|
874
|
+
if (seg === "..") {
|
|
875
|
+
stack.pop();
|
|
876
|
+
} else {
|
|
877
|
+
stack.push(seg);
|
|
878
|
+
}
|
|
879
|
+
}
|
|
880
|
+
return stack.join("/");
|
|
881
|
+
}
|
|
882
|
+
function parseRelationshipsMap(relsXml, baseDir) {
|
|
883
|
+
const map = /* @__PURE__ */ new Map();
|
|
884
|
+
const relRegex = /<Relationship\b[^>]*>/g;
|
|
885
|
+
let match;
|
|
886
|
+
while ((match = relRegex.exec(relsXml)) !== null) {
|
|
887
|
+
const tag = match[0];
|
|
888
|
+
const idMatch = /\bId="([^"]+)"/.exec(tag);
|
|
889
|
+
const targetMatch = /\bTarget="([^"]+)"/.exec(tag);
|
|
890
|
+
if (idMatch && targetMatch) {
|
|
891
|
+
map.set(idMatch[1], resolveOpcPath(baseDir, targetMatch[1]));
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
return map;
|
|
895
|
+
}
|
|
896
|
+
function mapPresetGeomToBoardShape(prst) {
|
|
897
|
+
switch (prst) {
|
|
898
|
+
case "roundRect":
|
|
899
|
+
case "foldedCorner":
|
|
900
|
+
return "roundRect";
|
|
901
|
+
case "ellipse":
|
|
902
|
+
return "ellipse";
|
|
903
|
+
case "diamond":
|
|
904
|
+
case "flowChartDecision":
|
|
905
|
+
return "diamond";
|
|
906
|
+
case "parallelogram":
|
|
907
|
+
case "flowChartInputOutput":
|
|
908
|
+
return "parallelogram";
|
|
909
|
+
case "can":
|
|
910
|
+
case "flowChartMagneticDisk":
|
|
911
|
+
return "cylinder";
|
|
912
|
+
case "hexagon":
|
|
913
|
+
case "flowChartPreparation":
|
|
914
|
+
return "hexagon";
|
|
915
|
+
case "cloud":
|
|
916
|
+
return "cloud";
|
|
917
|
+
case "flowChartDocument":
|
|
918
|
+
return "document";
|
|
919
|
+
case "wedgeRectCallout":
|
|
920
|
+
case "wedgeRoundRectCallout":
|
|
921
|
+
return "callout";
|
|
922
|
+
default:
|
|
923
|
+
return "rect";
|
|
924
|
+
}
|
|
925
|
+
}
|
|
926
|
+
function extractXfrmBox(xmlBlock) {
|
|
927
|
+
const xfrmMatch = /<(?:a|p):xfrm\b([^>]*)>([\s\S]*?)<\/(?:a|p):xfrm>/.exec(xmlBlock);
|
|
928
|
+
if (!xfrmMatch) return null;
|
|
929
|
+
const attrs = xfrmMatch[1] ?? "";
|
|
930
|
+
const inner = xfrmMatch[2] ?? "";
|
|
931
|
+
const offMatch = /<a:off\b[^>]*\bx="(-?\d+)"[^>]*\by="(-?\d+)"/.exec(inner);
|
|
932
|
+
const extMatch = /<a:ext\b[^>]*\bcx="(-?\d+)"[^>]*\bcy="(-?\d+)"/.exec(inner);
|
|
933
|
+
if (!offMatch || !extMatch) return null;
|
|
934
|
+
return {
|
|
935
|
+
xEmu: Number(offMatch[1]),
|
|
936
|
+
yEmu: Number(offMatch[2]),
|
|
937
|
+
cxEmu: Math.max(0, Number(extMatch[1])),
|
|
938
|
+
cyEmu: Math.max(0, Number(extMatch[2])),
|
|
939
|
+
flipH: /\bflipH="1"|\bflipH="true"/.test(attrs),
|
|
940
|
+
flipV: /\bflipV="1"|\bflipV="true"/.test(attrs)
|
|
941
|
+
};
|
|
942
|
+
}
|
|
943
|
+
function extractParagraphText(xmlBlock) {
|
|
944
|
+
const paragraphs = findXmlBlocks(xmlBlock, "a:p");
|
|
945
|
+
if (paragraphs.length === 0) {
|
|
946
|
+
const runs = [];
|
|
947
|
+
const tRegex = /<a:t(?:\s[^>]*)?>([\s\S]*?)<\/a:t>/g;
|
|
948
|
+
let m;
|
|
949
|
+
while ((m = tRegex.exec(xmlBlock)) !== null) {
|
|
950
|
+
runs.push(unescapeXml(m[1]));
|
|
951
|
+
}
|
|
952
|
+
return runs.join("").trim();
|
|
953
|
+
}
|
|
954
|
+
const lines = [];
|
|
955
|
+
for (const pXml of paragraphs) {
|
|
956
|
+
const runs = [];
|
|
957
|
+
const tRegex = /<a:t(?:\s[^>]*)?>([\s\S]*?)<\/a:t>/g;
|
|
958
|
+
let m;
|
|
959
|
+
while ((m = tRegex.exec(pXml)) !== null) {
|
|
960
|
+
runs.push(unescapeXml(m[1]));
|
|
961
|
+
}
|
|
962
|
+
lines.push(runs.join(""));
|
|
963
|
+
}
|
|
964
|
+
return lines.join("\n").trim();
|
|
965
|
+
}
|
|
966
|
+
function resolveMediaMimeType(path) {
|
|
967
|
+
const lower = path.toLowerCase();
|
|
968
|
+
if (lower.endsWith(".svg")) return "image/svg+xml";
|
|
969
|
+
if (lower.endsWith(".jpg") || lower.endsWith(".jpeg")) return "image/jpeg";
|
|
970
|
+
if (lower.endsWith(".gif")) return "image/gif";
|
|
971
|
+
if (lower.endsWith(".webp")) return "image/webp";
|
|
972
|
+
return "image/png";
|
|
973
|
+
}
|
|
974
|
+
async function importPptxBytesToBoardElements(pptxBytes, options) {
|
|
975
|
+
const zipEntries = await readZipArchiveEntries(pptxBytes);
|
|
976
|
+
if (zipEntries.size === 0) return [];
|
|
977
|
+
const decoder = new TextDecoder("utf-8", { fatal: false });
|
|
978
|
+
const getTextEntry = (name) => {
|
|
979
|
+
const bytes = zipEntries.get(name);
|
|
980
|
+
return bytes ? decoder.decode(bytes) : void 0;
|
|
981
|
+
};
|
|
982
|
+
let slideWidthEmu = 12192e3;
|
|
983
|
+
let slideHeightEmu = 6858e3;
|
|
984
|
+
const orderedSlidePaths = [];
|
|
985
|
+
const presXml = getTextEntry("ppt/presentation.xml");
|
|
986
|
+
const presRelsXml = getTextEntry("ppt/_rels/presentation.xml.rels");
|
|
987
|
+
if (presXml) {
|
|
988
|
+
const szMatch = /<p:sldSz\b[^>]*\bcx="(\d+)"[^>]*\bcy="(\d+)"/.exec(presXml);
|
|
989
|
+
if (szMatch) {
|
|
990
|
+
slideWidthEmu = Math.max(914400, Number(szMatch[1]));
|
|
991
|
+
slideHeightEmu = Math.max(914400, Number(szMatch[2]));
|
|
992
|
+
}
|
|
993
|
+
if (presRelsXml) {
|
|
994
|
+
const presRels = parseRelationshipsMap(presRelsXml, "ppt");
|
|
995
|
+
const sldIdRegex = /<p:sldId\b[^>]*\br:id="([^"]+)"/g;
|
|
996
|
+
let sldMatch;
|
|
997
|
+
while ((sldMatch = sldIdRegex.exec(presXml)) !== null) {
|
|
998
|
+
const targetPath = presRels.get(sldMatch[1]);
|
|
999
|
+
if (targetPath && zipEntries.has(targetPath)) {
|
|
1000
|
+
orderedSlidePaths.push(targetPath);
|
|
1001
|
+
}
|
|
1002
|
+
}
|
|
1003
|
+
}
|
|
1004
|
+
}
|
|
1005
|
+
if (orderedSlidePaths.length === 0) {
|
|
1006
|
+
const fallbackSlides = Array.from(zipEntries.keys()).filter((k) => /^ppt\/slides\/slide\d+\.xml$/i.test(k)).sort((a, b) => {
|
|
1007
|
+
const na = Number(/slide(\d+)\.xml/i.exec(a)?.[1] ?? 0);
|
|
1008
|
+
const nb = Number(/slide(\d+)\.xml/i.exec(b)?.[1] ?? 0);
|
|
1009
|
+
return na - nb;
|
|
1010
|
+
});
|
|
1011
|
+
orderedSlidePaths.push(...fallbackSlides);
|
|
1012
|
+
}
|
|
1013
|
+
if (orderedSlidePaths.length === 0) return [];
|
|
1014
|
+
const originX = options?.originX ?? 80;
|
|
1015
|
+
const originY = options?.originY ?? 80;
|
|
1016
|
+
const columns = Math.max(1, options?.columns ?? (orderedSlidePaths.length <= 2 ? orderedSlidePaths.length : 2));
|
|
1017
|
+
const gapX = options?.gapX ?? 64;
|
|
1018
|
+
const gapY = options?.gapY ?? 64;
|
|
1019
|
+
const frameW = options?.frameWidth ?? 780;
|
|
1020
|
+
const headerH = 44;
|
|
1021
|
+
const pad = 20;
|
|
1022
|
+
const innerW = frameW - pad * 2;
|
|
1023
|
+
const innerH = Math.max(240, Math.round(innerW * (slideHeightEmu / slideWidthEmu)));
|
|
1024
|
+
const frameH = headerH + innerH + pad;
|
|
1025
|
+
const frames = [];
|
|
1026
|
+
const childElements = [];
|
|
1027
|
+
orderedSlidePaths.forEach((slidePath, slideIdx) => {
|
|
1028
|
+
const slideXml = getTextEntry(slidePath);
|
|
1029
|
+
if (!slideXml) return;
|
|
1030
|
+
const slideFileName = slidePath.split("/").pop() ?? `slide${slideIdx + 1}.xml`;
|
|
1031
|
+
const slideDir = slidePath.slice(0, Math.max(0, slidePath.lastIndexOf("/")));
|
|
1032
|
+
const slideRelsPath = `${slideDir}/_rels/${slideFileName}.rels`;
|
|
1033
|
+
const slideRels = zipEntries.has(slideRelsPath) ? parseRelationshipsMap(getTextEntry(slideRelsPath) ?? "", slideDir) : /* @__PURE__ */ new Map();
|
|
1034
|
+
const col = slideIdx % columns;
|
|
1035
|
+
const row = Math.floor(slideIdx / columns);
|
|
1036
|
+
const fx = originX + col * (frameW + gapX);
|
|
1037
|
+
const fy = originY + row * (frameH + gapY);
|
|
1038
|
+
const frameId = `frame-pptx-${slideIdx + 1}-${(0, import_core3.generateRandomId)(5)}`;
|
|
1039
|
+
const toBoardX = (xEmu) => Math.round(fx + pad + Math.max(0, xEmu) / slideWidthEmu * innerW);
|
|
1040
|
+
const toBoardY = (yEmu) => Math.round(fy + headerH + Math.max(0, yEmu) / slideHeightEmu * innerH);
|
|
1041
|
+
const toBoardW = (wEmu) => Math.max(32, Math.round(Math.max(12700, wEmu) / slideWidthEmu * innerW));
|
|
1042
|
+
const toBoardH = (hEmu) => Math.max(24, Math.round(Math.max(12700, hEmu) / slideHeightEmu * innerH));
|
|
1043
|
+
let slideTitle = "";
|
|
1044
|
+
const slideChildren = [];
|
|
1045
|
+
const spBlocks = findXmlBlocks(slideXml, "p:sp");
|
|
1046
|
+
spBlocks.forEach((spXml, spIdx) => {
|
|
1047
|
+
const cNvPrMatch = /<p:cNvPr\b[^>]*\bname="([^"]*)"/.exec(spXml);
|
|
1048
|
+
const spName = cNvPrMatch ? unescapeXml(cNvPrMatch[1]) : "";
|
|
1049
|
+
const isTitlePlaceholder = /<p:ph\b[^>]*\btype="(?:title|ctrTitle)"/.test(spXml);
|
|
1050
|
+
const text = extractParagraphText(spXml);
|
|
1051
|
+
if (spName === "Slide Frame Title" && text) {
|
|
1052
|
+
slideTitle = text;
|
|
1053
|
+
return;
|
|
1054
|
+
}
|
|
1055
|
+
if (!slideTitle && isTitlePlaceholder && text) {
|
|
1056
|
+
slideTitle = text;
|
|
1057
|
+
}
|
|
1058
|
+
const xfrm = extractXfrmBox(spXml);
|
|
1059
|
+
const bx = xfrm ? toBoardX(xfrm.xEmu) : fx + pad + spIdx % 3 * 180;
|
|
1060
|
+
const by = xfrm ? toBoardY(xfrm.yEmu) : fy + headerH + 24 + Math.floor(spIdx / 3) * 80;
|
|
1061
|
+
const bw = xfrm ? toBoardW(xfrm.cxEmu) : 160;
|
|
1062
|
+
const bh = xfrm ? toBoardH(xfrm.cyEmu) : 56;
|
|
1063
|
+
const spPrBlock = findXmlBlocks(spXml, "p:spPr")[0] ?? "";
|
|
1064
|
+
const lnBlock = findXmlBlocks(spPrBlock, "a:ln")[0] ?? "";
|
|
1065
|
+
const spPrWithoutLn = lnBlock ? spPrBlock.replace(lnBlock, "") : spPrBlock;
|
|
1066
|
+
const hasNoFill = /<a:noFill\s*\/>/.test(spPrWithoutLn);
|
|
1067
|
+
const fillClrMatch = /<a:srgbClr\b[^>]*\bval="([0-9a-fA-F]{6})"/.exec(spPrWithoutLn);
|
|
1068
|
+
const lnNoFill = !lnBlock || /<a:noFill\s*\/>/.test(lnBlock);
|
|
1069
|
+
const strokeClrMatch = /<a:srgbClr\b[^>]*\bval="([0-9a-fA-F]{6})"/.exec(lnBlock);
|
|
1070
|
+
const isTxBox = /<p:cNvSpPr\b[^>]*\btxBox="1"/.test(spXml);
|
|
1071
|
+
const txBodyBlock = findXmlBlocks(spXml, "p:txBody")[0] ?? "";
|
|
1072
|
+
const textClrMatch = /<a:srgbClr\b[^>]*\bval="([0-9a-fA-F]{6})"/.exec(txBodyBlock);
|
|
1073
|
+
const szMatch = /\bsz="(\d+)"/.exec(txBodyBlock);
|
|
1074
|
+
const fontSize = szMatch ? Math.max(10, Math.min(28, Math.round(Number(szMatch[1]) / 100))) : 13;
|
|
1075
|
+
const isBold = /\bb="1"|\bb="true"/.test(txBodyBlock);
|
|
1076
|
+
const algnMatch = /\balgn="(l|ctr|r)"/.exec(txBodyBlock);
|
|
1077
|
+
const align = algnMatch?.[1] === "ctr" ? "center" : algnMatch?.[1] === "r" ? "right" : "left";
|
|
1078
|
+
if ((hasNoFill || !fillClrMatch && isTxBox) && (lnNoFill || !strokeClrMatch)) {
|
|
1079
|
+
if (!text) return;
|
|
1080
|
+
const textEl = {
|
|
1081
|
+
id: `pptx-text-${slideIdx + 1}-${spIdx + 1}-${(0, import_core3.generateRandomId)(4)}`,
|
|
1082
|
+
type: "text",
|
|
1083
|
+
text,
|
|
1084
|
+
fontSize,
|
|
1085
|
+
fontWeight: isBold ? "bold" : "normal",
|
|
1086
|
+
color: textClrMatch ? `#${textClrMatch[1].toUpperCase()}` : "#0F172A",
|
|
1087
|
+
align,
|
|
1088
|
+
x: bx,
|
|
1089
|
+
y: by,
|
|
1090
|
+
width: bw,
|
|
1091
|
+
height: bh,
|
|
1092
|
+
frameId
|
|
1093
|
+
};
|
|
1094
|
+
slideChildren.push(textEl);
|
|
1095
|
+
return;
|
|
1096
|
+
}
|
|
1097
|
+
const prstMatch = /<a:prstGeom\b[^>]*\bprst="([^"]+)"/.exec(spPrBlock);
|
|
1098
|
+
const shapeType = mapPresetGeomToBoardShape(prstMatch?.[1]);
|
|
1099
|
+
const lnWMatch = /<a:ln\b[^>]*\bw="(\d+)"/.exec(lnBlock);
|
|
1100
|
+
const strokeWidth = lnWMatch ? Math.max(1, Math.min(6, Math.round(Number(lnWMatch[1]) / 12700))) : 1.5;
|
|
1101
|
+
const dashed = /<a:prstDash\b[^>]*\bval="(?:dash|sysDash|lgDash)"/.test(lnBlock);
|
|
1102
|
+
const shapeEl = {
|
|
1103
|
+
id: `pptx-shape-${slideIdx + 1}-${spIdx + 1}-${(0, import_core3.generateRandomId)(4)}`,
|
|
1104
|
+
type: "shape",
|
|
1105
|
+
shapeType,
|
|
1106
|
+
text: text || spName || "",
|
|
1107
|
+
fill: fillClrMatch ? `#${fillClrMatch[1].toUpperCase()}` : "#EFF6FF",
|
|
1108
|
+
stroke: strokeClrMatch ? `#${strokeClrMatch[1].toUpperCase()}` : "#2563EB",
|
|
1109
|
+
strokeWidth,
|
|
1110
|
+
textColor: textClrMatch ? `#${textClrMatch[1].toUpperCase()}` : "#1E293B",
|
|
1111
|
+
...dashed ? { dashed: true } : {},
|
|
1112
|
+
fontSize,
|
|
1113
|
+
x: bx,
|
|
1114
|
+
y: by,
|
|
1115
|
+
width: bw,
|
|
1116
|
+
height: bh,
|
|
1117
|
+
frameId
|
|
1118
|
+
};
|
|
1119
|
+
slideChildren.push(shapeEl);
|
|
1120
|
+
});
|
|
1121
|
+
const graphicFrames = findXmlBlocks(slideXml, "p:graphicFrame");
|
|
1122
|
+
graphicFrames.forEach((gfXml, gfIdx) => {
|
|
1123
|
+
const tblBlock = findXmlBlocks(gfXml, "a:tbl")[0];
|
|
1124
|
+
if (!tblBlock) return;
|
|
1125
|
+
const trBlocks = findXmlBlocks(tblBlock, "a:tr");
|
|
1126
|
+
const parsedRows = trBlocks.map(
|
|
1127
|
+
(trXml) => findXmlBlocks(trXml, "a:tc").map((tcXml) => extractParagraphText(tcXml))
|
|
1128
|
+
);
|
|
1129
|
+
if (parsedRows.length === 0) return;
|
|
1130
|
+
const xfrm = extractXfrmBox(gfXml);
|
|
1131
|
+
const cNvPrMatch = /<p:cNvPr\b[^>]*\bname="([^"]*)"/.exec(gfXml);
|
|
1132
|
+
const tblTitle = cNvPrMatch ? unescapeXml(cNvPrMatch[1]) : void 0;
|
|
1133
|
+
const headers = parsedRows[0];
|
|
1134
|
+
const rows = parsedRows.slice(1);
|
|
1135
|
+
const tableEl = {
|
|
1136
|
+
id: `pptx-table-${slideIdx + 1}-${gfIdx + 1}-${(0, import_core3.generateRandomId)(4)}`,
|
|
1137
|
+
type: "table",
|
|
1138
|
+
...tblTitle ? { title: tblTitle } : {},
|
|
1139
|
+
headers: headers.length > 0 ? headers : ["\u5217 1"],
|
|
1140
|
+
rows,
|
|
1141
|
+
headerFill: "#EFF6FF",
|
|
1142
|
+
borderColor: "#CBD5E1",
|
|
1143
|
+
x: xfrm ? toBoardX(xfrm.xEmu) : fx + pad + 24,
|
|
1144
|
+
y: xfrm ? toBoardY(xfrm.yEmu) : fy + headerH + 40,
|
|
1145
|
+
width: xfrm ? toBoardW(xfrm.cxEmu) : 360,
|
|
1146
|
+
height: xfrm ? toBoardH(xfrm.cyEmu) : 160,
|
|
1147
|
+
frameId
|
|
1148
|
+
};
|
|
1149
|
+
slideChildren.push(tableEl);
|
|
1150
|
+
});
|
|
1151
|
+
const picBlocks = findXmlBlocks(slideXml, "p:pic");
|
|
1152
|
+
picBlocks.forEach((picXml, picIdx) => {
|
|
1153
|
+
const embedMatch = /<a:blip\b[^>]*\br:embed="([^"]+)"/.exec(picXml);
|
|
1154
|
+
const mediaPath = embedMatch ? slideRels.get(embedMatch[1]) : void 0;
|
|
1155
|
+
const mediaBytes = mediaPath ? zipEntries.get(mediaPath) : void 0;
|
|
1156
|
+
let srcDataUrl = 'data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="240" height="160" viewBox="0 0 240 160"><rect width="240" height="160" rx="10" fill="%23EFF6FF"/><text x="120" y="86" text-anchor="middle" font-size="13" fill="%231D4ED8">PPTX Media</text></svg>';
|
|
1157
|
+
if (mediaPath && mediaBytes && mediaBytes.length > 0) {
|
|
1158
|
+
const mime = resolveMediaMimeType(mediaPath);
|
|
1159
|
+
srcDataUrl = `data:${mime};base64,${uint8ToBase64(mediaBytes)}`;
|
|
1160
|
+
}
|
|
1161
|
+
const xfrm = extractXfrmBox(picXml);
|
|
1162
|
+
const cNvPrMatch = /<p:cNvPr\b[^>]*\b(?:descr|name)="([^"]*)"/.exec(picXml);
|
|
1163
|
+
const caption = cNvPrMatch ? unescapeXml(cNvPrMatch[1]) : mediaPath?.split("/").pop();
|
|
1164
|
+
const imageEl = {
|
|
1165
|
+
id: `pptx-image-${slideIdx + 1}-${picIdx + 1}-${(0, import_core3.generateRandomId)(4)}`,
|
|
1166
|
+
type: "image",
|
|
1167
|
+
src: srcDataUrl,
|
|
1168
|
+
...caption ? { caption } : {},
|
|
1169
|
+
fit: "contain",
|
|
1170
|
+
x: xfrm ? toBoardX(xfrm.xEmu) : fx + pad + 40,
|
|
1171
|
+
y: xfrm ? toBoardY(xfrm.yEmu) : fy + headerH + 40,
|
|
1172
|
+
width: xfrm ? toBoardW(xfrm.cxEmu) : 240,
|
|
1173
|
+
height: xfrm ? toBoardH(xfrm.cyEmu) : 160,
|
|
1174
|
+
frameId
|
|
1175
|
+
};
|
|
1176
|
+
slideChildren.push(imageEl);
|
|
1177
|
+
});
|
|
1178
|
+
const cxnBlocks = findXmlBlocks(slideXml, "p:cxnSp");
|
|
1179
|
+
cxnBlocks.forEach((cxnXml, cxnIdx) => {
|
|
1180
|
+
const xfrm = extractXfrmBox(cxnXml);
|
|
1181
|
+
if (!xfrm) return;
|
|
1182
|
+
const xLeft = toBoardX(xfrm.xEmu);
|
|
1183
|
+
const yTop = toBoardY(xfrm.yEmu);
|
|
1184
|
+
const w = Math.max(4, Math.round(xfrm.cxEmu / slideWidthEmu * innerW));
|
|
1185
|
+
const h = Math.max(4, Math.round(xfrm.cyEmu / slideHeightEmu * innerH));
|
|
1186
|
+
const x1 = xfrm.flipH ? xLeft + w : xLeft;
|
|
1187
|
+
const x2 = xfrm.flipH ? xLeft : xLeft + w;
|
|
1188
|
+
const y1 = xfrm.flipV ? yTop + h : yTop;
|
|
1189
|
+
const y2 = xfrm.flipV ? yTop : yTop + h;
|
|
1190
|
+
const lnBlock = findXmlBlocks(cxnXml, "a:ln")[0] ?? "";
|
|
1191
|
+
const strokeMatch = /<a:srgbClr\b[^>]*\bval="([0-9a-fA-F]{6})"/.exec(lnBlock);
|
|
1192
|
+
const dashed = /<a:prstDash\b[^>]*\bval="(?:dash|sysDash|lgDash)"/.test(lnBlock);
|
|
1193
|
+
const hasStart = /<a:headEnd\b[^>]*\btype="(?!none)[^"]+"/.test(lnBlock);
|
|
1194
|
+
const hasEnd = /<a:tailEnd\b[^>]*\btype="(?!none)[^"]+"/.test(lnBlock);
|
|
1195
|
+
const isStraight = /<a:prstGeom\b[^>]*\bprst="straightConnector1"/.test(cxnXml);
|
|
1196
|
+
const connEl = {
|
|
1197
|
+
id: `pptx-conn-${slideIdx + 1}-${cxnIdx + 1}-${(0, import_core3.generateRandomId)(4)}`,
|
|
1198
|
+
type: "connector",
|
|
1199
|
+
routeType: isStraight ? "straight" : "orthogonal",
|
|
1200
|
+
from: { x: x1, y: y1 },
|
|
1201
|
+
to: { x: x2, y: y2 },
|
|
1202
|
+
stroke: strokeMatch ? `#${strokeMatch[1].toUpperCase()}` : "#475569",
|
|
1203
|
+
strokeWidth: 2,
|
|
1204
|
+
dashed,
|
|
1205
|
+
startMarker: hasStart ? "arrow" : "none",
|
|
1206
|
+
endMarker: hasEnd ? "arrow" : "none",
|
|
1207
|
+
x: Math.min(x1, x2),
|
|
1208
|
+
y: Math.min(y1, y2),
|
|
1209
|
+
width: Math.max(8, Math.abs(x2 - x1)),
|
|
1210
|
+
height: Math.max(8, Math.abs(y2 - y1)),
|
|
1211
|
+
frameId
|
|
1212
|
+
};
|
|
1213
|
+
slideChildren.push(connEl);
|
|
1214
|
+
});
|
|
1215
|
+
if (!slideTitle) {
|
|
1216
|
+
const firstTextChild = slideChildren.find(
|
|
1217
|
+
(c) => (c.type === "shape" || c.type === "text") && Boolean(c.text.trim())
|
|
1218
|
+
);
|
|
1219
|
+
slideTitle = firstTextChild ? firstTextChild.text.split(/\r?\n/)[0].slice(0, 36) : `\u5E7B\u706F\u7247 ${slideIdx + 1}`;
|
|
1220
|
+
}
|
|
1221
|
+
const strippedTitle = slideTitle.replace(/^\d+\s*[·.-]\s*/, "").trim() || `\u5E7B\u706F\u7247 ${slideIdx + 1}`;
|
|
1222
|
+
const numPrefix = String(slideIdx + 1).padStart(2, "0");
|
|
1223
|
+
frames.push({
|
|
1224
|
+
id: frameId,
|
|
1225
|
+
type: "frame",
|
|
1226
|
+
title: `${numPrefix} \xB7 ${strippedTitle}`,
|
|
1227
|
+
x: fx,
|
|
1228
|
+
y: fy,
|
|
1229
|
+
width: frameW,
|
|
1230
|
+
height: frameH,
|
|
1231
|
+
backgroundColor: "#FFFFFF",
|
|
1232
|
+
borderColor: "#93C5FD",
|
|
1233
|
+
metadata: {
|
|
1234
|
+
importedFrom: "pptx",
|
|
1235
|
+
slideIndex: slideIdx + 1
|
|
1236
|
+
}
|
|
1237
|
+
});
|
|
1238
|
+
childElements.push(...slideChildren);
|
|
1239
|
+
});
|
|
1240
|
+
return [...frames, ...childElements];
|
|
1241
|
+
}
|
|
1242
|
+
function decodePdfLiteralString(raw) {
|
|
1243
|
+
let out = "";
|
|
1244
|
+
for (let i = 0; i < raw.length; i += 1) {
|
|
1245
|
+
const ch = raw[i];
|
|
1246
|
+
if (ch !== "\\") {
|
|
1247
|
+
out += ch;
|
|
1248
|
+
continue;
|
|
1249
|
+
}
|
|
1250
|
+
i += 1;
|
|
1251
|
+
if (i >= raw.length) break;
|
|
1252
|
+
const next = raw[i];
|
|
1253
|
+
if (next === "n") out += "\n";
|
|
1254
|
+
else if (next === "r") out += "\r";
|
|
1255
|
+
else if (next === "t") out += " ";
|
|
1256
|
+
else if (next >= "0" && next <= "7") {
|
|
1257
|
+
let oct = next;
|
|
1258
|
+
if (i + 1 < raw.length && raw[i + 1] >= "0" && raw[i + 1] <= "7") {
|
|
1259
|
+
oct += raw[++i];
|
|
1260
|
+
if (i + 1 < raw.length && raw[i + 1] >= "0" && raw[i + 1] <= "7") {
|
|
1261
|
+
oct += raw[++i];
|
|
1262
|
+
}
|
|
1263
|
+
}
|
|
1264
|
+
out += String.fromCharCode(parseInt(oct, 8));
|
|
1265
|
+
} else {
|
|
1266
|
+
out += next;
|
|
1267
|
+
}
|
|
1268
|
+
}
|
|
1269
|
+
return out;
|
|
1270
|
+
}
|
|
1271
|
+
function decodePdfHexString(hexRaw) {
|
|
1272
|
+
const clean = hexRaw.replace(/\s+/g, "");
|
|
1273
|
+
if (clean.length === 0) return "";
|
|
1274
|
+
const padded = clean.length % 2 === 1 ? `${clean}0` : clean;
|
|
1275
|
+
if (padded.length >= 4 && padded.slice(0, 4).toUpperCase() === "FEFF") {
|
|
1276
|
+
let text2 = "";
|
|
1277
|
+
for (let i = 4; i + 3 < padded.length; i += 4) {
|
|
1278
|
+
const code = parseInt(padded.slice(i, i + 4), 16);
|
|
1279
|
+
if (code >= 32) text2 += String.fromCharCode(code);
|
|
1280
|
+
}
|
|
1281
|
+
return text2;
|
|
1282
|
+
}
|
|
1283
|
+
let text = "";
|
|
1284
|
+
for (let i = 0; i + 1 < padded.length; i += 2) {
|
|
1285
|
+
const byte = parseInt(padded.slice(i, i + 2), 16);
|
|
1286
|
+
if (byte >= 32 && byte <= 126) {
|
|
1287
|
+
text += String.fromCharCode(byte);
|
|
1288
|
+
} else if (byte >= 160 && byte <= 255) {
|
|
1289
|
+
text += String.fromCharCode(byte);
|
|
1290
|
+
}
|
|
1291
|
+
}
|
|
1292
|
+
return text;
|
|
1293
|
+
}
|
|
1294
|
+
function parsePdfContentStreamText(streamText) {
|
|
1295
|
+
const lines = [];
|
|
1296
|
+
const btRegex = /\bBT\b([\s\S]*?)\bET\b/g;
|
|
1297
|
+
const targetChunks = [];
|
|
1298
|
+
let btMatch;
|
|
1299
|
+
while ((btMatch = btRegex.exec(streamText)) !== null) {
|
|
1300
|
+
targetChunks.push(btMatch[1]);
|
|
1301
|
+
}
|
|
1302
|
+
if (targetChunks.length === 0) {
|
|
1303
|
+
targetChunks.push(streamText);
|
|
1304
|
+
}
|
|
1305
|
+
for (const chunk of targetChunks) {
|
|
1306
|
+
const opRegex = /\(((?:\\.|[^\\()])*)\)\s*Tj|<([0-9a-fA-F\s]+)>\s*Tj|\[((?:[\s\S]*?))\]\s*TJ/g;
|
|
1307
|
+
let m;
|
|
1308
|
+
while ((m = opRegex.exec(chunk)) !== null) {
|
|
1309
|
+
let extracted = "";
|
|
1310
|
+
if (m[1] !== void 0) {
|
|
1311
|
+
extracted = decodePdfLiteralString(m[1]);
|
|
1312
|
+
} else if (m[2] !== void 0) {
|
|
1313
|
+
extracted = decodePdfHexString(m[2]);
|
|
1314
|
+
} else if (m[3] !== void 0) {
|
|
1315
|
+
const arrBody = m[3];
|
|
1316
|
+
const parts = [];
|
|
1317
|
+
const subRegex = /\(((?:\\.|[^\\()])*)\)|<([0-9a-fA-F\s]+)>/g;
|
|
1318
|
+
let sm;
|
|
1319
|
+
while ((sm = subRegex.exec(arrBody)) !== null) {
|
|
1320
|
+
if (sm[1] !== void 0) parts.push(decodePdfLiteralString(sm[1]));
|
|
1321
|
+
else if (sm[2] !== void 0) parts.push(decodePdfHexString(sm[2]));
|
|
1322
|
+
}
|
|
1323
|
+
extracted = parts.join("");
|
|
1324
|
+
}
|
|
1325
|
+
const trimmed = extracted.replace(/\s+/g, " ").trim();
|
|
1326
|
+
if (trimmed) {
|
|
1327
|
+
lines.push(trimmed);
|
|
1328
|
+
}
|
|
1329
|
+
}
|
|
1330
|
+
}
|
|
1331
|
+
return lines.slice(0, 12);
|
|
1332
|
+
}
|
|
1333
|
+
async function extractPdfPageTextSnippets(pdfDoc, pageIndex) {
|
|
1334
|
+
try {
|
|
1335
|
+
const page = pdfDoc.getPages()[pageIndex];
|
|
1336
|
+
if (!page) return [];
|
|
1337
|
+
const rawContents = page.node.Contents();
|
|
1338
|
+
if (!rawContents) return [];
|
|
1339
|
+
const lookedUp = pdfDoc.context.lookup(rawContents);
|
|
1340
|
+
const refsOrStreams = lookedUp instanceof import_pdf_lib.PDFArray ? lookedUp.asArray() : [rawContents];
|
|
1341
|
+
const latin1 = new TextDecoder("latin1");
|
|
1342
|
+
const collected = [];
|
|
1343
|
+
for (const item of refsOrStreams) {
|
|
1344
|
+
const streamObj = pdfDoc.context.lookup(item);
|
|
1345
|
+
if (!(streamObj instanceof import_pdf_lib.PDFRawStream)) continue;
|
|
1346
|
+
const filterObj = streamObj.dict.get(import_pdf_lib.PDFName.of("Filter"));
|
|
1347
|
+
const filterStr = filterObj ? filterObj.toString() : "";
|
|
1348
|
+
let decodedBytes = null;
|
|
1349
|
+
if (!filterStr) {
|
|
1350
|
+
decodedBytes = streamObj.contents;
|
|
1351
|
+
} else if (filterStr.includes("FlateDecode")) {
|
|
1352
|
+
decodedBytes = await decompressBytesIfSupported(streamObj.contents, "deflate");
|
|
1353
|
+
}
|
|
1354
|
+
if (decodedBytes && decodedBytes.length > 0) {
|
|
1355
|
+
const contentStr = latin1.decode(decodedBytes);
|
|
1356
|
+
collected.push(...parsePdfContentStreamText(contentStr));
|
|
1357
|
+
}
|
|
1358
|
+
}
|
|
1359
|
+
return Array.from(new Set(collected)).slice(0, 10);
|
|
1360
|
+
} catch {
|
|
1361
|
+
return [];
|
|
1362
|
+
}
|
|
1363
|
+
}
|
|
1364
|
+
async function importPdfBytesToBoardElements(pdfBytes, options) {
|
|
1365
|
+
const pdfDoc = await import_pdf_lib.PDFDocument.load(pdfBytes, { ignoreEncryption: true });
|
|
1366
|
+
const pages = pdfDoc.getPages();
|
|
1367
|
+
if (pages.length === 0) return [];
|
|
1368
|
+
const docTitle = pdfDoc.getTitle()?.trim() || "PDF \u6587\u6863\u8BC4\u5BA1";
|
|
1369
|
+
const originX = options?.originX ?? 80;
|
|
1370
|
+
const originY = options?.originY ?? 80;
|
|
1371
|
+
const columns = Math.max(1, options?.columns ?? (pages.length <= 2 ? pages.length : 3));
|
|
1372
|
+
const gapX = options?.gapX ?? 56;
|
|
1373
|
+
const gapY = options?.gapY ?? 56;
|
|
1374
|
+
const headerH = 44;
|
|
1375
|
+
const pad = 20;
|
|
1376
|
+
const pageSpecs = pages.map((p) => {
|
|
1377
|
+
const { width, height } = p.getSize();
|
|
1378
|
+
const wPt = Math.max(72, Math.round(width || 595));
|
|
1379
|
+
const hPt = Math.max(72, Math.round(height || 842));
|
|
1380
|
+
const targetSheetW = options?.frameWidth ? Math.max(240, options.frameWidth - pad * 2) : wPt >= hPt ? 560 : 440;
|
|
1381
|
+
const scale = targetSheetW / wPt;
|
|
1382
|
+
const sheetW = Math.round(wPt * scale);
|
|
1383
|
+
const sheetH = Math.max(200, Math.round(hPt * scale));
|
|
1384
|
+
return {
|
|
1385
|
+
wPt,
|
|
1386
|
+
hPt,
|
|
1387
|
+
sheetW,
|
|
1388
|
+
sheetH,
|
|
1389
|
+
frameW: sheetW + pad * 2,
|
|
1390
|
+
frameH: headerH + sheetH + pad
|
|
1391
|
+
};
|
|
1392
|
+
});
|
|
1393
|
+
const cellW = Math.max(...pageSpecs.map((s) => s.frameW));
|
|
1394
|
+
const cellH = Math.max(...pageSpecs.map((s) => s.frameH));
|
|
1395
|
+
const frames = [];
|
|
1396
|
+
const children = [];
|
|
1397
|
+
for (let idx = 0; idx < pageSpecs.length; idx += 1) {
|
|
1398
|
+
const spec = pageSpecs[idx];
|
|
1399
|
+
const col = idx % columns;
|
|
1400
|
+
const row = Math.floor(idx / columns);
|
|
1401
|
+
const fx = originX + col * (cellW + gapX);
|
|
1402
|
+
const fy = originY + row * (cellH + gapY);
|
|
1403
|
+
const frameId = `frame-pdf-${idx + 1}-${(0, import_core3.generateRandomId)(5)}`;
|
|
1404
|
+
const frameTitle = `PDF \u7B2C ${idx + 1} \u9875 (${spec.wPt}\xD7${spec.hPt})`;
|
|
1405
|
+
frames.push({
|
|
1406
|
+
id: frameId,
|
|
1407
|
+
type: "frame",
|
|
1408
|
+
title: frameTitle,
|
|
1409
|
+
x: fx,
|
|
1410
|
+
y: fy,
|
|
1411
|
+
width: spec.frameW,
|
|
1412
|
+
height: spec.frameH,
|
|
1413
|
+
backgroundColor: "#F8FAFC",
|
|
1414
|
+
borderColor: "#94A3B8",
|
|
1415
|
+
metadata: {
|
|
1416
|
+
importedFrom: "pdf",
|
|
1417
|
+
pageNumber: idx + 1,
|
|
1418
|
+
pageWidthPt: spec.wPt,
|
|
1419
|
+
pageHeightPt: spec.hPt
|
|
1420
|
+
}
|
|
1421
|
+
});
|
|
1422
|
+
const snippets = await extractPdfPageTextSnippets(pdfDoc, idx);
|
|
1423
|
+
const sheetX = fx + pad;
|
|
1424
|
+
const sheetY = fy + headerH;
|
|
1425
|
+
const sheetCard = {
|
|
1426
|
+
id: `pdf-sheet-${idx + 1}-${(0, import_core3.generateRandomId)(4)}`,
|
|
1427
|
+
type: "shape",
|
|
1428
|
+
shapeType: "rect",
|
|
1429
|
+
text: snippets.length > 0 ? "" : `${docTitle}
|
|
1430
|
+
\u7B2C ${idx + 1} / ${pages.length} \u9875 (${spec.wPt}\xD7${spec.hPt} pt)
|
|
1431
|
+
\u5728\u6B64\u5904\u8D34\u4E0A\u4FBF\u7B7E\u6216\u753B\u7B14\u6279\u6CE8`,
|
|
1432
|
+
fill: "#FFFFFF",
|
|
1433
|
+
stroke: "#CBD5E1",
|
|
1434
|
+
strokeWidth: 1.5,
|
|
1435
|
+
textColor: "#64748B",
|
|
1436
|
+
fontSize: 12,
|
|
1437
|
+
x: sheetX,
|
|
1438
|
+
y: sheetY,
|
|
1439
|
+
width: spec.sheetW,
|
|
1440
|
+
height: spec.sheetH,
|
|
1441
|
+
frameId
|
|
1442
|
+
};
|
|
1443
|
+
children.push(sheetCard);
|
|
1444
|
+
if (snippets.length > 0) {
|
|
1445
|
+
const textEl = {
|
|
1446
|
+
id: `pdf-text-${idx + 1}-${(0, import_core3.generateRandomId)(4)}`,
|
|
1447
|
+
type: "text",
|
|
1448
|
+
text: snippets.join("\n"),
|
|
1449
|
+
fontSize: 13,
|
|
1450
|
+
fontWeight: "normal",
|
|
1451
|
+
color: "#1E293B",
|
|
1452
|
+
align: "left",
|
|
1453
|
+
x: sheetX + 20,
|
|
1454
|
+
y: sheetY + 20,
|
|
1455
|
+
width: Math.max(120, spec.sheetW - 40),
|
|
1456
|
+
height: Math.min(spec.sheetH - 40, Math.max(48, snippets.length * 24)),
|
|
1457
|
+
frameId
|
|
1458
|
+
};
|
|
1459
|
+
children.push(textEl);
|
|
1460
|
+
}
|
|
1461
|
+
}
|
|
1462
|
+
return [...frames, ...children];
|
|
1463
|
+
}
|
|
1464
|
+
async function importDeckOrPdfToBoardFrames(fileBytes, fileNameOrFormat, options) {
|
|
1465
|
+
if (!fileBytes || fileBytes.length < 4) return [];
|
|
1466
|
+
const hint = (fileNameOrFormat ?? "").trim().toLowerCase();
|
|
1467
|
+
const isPdfHeader = fileBytes[0] === 37 && fileBytes[1] === 80 && fileBytes[2] === 68 && fileBytes[3] === 70;
|
|
1468
|
+
const isZipHeader = fileBytes[0] === 80 && fileBytes[1] === 75 && (fileBytes[2] === 3 || fileBytes[2] === 5);
|
|
1469
|
+
if (hint === "pdf" || hint.endsWith(".pdf") || isPdfHeader && !hint.endsWith(".pptx")) {
|
|
1470
|
+
return await importPdfBytesToBoardElements(fileBytes, options);
|
|
1471
|
+
}
|
|
1472
|
+
if (hint === "pptx" || hint.endsWith(".pptx") || isZipHeader) {
|
|
1473
|
+
return await importPptxBytesToBoardElements(fileBytes, options);
|
|
1474
|
+
}
|
|
1475
|
+
if (isPdfHeader) {
|
|
1476
|
+
return await importPdfBytesToBoardElements(fileBytes, options);
|
|
1477
|
+
}
|
|
1478
|
+
return [];
|
|
1479
|
+
}
|
|
1480
|
+
|
|
1481
|
+
// src/mermaid/mermaid-codec.ts
|
|
1482
|
+
var import_core4 = require("@univerjs/core");
|
|
622
1483
|
|
|
623
1484
|
// src/engine/connector-router.ts
|
|
624
1485
|
var PORT_STUB_DISTANCE = 24;
|
|
@@ -1299,7 +2160,7 @@ function findNextFlowEdge(stmt, startIndex) {
|
|
|
1299
2160
|
return null;
|
|
1300
2161
|
}
|
|
1301
2162
|
function parseFlowchartDiagram(lines, options) {
|
|
1302
|
-
const prefix = options?.idPrefix || `mmf-${(0,
|
|
2163
|
+
const prefix = options?.idPrefix || `mmf-${(0, import_core4.generateRandomId)(4)}`;
|
|
1303
2164
|
const originX = options?.originX ?? 80;
|
|
1304
2165
|
const originY = options?.originY ?? 80;
|
|
1305
2166
|
let direction = options?.direction ?? "TD";
|
|
@@ -1673,7 +2534,7 @@ function parseFlowchartDiagram(lines, options) {
|
|
|
1673
2534
|
return [...frameElements, ...shapeElements, ...connectorElements];
|
|
1674
2535
|
}
|
|
1675
2536
|
function parseSequenceDiagram(lines, options) {
|
|
1676
|
-
const prefix = options?.idPrefix || `mms-${(0,
|
|
2537
|
+
const prefix = options?.idPrefix || `mms-${(0, import_core4.generateRandomId)(4)}`;
|
|
1677
2538
|
const originX = options?.originX ?? 80;
|
|
1678
2539
|
const originY = options?.originY ?? 80;
|
|
1679
2540
|
const participants = /* @__PURE__ */ new Map();
|
|
@@ -1947,7 +2808,7 @@ function mapUmlOperatorToMarkers(op) {
|
|
|
1947
2808
|
}
|
|
1948
2809
|
}
|
|
1949
2810
|
function parseClassDiagram(lines, options) {
|
|
1950
|
-
const prefix = options?.idPrefix || `mmc-${(0,
|
|
2811
|
+
const prefix = options?.idPrefix || `mmc-${(0, import_core4.generateRandomId)(4)}`;
|
|
1951
2812
|
const originX = options?.originX ?? 80;
|
|
1952
2813
|
const originY = options?.originY ?? 80;
|
|
1953
2814
|
const classes = /* @__PURE__ */ new Map();
|
|
@@ -2081,7 +2942,7 @@ function parseClassDiagram(lines, options) {
|
|
|
2081
2942
|
return [...cards, ...connectors];
|
|
2082
2943
|
}
|
|
2083
2944
|
function parseErDiagram(lines, options) {
|
|
2084
|
-
const prefix = options?.idPrefix || `mme-${(0,
|
|
2945
|
+
const prefix = options?.idPrefix || `mme-${(0, import_core4.generateRandomId)(4)}`;
|
|
2085
2946
|
const originX = options?.originX ?? 80;
|
|
2086
2947
|
const originY = options?.originY ?? 80;
|
|
2087
2948
|
const entities = /* @__PURE__ */ new Map();
|
|
@@ -2236,7 +3097,7 @@ function unwrapMindmapLabel(raw) {
|
|
|
2236
3097
|
return unquoteLabel(s);
|
|
2237
3098
|
}
|
|
2238
3099
|
function parseMindmapDiagram(lines, options) {
|
|
2239
|
-
const prefix = options?.idPrefix || `mmm-${(0,
|
|
3100
|
+
const prefix = options?.idPrefix || `mmm-${(0, import_core4.generateRandomId)(4)}`;
|
|
2240
3101
|
const originX = options?.originX ?? 340;
|
|
2241
3102
|
const originY = options?.originY ?? 220;
|
|
2242
3103
|
const rawNodes = [];
|
|
@@ -2671,14 +3532,17 @@ function exportBoardToMermaid(snapshot, options) {
|
|
|
2671
3532
|
}
|
|
2672
3533
|
|
|
2673
3534
|
// src/services/board-selection.service.ts
|
|
2674
|
-
var
|
|
3535
|
+
var import_core5 = require("@univerjs/core");
|
|
2675
3536
|
var import_rxjs = require("rxjs");
|
|
2676
|
-
var
|
|
3537
|
+
var SET_VIEWPORT_CMD_ID = "boards.command.set-viewport";
|
|
3538
|
+
var IBoardSelectionService = (0, import_core5.createIdentifier)(
|
|
2677
3539
|
"yudao.boards.selection-service"
|
|
2678
3540
|
);
|
|
2679
|
-
var BoardSelectionService = class extends
|
|
2680
|
-
constructor() {
|
|
2681
|
-
super(
|
|
3541
|
+
var BoardSelectionService = class extends import_core5.Disposable {
|
|
3542
|
+
constructor(_commandService, _univerInstanceService) {
|
|
3543
|
+
super();
|
|
3544
|
+
this._commandService = _commandService;
|
|
3545
|
+
this._univerInstanceService = _univerInstanceService;
|
|
2682
3546
|
this._selectedIds$ = new import_rxjs.BehaviorSubject([]);
|
|
2683
3547
|
this.selectedIds$ = this._selectedIds$.asObservable();
|
|
2684
3548
|
this._editingElementId$ = new import_rxjs.BehaviorSubject(null);
|
|
@@ -2691,6 +3555,10 @@ var BoardSelectionService = class extends import_core4.Disposable {
|
|
|
2691
3555
|
this.activeStickyColor$ = this._activeStickyColor$.asObservable();
|
|
2692
3556
|
this._mermaidModalOpen$ = new import_rxjs.BehaviorSubject(false);
|
|
2693
3557
|
this.mermaidModalOpen$ = this._mermaidModalOpen$.asObservable();
|
|
3558
|
+
this._votingModalOpen$ = new import_rxjs.BehaviorSubject(false);
|
|
3559
|
+
this.votingModalOpen$ = this._votingModalOpen$.asObservable();
|
|
3560
|
+
this._docImportModalOpen$ = new import_rxjs.BehaviorSubject(false);
|
|
3561
|
+
this.docImportModalOpen$ = this._docImportModalOpen$.asObservable();
|
|
2694
3562
|
this._presentation$ = new import_rxjs.BehaviorSubject({
|
|
2695
3563
|
active: false,
|
|
2696
3564
|
frameIndex: 0,
|
|
@@ -2703,6 +3571,16 @@ var BoardSelectionService = class extends import_core4.Disposable {
|
|
|
2703
3571
|
running: false
|
|
2704
3572
|
});
|
|
2705
3573
|
this.timer$ = this._timer$.asObservable();
|
|
3574
|
+
this._currentUserId$ = new import_rxjs.BehaviorSubject("user-local");
|
|
3575
|
+
this.currentUserId$ = this._currentUserId$.asObservable();
|
|
3576
|
+
this._currentUserName = "\u5F53\u524D\u6210\u5458";
|
|
3577
|
+
this._collaborators$ = new import_rxjs.BehaviorSubject([]);
|
|
3578
|
+
this.collaborators$ = this._collaborators$.asObservable();
|
|
3579
|
+
this._spotlight$ = new import_rxjs.BehaviorSubject({
|
|
3580
|
+
spotlightHostId: null,
|
|
3581
|
+
followingUserId: null
|
|
3582
|
+
});
|
|
3583
|
+
this.spotlight$ = this._spotlight$.asObservable();
|
|
2706
3584
|
}
|
|
2707
3585
|
dispose() {
|
|
2708
3586
|
super.dispose();
|
|
@@ -2712,8 +3590,13 @@ var BoardSelectionService = class extends import_core4.Disposable {
|
|
|
2712
3590
|
this._activeShapeType$.complete();
|
|
2713
3591
|
this._activeStickyColor$.complete();
|
|
2714
3592
|
this._mermaidModalOpen$.complete();
|
|
3593
|
+
this._votingModalOpen$.complete();
|
|
3594
|
+
this._docImportModalOpen$.complete();
|
|
2715
3595
|
this._presentation$.complete();
|
|
2716
3596
|
this._timer$.complete();
|
|
3597
|
+
this._currentUserId$.complete();
|
|
3598
|
+
this._collaborators$.complete();
|
|
3599
|
+
this._spotlight$.complete();
|
|
2717
3600
|
}
|
|
2718
3601
|
getSelectedIds() {
|
|
2719
3602
|
return [...this._selectedIds$.getValue()];
|
|
@@ -2765,6 +3648,18 @@ var BoardSelectionService = class extends import_core4.Disposable {
|
|
|
2765
3648
|
setMermaidModalOpen(open) {
|
|
2766
3649
|
this._mermaidModalOpen$.next(open);
|
|
2767
3650
|
}
|
|
3651
|
+
isVotingModalOpen() {
|
|
3652
|
+
return this._votingModalOpen$.getValue();
|
|
3653
|
+
}
|
|
3654
|
+
setVotingModalOpen(open) {
|
|
3655
|
+
this._votingModalOpen$.next(open);
|
|
3656
|
+
}
|
|
3657
|
+
isDocImportModalOpen() {
|
|
3658
|
+
return this._docImportModalOpen$.getValue();
|
|
3659
|
+
}
|
|
3660
|
+
setDocImportModalOpen(open) {
|
|
3661
|
+
this._docImportModalOpen$.next(open);
|
|
3662
|
+
}
|
|
2768
3663
|
getPresentationState() {
|
|
2769
3664
|
return { ...this._presentation$.getValue() };
|
|
2770
3665
|
}
|
|
@@ -2783,19 +3678,126 @@ var BoardSelectionService = class extends import_core4.Disposable {
|
|
|
2783
3678
|
...patch
|
|
2784
3679
|
});
|
|
2785
3680
|
}
|
|
3681
|
+
getCurrentUserId() {
|
|
3682
|
+
return this._currentUserId$.getValue();
|
|
3683
|
+
}
|
|
3684
|
+
getCurrentUserName() {
|
|
3685
|
+
return this._currentUserName;
|
|
3686
|
+
}
|
|
3687
|
+
setCurrentUserId(userId, userName) {
|
|
3688
|
+
if (userName) {
|
|
3689
|
+
this._currentUserName = userName;
|
|
3690
|
+
}
|
|
3691
|
+
this._currentUserId$.next(userId);
|
|
3692
|
+
this._syncViewportToActiveLeader();
|
|
3693
|
+
}
|
|
3694
|
+
getCollaborators() {
|
|
3695
|
+
return this._collaborators$.getValue().map((c) => ({
|
|
3696
|
+
...c,
|
|
3697
|
+
viewport: { ...c.viewport },
|
|
3698
|
+
...c.cursor ? { cursor: { ...c.cursor } } : {}
|
|
3699
|
+
}));
|
|
3700
|
+
}
|
|
3701
|
+
updateRemoteCollaborator(presence) {
|
|
3702
|
+
const normalized = {
|
|
3703
|
+
userId: presence.userId,
|
|
3704
|
+
userName: presence.userName,
|
|
3705
|
+
color: presence.color,
|
|
3706
|
+
viewport: { ...presence.viewport },
|
|
3707
|
+
...presence.cursor ? { cursor: { ...presence.cursor } } : {},
|
|
3708
|
+
updatedAt: presence.updatedAt ?? Date.now()
|
|
3709
|
+
};
|
|
3710
|
+
const current = this._collaborators$.getValue();
|
|
3711
|
+
const idx = current.findIndex((item) => item.userId === normalized.userId);
|
|
3712
|
+
const next = idx >= 0 ? current.map((item, i) => i === idx ? normalized : item) : [...current, normalized];
|
|
3713
|
+
this._collaborators$.next(next);
|
|
3714
|
+
this._syncViewportToActiveLeader();
|
|
3715
|
+
}
|
|
3716
|
+
removeRemoteCollaborator(userId) {
|
|
3717
|
+
const current = this._collaborators$.getValue();
|
|
3718
|
+
if (current.some((c) => c.userId === userId)) {
|
|
3719
|
+
this._collaborators$.next(current.filter((c) => c.userId !== userId));
|
|
3720
|
+
}
|
|
3721
|
+
const spot = this._spotlight$.getValue();
|
|
3722
|
+
if (spot.followingUserId === userId || spot.spotlightHostId === userId) {
|
|
3723
|
+
this._spotlight$.next({
|
|
3724
|
+
spotlightHostId: spot.spotlightHostId === userId ? null : spot.spotlightHostId,
|
|
3725
|
+
followingUserId: spot.followingUserId === userId ? null : spot.followingUserId
|
|
3726
|
+
});
|
|
3727
|
+
}
|
|
3728
|
+
}
|
|
3729
|
+
getSpotlightState() {
|
|
3730
|
+
return { ...this._spotlight$.getValue() };
|
|
3731
|
+
}
|
|
3732
|
+
setFollowingUser(userId) {
|
|
3733
|
+
this._spotlight$.next({
|
|
3734
|
+
...this._spotlight$.getValue(),
|
|
3735
|
+
followingUserId: userId
|
|
3736
|
+
});
|
|
3737
|
+
this._syncViewportToActiveLeader();
|
|
3738
|
+
}
|
|
3739
|
+
setSpotlightHost(hostUserId) {
|
|
3740
|
+
const current = this._spotlight$.getValue();
|
|
3741
|
+
this._spotlight$.next({
|
|
3742
|
+
spotlightHostId: hostUserId,
|
|
3743
|
+
followingUserId: hostUserId ? null : current.followingUserId
|
|
3744
|
+
});
|
|
3745
|
+
this._syncViewportToActiveLeader();
|
|
3746
|
+
}
|
|
3747
|
+
resolveEffectiveViewport(localViewport) {
|
|
3748
|
+
const leader = this._resolveActiveLeader();
|
|
3749
|
+
if (leader) {
|
|
3750
|
+
return { ...leader.viewport };
|
|
3751
|
+
}
|
|
3752
|
+
return { ...localViewport };
|
|
3753
|
+
}
|
|
3754
|
+
_resolveActiveLeader() {
|
|
3755
|
+
const { followingUserId, spotlightHostId } = this._spotlight$.getValue();
|
|
3756
|
+
const myId = this._currentUserId$.getValue();
|
|
3757
|
+
const collaborators = this._collaborators$.getValue();
|
|
3758
|
+
if (followingUserId && followingUserId !== myId) {
|
|
3759
|
+
const target = collaborators.find((c) => c.userId === followingUserId);
|
|
3760
|
+
if (target) return target;
|
|
3761
|
+
}
|
|
3762
|
+
if (spotlightHostId && spotlightHostId !== myId) {
|
|
3763
|
+
const host = collaborators.find((c) => c.userId === spotlightHostId);
|
|
3764
|
+
if (host) return host;
|
|
3765
|
+
}
|
|
3766
|
+
return void 0;
|
|
3767
|
+
}
|
|
3768
|
+
_syncViewportToActiveLeader() {
|
|
3769
|
+
const leader = this._resolveActiveLeader();
|
|
3770
|
+
if (!leader || !this._commandService || !this._univerInstanceService) {
|
|
3771
|
+
return;
|
|
3772
|
+
}
|
|
3773
|
+
const activeUnit = this._univerInstanceService.getCurrentUnitOfType(
|
|
3774
|
+
import_core5.UniverInstanceType.UNIVER_BOARD
|
|
3775
|
+
);
|
|
3776
|
+
if (!activeUnit) {
|
|
3777
|
+
return;
|
|
3778
|
+
}
|
|
3779
|
+
this._commandService.syncExecuteCommand(SET_VIEWPORT_CMD_ID, {
|
|
3780
|
+
unitId: activeUnit.getUnitId(),
|
|
3781
|
+
viewport: { ...leader.viewport }
|
|
3782
|
+
});
|
|
3783
|
+
}
|
|
2786
3784
|
};
|
|
3785
|
+
BoardSelectionService = __decorateClass([
|
|
3786
|
+
__decorateParam(0, (0, import_core5.Optional)(import_core5.ICommandService)),
|
|
3787
|
+
__decorateParam(1, (0, import_core5.Optional)(import_core5.IUniverInstanceService))
|
|
3788
|
+
], BoardSelectionService);
|
|
2787
3789
|
|
|
2788
3790
|
// src/commands/mutations/board.mutation.ts
|
|
2789
|
-
var
|
|
3791
|
+
var import_core6 = require("@univerjs/core");
|
|
2790
3792
|
var ApplyBoardSnapshotMutation = {
|
|
2791
3793
|
id: "boards.mutation.apply-snapshot",
|
|
2792
|
-
type:
|
|
3794
|
+
type: import_core6.CommandType.MUTATION,
|
|
2793
3795
|
handler: (accessor, params) => {
|
|
2794
3796
|
if (!params?.unitId || !params.snapshot) return false;
|
|
2795
|
-
const instanceService = accessor.get(
|
|
3797
|
+
const instanceService = accessor.get(import_core6.IUniverInstanceService);
|
|
2796
3798
|
const unit = instanceService.getUnit(
|
|
2797
3799
|
params.unitId,
|
|
2798
|
-
|
|
3800
|
+
import_core6.UniverInstanceType.UNIVER_BOARD
|
|
2799
3801
|
);
|
|
2800
3802
|
if (!unit) return false;
|
|
2801
3803
|
unit.__applySnapshot(params.snapshot);
|
|
@@ -2804,13 +3806,13 @@ var ApplyBoardSnapshotMutation = {
|
|
|
2804
3806
|
};
|
|
2805
3807
|
var SetBoardViewportMutation = {
|
|
2806
3808
|
id: "boards.mutation.set-viewport",
|
|
2807
|
-
type:
|
|
3809
|
+
type: import_core6.CommandType.MUTATION,
|
|
2808
3810
|
handler: (accessor, params) => {
|
|
2809
3811
|
if (!params?.unitId || !params.viewport) return false;
|
|
2810
|
-
const instanceService = accessor.get(
|
|
3812
|
+
const instanceService = accessor.get(import_core6.IUniverInstanceService);
|
|
2811
3813
|
const unit = instanceService.getUnit(
|
|
2812
3814
|
params.unitId,
|
|
2813
|
-
|
|
3815
|
+
import_core6.UniverInstanceType.UNIVER_BOARD
|
|
2814
3816
|
);
|
|
2815
3817
|
if (!unit) return false;
|
|
2816
3818
|
unit.__setViewport(params.viewport);
|
|
@@ -2820,13 +3822,13 @@ var SetBoardViewportMutation = {
|
|
|
2820
3822
|
|
|
2821
3823
|
// src/commands/commands/board.command.ts
|
|
2822
3824
|
function resolveBoardUnit(accessor, explicitUnitId) {
|
|
2823
|
-
const instanceService = accessor.get(
|
|
2824
|
-
const resolved = explicitUnitId ? instanceService.getUnit(explicitUnitId,
|
|
3825
|
+
const instanceService = accessor.get(import_core7.IUniverInstanceService);
|
|
3826
|
+
const resolved = explicitUnitId ? instanceService.getUnit(explicitUnitId, import_core7.UniverInstanceType.UNIVER_BOARD) : instanceService.getCurrentUnitOfType(import_core7.UniverInstanceType.UNIVER_BOARD);
|
|
2825
3827
|
return resolved ?? null;
|
|
2826
3828
|
}
|
|
2827
3829
|
function commitUndoableSnapshot(accessor, unit, beforeSnapshot, afterSnapshot) {
|
|
2828
|
-
const commandService = accessor.get(
|
|
2829
|
-
const undoRedoService = accessor.get(
|
|
3830
|
+
const commandService = accessor.get(import_core7.ICommandService);
|
|
3831
|
+
const undoRedoService = accessor.get(import_core7.IUndoRedoService);
|
|
2830
3832
|
const unitId = unit.getUnitId();
|
|
2831
3833
|
const ok = commandService.syncExecuteCommand(ApplyBoardSnapshotMutation.id, {
|
|
2832
3834
|
unitId,
|
|
@@ -2853,7 +3855,7 @@ function commitUndoableSnapshot(accessor, unit, beforeSnapshot, afterSnapshot) {
|
|
|
2853
3855
|
}
|
|
2854
3856
|
var AddBoardElementsCommand = {
|
|
2855
3857
|
id: "boards.command.add-elements",
|
|
2856
|
-
type:
|
|
3858
|
+
type: import_core7.CommandType.COMMAND,
|
|
2857
3859
|
handler: (accessor, params) => {
|
|
2858
3860
|
const unit = resolveBoardUnit(accessor, params?.unitId);
|
|
2859
3861
|
if (!unit) return false;
|
|
@@ -2892,7 +3894,7 @@ var AddBoardElementsCommand = {
|
|
|
2892
3894
|
};
|
|
2893
3895
|
var UpdateBoardElementsCommand = {
|
|
2894
3896
|
id: "boards.command.update-elements",
|
|
2895
|
-
type:
|
|
3897
|
+
type: import_core7.CommandType.COMMAND,
|
|
2896
3898
|
handler: (accessor, params) => {
|
|
2897
3899
|
if (!params?.updates?.length) return false;
|
|
2898
3900
|
const unit = resolveBoardUnit(accessor, params.unitId);
|
|
@@ -2904,12 +3906,12 @@ var UpdateBoardElementsCommand = {
|
|
|
2904
3906
|
const existing = afterSnapshot.elements[item.id];
|
|
2905
3907
|
if (!existing) continue;
|
|
2906
3908
|
if (item.element) {
|
|
2907
|
-
afterSnapshot.elements[item.id] =
|
|
3909
|
+
afterSnapshot.elements[item.id] = import_core7.Tools.deepClone(item.element);
|
|
2908
3910
|
changed = true;
|
|
2909
3911
|
} else if (item.patch) {
|
|
2910
3912
|
afterSnapshot.elements[item.id] = {
|
|
2911
3913
|
...existing,
|
|
2912
|
-
...
|
|
3914
|
+
...import_core7.Tools.deepClone(item.patch),
|
|
2913
3915
|
id: existing.id,
|
|
2914
3916
|
type: existing.type
|
|
2915
3917
|
};
|
|
@@ -2922,7 +3924,7 @@ var UpdateBoardElementsCommand = {
|
|
|
2922
3924
|
};
|
|
2923
3925
|
var DeleteBoardElementsCommand = {
|
|
2924
3926
|
id: "boards.command.delete-elements",
|
|
2925
|
-
type:
|
|
3927
|
+
type: import_core7.CommandType.COMMAND,
|
|
2926
3928
|
handler: (accessor, params) => {
|
|
2927
3929
|
const unit = resolveBoardUnit(accessor, params?.unitId);
|
|
2928
3930
|
if (!unit) return false;
|
|
@@ -2976,7 +3978,7 @@ var DeleteBoardElementsCommand = {
|
|
|
2976
3978
|
};
|
|
2977
3979
|
var AlignBoardElementsCommand = {
|
|
2978
3980
|
id: "boards.command.align-elements",
|
|
2979
|
-
type:
|
|
3981
|
+
type: import_core7.CommandType.COMMAND,
|
|
2980
3982
|
handler: (accessor, params) => {
|
|
2981
3983
|
const unit = resolveBoardUnit(accessor, params?.unitId);
|
|
2982
3984
|
if (!unit) return false;
|
|
@@ -3029,7 +4031,7 @@ var AlignBoardElementsCommand = {
|
|
|
3029
4031
|
};
|
|
3030
4032
|
var GroupBoardElementsInFrameCommand = {
|
|
3031
4033
|
id: "boards.command.group-in-frame",
|
|
3032
|
-
type:
|
|
4034
|
+
type: import_core7.CommandType.COMMAND,
|
|
3033
4035
|
handler: (accessor, params) => {
|
|
3034
4036
|
const unit = resolveBoardUnit(accessor, params?.unitId);
|
|
3035
4037
|
if (!unit) return false;
|
|
@@ -3050,7 +4052,7 @@ var GroupBoardElementsInFrameCommand = {
|
|
|
3050
4052
|
}
|
|
3051
4053
|
const pad = params?.padding ?? 32;
|
|
3052
4054
|
const topHeader = 48;
|
|
3053
|
-
const frameId = params?.frameId || `frame-${(0,
|
|
4055
|
+
const frameId = params?.frameId || `frame-${(0, import_core7.generateRandomId)(6)}`;
|
|
3054
4056
|
const frameIndex = afterSnapshot.frameOrder.length + 1;
|
|
3055
4057
|
const frame = {
|
|
3056
4058
|
id: frameId,
|
|
@@ -3098,7 +4100,7 @@ function findRootMindmapId(nodeId, elements) {
|
|
|
3098
4100
|
}
|
|
3099
4101
|
var AddMindmapChildCommand = {
|
|
3100
4102
|
id: "boards.command.add-mindmap-child",
|
|
3101
|
-
type:
|
|
4103
|
+
type: import_core7.CommandType.COMMAND,
|
|
3102
4104
|
handler: (accessor, params) => {
|
|
3103
4105
|
const unit = resolveBoardUnit(accessor, params?.unitId);
|
|
3104
4106
|
if (!unit) return false;
|
|
@@ -3113,7 +4115,7 @@ var AddMindmapChildCommand = {
|
|
|
3113
4115
|
const existingChildren = Object.values(afterSnapshot.elements).filter(
|
|
3114
4116
|
(el) => el.type === "mindmap" && el.parentId === parentId
|
|
3115
4117
|
);
|
|
3116
|
-
const childId = params?.id || `mindmap-${(0,
|
|
4118
|
+
const childId = params?.id || `mindmap-${(0, import_core7.generateRandomId)(6)}`;
|
|
3117
4119
|
const color = !parent.parentId ? MINDMAP_BRANCH_PALETTE[existingChildren.length % MINDMAP_BRANCH_PALETTE.length] : parent.branchColor || "#2563EB";
|
|
3118
4120
|
const child = {
|
|
3119
4121
|
id: childId,
|
|
@@ -3144,7 +4146,7 @@ var AddMindmapChildCommand = {
|
|
|
3144
4146
|
};
|
|
3145
4147
|
var AddMindmapSiblingCommand = {
|
|
3146
4148
|
id: "boards.command.add-mindmap-sibling",
|
|
3147
|
-
type:
|
|
4149
|
+
type: import_core7.CommandType.COMMAND,
|
|
3148
4150
|
handler: (accessor, params) => {
|
|
3149
4151
|
const unit = resolveBoardUnit(accessor, params?.unitId);
|
|
3150
4152
|
if (!unit) return false;
|
|
@@ -3154,7 +4156,7 @@ var AddMindmapSiblingCommand = {
|
|
|
3154
4156
|
const node = unit.getElement(nodeId);
|
|
3155
4157
|
if (!node || node.type !== "mindmap") return false;
|
|
3156
4158
|
const targetParentId = node.parentId ?? node.id;
|
|
3157
|
-
return accessor.get(
|
|
4159
|
+
return accessor.get(import_core7.ICommandService).syncExecuteCommand(AddMindmapChildCommand.id, {
|
|
3158
4160
|
unitId: unit.getUnitId(),
|
|
3159
4161
|
parentId: targetParentId,
|
|
3160
4162
|
text: params?.text ?? "\u540C\u7EA7\u4E3B\u9898",
|
|
@@ -3164,7 +4166,7 @@ var AddMindmapSiblingCommand = {
|
|
|
3164
4166
|
};
|
|
3165
4167
|
var LayoutBoardMindmapCommand = {
|
|
3166
4168
|
id: "boards.command.layout-mindmap",
|
|
3167
|
-
type:
|
|
4169
|
+
type: import_core7.CommandType.COMMAND,
|
|
3168
4170
|
handler: (accessor, params) => {
|
|
3169
4171
|
const unit = resolveBoardUnit(accessor, params?.unitId);
|
|
3170
4172
|
if (!unit) return false;
|
|
@@ -3179,7 +4181,7 @@ var LayoutBoardMindmapCommand = {
|
|
|
3179
4181
|
};
|
|
3180
4182
|
var VoteBoardStickyCommand = {
|
|
3181
4183
|
id: "boards.command.vote-sticky",
|
|
3182
|
-
type:
|
|
4184
|
+
type: import_core7.CommandType.COMMAND,
|
|
3183
4185
|
handler: (accessor, params) => {
|
|
3184
4186
|
if (!params?.elementId) return false;
|
|
3185
4187
|
const unit = resolveBoardUnit(accessor, params.unitId);
|
|
@@ -3205,7 +4207,7 @@ var VoteBoardStickyCommand = {
|
|
|
3205
4207
|
};
|
|
3206
4208
|
var ImportMermaidToBoardCommand = {
|
|
3207
4209
|
id: "boards.command.import-mermaid",
|
|
3208
|
-
type:
|
|
4210
|
+
type: import_core7.CommandType.COMMAND,
|
|
3209
4211
|
handler: (accessor, params) => {
|
|
3210
4212
|
if (!params?.mermaidCode?.trim()) return false;
|
|
3211
4213
|
const unit = resolveBoardUnit(accessor, params.unitId);
|
|
@@ -3252,7 +4254,7 @@ var ImportMermaidToBoardCommand = {
|
|
|
3252
4254
|
};
|
|
3253
4255
|
var SetBoardViewportCommand = {
|
|
3254
4256
|
id: "boards.command.set-viewport",
|
|
3255
|
-
type:
|
|
4257
|
+
type: import_core7.CommandType.COMMAND,
|
|
3256
4258
|
handler: (accessor, params) => {
|
|
3257
4259
|
const unit = resolveBoardUnit(accessor, params?.unitId);
|
|
3258
4260
|
if (!unit) return false;
|
|
@@ -3262,7 +4264,7 @@ var SetBoardViewportCommand = {
|
|
|
3262
4264
|
...params?.panY !== void 0 ? { panY: params.panY } : {},
|
|
3263
4265
|
...params?.zoom !== void 0 ? { zoom: params.zoom } : {}
|
|
3264
4266
|
};
|
|
3265
|
-
return accessor.get(
|
|
4267
|
+
return accessor.get(import_core7.ICommandService).syncExecuteCommand(SetBoardViewportMutation.id, {
|
|
3266
4268
|
unitId: unit.getUnitId(),
|
|
3267
4269
|
viewport: patch
|
|
3268
4270
|
});
|
|
@@ -3270,7 +4272,7 @@ var SetBoardViewportCommand = {
|
|
|
3270
4272
|
};
|
|
3271
4273
|
var AddBoardCommentCommand = {
|
|
3272
4274
|
id: "boards.command.add-comment",
|
|
3273
|
-
type:
|
|
4275
|
+
type: import_core7.CommandType.COMMAND,
|
|
3274
4276
|
handler: (accessor, params) => {
|
|
3275
4277
|
if (!params || typeof params.x !== "number" || typeof params.y !== "number") return false;
|
|
3276
4278
|
const unit = resolveBoardUnit(accessor, params.unitId);
|
|
@@ -3278,7 +4280,7 @@ var AddBoardCommentCommand = {
|
|
|
3278
4280
|
const beforeSnapshot = unit.save();
|
|
3279
4281
|
const afterSnapshot = unit.save();
|
|
3280
4282
|
const comment = {
|
|
3281
|
-
id: params.id || `comment-${(0,
|
|
4283
|
+
id: params.id || `comment-${(0, import_core7.generateRandomId)(6)}`,
|
|
3282
4284
|
x: Math.round(params.x),
|
|
3283
4285
|
y: Math.round(params.y),
|
|
3284
4286
|
author: params.author ?? "\u534F\u4F5C\u6210\u5458",
|
|
@@ -3292,20 +4294,20 @@ var AddBoardCommentCommand = {
|
|
|
3292
4294
|
};
|
|
3293
4295
|
var ReplaceBoardSnapshotCommand = {
|
|
3294
4296
|
id: "boards.command.replace-snapshot",
|
|
3295
|
-
type:
|
|
4297
|
+
type: import_core7.CommandType.COMMAND,
|
|
3296
4298
|
handler: (accessor, params) => {
|
|
3297
4299
|
if (!params?.snapshot) return false;
|
|
3298
4300
|
const unit = resolveBoardUnit(accessor, params.unitId);
|
|
3299
4301
|
if (!unit) return false;
|
|
3300
4302
|
const beforeSnapshot = unit.save();
|
|
3301
|
-
const afterSnapshot =
|
|
4303
|
+
const afterSnapshot = import_core7.Tools.deepClone(params.snapshot);
|
|
3302
4304
|
afterSnapshot.id = unit.getUnitId();
|
|
3303
4305
|
return commitUndoableSnapshot(accessor, unit, beforeSnapshot, afterSnapshot);
|
|
3304
4306
|
}
|
|
3305
4307
|
};
|
|
3306
4308
|
var UpdateBoardPropsCommand = {
|
|
3307
4309
|
id: "boards.command.update-props",
|
|
3308
|
-
type:
|
|
4310
|
+
type: import_core7.CommandType.COMMAND,
|
|
3309
4311
|
handler: (accessor, params) => {
|
|
3310
4312
|
if (!params?.patch) return false;
|
|
3311
4313
|
const unit = resolveBoardUnit(accessor, params.unitId);
|
|
@@ -3330,19 +4332,233 @@ var UpdateBoardPropsCommand = {
|
|
|
3330
4332
|
...params.patch.viewport
|
|
3331
4333
|
};
|
|
3332
4334
|
}
|
|
4335
|
+
if (params.patch.brainstorm !== void 0) {
|
|
4336
|
+
if (params.patch.brainstorm === null) {
|
|
4337
|
+
delete afterSnapshot.brainstorm;
|
|
4338
|
+
} else {
|
|
4339
|
+
afterSnapshot.brainstorm = import_core7.Tools.deepClone(params.patch.brainstorm);
|
|
4340
|
+
}
|
|
4341
|
+
}
|
|
4342
|
+
if (params.patch.votingSession !== void 0) {
|
|
4343
|
+
if (params.patch.votingSession === null) {
|
|
4344
|
+
delete afterSnapshot.votingSession;
|
|
4345
|
+
} else {
|
|
4346
|
+
afterSnapshot.votingSession = import_core7.Tools.deepClone(params.patch.votingSession);
|
|
4347
|
+
}
|
|
4348
|
+
}
|
|
3333
4349
|
return commitUndoableSnapshot(accessor, unit, beforeSnapshot, afterSnapshot);
|
|
3334
4350
|
}
|
|
3335
4351
|
};
|
|
4352
|
+
var StartPrivateBrainstormCommand = {
|
|
4353
|
+
id: "boards.command.start-private-brainstorm",
|
|
4354
|
+
type: import_core7.CommandType.COMMAND,
|
|
4355
|
+
handler: (accessor, params) => {
|
|
4356
|
+
const unit = resolveBoardUnit(accessor, params?.unitId);
|
|
4357
|
+
if (!unit) return false;
|
|
4358
|
+
const beforeSnapshot = unit.save();
|
|
4359
|
+
const afterSnapshot = unit.save();
|
|
4360
|
+
const defaultFacilitator = accessor.has(IBoardSelectionService) ? accessor.get(IBoardSelectionService).getCurrentUserId() : void 0;
|
|
4361
|
+
const facilitatorId = params?.facilitatorId ?? defaultFacilitator;
|
|
4362
|
+
afterSnapshot.brainstorm = {
|
|
4363
|
+
active: true,
|
|
4364
|
+
hideAuthorNames: params?.hideAuthorNames ?? false,
|
|
4365
|
+
revealed: false,
|
|
4366
|
+
...facilitatorId ? { facilitatorId } : {}
|
|
4367
|
+
};
|
|
4368
|
+
return commitUndoableSnapshot(accessor, unit, beforeSnapshot, afterSnapshot);
|
|
4369
|
+
}
|
|
4370
|
+
};
|
|
4371
|
+
var RevealPrivateBrainstormCommand = {
|
|
4372
|
+
id: "boards.command.reveal-private-brainstorm",
|
|
4373
|
+
type: import_core7.CommandType.COMMAND,
|
|
4374
|
+
handler: (accessor, params) => {
|
|
4375
|
+
const unit = resolveBoardUnit(accessor, params?.unitId);
|
|
4376
|
+
if (!unit) return false;
|
|
4377
|
+
const beforeSnapshot = unit.save();
|
|
4378
|
+
const afterSnapshot = unit.save();
|
|
4379
|
+
afterSnapshot.brainstorm = {
|
|
4380
|
+
...afterSnapshot.brainstorm ?? { active: true },
|
|
4381
|
+
revealed: true
|
|
4382
|
+
};
|
|
4383
|
+
return commitUndoableSnapshot(accessor, unit, beforeSnapshot, afterSnapshot);
|
|
4384
|
+
}
|
|
4385
|
+
};
|
|
4386
|
+
var StopPrivateBrainstormCommand = {
|
|
4387
|
+
id: "boards.command.stop-private-brainstorm",
|
|
4388
|
+
type: import_core7.CommandType.COMMAND,
|
|
4389
|
+
handler: (accessor, params) => {
|
|
4390
|
+
const unit = resolveBoardUnit(accessor, params?.unitId);
|
|
4391
|
+
if (!unit) return false;
|
|
4392
|
+
const beforeSnapshot = unit.save();
|
|
4393
|
+
const afterSnapshot = unit.save();
|
|
4394
|
+
afterSnapshot.brainstorm = {
|
|
4395
|
+
...afterSnapshot.brainstorm ?? {},
|
|
4396
|
+
active: false,
|
|
4397
|
+
revealed: true
|
|
4398
|
+
};
|
|
4399
|
+
return commitUndoableSnapshot(accessor, unit, beforeSnapshot, afterSnapshot);
|
|
4400
|
+
}
|
|
4401
|
+
};
|
|
4402
|
+
var StartBoardVotingSessionCommand = {
|
|
4403
|
+
id: "boards.command.start-voting-session",
|
|
4404
|
+
type: import_core7.CommandType.COMMAND,
|
|
4405
|
+
handler: (accessor, params) => {
|
|
4406
|
+
const unit = resolveBoardUnit(accessor, params?.unitId);
|
|
4407
|
+
if (!unit) return false;
|
|
4408
|
+
const beforeSnapshot = unit.save();
|
|
4409
|
+
const afterSnapshot = unit.save();
|
|
4410
|
+
const maxVotesPerUser = Math.max(1, Math.floor(params?.maxVotesPerUser ?? 5));
|
|
4411
|
+
if (params?.resetExistingStickyVotes) {
|
|
4412
|
+
for (const el of Object.values(afterSnapshot.elements)) {
|
|
4413
|
+
if (el.type === "sticky") {
|
|
4414
|
+
el.votes = [];
|
|
4415
|
+
}
|
|
4416
|
+
}
|
|
4417
|
+
}
|
|
4418
|
+
afterSnapshot.votingSession = {
|
|
4419
|
+
id: params?.id || `voting-${(0, import_core7.generateRandomId)(6)}`,
|
|
4420
|
+
title: params?.title?.trim() || "\u56E2\u961F\u65B9\u6848\u4F18\u5148\u7EA7\u6295\u7968",
|
|
4421
|
+
active: true,
|
|
4422
|
+
maxVotesPerUser,
|
|
4423
|
+
allowMultiplePerSticky: params?.allowMultiplePerSticky ?? true,
|
|
4424
|
+
...params?.targetFrameId ? { targetFrameId: params.targetFrameId } : {},
|
|
4425
|
+
votesByUser: {},
|
|
4426
|
+
startedAt: params?.startedAt ?? (/* @__PURE__ */ new Date()).toISOString()
|
|
4427
|
+
};
|
|
4428
|
+
return commitUndoableSnapshot(accessor, unit, beforeSnapshot, afterSnapshot);
|
|
4429
|
+
}
|
|
4430
|
+
};
|
|
4431
|
+
var CastBoardSessionVoteCommand = {
|
|
4432
|
+
id: "boards.command.cast-session-vote",
|
|
4433
|
+
type: import_core7.CommandType.COMMAND,
|
|
4434
|
+
handler: (accessor, params) => {
|
|
4435
|
+
if (!params?.elementId) return false;
|
|
4436
|
+
const unit = resolveBoardUnit(accessor, params.unitId);
|
|
4437
|
+
if (!unit) return false;
|
|
4438
|
+
const beforeSnapshot = unit.save();
|
|
4439
|
+
const afterSnapshot = unit.save();
|
|
4440
|
+
const session = afterSnapshot.votingSession;
|
|
4441
|
+
if (!session || !session.active) return false;
|
|
4442
|
+
const sticky = afterSnapshot.elements[params.elementId];
|
|
4443
|
+
if (!sticky || sticky.type !== "sticky") return false;
|
|
4444
|
+
if (session.targetFrameId) {
|
|
4445
|
+
const targetFrame = afterSnapshot.elements[session.targetFrameId];
|
|
4446
|
+
if (targetFrame && targetFrame.type === "frame") {
|
|
4447
|
+
const cx = sticky.x + sticky.width / 2;
|
|
4448
|
+
const cy = sticky.y + sticky.height / 2;
|
|
4449
|
+
const insideFrame = sticky.frameId === targetFrame.id || cx >= targetFrame.x && cx <= targetFrame.x + targetFrame.width && cy >= targetFrame.y && cy <= targetFrame.y + targetFrame.height;
|
|
4450
|
+
if (!insideFrame) return false;
|
|
4451
|
+
}
|
|
4452
|
+
}
|
|
4453
|
+
const voterId = params.voterId || (accessor.has(IBoardSelectionService) ? accessor.get(IBoardSelectionService).getCurrentUserId() : "anonymous");
|
|
4454
|
+
const userVotes = session.votesByUser[voterId] ?? (session.votesByUser[voterId] = []);
|
|
4455
|
+
if (params.unvote) {
|
|
4456
|
+
const lastVoteIdx = userVotes.lastIndexOf(params.elementId);
|
|
4457
|
+
if (lastVoteIdx === -1) return false;
|
|
4458
|
+
userVotes.splice(lastVoteIdx, 1);
|
|
4459
|
+
for (let i = sticky.votes.length - 1; i >= 0; i -= 1) {
|
|
4460
|
+
if (sticky.votes[i] === voterId || sticky.votes[i].startsWith(`${voterId}#`)) {
|
|
4461
|
+
sticky.votes.splice(i, 1);
|
|
4462
|
+
break;
|
|
4463
|
+
}
|
|
4464
|
+
}
|
|
4465
|
+
return commitUndoableSnapshot(accessor, unit, beforeSnapshot, afterSnapshot);
|
|
4466
|
+
}
|
|
4467
|
+
if (userVotes.length >= session.maxVotesPerUser) {
|
|
4468
|
+
return false;
|
|
4469
|
+
}
|
|
4470
|
+
if (session.allowMultiplePerSticky === false && userVotes.includes(params.elementId)) {
|
|
4471
|
+
return false;
|
|
4472
|
+
}
|
|
4473
|
+
userVotes.push(params.elementId);
|
|
4474
|
+
if (!sticky.votes.includes(voterId)) {
|
|
4475
|
+
sticky.votes.push(voterId);
|
|
4476
|
+
} else {
|
|
4477
|
+
const countOnSticky = userVotes.filter((id) => id === params.elementId).length;
|
|
4478
|
+
sticky.votes.push(`${voterId}#${countOnSticky}`);
|
|
4479
|
+
}
|
|
4480
|
+
return commitUndoableSnapshot(accessor, unit, beforeSnapshot, afterSnapshot);
|
|
4481
|
+
}
|
|
4482
|
+
};
|
|
4483
|
+
var EndBoardVotingSessionCommand = {
|
|
4484
|
+
id: "boards.command.end-voting-session",
|
|
4485
|
+
type: import_core7.CommandType.COMMAND,
|
|
4486
|
+
handler: (accessor, params) => {
|
|
4487
|
+
const unit = resolveBoardUnit(accessor, params?.unitId);
|
|
4488
|
+
if (!unit) return false;
|
|
4489
|
+
const beforeSnapshot = unit.save();
|
|
4490
|
+
const afterSnapshot = unit.save();
|
|
4491
|
+
if (!afterSnapshot.votingSession) return false;
|
|
4492
|
+
afterSnapshot.votingSession = {
|
|
4493
|
+
...afterSnapshot.votingSession,
|
|
4494
|
+
active: false,
|
|
4495
|
+
endedAt: params?.endedAt ?? (/* @__PURE__ */ new Date()).toISOString()
|
|
4496
|
+
};
|
|
4497
|
+
return commitUndoableSnapshot(accessor, unit, beforeSnapshot, afterSnapshot);
|
|
4498
|
+
}
|
|
4499
|
+
};
|
|
4500
|
+
var ImportDocumentPagesToBoardCommand = {
|
|
4501
|
+
id: "boards.command.import-document-pages",
|
|
4502
|
+
type: import_core7.CommandType.COMMAND,
|
|
4503
|
+
handler: async (accessor, params) => {
|
|
4504
|
+
if (!params?.fileBytes || params.fileBytes.length === 0) return false;
|
|
4505
|
+
const unit = resolveBoardUnit(accessor, params.unitId);
|
|
4506
|
+
if (!unit) return false;
|
|
4507
|
+
const parsedElements = await importDeckOrPdfToBoardFrames(
|
|
4508
|
+
params.fileBytes,
|
|
4509
|
+
params.format ?? params.fileName,
|
|
4510
|
+
{
|
|
4511
|
+
originX: params.originX ?? 80,
|
|
4512
|
+
originY: params.originY ?? 80,
|
|
4513
|
+
columns: params.columns
|
|
4514
|
+
}
|
|
4515
|
+
);
|
|
4516
|
+
if (parsedElements.length === 0) return false;
|
|
4517
|
+
const beforeSnapshot = unit.save();
|
|
4518
|
+
const afterSnapshot = unit.save();
|
|
4519
|
+
if (params.replaceExisting) {
|
|
4520
|
+
afterSnapshot.elements = {};
|
|
4521
|
+
afterSnapshot.elementOrder = [];
|
|
4522
|
+
afterSnapshot.frameOrder = [];
|
|
4523
|
+
}
|
|
4524
|
+
const importedFrameIds = [];
|
|
4525
|
+
for (const el of parsedElements) {
|
|
4526
|
+
afterSnapshot.elements[el.id] = el;
|
|
4527
|
+
afterSnapshot.elementOrder = afterSnapshot.elementOrder.filter((id) => id !== el.id);
|
|
4528
|
+
if (el.type === "frame") {
|
|
4529
|
+
const firstNonFrame = afterSnapshot.elementOrder.findIndex(
|
|
4530
|
+
(id) => afterSnapshot.elements[id]?.type !== "frame"
|
|
4531
|
+
);
|
|
4532
|
+
if (firstNonFrame === -1) {
|
|
4533
|
+
afterSnapshot.elementOrder.push(el.id);
|
|
4534
|
+
} else {
|
|
4535
|
+
afterSnapshot.elementOrder.splice(firstNonFrame, 0, el.id);
|
|
4536
|
+
}
|
|
4537
|
+
if (!afterSnapshot.frameOrder.includes(el.id)) {
|
|
4538
|
+
afterSnapshot.frameOrder.push(el.id);
|
|
4539
|
+
}
|
|
4540
|
+
importedFrameIds.push(el.id);
|
|
4541
|
+
} else {
|
|
4542
|
+
afterSnapshot.elementOrder.push(el.id);
|
|
4543
|
+
}
|
|
4544
|
+
}
|
|
4545
|
+
const ok = commitUndoableSnapshot(accessor, unit, beforeSnapshot, afterSnapshot);
|
|
4546
|
+
if (ok && accessor.has(IBoardSelectionService) && importedFrameIds.length > 0) {
|
|
4547
|
+
accessor.get(IBoardSelectionService).selectElements(importedFrameIds);
|
|
4548
|
+
}
|
|
4549
|
+
return ok;
|
|
4550
|
+
}
|
|
4551
|
+
};
|
|
3336
4552
|
|
|
3337
4553
|
// src/models/board-unit-model.ts
|
|
3338
|
-
var
|
|
4554
|
+
var import_core9 = require("@univerjs/core");
|
|
3339
4555
|
var import_rxjs2 = require("rxjs");
|
|
3340
4556
|
|
|
3341
4557
|
// src/presets/board-presets.ts
|
|
3342
|
-
var
|
|
4558
|
+
var import_core8 = require("@univerjs/core");
|
|
3343
4559
|
function createDefaultBoardUnitData(partial) {
|
|
3344
|
-
const id = partial?.id || `board-${(0,
|
|
3345
|
-
const rawElements = partial?.elements ?
|
|
4560
|
+
const id = partial?.id || `board-${(0, import_core8.generateRandomId)(6)}`;
|
|
4561
|
+
const rawElements = partial?.elements ? import_core8.Tools.deepClone(partial.elements) : {};
|
|
3346
4562
|
const elementOrder = partial?.elementOrder ? [...partial.elementOrder] : Object.keys(rawElements);
|
|
3347
4563
|
const frameOrder = partial?.frameOrder ? [...partial.frameOrder] : elementOrder.filter((eid) => rawElements[eid]?.type === "frame");
|
|
3348
4564
|
return {
|
|
@@ -3356,7 +4572,9 @@ function createDefaultBoardUnitData(partial) {
|
|
|
3356
4572
|
elementOrder,
|
|
3357
4573
|
elements: rawElements,
|
|
3358
4574
|
frameOrder,
|
|
3359
|
-
comments: partial?.comments ?
|
|
4575
|
+
comments: partial?.comments ? import_core8.Tools.deepClone(partial.comments) : [],
|
|
4576
|
+
...partial?.brainstorm ? { brainstorm: import_core8.Tools.deepClone(partial.brainstorm) } : {},
|
|
4577
|
+
...partial?.votingSession ? { votingSession: import_core8.Tools.deepClone(partial.votingSession) } : {}
|
|
3360
4578
|
};
|
|
3361
4579
|
}
|
|
3362
4580
|
function createSampleArchitectureBoardData(partial) {
|
|
@@ -3807,6 +5025,7 @@ function createSampleArchitectureBoardData(partial) {
|
|
|
3807
5025
|
text: "\u7F51\u5173\u7070\u5EA6\u81EA\u52A8\u5316\u53D1\u5E03\u96F6\u6545\u969C\u5B8C\u6210",
|
|
3808
5026
|
color: "green",
|
|
3809
5027
|
author: "\u6797\u5DE5",
|
|
5028
|
+
authorId: "user-lin",
|
|
3810
5029
|
votes: ["u1", "u2", "u3"],
|
|
3811
5030
|
tags: ["DevOps"],
|
|
3812
5031
|
x: 936,
|
|
@@ -3821,6 +5040,7 @@ function createSampleArchitectureBoardData(partial) {
|
|
|
3821
5040
|
text: "\u5927\u4FC3\u538B\u6D4B\u6162 SQL \u9700\u63D0\u524D\u4E00\u5468\u5DE1\u68C0",
|
|
3822
5041
|
color: "yellow",
|
|
3823
5042
|
author: "\u9648\u5DE5",
|
|
5043
|
+
authorId: "user-chen",
|
|
3824
5044
|
votes: ["u1", "u4"],
|
|
3825
5045
|
tags: ["DBA"],
|
|
3826
5046
|
x: 1086,
|
|
@@ -3835,6 +5055,7 @@ function createSampleArchitectureBoardData(partial) {
|
|
|
3835
5055
|
text: "\u63A5\u5165 Mermaid \u4EE3\u7801\u4E00\u952E\u751F\u6210\u67B6\u6784\u56FE\u6587\u6863",
|
|
3836
5056
|
color: "blue",
|
|
3837
5057
|
author: "\u5468\u5DE5",
|
|
5058
|
+
authorId: "user-zhou",
|
|
3838
5059
|
votes: ["u1", "u2", "u3", "u4", "u5"],
|
|
3839
5060
|
tags: ["P0"],
|
|
3840
5061
|
x: 1236,
|
|
@@ -3892,10 +5113,10 @@ function createSampleArchitectureBoardData(partial) {
|
|
|
3892
5113
|
}
|
|
3893
5114
|
|
|
3894
5115
|
// src/models/board-unit-model.ts
|
|
3895
|
-
var BoardUnitModel = class extends
|
|
5116
|
+
var BoardUnitModel = class extends import_core9.UnitModel {
|
|
3896
5117
|
constructor(snapshot) {
|
|
3897
5118
|
super();
|
|
3898
|
-
this.type =
|
|
5119
|
+
this.type = import_core9.UniverInstanceType.UNIVER_BOARD;
|
|
3899
5120
|
this._snapshotChanged$ = new import_rxjs2.Subject();
|
|
3900
5121
|
this.snapshotChanged$ = this._snapshotChanged$.asObservable();
|
|
3901
5122
|
this._snapshot = createDefaultBoardUnitData(snapshot);
|
|
@@ -3923,7 +5144,7 @@ var BoardUnitModel = class extends import_core8.UnitModel {
|
|
|
3923
5144
|
return this._snapshot;
|
|
3924
5145
|
}
|
|
3925
5146
|
save() {
|
|
3926
|
-
return
|
|
5147
|
+
return import_core9.Tools.deepClone(this._snapshot);
|
|
3927
5148
|
}
|
|
3928
5149
|
getRev() {
|
|
3929
5150
|
return this._snapshot.rev;
|
|
@@ -3994,13 +5215,19 @@ var BoardUnitModel = class extends import_core8.UnitModel {
|
|
|
3994
5215
|
});
|
|
3995
5216
|
}
|
|
3996
5217
|
getComments() {
|
|
3997
|
-
return
|
|
5218
|
+
return import_core9.Tools.deepClone(this._snapshot.comments);
|
|
5219
|
+
}
|
|
5220
|
+
getBrainstormConfig() {
|
|
5221
|
+
return this._snapshot.brainstorm ? import_core9.Tools.deepClone(this._snapshot.brainstorm) : void 0;
|
|
5222
|
+
}
|
|
5223
|
+
getVotingSession() {
|
|
5224
|
+
return this._snapshot.votingSession ? import_core9.Tools.deepClone(this._snapshot.votingSession) : void 0;
|
|
3998
5225
|
}
|
|
3999
5226
|
/** Internal synchronous mutators called exclusively by registered IMutation handlers */
|
|
4000
5227
|
__applySnapshot(nextSnapshot) {
|
|
4001
5228
|
const prevUnitId = this._snapshot.id;
|
|
4002
5229
|
const normalized = createDefaultBoardUnitData({
|
|
4003
|
-
...
|
|
5230
|
+
...import_core9.Tools.deepClone(nextSnapshot),
|
|
4004
5231
|
id: prevUnitId
|
|
4005
5232
|
});
|
|
4006
5233
|
const prevName = this._snapshot.name;
|
|
@@ -4013,7 +5240,7 @@ var BoardUnitModel = class extends import_core8.UnitModel {
|
|
|
4013
5240
|
}
|
|
4014
5241
|
__addElements(elements, insertAtBack = false) {
|
|
4015
5242
|
for (const raw of elements) {
|
|
4016
|
-
const el =
|
|
5243
|
+
const el = import_core9.Tools.deepClone(raw);
|
|
4017
5244
|
this._snapshot.elements[el.id] = el;
|
|
4018
5245
|
this._snapshot.elementOrder = this._snapshot.elementOrder.filter((id) => id !== el.id);
|
|
4019
5246
|
if (el.type === "frame" || insertAtBack) {
|
|
@@ -4038,7 +5265,7 @@ var BoardUnitModel = class extends import_core8.UnitModel {
|
|
|
4038
5265
|
__updateElements(updates) {
|
|
4039
5266
|
for (const item of updates) {
|
|
4040
5267
|
if (this._snapshot.elements[item.id]) {
|
|
4041
|
-
this._snapshot.elements[item.id] =
|
|
5268
|
+
this._snapshot.elements[item.id] = import_core9.Tools.deepClone(item.element);
|
|
4042
5269
|
}
|
|
4043
5270
|
}
|
|
4044
5271
|
this.incrementRev();
|
|
@@ -4094,11 +5321,25 @@ var BoardUnitModel = class extends import_core8.UnitModel {
|
|
|
4094
5321
|
if (patch.elementOrder !== void 0) {
|
|
4095
5322
|
this._snapshot.elementOrder = [...patch.elementOrder];
|
|
4096
5323
|
}
|
|
5324
|
+
if (patch.brainstorm !== void 0) {
|
|
5325
|
+
if (patch.brainstorm === null) {
|
|
5326
|
+
delete this._snapshot.brainstorm;
|
|
5327
|
+
} else {
|
|
5328
|
+
this._snapshot.brainstorm = import_core9.Tools.deepClone(patch.brainstorm);
|
|
5329
|
+
}
|
|
5330
|
+
}
|
|
5331
|
+
if (patch.votingSession !== void 0) {
|
|
5332
|
+
if (patch.votingSession === null) {
|
|
5333
|
+
delete this._snapshot.votingSession;
|
|
5334
|
+
} else {
|
|
5335
|
+
this._snapshot.votingSession = import_core9.Tools.deepClone(patch.votingSession);
|
|
5336
|
+
}
|
|
5337
|
+
}
|
|
4097
5338
|
this.incrementRev();
|
|
4098
5339
|
this._notifyChange();
|
|
4099
5340
|
}
|
|
4100
5341
|
__setComments(comments) {
|
|
4101
|
-
this._snapshot.comments =
|
|
5342
|
+
this._snapshot.comments = import_core9.Tools.deepClone(comments);
|
|
4102
5343
|
this.incrementRev();
|
|
4103
5344
|
this._notifyChange();
|
|
4104
5345
|
}
|
|
@@ -4108,11 +5349,11 @@ var BoardUnitModel = class extends import_core8.UnitModel {
|
|
|
4108
5349
|
};
|
|
4109
5350
|
|
|
4110
5351
|
// src/services/board-io.service.ts
|
|
4111
|
-
var
|
|
5352
|
+
var import_core11 = require("@univerjs/core");
|
|
4112
5353
|
var import_rxjs3 = require("rxjs");
|
|
4113
5354
|
|
|
4114
5355
|
// src/exporter/board-csv-exporter.ts
|
|
4115
|
-
var
|
|
5356
|
+
var import_core10 = require("@univerjs/core");
|
|
4116
5357
|
var STICKY_COLORS_CYCLE = [
|
|
4117
5358
|
"yellow",
|
|
4118
5359
|
"blue",
|
|
@@ -4252,7 +5493,7 @@ function importCsvToBoardStickies(csvText, options) {
|
|
|
4252
5493
|
const PAD_X = 32;
|
|
4253
5494
|
const PAD_TOP = 54;
|
|
4254
5495
|
const PAD_BOTTOM = 32;
|
|
4255
|
-
const frameId = `frame-csv-${(0,
|
|
5496
|
+
const frameId = `frame-csv-${(0, import_core10.generateRandomId)(5)}`;
|
|
4256
5497
|
const stickies = [];
|
|
4257
5498
|
dataRows.forEach((r, idx) => {
|
|
4258
5499
|
const col = idx % cols;
|
|
@@ -4265,7 +5506,7 @@ function importCsvToBoardStickies(csvText, options) {
|
|
|
4265
5506
|
const votes = Array.from({ length: Math.min(50, voteNum) }, (_, vIdx) => `csv-voter-${vIdx + 1}`);
|
|
4266
5507
|
const tags = tagsCol >= 0 && r[tagsCol]?.trim() ? r[tagsCol].split(/[;|]/).map((t) => t.trim()).filter(Boolean) : void 0;
|
|
4267
5508
|
stickies.push({
|
|
4268
|
-
id: `sticky-csv-${(0,
|
|
5509
|
+
id: `sticky-csv-${(0, import_core10.generateRandomId)(5)}`,
|
|
4269
5510
|
type: "sticky",
|
|
4270
5511
|
text: primaryText,
|
|
4271
5512
|
color,
|
|
@@ -4296,7 +5537,7 @@ function importCsvToBoardStickies(csvText, options) {
|
|
|
4296
5537
|
}
|
|
4297
5538
|
|
|
4298
5539
|
// src/exporter/board-pdf-exporter.ts
|
|
4299
|
-
var
|
|
5540
|
+
var import_pdf_lib2 = require("pdf-lib");
|
|
4300
5541
|
|
|
4301
5542
|
// src/exporter/board-svg-exporter.ts
|
|
4302
5543
|
function escapeXml(raw) {
|
|
@@ -4873,21 +6114,21 @@ function exportBoardToSvg(snapshot, options) {
|
|
|
4873
6114
|
|
|
4874
6115
|
// src/exporter/board-pdf-exporter.ts
|
|
4875
6116
|
function parseHexRgb(color, fallback = { r: 0.97, g: 0.98, b: 0.99 }) {
|
|
4876
|
-
if (!color) return (0,
|
|
6117
|
+
if (!color) return (0, import_pdf_lib2.rgb)(fallback.r, fallback.g, fallback.b);
|
|
4877
6118
|
const hex = color.trim().replace(/^#/, "");
|
|
4878
6119
|
if (/^[0-9a-fA-F]{6}$/.test(hex)) {
|
|
4879
6120
|
const r = parseInt(hex.slice(0, 2), 16) / 255;
|
|
4880
6121
|
const g = parseInt(hex.slice(2, 4), 16) / 255;
|
|
4881
6122
|
const b = parseInt(hex.slice(4, 6), 16) / 255;
|
|
4882
|
-
return (0,
|
|
6123
|
+
return (0, import_pdf_lib2.rgb)(r, g, b);
|
|
4883
6124
|
}
|
|
4884
6125
|
if (/^[0-9a-fA-F]{3}$/.test(hex)) {
|
|
4885
6126
|
const r = parseInt(hex[0] + hex[0], 16) / 255;
|
|
4886
6127
|
const g = parseInt(hex[1] + hex[1], 16) / 255;
|
|
4887
6128
|
const b = parseInt(hex[2] + hex[2], 16) / 255;
|
|
4888
|
-
return (0,
|
|
6129
|
+
return (0, import_pdf_lib2.rgb)(r, g, b);
|
|
4889
6130
|
}
|
|
4890
|
-
return (0,
|
|
6131
|
+
return (0, import_pdf_lib2.rgb)(fallback.r, fallback.g, fallback.b);
|
|
4891
6132
|
}
|
|
4892
6133
|
function toWinAnsiSafe(raw) {
|
|
4893
6134
|
if (!raw) return "";
|
|
@@ -5055,7 +6296,7 @@ function renderElementsToPdfPage(page, bounds, elements, snapshot, fontRegular,
|
|
|
5055
6296
|
y: toPdfY(el.y, el.height),
|
|
5056
6297
|
width: el.width,
|
|
5057
6298
|
height: el.height,
|
|
5058
|
-
color: (0,
|
|
6299
|
+
color: (0, import_pdf_lib2.rgb)(1, 1, 1),
|
|
5059
6300
|
borderColor: parseHexRgb("#CBD5E1"),
|
|
5060
6301
|
borderWidth: 1.2
|
|
5061
6302
|
});
|
|
@@ -5098,7 +6339,7 @@ function renderElementsToPdfPage(page, bounds, elements, snapshot, fontRegular,
|
|
|
5098
6339
|
y: toPdfY(el.y, el.height),
|
|
5099
6340
|
width: el.width,
|
|
5100
6341
|
height: el.height,
|
|
5101
|
-
color: (0,
|
|
6342
|
+
color: (0, import_pdf_lib2.rgb)(1, 1, 1),
|
|
5102
6343
|
borderColor: parseHexRgb("#94A3B8"),
|
|
5103
6344
|
borderWidth: 1.2
|
|
5104
6345
|
});
|
|
@@ -5209,11 +6450,11 @@ function renderElementsToPdfPage(page, bounds, elements, snapshot, fontRegular,
|
|
|
5209
6450
|
}
|
|
5210
6451
|
}
|
|
5211
6452
|
async function exportBoardToPdfBytes(snapshot, options) {
|
|
5212
|
-
const pdfDoc = await
|
|
6453
|
+
const pdfDoc = await import_pdf_lib2.PDFDocument.create();
|
|
5213
6454
|
pdfDoc.setTitle(toWinAnsiSafe(snapshot.name || "Univer Board") || "Univer Board");
|
|
5214
6455
|
pdfDoc.setCreator("Univer Boards");
|
|
5215
|
-
const fontRegular = await pdfDoc.embedFont(
|
|
5216
|
-
const fontBold = await pdfDoc.embedFont(
|
|
6456
|
+
const fontRegular = await pdfDoc.embedFont(import_pdf_lib2.StandardFonts.Helvetica);
|
|
6457
|
+
const fontBold = await pdfDoc.embedFont(import_pdf_lib2.StandardFonts.HelveticaBold);
|
|
5217
6458
|
const orderedElements = (snapshot.elementOrder.length ? snapshot.elementOrder : Object.keys(snapshot.elements)).map((id) => snapshot.elements[id]).filter((el) => Boolean(el && !el.hidden));
|
|
5218
6459
|
const useFramesMode = (options?.mode === "frames" || options?.perFrame === true) && !options?.frameId;
|
|
5219
6460
|
if (options?.frameId) {
|
|
@@ -5907,8 +7148,8 @@ async function exportBoardToRasterDataUrl(snapshot, format = "png", scale = 2) {
|
|
|
5907
7148
|
}
|
|
5908
7149
|
|
|
5909
7150
|
// src/services/board-io.service.ts
|
|
5910
|
-
var IBoardIoService = (0,
|
|
5911
|
-
var BoardIoService = class extends
|
|
7151
|
+
var IBoardIoService = (0, import_core11.createIdentifier)("yudao.boards.io-service");
|
|
7152
|
+
var BoardIoService = class extends import_core11.Disposable {
|
|
5912
7153
|
constructor() {
|
|
5913
7154
|
super(...arguments);
|
|
5914
7155
|
this._adapter = { name: "pure-ts-default" };
|
|
@@ -5985,11 +7226,20 @@ var BoardIoService = class extends import_core10.Disposable {
|
|
|
5985
7226
|
importCsvStickies(csvText, options) {
|
|
5986
7227
|
return importCsvToBoardStickies(csvText, options);
|
|
5987
7228
|
}
|
|
7229
|
+
async importPptx(pptxBytes, options) {
|
|
7230
|
+
return await importPptxBytesToBoardElements(pptxBytes, options);
|
|
7231
|
+
}
|
|
7232
|
+
async importPdf(pdfBytes, options) {
|
|
7233
|
+
return await importPdfBytesToBoardElements(pdfBytes, options);
|
|
7234
|
+
}
|
|
7235
|
+
async importDocumentFrames(fileBytes, fileNameOrFormat, options) {
|
|
7236
|
+
return await importDeckOrPdfToBoardFrames(fileBytes, fileNameOrFormat, options);
|
|
7237
|
+
}
|
|
5988
7238
|
};
|
|
5989
7239
|
|
|
5990
7240
|
// src/plugin.ts
|
|
5991
7241
|
var UNIVER_BOARDS_PLUGIN_NAME = "UNIVER_BOARDS_PLUGIN";
|
|
5992
|
-
var UniverBoardsPlugin = class extends
|
|
7242
|
+
var UniverBoardsPlugin = class extends import_core12.Plugin {
|
|
5993
7243
|
constructor(_config = {}, _injector, _univerInstanceService, _commandService) {
|
|
5994
7244
|
super();
|
|
5995
7245
|
this._config = _config;
|
|
@@ -6006,11 +7256,11 @@ var UniverBoardsPlugin = class extends import_core11.Plugin {
|
|
|
6006
7256
|
onStarting() {
|
|
6007
7257
|
this.disposeWithMe(
|
|
6008
7258
|
this._univerInstanceService.registerCtorForType(
|
|
6009
|
-
|
|
7259
|
+
import_core12.UniverInstanceType.UNIVER_BOARD,
|
|
6010
7260
|
BoardUnitModel
|
|
6011
7261
|
)
|
|
6012
7262
|
);
|
|
6013
|
-
const focusSub = this._univerInstanceService.getCurrentTypeOfUnit$(
|
|
7263
|
+
const focusSub = this._univerInstanceService.getCurrentTypeOfUnit$(import_core12.UniverInstanceType.UNIVER_BOARD).subscribe((unit) => {
|
|
6014
7264
|
if (unit && this._univerInstanceService.getFocusedUnit()?.getUnitId() !== unit.getUnitId()) {
|
|
6015
7265
|
this._univerInstanceService.focusUnit(unit.getUnitId());
|
|
6016
7266
|
}
|
|
@@ -6042,7 +7292,14 @@ var UniverBoardsPlugin = class extends import_core11.Plugin {
|
|
|
6042
7292
|
SetBoardViewportCommand,
|
|
6043
7293
|
AddBoardCommentCommand,
|
|
6044
7294
|
ReplaceBoardSnapshotCommand,
|
|
6045
|
-
UpdateBoardPropsCommand
|
|
7295
|
+
UpdateBoardPropsCommand,
|
|
7296
|
+
StartPrivateBrainstormCommand,
|
|
7297
|
+
RevealPrivateBrainstormCommand,
|
|
7298
|
+
StopPrivateBrainstormCommand,
|
|
7299
|
+
StartBoardVotingSessionCommand,
|
|
7300
|
+
CastBoardSessionVoteCommand,
|
|
7301
|
+
EndBoardVotingSessionCommand,
|
|
7302
|
+
ImportDocumentPagesToBoardCommand
|
|
6046
7303
|
];
|
|
6047
7304
|
for (const cmd of commands) {
|
|
6048
7305
|
this.disposeWithMe(this._commandService.registerCommand(cmd));
|
|
@@ -6050,13 +7307,13 @@ var UniverBoardsPlugin = class extends import_core11.Plugin {
|
|
|
6050
7307
|
}
|
|
6051
7308
|
};
|
|
6052
7309
|
UniverBoardsPlugin = __decorateClass([
|
|
6053
|
-
__decorateParam(1, (0,
|
|
6054
|
-
__decorateParam(2,
|
|
6055
|
-
__decorateParam(3,
|
|
7310
|
+
__decorateParam(1, (0, import_core12.Inject)(import_core12.Injector)),
|
|
7311
|
+
__decorateParam(2, import_core12.IUniverInstanceService),
|
|
7312
|
+
__decorateParam(3, import_core12.ICommandService)
|
|
6056
7313
|
], UniverBoardsPlugin);
|
|
6057
7314
|
|
|
6058
7315
|
// src/index.ts
|
|
6059
|
-
var VERSION = "1.6.
|
|
7316
|
+
var VERSION = "1.6.219";
|
|
6060
7317
|
// Annotate the CommonJS export names for ESM import in node:
|
|
6061
7318
|
0 && (module.exports = {
|
|
6062
7319
|
AddBoardCommentCommand,
|
|
@@ -6069,17 +7326,24 @@ var VERSION = "1.6.218";
|
|
|
6069
7326
|
BoardIoService,
|
|
6070
7327
|
BoardSelectionService,
|
|
6071
7328
|
BoardUnitModel,
|
|
7329
|
+
CastBoardSessionVoteCommand,
|
|
6072
7330
|
DeleteBoardElementsCommand,
|
|
7331
|
+
EndBoardVotingSessionCommand,
|
|
6073
7332
|
GroupBoardElementsInFrameCommand,
|
|
6074
7333
|
IBoardIoService,
|
|
6075
7334
|
IBoardSelectionService,
|
|
7335
|
+
ImportDocumentPagesToBoardCommand,
|
|
6076
7336
|
ImportMermaidToBoardCommand,
|
|
6077
7337
|
LayoutBoardMindmapCommand,
|
|
6078
7338
|
MERMAID_PRESET_TEMPLATES,
|
|
6079
7339
|
MINDMAP_BRANCH_PALETTE,
|
|
6080
7340
|
ReplaceBoardSnapshotCommand,
|
|
7341
|
+
RevealPrivateBrainstormCommand,
|
|
6081
7342
|
SetBoardViewportCommand,
|
|
6082
7343
|
SetBoardViewportMutation,
|
|
7344
|
+
StartBoardVotingSessionCommand,
|
|
7345
|
+
StartPrivateBrainstormCommand,
|
|
7346
|
+
StopPrivateBrainstormCommand,
|
|
6083
7347
|
UNIVER_BOARDS_PLUGIN_NAME,
|
|
6084
7348
|
UniverBoardsPlugin,
|
|
6085
7349
|
UpdateBoardElementsCommand,
|
|
@@ -6089,6 +7353,7 @@ var VERSION = "1.6.218";
|
|
|
6089
7353
|
buildShapeSvgPath,
|
|
6090
7354
|
computeBoardBounds,
|
|
6091
7355
|
computeBoardConnectorPath,
|
|
7356
|
+
computeBoardVotingLeaderboard,
|
|
6092
7357
|
createDefaultBoardElement,
|
|
6093
7358
|
createDefaultBoardUnitData,
|
|
6094
7359
|
createSampleArchitectureBoardData,
|
|
@@ -6103,7 +7368,11 @@ var VERSION = "1.6.218";
|
|
|
6103
7368
|
getElementPortPoint,
|
|
6104
7369
|
getMindmapDescendantIds,
|
|
6105
7370
|
importCsvToBoardStickies,
|
|
7371
|
+
importDeckOrPdfToBoardFrames,
|
|
7372
|
+
importPdfBytesToBoardElements,
|
|
7373
|
+
importPptxBytesToBoardElements,
|
|
6106
7374
|
isMindmapNodeCollapsedHidden,
|
|
7375
|
+
isStickyMaskedForViewer,
|
|
6107
7376
|
layoutBoardMindmap,
|
|
6108
7377
|
parseMermaidToBoardElements,
|
|
6109
7378
|
parseRfc4180Csv,
|