@peter.prib/renderengine 0.10.0 → 0.13.0
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 +10 -4
- package/dist/renderengine-workspace.umd.js +5779 -3731
- package/dist/renderengine.umd.js +5757 -3725
- package/documentation/REFERENCE.md +3291 -3077
- package/package.json +2 -2
- package/src/charting/Axis.js +47 -5
- package/src/charting/Chart.js +25 -0
- package/src/charting/ChartChooser.js +5 -4
- package/src/charting/DiagramEditor.js +239 -34
- package/src/charting/Legend.js +16 -0
- package/src/charting/ModelFileFormat.js +47 -0
- package/src/charting/archimate/ArchimateCanvasEditor.js +1108 -1012
- package/src/charting/archimate/deleteFromModel.js +57 -0
- package/src/charting/archimate/elementMenuItems.js +3 -1
- package/src/charting/archimate/heatMaps.js +169 -0
- package/src/charting/archimate/index.js +1 -0
- package/src/charting/charts/BarChart.js +5 -5
- package/src/charting/charts/BarChartBase.js +21 -3
- package/src/charting/charts/GroupedBarChart.js +42 -22
- package/src/charting/charts/LineChart.js +9 -8
- package/src/charting/charts/PieChart.js +2 -2
- package/src/charting/charts/TableChart.js +34 -5
- package/src/charting/diagrams/ArchimateModel.js +33 -0
- package/src/charting/diagrams/DeleteFromModelCommand.js +81 -0
- package/src/charting/diagrams/EdgeGeometry.js +16 -0
- package/src/charting/edgeStyle/EdgeStyleSchema.js +6 -2
- package/src/charting/pivot/PivotChart.js +50 -0
- package/src/charting/pivot/PivotGridChart.js +191 -0
- package/src/charting/pivot/PivotView.js +740 -0
- package/src/charting/table/TableView.js +84 -15
- package/src/charting/table/TableViewChart.js +5 -3
- package/src/charting/templates/Template.js +10 -0
- package/src/exportImage.js +45 -18
- package/src/index.js +2899 -2807
- package/src/workspace/parts/ArchimateCanvasPart.js +3 -0
- package/src/workspace/parts/DiagramEditorPart.js +2 -0
- package/src/workspace/parts/ModelHosted.js +15 -4
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { pickFile } from './toolbar/pickFile.js';
|
|
2
2
|
import { downloadBlob } from '../exportImage.js';
|
|
3
|
+
import { FormDialog } from './FormDialog.js';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* ModelFileFormat — one file format a model is exported to and imported
|
|
@@ -100,6 +101,52 @@ export function modelFileMenuItems(formats, {
|
|
|
100
101
|
return groups.flatMap((group, i) => (i ? [{ separator: true }, ...group] : group));
|
|
101
102
|
}
|
|
102
103
|
|
|
104
|
+
/**
|
|
105
|
+
* The part of pasted text that is a model in `format`: the text as it is when
|
|
106
|
+
* the format recognizes it; else, as an assistant or a page would wrap it, a
|
|
107
|
+
* fenced block (```json … ```), or the text from its first { (or [) to its
|
|
108
|
+
* last } (or ]). Null when none is.
|
|
109
|
+
* @param {ModelFileFormat} format - one that reads text
|
|
110
|
+
* @param {string} text
|
|
111
|
+
* @returns {string|null}
|
|
112
|
+
*/
|
|
113
|
+
export function findPayload(format, text) {
|
|
114
|
+
const candidates = [String(text ?? '').trim()];
|
|
115
|
+
for (const m of candidates[0].matchAll(/```[\w-]*[ \t]*\r?\n([\s\S]*?)```/g)) candidates.push(m[1].trim());
|
|
116
|
+
for (const [open, close] of [['{', '}'], ['[', ']']]) {
|
|
117
|
+
const from = candidates[0].indexOf(open), to = candidates[0].lastIndexOf(close);
|
|
118
|
+
if (from >= 0 && to > from) candidates.push(candidates[0].slice(from, to + 1));
|
|
119
|
+
}
|
|
120
|
+
return candidates.find(c => c && format.recognizes(c)) ?? null;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Import a model from pasted text rather than a file: a dialog with a text
|
|
125
|
+
* box; what is pasted may be wrapped in other text (findPayload). The new
|
|
126
|
+
* model goes to `onImport`; text with no model in it is refused in the dialog.
|
|
127
|
+
* @param {ModelFileFormat} format - one that reads text
|
|
128
|
+
* @returns {FormDialog}
|
|
129
|
+
*/
|
|
130
|
+
export function askPasteImport(format, { onImport, document: doc = globalThis.document } = {}) {
|
|
131
|
+
let model = null;
|
|
132
|
+
const dialog = new FormDialog({
|
|
133
|
+
title: `Paste ${format.label}`,
|
|
134
|
+
description: `Paste the ${format.label} text: a file's contents, or an answer or page that has it in it (in a \`\`\` block, say).`,
|
|
135
|
+
fields: [{ key: 'text', label: 'Text', type: 'textarea', rows: 14, value: '' }],
|
|
136
|
+
submitLabel: 'Import',
|
|
137
|
+
idPrefix: 'paste-import-',
|
|
138
|
+
document: doc,
|
|
139
|
+
validate: ({ text }) => {
|
|
140
|
+
const payload = findPayload(format, text);
|
|
141
|
+
if (!payload) return `No ${format.label} found in what is pasted`;
|
|
142
|
+
try { model = format.import(payload); return null; } catch (err) { return `It could not be read: ${err.message}`; }
|
|
143
|
+
},
|
|
144
|
+
onApply: () => onImport(model),
|
|
145
|
+
});
|
|
146
|
+
dialog.open();
|
|
147
|
+
return dialog;
|
|
148
|
+
}
|
|
149
|
+
|
|
103
150
|
/**
|
|
104
151
|
* Ask for a file and import it in `format`; resolves to the new model, or
|
|
105
152
|
* null when no file was chosen or it could not be read (reported).
|