@peter.prib/renderengine 0.0.0-stage → 0.2.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/LICENSE +21 -0
- package/README.md +203 -2
- package/REFERENCE.md +2198 -0
- package/dist/renderengine-workspace.umd.js +46905 -0
- package/dist/renderengine.umd.js +42223 -0
- package/examples/archimate.html +66 -0
- package/examples/diagram-editor.html +51 -0
- package/package.json +65 -4
- package/src/BaseRenderer.js +57 -0
- package/src/CanvasRenderer.js +194 -0
- package/src/Mat4.js +111 -0
- package/src/OrbitCamera.js +57 -0
- package/src/RendererFactory.js +50 -0
- package/src/SVGRenderer.js +439 -0
- package/src/archimate.js +723 -0
- package/src/archimateArchiFormat.js +1693 -0
- package/src/archimateArchiTypes.js +72 -0
- package/src/archimateArchive.js +140 -0
- package/src/archimateCSV.js +127 -0
- package/src/archimateDrawio.js +182 -0
- package/src/archimateExchangeFormat.js +546 -0
- package/src/archimateRelationshipTable.js +93 -0
- package/src/archimateSpecializations.js +161 -0
- package/src/chartCatalog.js +589 -0
- package/src/charting/ArchimateDiagramEditor.js +1624 -0
- package/src/charting/ArchimateSpecializationSelector.js +134 -0
- package/src/charting/Axis.js +68 -0
- package/src/charting/CameraSeeder.js +30 -0
- package/src/charting/CatalogDialog.js +92 -0
- package/src/charting/Chart.js +37 -0
- package/src/charting/Chart3D.js +99 -0
- package/src/charting/ChartBox.js +80 -0
- package/src/charting/ChartData.js +27 -0
- package/src/charting/ChartRegistry.js +76 -0
- package/src/charting/CheckboxTreeSelector.js +304 -0
- package/src/charting/ColorField.js +107 -0
- package/src/charting/ColorPalette.js +88 -0
- package/src/charting/CommandHistory.js +176 -0
- package/src/charting/DataFilter.js +52 -0
- package/src/charting/Diagram.js +36 -0
- package/src/charting/Diagram3D.js +29 -0
- package/src/charting/DiagramClipboard.js +31 -0
- package/src/charting/DiagramEditor.js +3330 -0
- package/src/charting/DiagramEditorCommand.js +110 -0
- package/src/charting/DiagramEditorCommands.js +237 -0
- package/src/charting/DiagramEditorEdgeCommands.js +142 -0
- package/src/charting/DiagramEditorState.js +98 -0
- package/src/charting/DiagramRegistry.js +86 -0
- package/src/charting/DiagramTypeRegistry.js +326 -0
- package/src/charting/DiagramViewPropertiesDialog.js +46 -0
- package/src/charting/Edge.js +113 -0
- package/src/charting/ErrorBars.js +37 -0
- package/src/charting/FilterSystem.js +285 -0
- package/src/charting/FindReplaceDialog.js +139 -0
- package/src/charting/FormDialog.js +385 -0
- package/src/charting/Gauge.js +58 -0
- package/src/charting/Hierarchy.js +175 -0
- package/src/charting/HintPanel.js +86 -0
- package/src/charting/ImageSelector.js +148 -0
- package/src/charting/InteractionManager.js +725 -0
- package/src/charting/Legend.js +58 -0
- package/src/charting/MenuBar.js +62 -0
- package/src/charting/ModelFileFormat.js +115 -0
- package/src/charting/OrbitControls.js +77 -0
- package/src/charting/Palette.js +119 -0
- package/src/charting/PopupMenu.js +117 -0
- package/src/charting/PropertiesPanel.js +155 -0
- package/src/charting/PropertyListEditor.js +96 -0
- package/src/charting/PropertyLog.js +92 -0
- package/src/charting/SettingsCascade.js +93 -0
- package/src/charting/SettingsDialog.js +53 -0
- package/src/charting/SettingsManager.js +179 -0
- package/src/charting/SettingsViewPropertiesDialog.js +58 -0
- package/src/charting/ShapePaths.js +27 -0
- package/src/charting/Statistics.js +134 -0
- package/src/charting/TemplateCatalog.js +59 -0
- package/src/charting/TemplateLibrary.js +103 -0
- package/src/charting/TextStyle.js +168 -0
- package/src/charting/ViewFit.js +55 -0
- package/src/charting/ViewMenu.js +70 -0
- package/src/charting/ViewPropertiesDialog.js +77 -0
- package/src/charting/ViewTabStrip.js +81 -0
- package/src/charting/archimate/ArchiFileFormat.js +32 -0
- package/src/charting/archimate/ArchimateCanvasEditor.js +815 -0
- package/src/charting/archimate/ArchimateCsvFileFormat.js +35 -0
- package/src/charting/archimate/ArchimateEdge.js +137 -0
- package/src/charting/archimate/ArchimateElementTemplate.js +195 -0
- package/src/charting/archimate/ArchimatePalette.js +102 -0
- package/src/charting/archimate/CsvImportDialog.js +105 -0
- package/src/charting/archimate/CustomViewpoints.js +74 -0
- package/src/charting/archimate/DerivedEdge.js +29 -0
- package/src/charting/archimate/DrawioFileFormat.js +24 -0
- package/src/charting/archimate/ElementFilterRule.js +21 -0
- package/src/charting/archimate/ExchangeFileFormat.js +28 -0
- package/src/charting/archimate/ViewGroupTemplate.js +137 -0
- package/src/charting/archimate/ViewLineEdge.js +84 -0
- package/src/charting/archimate/ViewpointRule.js +45 -0
- package/src/charting/archimate/archimateFileFormats.js +12 -0
- package/src/charting/archimate/archimateNames.js +5 -0
- package/src/charting/archimate/csvMapping.js +122 -0
- package/src/charting/archimate/elementMenuItems.js +32 -0
- package/src/charting/archimate/elementProperties.js +146 -0
- package/src/charting/archimate/elementTypeChoices.js +7 -0
- package/src/charting/archimate/elementTypeGroups.js +19 -0
- package/src/charting/archimate/index.js +17 -0
- package/src/charting/archimate/specializationCatalogDialog.js +64 -0
- package/src/charting/archimate/typeGlyph.js +29 -0
- package/src/charting/arrangement/Arrangement.js +112 -0
- package/src/charting/arrangement/ArrangementCommand.js +29 -0
- package/src/charting/arrangement/BackgroundCommand.js +41 -0
- package/src/charting/arrangement/BackgroundGroup.js +18 -0
- package/src/charting/arrangement/GroupCommand.js +46 -0
- package/src/charting/arrangement/ItemGroup.js +62 -0
- package/src/charting/arrangement/LockCommand.js +32 -0
- package/src/charting/arrangement/UngroupCommand.js +27 -0
- package/src/charting/arrangement/alignment.js +88 -0
- package/src/charting/arrangement/arrangeMenuItems.js +25 -0
- package/src/charting/arrangement/index.js +11 -0
- package/src/charting/arrangement/layouts.js +233 -0
- package/src/charting/canvas/ArchiHint.js +78 -0
- package/src/charting/canvas/CanvasBoxKind.js +39 -0
- package/src/charting/canvas/CanvasPalette.js +49 -0
- package/src/charting/canvas/CanvasTemplateLibrary.js +61 -0
- package/src/charting/canvas/CanvasTemplateMenu.js +151 -0
- package/src/charting/canvas/EditHintCommand.js +28 -0
- package/src/charting/canvas/canvasBoxKinds.js +27 -0
- package/src/charting/canvas/canvasBoxMenuItems.js +40 -0
- package/src/charting/canvas/defaultCanvasTemplates.js +186 -0
- package/src/charting/canvas/diagramBoxKinds.js +12 -0
- package/src/charting/canvas/hintMenuItems.js +49 -0
- package/src/charting/charts/ArcGauge.js +55 -0
- package/src/charting/charts/AreaChart.js +71 -0
- package/src/charting/charts/BarChart.js +80 -0
- package/src/charting/charts/BarChart3D.js +56 -0
- package/src/charting/charts/BarChart3DOrbit.js +53 -0
- package/src/charting/charts/BarChartBase.js +70 -0
- package/src/charting/charts/BarGauge.js +42 -0
- package/src/charting/charts/BoxPlotChart.js +41 -0
- package/src/charting/charts/BubbleChart.js +99 -0
- package/src/charting/charts/BubbleChart3D.js +78 -0
- package/src/charting/charts/BulletGauge.js +87 -0
- package/src/charting/charts/CalendarHeatmapChart.js +204 -0
- package/src/charting/charts/CandlestickChart.js +54 -0
- package/src/charting/charts/ChordDiagram.js +130 -0
- package/src/charting/charts/DensityChart.js +73 -0
- package/src/charting/charts/DialGauge.js +65 -0
- package/src/charting/charts/DonutChart.js +15 -0
- package/src/charting/charts/FunnelChart.js +47 -0
- package/src/charting/charts/GanttChart.js +201 -0
- package/src/charting/charts/GaugeChart.js +175 -0
- package/src/charting/charts/GeoMapChart.js +146 -0
- package/src/charting/charts/GroupedBarChart.js +88 -0
- package/src/charting/charts/GroupedDistributionChart.js +70 -0
- package/src/charting/charts/HeatmapChart.js +80 -0
- package/src/charting/charts/HierarchyChart.js +39 -0
- package/src/charting/charts/HistogramChart.js +45 -0
- package/src/charting/charts/KpiTile.js +72 -0
- package/src/charting/charts/LagPlotChart.js +41 -0
- package/src/charting/charts/LineChart.js +124 -0
- package/src/charting/charts/MultiRingGauge.js +54 -0
- package/src/charting/charts/OutlineChart.js +95 -0
- package/src/charting/charts/ParallelCoordinatesChart.js +130 -0
- package/src/charting/charts/PieChart.js +56 -0
- package/src/charting/charts/PipeChart.js +88 -0
- package/src/charting/charts/PopulationPyramidChart.js +106 -0
- package/src/charting/charts/QQPlotChart.js +64 -0
- package/src/charting/charts/RadarChart.js +76 -0
- package/src/charting/charts/RadialBarChart.js +96 -0
- package/src/charting/charts/RingGauge.js +23 -0
- package/src/charting/charts/SankeyDiagram.js +174 -0
- package/src/charting/charts/ScatterChart.js +104 -0
- package/src/charting/charts/StackedAreaChart.js +15 -0
- package/src/charting/charts/StackedBarChart.js +33 -0
- package/src/charting/charts/StackedBarChart3DOrbit.js +58 -0
- package/src/charting/charts/StreamGraphChart.js +131 -0
- package/src/charting/charts/SunburstChart.js +57 -0
- package/src/charting/charts/ThermometerGauge.js +43 -0
- package/src/charting/charts/TreemapChart.js +54 -0
- package/src/charting/charts/ViolinChart.js +37 -0
- package/src/charting/charts/WaterfallChart.js +66 -0
- package/src/charting/charts/WordCloudChart.js +104 -0
- package/src/charting/diagramModel/AddViewCommand.js +33 -0
- package/src/charting/diagramModel/DiagramModel.js +39 -0
- package/src/charting/diagramModel/DiagramModelSearch.js +22 -0
- package/src/charting/diagramModel/DiagramView.js +50 -0
- package/src/charting/diagramModel/ModelHistory.js +43 -0
- package/src/charting/diagramModel/ModelReport.js +153 -0
- package/src/charting/diagramModel/ModelSearch.js +223 -0
- package/src/charting/diagramModel/RemoveViewCommand.js +25 -0
- package/src/charting/diagramModel/RenameViewCommand.js +21 -0
- package/src/charting/diagramModel/ReplaceTextCommand.js +25 -0
- package/src/charting/diagramModel/ViewSetChecker.js +34 -0
- package/src/charting/diagramModel/ViewSetModel.js +243 -0
- package/src/charting/diagramModel/index.js +6 -0
- package/src/charting/diagramModel/nameTransforms.js +29 -0
- package/src/charting/diagrams/ArchimateCommands.js +141 -0
- package/src/charting/diagrams/ArchimateDiagram.js +263 -0
- package/src/charting/diagrams/ArchimateModel.js +1155 -0
- package/src/charting/diagrams/ArchimateModelChecker.js +125 -0
- package/src/charting/diagrams/ArchimateModelReport.js +128 -0
- package/src/charting/diagrams/ArchimateModelSearch.js +41 -0
- package/src/charting/diagrams/ArchimateValidator.js +357 -0
- package/src/charting/diagrams/CanvasView.js +112 -0
- package/src/charting/diagrams/ContextMenu.js +37 -0
- package/src/charting/diagrams/DataModelDiagram.js +86 -0
- package/src/charting/diagrams/DataModelRelationshipStrategy.js +38 -0
- package/src/charting/diagrams/DerivedRelationships.js +102 -0
- package/src/charting/diagrams/EbnfDiagram.js +39 -0
- package/src/charting/diagrams/EdgeGeometry.js +553 -0
- package/src/charting/diagrams/EditViewItemCommand.js +128 -0
- package/src/charting/diagrams/ElementInstance.js +157 -0
- package/src/charting/diagrams/GraphDiagram.js +1340 -0
- package/src/charting/diagrams/GraphDiagram3D.js +152 -0
- package/src/charting/diagrams/GraphMetrics.js +81 -0
- package/src/charting/diagrams/GridOverlay.js +137 -0
- package/src/charting/diagrams/ImportRowsCommand.js +62 -0
- package/src/charting/diagrams/LabelHelper.js +108 -0
- package/src/charting/diagrams/MergeElementsCommand.js +101 -0
- package/src/charting/diagrams/NestInstanceCommand.js +34 -0
- package/src/charting/diagrams/NodeGeometry.js +158 -0
- package/src/charting/diagrams/PlaceItemsCommand.js +77 -0
- package/src/charting/diagrams/RadialLayout.js +101 -0
- package/src/charting/diagrams/RelationshipInstance.js +93 -0
- package/src/charting/diagrams/RemoveGroupFromViewCommand.js +28 -0
- package/src/charting/diagrams/RemoveLineCommand.js +27 -0
- package/src/charting/diagrams/ShowElementCommand.js +43 -0
- package/src/charting/diagrams/SvgCoordinate.js +17 -0
- package/src/charting/diagrams/SvgZoom.js +127 -0
- package/src/charting/diagrams/Tooltip.js +62 -0
- package/src/charting/diagrams/ViewConnectionInstance.js +102 -0
- package/src/charting/diagrams/ViewObjectInstance.js +56 -0
- package/src/charting/diagrams/commands/AddEdgeCommand.js +34 -0
- package/src/charting/diagrams/commands/AddNodeCommand.js +28 -0
- package/src/charting/diagrams/commands/AddWaypointCommand.js +27 -0
- package/src/charting/diagrams/commands/CreateFolderCommand.js +27 -0
- package/src/charting/diagrams/commands/DeleteEdgeCommand.js +30 -0
- package/src/charting/diagrams/commands/DeleteFolderCommand.js +47 -0
- package/src/charting/diagrams/commands/DeleteNodeCommand.js +35 -0
- package/src/charting/diagrams/commands/DeleteWaypointCommand.js +24 -0
- package/src/charting/diagrams/commands/GraphCommand.js +65 -0
- package/src/charting/diagrams/commands/InvertEdgeCommand.js +24 -0
- package/src/charting/diagrams/commands/MoveNodeCommand.js +44 -0
- package/src/charting/diagrams/commands/MoveWaypointCommand.js +27 -0
- package/src/charting/diagrams/commands/RenameEdgeCommand.js +23 -0
- package/src/charting/diagrams/commands/RenameFolderCommand.js +31 -0
- package/src/charting/diagrams/commands/RenameNodeCommand.js +27 -0
- package/src/charting/diagrams/commands/ResizeNodeCommand.js +46 -0
- package/src/charting/diagrams/commands/UpdateEdgeSideCommand.js +40 -0
- package/src/charting/diagrams/commands/index.js +17 -0
- package/src/charting/diagrams/duplicates.js +49 -0
- package/src/charting/diagrams/nesting.js +30 -0
- package/src/charting/diagrams/roadmap.js +77 -0
- package/src/charting/edgeMarkers/ArrowMarker.js +15 -0
- package/src/charting/edgeMarkers/CircleMarker.js +13 -0
- package/src/charting/edgeMarkers/CrowsFootMarker.js +16 -0
- package/src/charting/edgeMarkers/DiamondMarker.js +15 -0
- package/src/charting/edgeMarkers/EdgeMarker.js +34 -0
- package/src/charting/edgeMarkers/HalfArrowMarker.js +8 -0
- package/src/charting/edgeMarkers/HollowDiamondMarker.js +18 -0
- package/src/charting/edgeMarkers/HollowTriangleMarker.js +18 -0
- package/src/charting/edgeMarkers/OpenArrowMarker.js +17 -0
- package/src/charting/edgeMarkers/index.js +27 -0
- package/src/charting/edgeStyle/EdgeStyleCascade.js +22 -0
- package/src/charting/edgeStyle/EdgeStyleDialog.js +51 -0
- package/src/charting/edgeStyle/EdgeStyleSchema.js +43 -0
- package/src/charting/edgeStyle/SetStyleCommand.js +12 -0
- package/src/charting/edgeStyle/index.js +4 -0
- package/src/charting/emphasis/EmphasisRule.js +42 -0
- package/src/charting/emphasis/HighlightRule.js +24 -0
- package/src/charting/gauges/ArcTrack.js +51 -0
- package/src/charting/gauges/GaugeAnimation.js +51 -0
- package/src/charting/gauges/GaugeBands.js +48 -0
- package/src/charting/gauges/GaugeScale.js +87 -0
- package/src/charting/gauges/GaugeTrack.js +44 -0
- package/src/charting/gauges/GaugeValue.js +61 -0
- package/src/charting/gauges/HorizontalTrack.js +14 -0
- package/src/charting/gauges/LinearTrack.js +29 -0
- package/src/charting/gauges/Sparkline.js +42 -0
- package/src/charting/gauges/VerticalTrack.js +17 -0
- package/src/charting/glyphs/ArrowGlyph.js +21 -0
- package/src/charting/glyphs/BatteryGlyph.js +18 -0
- package/src/charting/glyphs/ChevronGlyph.js +18 -0
- package/src/charting/glyphs/CircleGlyph.js +15 -0
- package/src/charting/glyphs/CloudGlyph.js +19 -0
- package/src/charting/glyphs/ComponentGlyph.js +18 -0
- package/src/charting/glyphs/ConstraintGlyph.js +24 -0
- package/src/charting/glyphs/ContractBoxGlyph.js +10 -0
- package/src/charting/glyphs/CubeGlyph.js +19 -0
- package/src/charting/glyphs/CylinderGlyph.js +19 -0
- package/src/charting/glyphs/DashedDoubleArrowGlyph.js +11 -0
- package/src/charting/glyphs/DeviceGlyph.js +17 -0
- package/src/charting/glyphs/DiamondGlyph.js +17 -0
- package/src/charting/glyphs/DocumentGlyph.js +17 -0
- package/src/charting/glyphs/DoubleArrowGlyph.js +23 -0
- package/src/charting/glyphs/DoubleCircleGlyph.js +24 -0
- package/src/charting/glyphs/EllipseGlyph.js +18 -0
- package/src/charting/glyphs/FactoryGlyph.js +20 -0
- package/src/charting/glyphs/FlagGlyph.js +16 -0
- package/src/charting/glyphs/GapCircleGlyph.js +17 -0
- package/src/charting/glyphs/GearGlyph.js +37 -0
- package/src/charting/glyphs/Glyph.js +98 -0
- package/src/charting/glyphs/GroupingBoxGlyph.js +13 -0
- package/src/charting/glyphs/HalfCircleGlyph.js +22 -0
- package/src/charting/glyphs/HexagonGlyph.js +28 -0
- package/src/charting/glyphs/IconGlyph.js +22 -0
- package/src/charting/glyphs/ImageGlyph.js +16 -0
- package/src/charting/glyphs/JunctionGlyph.js +17 -0
- package/src/charting/glyphs/LollipopGlyph.js +22 -0
- package/src/charting/glyphs/MagnifierGlyph.js +17 -0
- package/src/charting/glyphs/NoteGlyph.js +33 -0
- package/src/charting/glyphs/ObjectBoxGlyph.js +21 -0
- package/src/charting/glyphs/OrJunctionGlyph.js +17 -0
- package/src/charting/glyphs/ParallelogramGlyph.js +20 -0
- package/src/charting/glyphs/PersonGlyph.js +23 -0
- package/src/charting/glyphs/PillGlyph.js +23 -0
- package/src/charting/glyphs/PinGlyph.js +18 -0
- package/src/charting/glyphs/PrincipleGlyph.js +23 -0
- package/src/charting/glyphs/ProductBoxGlyph.js +16 -0
- package/src/charting/glyphs/RectGlyph.js +15 -0
- package/src/charting/glyphs/RoundedBoxGlyph.js +13 -0
- package/src/charting/glyphs/StackGlyph.js +14 -0
- package/src/charting/glyphs/StepsGlyph.js +20 -0
- package/src/charting/glyphs/StickFigureGlyph.js +32 -0
- package/src/charting/glyphs/SystemSoftwareBoxGlyph.js +16 -0
- package/src/charting/glyphs/TabbedBoxGlyph.js +37 -0
- package/src/charting/glyphs/TargetGlyph.js +23 -0
- package/src/charting/glyphs/WavyBoxGlyph.js +17 -0
- package/src/charting/glyphs/WheelGlyph.js +28 -0
- package/src/charting/glyphs/drawGlyph.js +28 -0
- package/src/charting/glyphs/glyphSvg.js +55 -0
- package/src/charting/glyphs/index.js +109 -0
- package/src/charting/modelTree/AnalysisPanel.js +159 -0
- package/src/charting/modelTree/DiagramTabs.js +217 -0
- package/src/charting/modelTree/ModelTree.js +164 -0
- package/src/charting/modelTree/ModelTreePanel.js +914 -0
- package/src/charting/modelTree/TreeBuilder.js +238 -0
- package/src/charting/modelTree/TreeModeRegistry.js +51 -0
- package/src/charting/modelTree/TreeViewMode.js +110 -0
- package/src/charting/modelTree/buildFilterTrees.js +138 -0
- package/src/charting/modelTree/modes/FlatTreeMode.js +46 -0
- package/src/charting/modelTree/modes/LayerGroupedTreeMode.js +62 -0
- package/src/charting/modelTree/modes/TypeGroupedTreeMode.js +60 -0
- package/src/charting/modelTree/treeLayers.js +11 -0
- package/src/charting/report/reportHtml.js +82 -0
- package/src/charting/report/reportViewer.js +118 -0
- package/src/charting/shapes/CircleShape.js +19 -0
- package/src/charting/shapes/PathShape.js +17 -0
- package/src/charting/shapes/RectShape.js +20 -0
- package/src/charting/shapes/Shape.js +20 -0
- package/src/charting/shapes/ShapeFactory.js +23 -0
- package/src/charting/storage/LocalJsonStore.js +43 -0
- package/src/charting/templates/ActorTemplate.js +36 -0
- package/src/charting/templates/BoxTemplate.js +27 -0
- package/src/charting/templates/CircleTemplate.js +18 -0
- package/src/charting/templates/ClassTemplate.js +20 -0
- package/src/charting/templates/CloudTemplate.js +43 -0
- package/src/charting/templates/ComponentTemplate.js +19 -0
- package/src/charting/templates/CylinderTemplate.js +30 -0
- package/src/charting/templates/DataStoreTemplate.js +16 -0
- package/src/charting/templates/DiamondTemplate.js +10 -0
- package/src/charting/templates/DocumentTemplate.js +32 -0
- package/src/charting/templates/EllipseTemplate.js +15 -0
- package/src/charting/templates/FinalStateTemplate.js +12 -0
- package/src/charting/templates/GlyphTemplate.js +47 -0
- package/src/charting/templates/HexagonTemplate.js +17 -0
- package/src/charting/templates/LifelineTemplate.js +20 -0
- package/src/charting/templates/ManualInputTemplate.js +12 -0
- package/src/charting/templates/NoteTemplate.js +23 -0
- package/src/charting/templates/OctagonTemplate.js +7 -0
- package/src/charting/templates/PackageTemplate.js +25 -0
- package/src/charting/templates/ParallelogramTemplate.js +11 -0
- package/src/charting/templates/PentagonTemplate.js +5 -0
- package/src/charting/templates/PolygonTemplate.js +18 -0
- package/src/charting/templates/PredefinedProcessTemplate.js +13 -0
- package/src/charting/templates/RectangleTemplate.js +28 -0
- package/src/charting/templates/RegularPolygonTemplate.js +21 -0
- package/src/charting/templates/RoundedRectangleTemplate.js +5 -0
- package/src/charting/templates/StadiumTemplate.js +8 -0
- package/src/charting/templates/StarTemplate.js +17 -0
- package/src/charting/templates/SwimlaneTemplate.js +18 -0
- package/src/charting/templates/Template.js +208 -0
- package/src/charting/templates/TrapezoidTemplate.js +11 -0
- package/src/charting/templates/TriangleTemplate.js +12 -0
- package/src/charting/templates/index.js +31 -0
- package/src/charting/templates/outline.js +59 -0
- package/src/charting/templates/svg.js +19 -0
- package/src/charting/textToShapes.js +61 -0
- package/src/charting/toolbar/ToolbarButton.js +38 -0
- package/src/charting/toolbar/ToolbarCheckbox.js +31 -0
- package/src/charting/toolbar/ToolbarItem.js +19 -0
- package/src/charting/toolbar/ToolbarMenu.js +36 -0
- package/src/charting/toolbar/ToolbarSelect.js +38 -0
- package/src/charting/toolbar/ToolbarSeparator.js +7 -0
- package/src/charting/toolbar/ToolbarText.js +22 -0
- package/src/charting/toolbar/index.js +8 -0
- package/src/charting/toolbar/pickFile.js +14 -0
- package/src/charting/viewDecorations.js +85 -0
- package/src/charting/zOrder.js +57 -0
- package/src/csvTable.js +61 -0
- package/src/datamodel.js +122 -0
- package/src/datawindow/BoundedWindow.js +36 -0
- package/src/datawindow/FlatDataWindow.js +34 -0
- package/src/datawindow/GraphDataWindow.js +40 -0
- package/src/datawindow/GroupedSampleDataWindow.js +16 -0
- package/src/datawindow/SeriesDataWindow.js +42 -0
- package/src/datawindow/index.js +31 -0
- package/src/diagramCatalog.js +30 -0
- package/src/ebnfDiagram.js +57 -0
- package/src/ebnfParser.js +129 -0
- package/src/exportImage.js +233 -0
- package/src/index.js +2636 -0
- package/src/itIcons.js +84 -0
- package/src/kernelExpr.js +243 -0
- package/src/propertiesDialog.js +463 -0
- package/src/railroadDiagram.js +571 -0
- package/src/treeModeCatalog.js +16 -0
- package/src/workspace/ContextBus.js +79 -0
- package/src/workspace/EditorShell.js +67 -0
- package/src/workspace/Part.js +163 -0
- package/src/workspace/PartFactory.js +49 -0
- package/src/workspace/PartRegistry.js +86 -0
- package/src/workspace/Workspace.js +321 -0
- package/src/workspace/archimateServices.js +33 -0
- package/src/workspace/dom.js +120 -0
- package/src/workspace/index.js +75 -0
- package/src/workspace/layout/GridNode.js +280 -0
- package/src/workspace/layout/LayoutNode.js +89 -0
- package/src/workspace/layout/PartNode.js +77 -0
- package/src/workspace/layout/SplitNode.js +114 -0
- package/src/workspace/layout/TabsNode.js +191 -0
- package/src/workspace/layout/index.js +24 -0
- package/src/workspace/parts/AdapterPart.js +33 -0
- package/src/workspace/parts/ArchimateCanvasPart.js +345 -0
- package/src/workspace/parts/ArchimateEditorPart.js +79 -0
- package/src/workspace/parts/ChartPart.js +115 -0
- package/src/workspace/parts/ContentPart.js +34 -0
- package/src/workspace/parts/DetailPart.js +46 -0
- package/src/workspace/parts/DiagramEditorPart.js +135 -0
- package/src/workspace/parts/EditorPart.js +388 -0
- package/src/workspace/parts/HtmlPart.js +25 -0
- package/src/workspace/parts/ListPart.js +57 -0
- package/src/workspace/parts/ModelFile.js +187 -0
- package/src/workspace/parts/ModelsPart.js +135 -0
- package/src/workspace/styles.js +258 -0
- package/src/workspace/themes.js +96 -0
- package/src/workspace/workArea.js +413 -0
- package/src/workspace/workAreaModel.js +197 -0
- package/src/workspace.js +16 -0
- package/src/zip/ZipArchive.js +160 -0
- package/src/zip/crc32.js +25 -0
- package/src/zip/inflate.js +159 -0
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure outline geometry for templates: curve sampling and ray/outline exits.
|
|
3
|
+
* Outlines are closed polygons given as [[x, y], ...]; curves are sampled
|
|
4
|
+
* finely enough (sub-pixel at diagram sizes) for edge attachment.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/** Points along an elliptical arc from angle `from` to `to` (radians), endpoints included. */
|
|
8
|
+
export function sampleArc(cx, cy, rx, ry, from, to, segments) {
|
|
9
|
+
return Array.from({ length: segments + 1 }, (_, i) => {
|
|
10
|
+
const a = from + ((to - from) * i) / segments;
|
|
11
|
+
return [cx + rx * Math.cos(a), cy + ry * Math.sin(a)];
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/** Points along a cubic bezier, excluding the start point. */
|
|
16
|
+
export function sampleCubic([x0, y0], [x1, y1], [x2, y2], [x3, y3], segments = 8) {
|
|
17
|
+
return Array.from({ length: segments }, (_, i) => {
|
|
18
|
+
const t = (i + 1) / segments, m = 1 - t;
|
|
19
|
+
const a = m * m * m, b = 3 * m * m * t, c = 3 * m * t * t, d = t * t * t;
|
|
20
|
+
return [a * x0 + b * x1 + c * x2 + d * x3, a * y0 + b * y1 + c * y2 + d * y3];
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** Points along a quadratic bezier, excluding the start point. */
|
|
25
|
+
export function sampleQuad([x0, y0], [x1, y1], [x2, y2], segments = 8) {
|
|
26
|
+
return Array.from({ length: segments }, (_, i) => {
|
|
27
|
+
const t = (i + 1) / segments, m = 1 - t;
|
|
28
|
+
return [m * m * x0 + 2 * m * t * x1 + t * t * x2, m * m * y0 + 2 * m * t * y1 + t * t * y2];
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** Rotate vector (x, y) by `degrees`, clockwise on screen (the SVG `rotate()` sense). */
|
|
33
|
+
export function rotateVector(x, y, degrees) {
|
|
34
|
+
if (!degrees) return [x, y];
|
|
35
|
+
const r = (degrees * Math.PI) / 180, c = Math.cos(r), s = Math.sin(r);
|
|
36
|
+
return [x * c - y * s, x * s + y * c];
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Distance from (cx, cy) along unit direction (ux, uy) to where the ray last
|
|
41
|
+
* crosses the polygon — the point a line arriving from outside first touches,
|
|
42
|
+
* which for concave outlines (star, cloud) is the outermost crossing. 0 if the
|
|
43
|
+
* ray never crosses it.
|
|
44
|
+
*/
|
|
45
|
+
export function rayExitDistance(points, cx, cy, ux, uy) {
|
|
46
|
+
let best = 0;
|
|
47
|
+
for (let i = 0; i < points.length; i++) {
|
|
48
|
+
const [ax, ay] = points[i];
|
|
49
|
+
const [bx, by] = points[(i + 1) % points.length];
|
|
50
|
+
const ex = bx - ax, ey = by - ay;
|
|
51
|
+
const denom = ux * ey - uy * ex;
|
|
52
|
+
if (Math.abs(denom) < 1e-12) continue;
|
|
53
|
+
const qx = ax - cx, qy = ay - cy;
|
|
54
|
+
const t = (qx * ey - qy * ex) / denom;
|
|
55
|
+
const s = (qx * uy - qy * ux) / denom;
|
|
56
|
+
if (t > best && s >= -1e-9 && s <= 1 + 1e-9) best = t;
|
|
57
|
+
}
|
|
58
|
+
return best;
|
|
59
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const SVG_NS = 'http://www.w3.org/2000/svg';
|
|
2
|
+
|
|
3
|
+
/** Create an SVG element; null/undefined attribute values are skipped. */
|
|
4
|
+
export function svgEl(tag, attrs = {}, doc = document) {
|
|
5
|
+
const node = doc.createElementNS(SVG_NS, tag);
|
|
6
|
+
for (const [k, v] of Object.entries(attrs)) {
|
|
7
|
+
if (v != null) node.setAttribute(k, String(v));
|
|
8
|
+
}
|
|
9
|
+
return node;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/** Serialize [[x, y], ...] into an SVG `points` attribute value. */
|
|
13
|
+
export function pointsAttr(points) {
|
|
14
|
+
return points.map(([x, y]) => `${round(x)},${round(y)}`).join(' ');
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function round(n) {
|
|
18
|
+
return Math.round(n * 100) / 100;
|
|
19
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Text to shapes: a list of names (pasted from a document, a spreadsheet, a
|
|
3
|
+
* mail) read as shapes to add, one definition for every editor.
|
|
4
|
+
*
|
|
5
|
+
* - One name per line; a tab after it starts its documentation. Blank lines
|
|
6
|
+
* are skipped, and bullets and numbering ("- ", "* ", "• ", "1. ", "2) ")
|
|
7
|
+
* taken off.
|
|
8
|
+
* - A first line `types=<type>,<type>,...` makes each tab-separated column
|
|
9
|
+
* that type, a line being a row of shapes (as from a spreadsheet's columns).
|
|
10
|
+
*
|
|
11
|
+
* `parseShapeText(text, { defaultType })` returns `{ items, rows }`: every
|
|
12
|
+
* item `{ name, type, documentation? }`, and with `types=` the rows they came
|
|
13
|
+
* in (else null: the editor lays them out in a grid).
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
const BULLET = /^\s*(?:[-*•▪◦]\s+|\d+[.)]\s+)/;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @param {string} text
|
|
20
|
+
* @param {Object} [options]
|
|
21
|
+
* @param {string} [options.defaultType] - The type of a shape from a plain list
|
|
22
|
+
* @param {(type: string) => (string|null)} [options.resolveType] - A `types=` name as the editor's type key, or null if unknown
|
|
23
|
+
* @returns {{items: Array<{name: string, type: string, documentation?: string}>, rows: (Array<Array<Object>>|null), unknownTypes: Array<string>}}
|
|
24
|
+
*/
|
|
25
|
+
export function parseShapeText(text, { defaultType = null, resolveType = (t) => t } = {}) {
|
|
26
|
+
const lines = String(text ?? '').split(/\r?\n/).map(l => l.replace(/\s+$/, '')).filter(l => l.trim());
|
|
27
|
+
const header = lines[0]?.trim().match(/^types\s*=\s*(.+)$/i);
|
|
28
|
+
if (header) {
|
|
29
|
+
const named = header[1].split(',').map(t => t.trim()).filter(Boolean);
|
|
30
|
+
const types = named.map(t => resolveType(t));
|
|
31
|
+
const unknownTypes = named.filter((t, i) => !types[i]);
|
|
32
|
+
const rows = lines.slice(1).map(line => line.split('\t')
|
|
33
|
+
.map((cell, i) => ({ name: cell.replace(BULLET, '').trim(), type: types[i] }))
|
|
34
|
+
.filter(item => item.name && item.type));
|
|
35
|
+
return { items: rows.flat(), rows: rows.filter(r => r.length), unknownTypes };
|
|
36
|
+
}
|
|
37
|
+
const items = lines.map(line => {
|
|
38
|
+
const [name, ...rest] = line.replace(BULLET, '').split('\t');
|
|
39
|
+
const documentation = rest.join('\t').trim();
|
|
40
|
+
return { name: name.trim(), type: defaultType, ...(documentation && { documentation }) };
|
|
41
|
+
}).filter(item => item.name);
|
|
42
|
+
return { items, rows: null, unknownTypes: [] };
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Where the parsed shapes go, their top-left corner at `at`: rows as they
|
|
47
|
+
* came, or a grid as square as it goes. Each item gains `x` and `y`, its
|
|
48
|
+
* centre.
|
|
49
|
+
* @param {{items, rows}} parsed
|
|
50
|
+
* @param {{x: number, y: number}} at
|
|
51
|
+
* @param {{width?: number, height?: number, gap?: number}} [size] - Each shape's size
|
|
52
|
+
*/
|
|
53
|
+
export function placeShapes({ items, rows }, at, { width = 120, height = 55, gap = 30 } = {}) {
|
|
54
|
+
const grid = rows ?? (() => {
|
|
55
|
+
const columns = Math.ceil(Math.sqrt(items.length));
|
|
56
|
+
const out = [];
|
|
57
|
+
items.forEach((item, i) => { (out[Math.floor(i / columns)] ??= []).push(item); });
|
|
58
|
+
return out;
|
|
59
|
+
})();
|
|
60
|
+
return grid.flatMap((row, r) => row.map((item, c) => ({ ...item, x: at.x + c * (width + gap) + width / 2, y: at.y + r * (height + gap) + height / 2 })));
|
|
61
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { ToolbarItem } from './ToolbarItem.js';
|
|
2
|
+
|
|
3
|
+
/** ToolbarButton — runs an action; with `active` it renders as a toggle. */
|
|
4
|
+
export class ToolbarButton extends ToolbarItem {
|
|
5
|
+
/**
|
|
6
|
+
* @param {string} label
|
|
7
|
+
* @param {() => void} action
|
|
8
|
+
* @param {Object} [options]
|
|
9
|
+
* @param {string} [options.title]
|
|
10
|
+
* @param {() => boolean} [options.active] - Toggle state, shown pressed when true
|
|
11
|
+
*/
|
|
12
|
+
constructor(label, action, { title, active } = {}) {
|
|
13
|
+
super();
|
|
14
|
+
this.label = label;
|
|
15
|
+
this.action = action;
|
|
16
|
+
this.title = title;
|
|
17
|
+
this.active = active;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
spec(bar) {
|
|
21
|
+
return {
|
|
22
|
+
tag: 'button',
|
|
23
|
+
text: this.label,
|
|
24
|
+
attrs: { type: 'button', title: this.title, 'aria-pressed': this.active ? String(!!this.active()) : null },
|
|
25
|
+
style: ToolbarItem.buttonStyle,
|
|
26
|
+
on: { click: () => bar.run(this.action) },
|
|
27
|
+
ref: (n) => this.refresh(n),
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
refresh(node) {
|
|
32
|
+
if (!this.active) return;
|
|
33
|
+
const on = !!this.active();
|
|
34
|
+
node.setAttribute('aria-pressed', String(on));
|
|
35
|
+
node.style.background = on ? '#e3f2fd' : '#fff';
|
|
36
|
+
node.style.borderColor = on ? '#0066cc' : '#ccc';
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ToolbarItem } from './ToolbarItem.js';
|
|
2
|
+
|
|
3
|
+
/** ToolbarCheckbox — a labelled on/off switch. */
|
|
4
|
+
export class ToolbarCheckbox extends ToolbarItem {
|
|
5
|
+
/**
|
|
6
|
+
* @param {string} label
|
|
7
|
+
* @param {() => boolean} checked
|
|
8
|
+
* @param {(checked: boolean) => void} onChange
|
|
9
|
+
*/
|
|
10
|
+
constructor(label, checked, onChange) {
|
|
11
|
+
super();
|
|
12
|
+
this.label = label;
|
|
13
|
+
this.checked = checked;
|
|
14
|
+
this.onChange = onChange;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
spec(bar) {
|
|
18
|
+
return {
|
|
19
|
+
tag: 'label',
|
|
20
|
+
style: { display: 'flex', alignItems: 'center', gap: '6px', cursor: 'pointer' },
|
|
21
|
+
children: [
|
|
22
|
+
{
|
|
23
|
+
tag: 'input',
|
|
24
|
+
attrs: { type: 'checkbox', checked: !!this.checked() },
|
|
25
|
+
on: { change: (e) => bar.run(() => this.onChange(e.target.checked)) },
|
|
26
|
+
},
|
|
27
|
+
this.label,
|
|
28
|
+
],
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ToolbarItem — one control in a MenuBar. Subclasses return an el() spec; the
|
|
3
|
+
* bar re-renders after an item acts, and calls refresh() on live items when the
|
|
4
|
+
* editor re-renders, so labels can track state (zoom %, toggles).
|
|
5
|
+
*/
|
|
6
|
+
export class ToolbarItem {
|
|
7
|
+
/** @returns {Object} el() spec */
|
|
8
|
+
spec(bar) {
|
|
9
|
+
throw new Error(`${this.constructor.name} must implement spec()`);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/** Update an already-rendered node from current state. */
|
|
13
|
+
refresh(node) {}
|
|
14
|
+
|
|
15
|
+
static buttonStyle = {
|
|
16
|
+
padding: '4px 10px', border: '1px solid #ccc', borderRadius: '3px', background: '#fff',
|
|
17
|
+
cursor: 'pointer', fontSize: '13px',
|
|
18
|
+
};
|
|
19
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { ToolbarItem } from './ToolbarItem.js';
|
|
2
|
+
import { PopupMenu } from '../PopupMenu.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* ToolbarMenu — a button that opens a PopupMenu. `items` may be a function,
|
|
6
|
+
* evaluated each time the menu opens, so labels can reflect current state.
|
|
7
|
+
*/
|
|
8
|
+
export class ToolbarMenu extends ToolbarItem {
|
|
9
|
+
/**
|
|
10
|
+
* @param {string} label
|
|
11
|
+
* @param {Array|(() => Array)} items - PopupMenu items: `{label, action, danger?}` or `{separator: true}`
|
|
12
|
+
*/
|
|
13
|
+
constructor(label, items) {
|
|
14
|
+
super();
|
|
15
|
+
this.label = label;
|
|
16
|
+
this.items = items;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
spec(bar) {
|
|
20
|
+
return {
|
|
21
|
+
tag: 'button',
|
|
22
|
+
text: `${this.label} ▾`,
|
|
23
|
+
attrs: { type: 'button', 'aria-haspopup': 'menu' },
|
|
24
|
+
style: ToolbarItem.buttonStyle,
|
|
25
|
+
on: {
|
|
26
|
+
click: (e) => {
|
|
27
|
+
e.stopPropagation();
|
|
28
|
+
const r = e.currentTarget.getBoundingClientRect();
|
|
29
|
+
const items = (typeof this.items === 'function' ? this.items() : this.items)
|
|
30
|
+
.map(item => (item.separator ? item : { ...item, action: () => bar.run(item.action) }));
|
|
31
|
+
PopupMenu.show(r.left, r.bottom + 2, items, e.currentTarget.ownerDocument);
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { ToolbarItem } from './ToolbarItem.js';
|
|
2
|
+
|
|
3
|
+
/** ToolbarSelect — a labelled dropdown. */
|
|
4
|
+
export class ToolbarSelect extends ToolbarItem {
|
|
5
|
+
/**
|
|
6
|
+
* @param {string} label
|
|
7
|
+
* @param {() => Array<[string, string, string?]>} choices - `[value, text, title?]`
|
|
8
|
+
* @param {() => string} value
|
|
9
|
+
* @param {(value: string) => void} onChange
|
|
10
|
+
*/
|
|
11
|
+
constructor(label, choices, value, onChange) {
|
|
12
|
+
super();
|
|
13
|
+
this.label = label;
|
|
14
|
+
this.choices = choices;
|
|
15
|
+
this.value = value;
|
|
16
|
+
this.onChange = onChange;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
spec(bar) {
|
|
20
|
+
const current = this.value();
|
|
21
|
+
return {
|
|
22
|
+
tag: 'label',
|
|
23
|
+
style: { display: 'flex', alignItems: 'center', gap: '6px' },
|
|
24
|
+
children: [
|
|
25
|
+
`${this.label}:`,
|
|
26
|
+
{
|
|
27
|
+
tag: 'select',
|
|
28
|
+
attrs: { 'aria-label': this.label },
|
|
29
|
+
style: { ...ToolbarItem.buttonStyle, padding: '3px 6px', maxWidth: '220px' },
|
|
30
|
+
on: { change: (e) => bar.run(() => this.onChange(e.target.value)) },
|
|
31
|
+
children: this.choices().map(([v, text, title]) => ({
|
|
32
|
+
tag: 'option', attrs: { value: v, title, selected: v === current }, text,
|
|
33
|
+
})),
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ToolbarItem } from './ToolbarItem.js';
|
|
2
|
+
|
|
3
|
+
/** ToolbarText — read-only text, recomputed whenever the editor re-renders. */
|
|
4
|
+
export class ToolbarText extends ToolbarItem {
|
|
5
|
+
/**
|
|
6
|
+
* @param {() => string} text
|
|
7
|
+
* @param {Object} [style]
|
|
8
|
+
*/
|
|
9
|
+
constructor(text, style = {}) {
|
|
10
|
+
super();
|
|
11
|
+
this.text = text;
|
|
12
|
+
this.style = style;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
spec() {
|
|
16
|
+
return { tag: 'span', text: this.text(), style: { fontSize: '12px', color: '#555', ...this.style } };
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
refresh(node) {
|
|
20
|
+
node.textContent = this.text();
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { ToolbarItem } from './ToolbarItem.js';
|
|
2
|
+
export { ToolbarButton } from './ToolbarButton.js';
|
|
3
|
+
export { ToolbarMenu } from './ToolbarMenu.js';
|
|
4
|
+
export { ToolbarSelect } from './ToolbarSelect.js';
|
|
5
|
+
export { ToolbarCheckbox } from './ToolbarCheckbox.js';
|
|
6
|
+
export { ToolbarText } from './ToolbarText.js';
|
|
7
|
+
export { ToolbarSeparator } from './ToolbarSeparator.js';
|
|
8
|
+
export { pickFile } from './pickFile.js';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ask the user for one file. Resolves with the File, or null if they cancel
|
|
3
|
+
* (browsers that report cancel) — callers just stop when there is no file.
|
|
4
|
+
*/
|
|
5
|
+
export function pickFile(accept, doc = document) {
|
|
6
|
+
return new Promise((resolve) => {
|
|
7
|
+
const input = doc.createElement('input');
|
|
8
|
+
input.type = 'file';
|
|
9
|
+
input.accept = accept;
|
|
10
|
+
input.addEventListener('change', () => resolve(input.files?.[0] ?? null), { once: true });
|
|
11
|
+
input.addEventListener('cancel', () => resolve(null), { once: true });
|
|
12
|
+
input.click();
|
|
13
|
+
});
|
|
14
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { el } from '../workspace/dom.js';
|
|
2
|
+
|
|
3
|
+
const DECORATION_CLASSES = ['view-title', 'view-watermark', 'view-watermark-container', 'view-watermark-bg'];
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Decorate a diagram's container: background colour/image, a title band and a
|
|
7
|
+
* watermark. Re-applying replaces the previous title and watermark.
|
|
8
|
+
*
|
|
9
|
+
* @param {HTMLElement} container
|
|
10
|
+
* @param {Object} d
|
|
11
|
+
* @param {string} [d.background]
|
|
12
|
+
* @param {string} [d.backgroundImage] - URL
|
|
13
|
+
* @param {string} [d.title]
|
|
14
|
+
* @param {'none'|'top'|'bottom'} [d.titlePosition]
|
|
15
|
+
* @param {string} [d.watermark] - Text
|
|
16
|
+
* @param {string} [d.watermarkRotation] - e.g. '-45°'
|
|
17
|
+
* @param {number} [d.watermarkOpacity] - 0–100
|
|
18
|
+
* @param {'none'|'repeat'|'tile'} [d.watermarkRepeat]
|
|
19
|
+
* @param {Document} [doc]
|
|
20
|
+
*/
|
|
21
|
+
export function applyViewDecorations(container, d = {}, doc = container.ownerDocument) {
|
|
22
|
+
// Unset: back to the page's own (another view's are not kept).
|
|
23
|
+
container.style.backgroundColor = d.background || '';
|
|
24
|
+
if (d.backgroundImage) {
|
|
25
|
+
Object.assign(container.style, { backgroundImage: `url('${d.backgroundImage}')`, backgroundSize: 'cover', backgroundPosition: 'center' });
|
|
26
|
+
} else {
|
|
27
|
+
container.style.backgroundImage = '';
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
container.querySelectorAll(DECORATION_CLASSES.map(c => `.${c}`).join(', ')).forEach(n => n.remove());
|
|
31
|
+
|
|
32
|
+
if (d.title && d.titlePosition && d.titlePosition !== 'none') {
|
|
33
|
+
const title = el({
|
|
34
|
+
cls: 'view-title', text: d.title,
|
|
35
|
+
style: { padding: '8px 12px', textAlign: 'center', fontSize: '16px', fontWeight: 'bold', background: 'rgba(255,255,255,0.95)', borderBottom: '1px solid #ddd' },
|
|
36
|
+
}, doc);
|
|
37
|
+
if (d.titlePosition === 'top') container.insertBefore(title, container.firstChild);
|
|
38
|
+
else container.appendChild(title);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (d.watermark) container.appendChild(watermark(container, d, doc));
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function watermark(container, d, doc) {
|
|
45
|
+
const rotation = d.watermarkRotation || '-45°';
|
|
46
|
+
const color = `rgba(0,0,0,${(d.watermarkOpacity ?? 20) / 100})`;
|
|
47
|
+
const layer = { position: 'absolute', pointerEvents: 'none', zIndex: '10' };
|
|
48
|
+
container.style.position = 'relative';
|
|
49
|
+
|
|
50
|
+
if (d.watermarkRepeat === 'repeat') {
|
|
51
|
+
const spacing = 200;
|
|
52
|
+
const width = container.offsetWidth || 1000;
|
|
53
|
+
const height = container.offsetHeight || 1000;
|
|
54
|
+
const marks = [];
|
|
55
|
+
for (let y = -height; y < height * 2; y += spacing) {
|
|
56
|
+
for (let x = -width; x < width * 2; x += spacing) {
|
|
57
|
+
marks.push({
|
|
58
|
+
text: d.watermark,
|
|
59
|
+
style: { position: 'absolute', top: `${y}px`, left: `${x}px`, transform: `rotate(${rotation})`, fontSize: '36px', color, fontWeight: 'bold', whiteSpace: 'nowrap' },
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return el({ cls: 'view-watermark-container', style: { ...layer, inset: '0', overflow: 'hidden' }, children: marks }, doc);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (d.watermarkRepeat === 'tile') {
|
|
67
|
+
const canvas = doc.createElement('canvas');
|
|
68
|
+
canvas.width = 200;
|
|
69
|
+
canvas.height = 200;
|
|
70
|
+
const ctx = canvas.getContext('2d');
|
|
71
|
+
ctx.translate(100, 100);
|
|
72
|
+
ctx.rotate(parseFloat(rotation) * Math.PI / 180);
|
|
73
|
+
Object.assign(ctx, { fillStyle: color, font: 'bold 24px sans-serif', textAlign: 'center', textBaseline: 'middle' });
|
|
74
|
+
ctx.fillText(d.watermark, 0, 0);
|
|
75
|
+
return el({
|
|
76
|
+
cls: 'view-watermark-bg',
|
|
77
|
+
style: { ...layer, inset: '0', backgroundImage: `url('${canvas.toDataURL()}')`, backgroundRepeat: 'repeat' },
|
|
78
|
+
}, doc);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return el({
|
|
82
|
+
cls: 'view-watermark', text: d.watermark,
|
|
83
|
+
style: { ...layer, top: '50%', left: '50%', transform: `translate(-50%, -50%) rotate(${rotation})`, fontSize: '48px', color, fontWeight: 'bold', whiteSpace: 'nowrap' },
|
|
84
|
+
}, doc);
|
|
85
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* zOrder — one stacking-order algorithm for every diagram editor.
|
|
3
|
+
*
|
|
4
|
+
* Items are anything with `id` and `zIndex`. They are drawn in ascending
|
|
5
|
+
* zIndex, ties in their given order (a stable sort), so that is the order these
|
|
6
|
+
* functions reason about. Each operation returns the new zIndex of every item
|
|
7
|
+
* as consecutive integers, which keeps raise/lower exact (no fractional
|
|
8
|
+
* squeezing) and lets a command undo by restoring the previous values.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/** Items in drawing order: ascending zIndex, ties in their given order (Array#sort is stable). */
|
|
12
|
+
export function stackingOrder(items) {
|
|
13
|
+
return [...items].sort((a, b) => (a.zIndex || 0) - (b.zIndex || 0));
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** The four ordering operations, as moves within the drawing order. */
|
|
17
|
+
export const Z_ORDER_OPS = Object.freeze({
|
|
18
|
+
front: (order, i) => [...order.slice(0, i), ...order.slice(i + 1), order[i]],
|
|
19
|
+
back: (order, i) => [order[i], ...order.slice(0, i), ...order.slice(i + 1)],
|
|
20
|
+
raise: (order, i) => (i >= order.length - 1 ? order : [...order.slice(0, i), order[i + 1], order[i], ...order.slice(i + 2)]),
|
|
21
|
+
lower: (order, i) => (i <= 0 ? order : [...order.slice(0, i - 1), order[i], order[i - 1], ...order.slice(i + 1)]),
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* New zIndex for every item after applying `op` to the item with `id`.
|
|
26
|
+
* Pinned items (a background) stay behind every other item: an item moves
|
|
27
|
+
* within its own layer, so "send to back" stops just above the pinned ones.
|
|
28
|
+
* @param {Array<{id: string, zIndex?: number}>} items
|
|
29
|
+
* @param {string} id
|
|
30
|
+
* @param {'front'|'back'|'raise'|'lower'} op
|
|
31
|
+
* @param {Object} [options]
|
|
32
|
+
* @param {(id: string) => boolean} [options.pinned] - Whether an item is pinned to the back
|
|
33
|
+
* @returns {Map<string, number>|null} null when `id` is not among the items
|
|
34
|
+
*/
|
|
35
|
+
export function reorderedZ(items, id, op, { pinned = () => false } = {}) {
|
|
36
|
+
const move = Z_ORDER_OPS[op];
|
|
37
|
+
if (!move) throw new TypeError(`Unknown z-order operation "${op}"`);
|
|
38
|
+
const order = stackingOrder(items);
|
|
39
|
+
const back = order.filter(item => pinned(item.id));
|
|
40
|
+
const rest = order.filter(item => !pinned(item.id));
|
|
41
|
+
const layer = pinned(id) ? back : rest;
|
|
42
|
+
const at = layer.findIndex(item => item.id === id);
|
|
43
|
+
if (at < 0) return null;
|
|
44
|
+
const moved = move(layer, at);
|
|
45
|
+
const all = layer === back ? [...moved, ...rest] : [...back, ...moved];
|
|
46
|
+
return new Map(all.map((item, z) => [item.id, z]));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* New zIndex for every item with the pinned ones behind the rest, each layer
|
|
51
|
+
* keeping its own order: what a view does when items become its background.
|
|
52
|
+
* @returns {Map<string, number>}
|
|
53
|
+
*/
|
|
54
|
+
export function pinnedBehind(items, pinned) {
|
|
55
|
+
const order = stackingOrder(items);
|
|
56
|
+
return new Map([...order.filter(i => pinned(i.id)), ...order.filter(i => !pinned(i.id))].map((item, z) => [item.id, z]));
|
|
57
|
+
}
|
package/src/csvTable.js
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CSV as a table: the one CSV reader (archimateCSV.js and the mapped CSV
|
|
3
|
+
* import both use it). Quoted cells may hold the delimiter, quotes ("") and
|
|
4
|
+
* line breaks; a byte-order mark is dropped; the delimiter (comma,
|
|
5
|
+
* semicolon or tab, as spreadsheets in different places write them) is
|
|
6
|
+
* the one the header line uses most, unless given.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/** A byte-order mark at the start (spreadsheets write one), dropped. */
|
|
10
|
+
const BOM = new RegExp('^' + String.fromCharCode(0xfeff));
|
|
11
|
+
|
|
12
|
+
/** The delimiter a header line uses most (outside quotes): ',', ';' or tab. */
|
|
13
|
+
export function guessDelimiter(text) {
|
|
14
|
+
const counts = { ',': 0, ';': 0, '\t': 0 };
|
|
15
|
+
let quoted = false;
|
|
16
|
+
for (const ch of String(text)) {
|
|
17
|
+
if (ch === '"') quoted = !quoted;
|
|
18
|
+
else if (!quoted && ch === '\n') break;
|
|
19
|
+
else if (!quoted && ch in counts) counts[ch]++;
|
|
20
|
+
}
|
|
21
|
+
return Object.entries(counts).sort((a, b) => b[1] - a[1])[0][1] ? Object.entries(counts).sort((a, b) => b[1] - a[1])[0][0] : ',';
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Every record of a CSV text, as arrays of cells.
|
|
26
|
+
* @param {string} text
|
|
27
|
+
* @param {string} [delimiter] - Default: guessDelimiter(text)
|
|
28
|
+
* @returns {Array<Array<string>>}
|
|
29
|
+
*/
|
|
30
|
+
export function parseCsvRecords(text, delimiter = guessDelimiter(text)) {
|
|
31
|
+
const s = String(text ?? '').replace(BOM, '');
|
|
32
|
+
const records = [];
|
|
33
|
+
let record = [], cell = '', quoted = false, i = 0;
|
|
34
|
+
const endCell = () => { record.push(cell); cell = ''; };
|
|
35
|
+
const endRecord = () => { endCell(); if (record.length > 1 || record[0] !== '') records.push(record); record = []; };
|
|
36
|
+
while (i < s.length) {
|
|
37
|
+
const ch = s[i];
|
|
38
|
+
if (quoted) {
|
|
39
|
+
if (ch === '"' && s[i + 1] === '"') { cell += '"'; i += 2; continue; }
|
|
40
|
+
if (ch === '"') { quoted = false; i++; continue; }
|
|
41
|
+
cell += ch; i++; continue;
|
|
42
|
+
}
|
|
43
|
+
if (ch === '"' && cell === '') { quoted = true; i++; continue; }
|
|
44
|
+
if (ch === delimiter) { endCell(); i++; continue; }
|
|
45
|
+
if (ch === '\r' || ch === '\n') { endRecord(); i += ch === '\r' && s[i + 1] === '\n' ? 2 : 1; continue; }
|
|
46
|
+
cell += ch; i++;
|
|
47
|
+
}
|
|
48
|
+
if (cell !== '' || record.length) endRecord();
|
|
49
|
+
return records;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* A CSV text as its header's columns and a row object per record (a cell a
|
|
54
|
+
* record lacks is '').
|
|
55
|
+
* @returns {{columns: Array<string>, rows: Array<Object<string, string>>}}
|
|
56
|
+
*/
|
|
57
|
+
export function parseCsvTable(text, { delimiter } = {}) {
|
|
58
|
+
const [header = [], ...records] = parseCsvRecords(text, delimiter);
|
|
59
|
+
const columns = header.map(c => c.trim());
|
|
60
|
+
return { columns, rows: records.map(cells => Object.fromEntries(columns.map((c, i) => [c, cells[i] ?? '']))) };
|
|
61
|
+
}
|