From 569dcae180346ac2365b551ff677f4288df1d6d7 Mon Sep 17 00:00:00 2001 From: Tobias Ortmayr Date: Wed, 11 Nov 2020 16:38:23 +0100 Subject: [PATCH] Add ExportSvgAction to protocol (#144) * Add ExportSvgAction to protocol Part of eclipse-glsp/glps/issues/117 --- PROTOCOL.md | 22 ++++++++++++++++++++++ README.md | 3 ++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/PROTOCOL.md b/PROTOCOL.md index b0899c3..4a4ee6c 100644 --- a/PROTOCOL.md +++ b/PROTOCOL.md @@ -38,6 +38,7 @@ - [2.6. Model Saving](#26-model-saving) - [2.6.1. SaveModelAction](#261-savemodelaction) - [2.6.2. SetDirtyStateAction](#262-setdirtystateaction) + - [2.6.2. ExportSvgAction](#263-exportsvgaction) - [2.7. Model Layout](#27-model-layout) - [2.7.1. RequestBoundsAction](#271-requestboundsaction) - [2.7.2. ComputedBoundsAction](#272-computedboundsaction) @@ -965,6 +966,27 @@ class SetDirtyStateAction implements Action { ``` +### 2.6.3. ExportSvgAction + +The client (or the server) sends an `ExportSvgAction` to indicate that the diagram, which represents the current model state, should be exported in SVG format. The action only provides the diagram SVG as plain string. The expected result of executing an `ExportSvgAction` is a new file in SVG-format on the underlying filesystem. However, other details like the target destination, concrete file name, file extension etc. are not specified in the protocol. So it is the responsibility of the action handler to process this information accordingly and export the result to the underlying filesystem. + +
Code + +```typescript +/** + * Sprotty's ExportSvgAction. + * Note that sprotty also provides a `RequestExportSvgAction` which is currently not supported in GLSP. + */ +class ExportSvgAction implements ResponseAction { + /** + * The diagram SModel as serializable SVG. + */ + public readonly svg:string; +} + +``` +
+ ## 2.7. Model Layout In GLSP the server usually controls the model's layout by applying bounds to all elements and sending an updated model to the client ([SetModelAction](#252-setmodelaction), [UpdateModelAction](#253-updatemodelaction)). However, calculating the correct bounds of each element may not be straight-forward as it may depend on certain client-side rendering properties, such as label size. diff --git a/README.md b/README.md index 3fb629c..e4f32f4 100644 --- a/README.md +++ b/README.md @@ -17,8 +17,9 @@ Below is a list of features that are supported by the different base technologie |------------------------------------------------------------------- |:--------------: |:-----------------: |:-------------------: |:-------------------: | | Model Saving | | ✓ | ✓ | | | Model Dirty State | | ✓ | ✓ | | +| Model SVG Export | | ✓ | | | | Model Layout | ✓ | ✓ | ✓ | ✓ | -| Model Edit Modes
- Edit
- Read-only |

  |

✓ |

  |

  | +| Model Edit Modes
- Edit
- Read-only |

  |

✓ |

  |

  | | Client View Port
- Center
- Fit to Screen |

✓ |

✓ |

✓ |

✓ | | Client Status Notification | ✓ | ✓ | ✓ | ✓ | | Client Message Notification | ✓ | ✓ | | |