Skip to content

Actions

Noah Baldwin edited this page May 11, 2025 · 3 revisions

Actions is in the RFC stage

Overview

Actions are to be usable in a similar manner to InkScape’s actions, however it is strictly not InkScapes actions, for the following reasons

  • Inkscape uses a copyleft license, which is nice until it’s not for certain contexts. So no code will be based on InkScape’s source code.
  • Inkscape actions are built for Inkscape, whereas our actions are intended for use by anyone wanting to make a vector editor
  • Inkscape uses its own DSL, whereas we’d rather use a well known, embeddable scripting language
  • Too many actions, we'd like to make a simple set of composable actions (e.g. cut = copy + delete)
  • Take inspiration from modern editors
    • Graphite is a vector editor that is procedural and reversible/non-destructive. We’d like actions to be the same

Actions

An action is essentially a method which takes in some arguments and changes the state of the application. Actions are pure functions; the application is expected to take the result and update it's own state to send to the next action.

Action Types

Manipulation

State

UI

Response Types

Action Specifications

UI

UI actions take the state and produce some UI output to the user application

enum UIAction {
  /// Display dialog with markdown content
  Dialog { content: String },
  /// Write content to clipboard
  Clipboard { content: String },
}
Action list

Returns the list of actions and their specification.

  • 📥 Input: Nothing
  • 🌟 Output: UIAction::Dialog
Copy

Copy the selected element(s) to clipboard

  • 📥 Input: State
  • 🌟 Ouput: UIAction::Clipboard
Export Start

Starts document serialization flow. Form submission should act Export Submit

  • 📥 Input: State
  • 🌟 Ouput: UIAction::Form
Export Submit

Serializes the document based on the provided options. Options may (optionally) be gathered from Export Start

  • 📥 Input: State, Export Options
  • 🌟 Ouput: UIAction::Form
New

Constructor for document. Effect of new state can be decided by the application (e.g. whether to overwrite existing state or create new tab)

  • 📥 Input: New Options
  • 🌟 Output: State

Serializes document

Manipulation

Manipulation actions take the application state and a set of options as input to produce a new

Align

Align each element on a given axis

  • Input: State, Alignment Axis
  • Output: State
Anchor Link

Wraps each selected element in a hyperlink. Selection moved to links.

  • 📥 Input: State, URL
  • 🌟 Output: State
Clone

Creates a deep copy of each selected element and puts it after the selected element. Selection moved to clones.

  • 📥 Input: State
  • 🌟 Output: State
Delete

Removes each selected element from the document.

  • 📥 Input: State
  • 🌟 Output: State

State

State tracks the following

  • The DOM tree
  • List of selected elements
  • Deletion stack

interface

  • rpc
  • bindings
  • scripting
Clone this wiki locally