@file-viewer/renderer-mindmap 2.1.1 → 2.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/xmind.js +26 -25
- package/package.json +2 -2
package/dist/xmind.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import JSZip from 'jszip';
|
|
2
2
|
import Panzoom, {} from '@panzoom/panzoom';
|
|
3
3
|
import { parseXmind8Xml, parseXmind2020Json, } from '@ljheee/xmind-parser';
|
|
4
|
-
import { createFileViewerZoomChangeEmitter, registerFileViewerZoomProvider, unregisterFileViewerZoomProvider, } from '@file-viewer/core';
|
|
4
|
+
import { createFileViewerTranslator, createFileViewerZoomChangeEmitter, registerFileViewerZoomProvider, unregisterFileViewerZoomProvider, } from '@file-viewer/core';
|
|
5
5
|
const NODE_WIDTH = 236;
|
|
6
6
|
const ROOT_WIDTH = 260;
|
|
7
7
|
const LEVEL_GAP = 112;
|
|
@@ -171,7 +171,7 @@ const createSheetView = (document, index) => {
|
|
|
171
171
|
height: Math.max(520, maxBottom + CANVAS_PADDING),
|
|
172
172
|
};
|
|
173
173
|
};
|
|
174
|
-
const loadXMindSheets = async (buffer) => {
|
|
174
|
+
const loadXMindSheets = async (buffer, unrecognizedMessage) => {
|
|
175
175
|
const zip = await JSZip.loadAsync(buffer);
|
|
176
176
|
const resources = {};
|
|
177
177
|
const resourceTasks = [];
|
|
@@ -199,27 +199,27 @@ const loadXMindSheets = async (buffer) => {
|
|
|
199
199
|
commentsXml: commentsXml ? await commentsXml.async('text') : undefined,
|
|
200
200
|
});
|
|
201
201
|
}
|
|
202
|
-
throw new Error(
|
|
202
|
+
throw new Error(unrecognizedMessage);
|
|
203
203
|
};
|
|
204
|
-
const badgeTexts = (node) => {
|
|
204
|
+
const badgeTexts = (node, t) => {
|
|
205
205
|
const badges = [];
|
|
206
206
|
if (node.priority) {
|
|
207
207
|
badges.push(`P${node.priority}`);
|
|
208
208
|
}
|
|
209
209
|
if (node.progress) {
|
|
210
|
-
badges.push(node.progress === 10 ? '
|
|
210
|
+
badges.push(node.progress === 10 ? t('xmind.badge.paused') : `${Math.min(100, Math.round((node.progress / 9) * 100))}%`);
|
|
211
211
|
}
|
|
212
212
|
if (node.collapsed) {
|
|
213
|
-
badges.push('
|
|
213
|
+
badges.push(t('xmind.badge.collapsed'));
|
|
214
214
|
}
|
|
215
215
|
if (node.detached) {
|
|
216
|
-
badges.push('
|
|
216
|
+
badges.push(t('xmind.badge.floating'));
|
|
217
217
|
}
|
|
218
218
|
if (node.summary) {
|
|
219
|
-
badges.push('
|
|
219
|
+
badges.push(t('xmind.badge.summary'));
|
|
220
220
|
}
|
|
221
221
|
if (node.callout) {
|
|
222
|
-
badges.push('
|
|
222
|
+
badges.push(t('xmind.badge.callout'));
|
|
223
223
|
}
|
|
224
224
|
node.markers.slice(0, 4).forEach(marker => badges.push(marker));
|
|
225
225
|
return badges;
|
|
@@ -240,7 +240,7 @@ const renderEdges = (svg, node) => {
|
|
|
240
240
|
renderEdges(svg, child);
|
|
241
241
|
});
|
|
242
242
|
};
|
|
243
|
-
const createNodeElement = (node, scrollToNode, shouldSuppressClick) => {
|
|
243
|
+
const createNodeElement = (node, scrollToNode, shouldSuppressClick, t) => {
|
|
244
244
|
const card = createElement('article', [
|
|
245
245
|
'xmind-node',
|
|
246
246
|
node.depth === 0 ? 'root' : '',
|
|
@@ -254,7 +254,7 @@ const createNodeElement = (node, scrollToNode, shouldSuppressClick) => {
|
|
|
254
254
|
card.style.width = `${node.width}px`;
|
|
255
255
|
card.style.minHeight = `${node.height}px`;
|
|
256
256
|
card.append(createElement('h3', undefined, node.title));
|
|
257
|
-
const badges = badgeTexts(node);
|
|
257
|
+
const badges = badgeTexts(node, t);
|
|
258
258
|
if (badges.length) {
|
|
259
259
|
const badgeList = createElement('div', 'xmind-badges');
|
|
260
260
|
badges.forEach(item => badgeList.append(createElement('span', undefined, item)));
|
|
@@ -278,7 +278,7 @@ const createNodeElement = (node, scrollToNode, shouldSuppressClick) => {
|
|
|
278
278
|
card.append(image);
|
|
279
279
|
}
|
|
280
280
|
else {
|
|
281
|
-
card.append(createElement('p', 'xmind-note',
|
|
281
|
+
card.append(createElement('p', 'xmind-note', t('xmind.imageResource', { name: node.image })));
|
|
282
282
|
}
|
|
283
283
|
}
|
|
284
284
|
if (node.hyperlink) {
|
|
@@ -302,6 +302,7 @@ const createNodeElement = (node, scrollToNode, shouldSuppressClick) => {
|
|
|
302
302
|
return card;
|
|
303
303
|
};
|
|
304
304
|
export default async function renderXMind(buffer, target, _type = 'xmind', context) {
|
|
305
|
+
const t = createFileViewerTranslator(context === null || context === void 0 ? void 0 : context.options);
|
|
305
306
|
const zoomEmitter = createFileViewerZoomChangeEmitter();
|
|
306
307
|
let status = 'loading';
|
|
307
308
|
let errorMessage = '';
|
|
@@ -327,13 +328,13 @@ export default async function renderXMind(buffer, target, _type = 'xmind', conte
|
|
|
327
328
|
const zoomOutButton = createElement('button', undefined, '-');
|
|
328
329
|
const zoomLabel = createElement('span', undefined, '100%');
|
|
329
330
|
const zoomInButton = createElement('button', undefined, '+');
|
|
330
|
-
const resetButton = createElement('button', undefined, '
|
|
331
|
+
const resetButton = createElement('button', undefined, t('xmind.toolbar.fit'));
|
|
331
332
|
[zoomOutButton, zoomInButton, resetButton].forEach(button => {
|
|
332
333
|
button.type = 'button';
|
|
333
334
|
});
|
|
334
|
-
zoomOutButton.title = '
|
|
335
|
-
zoomInButton.title = '
|
|
336
|
-
resetButton.title = '
|
|
335
|
+
zoomOutButton.title = t('xmind.toolbar.zoomOut');
|
|
336
|
+
zoomInButton.title = t('xmind.toolbar.zoomIn');
|
|
337
|
+
resetButton.title = t('xmind.toolbar.fitTitle');
|
|
337
338
|
actions.append(zoomOutButton, zoomLabel, zoomInButton, resetButton);
|
|
338
339
|
toolbar.append(title, actions);
|
|
339
340
|
const tabs = createElement('nav', 'xmind-tabs');
|
|
@@ -348,7 +349,7 @@ export default async function renderXMind(buffer, target, _type = 'xmind', conte
|
|
|
348
349
|
stage.setAttribute('aria-keyshortcuts', 'Space ArrowLeft ArrowRight ArrowUp ArrowDown Control+0 Meta+0');
|
|
349
350
|
const zoomBox = createElement('div', 'xmind-zoom-box');
|
|
350
351
|
const surface = createElement('div', 'xmind-surface');
|
|
351
|
-
const state = createElement('div', 'xmind-state', '
|
|
352
|
+
const state = createElement('div', 'xmind-state', t('xmind.state.loading'));
|
|
352
353
|
zoomBox.append(surface);
|
|
353
354
|
stage.append(zoomBox, state);
|
|
354
355
|
body.append(sidebar, stage);
|
|
@@ -500,10 +501,10 @@ export default async function renderXMind(buffer, target, _type = 'xmind', conte
|
|
|
500
501
|
sidebar.replaceChildren();
|
|
501
502
|
const stats = createElement('div', 'xmind-stats');
|
|
502
503
|
[
|
|
503
|
-
['
|
|
504
|
-
['
|
|
505
|
-
['
|
|
506
|
-
['
|
|
504
|
+
[t('xmind.stats.nodes'), sheet.nodeCount],
|
|
505
|
+
[t('xmind.stats.depth'), sheet.maxDepth + 1],
|
|
506
|
+
[t('xmind.stats.theme'), sheet.theme],
|
|
507
|
+
[t('xmind.stats.template'), sheet.template],
|
|
507
508
|
].forEach(([label, value]) => {
|
|
508
509
|
const cell = document.createElement('div');
|
|
509
510
|
cell.append(createElement('span', undefined, String(label)), createElement('strong', undefined, String(value)));
|
|
@@ -537,7 +538,7 @@ export default async function renderXMind(buffer, target, _type = 'xmind', conte
|
|
|
537
538
|
renderEdges(svg, sheet.root);
|
|
538
539
|
surface.append(svg);
|
|
539
540
|
walkMindNodes(sheet.root, node => {
|
|
540
|
-
surface.append(createNodeElement(node, scrollToNode, () => suppressNodeClick));
|
|
541
|
+
surface.append(createNodeElement(node, scrollToNode, () => suppressNodeClick, t));
|
|
541
542
|
});
|
|
542
543
|
renderSidebar(sheet);
|
|
543
544
|
applyZoom();
|
|
@@ -562,19 +563,19 @@ export default async function renderXMind(buffer, target, _type = 'xmind', conte
|
|
|
562
563
|
state.classList.toggle('error', status === 'error');
|
|
563
564
|
state.textContent = status === 'error'
|
|
564
565
|
? errorMessage
|
|
565
|
-
: '
|
|
566
|
+
: t('xmind.state.loading');
|
|
566
567
|
};
|
|
567
568
|
const load = async () => {
|
|
568
569
|
status = 'loading';
|
|
569
570
|
errorMessage = '';
|
|
570
571
|
syncState();
|
|
571
572
|
try {
|
|
572
|
-
const parsed = await loadXMindSheets(buffer);
|
|
573
|
+
const parsed = await loadXMindSheets(buffer, t('xmind.error.unrecognized'));
|
|
573
574
|
if (disposed) {
|
|
574
575
|
return;
|
|
575
576
|
}
|
|
576
577
|
if (!Array.isArray(parsed) || !parsed.length) {
|
|
577
|
-
throw new Error('
|
|
578
|
+
throw new Error(t('xmind.error.noCanvas'));
|
|
578
579
|
}
|
|
579
580
|
sheets = parsed.map(createSheetView);
|
|
580
581
|
activeSheetIndex = 0;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@file-viewer/renderer-mindmap",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.3",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Standalone XMind and mind map renderer plugin for Flyfish File Viewer.",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"LICENSE"
|
|
54
54
|
],
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"@file-viewer/core": "^2.1.
|
|
56
|
+
"@file-viewer/core": "^2.1.3",
|
|
57
57
|
"@ljheee/xmind-parser": "^1.1.3",
|
|
58
58
|
"@panzoom/panzoom": "^4.6.2",
|
|
59
59
|
"jszip": "^3.10.1"
|