webwriter-app / webwriter

Authoring tool for interactive content
https://webwriter.app
Other
16 stars 1 forks source link

Package & Widget Concept #46

Open salmenf opened 10 months ago

salmenf commented 10 months ago

Package & Widget Concept

Phases

  1. Package Development
  2. Explorable Authoring
  3. Explorable Usage

Structure

A package is a set of elements to be used in WebWriter, implemented by a developer. It contains several parts with a package.json file serving as the entrypoint. It should follow NPM's conventions to provide metadata for the widget package. Specifically, these rules apply:

Elements

Widgets

Widgets are interactive elements visible to both authors and users.

Custom Elements Manifest (CEM) is a way to describe custom elements, adding metadata. For WebWriter, this could serve several functions.The @custom-elements-manifest/analyzer library is useful for this - During widget development, this can be run when neccessary.

Attributes & Events

Attributes represent the permanent state of the widget. WebWriter tracks changes in attributes and is able to undo/redo them. For non-permanent state, properties should be used. Attributes of the widget and events that may be emitted can be annotated for purposes of documentation.

Supported attributes & events
class - State of the editor

Slots

Slots are elements inside the widget's shadow tree in which content can be placed. This allows for a nesting of elements in WebWriter. Developers can specify the the allowed content of the slot with a content expression. The content expression is added as a custom JSDoc annotation on the component.

Parts & CSS variables

Parts and CSS variables enable styling the internals of the widget by WebWriter or developed stylesheets. Developers can annotate CSS variables with a CSS type that enables WebWriter to generate a widget allowing the user to manipulate the CSS variable. For example, the widget may have a --canvas-color variable that is of the CSS type <color>, allowing authors to use a color picker to choose a color.

Themes

Themes are stylesheets intended to be applied to the whole explorable.

Snippets

Snippets are arbitrary HTML fragments to be inserted into the explorable.