sns-boardview v0.0.32
sns-boardview
a "preact" editor component for "shareable-note-stickers"
Overview
While shareable-note-stickers implements the underlying data model for a shareable hierarchical collection of "boards" containing scriptable widgets (called "stickers"), this module provides a preact component that displays one of these boards of stickers and offers all methods to visually select and edit them.
While the data model is principally shareable, you will have to add a "sharing adapter" such as the sns-collabs-adapter to actually provide that feature.
Finally, to get a real application, you'll have to combine both modules and add a proper user interface - similar to NoteStickers.
Because of this modularity, it is not too difficult to use a different sharing framework (such as Y.js or automerge), modify the user interface according to your personal needs or even develop a headless tool that analyzes and/or changes the shared data without user intervention.
Usage
"sns-boardview" is intended for being used as a module within a "host application". In order to use it, simply import the SNS_BoardView
class:
import { SNS_BoardView } from '[sns-boardview](https://rozek.github.io/sns-boardview/dist/sns-boardview.modern.js)'
Then, as part of your user interface, instantiate the SNS_BoardView
like any other preact component:
html`<${SNS_BoardView}
PUX=${...}
Mode=${...} Board=${...} StickerList=${...}
LassoMode="..." selectedStickers=${...}
onSelectionChange=${(selectedStickers:SNS_Sticker[]) => {...}}
onGeometryChange=${(StickerList:SNS_Sticker[],GeometryList:SNS_Geometry[]) => {...}}
SnapToGrid=${...} GridWidth=${...} GridHeight=${...}
/>`
Attributes
SNS_BoardView
handles the following attributes:
PUX
- specifies a previously created ProtoUX instanceClasses
- specifies an optional string with additional CSS classes that should be used to style thisSNS_BoardView
Board
- specifies theSNS_Board
that should be shown (and may benull
if there is noSNS_Project
or the currentSNS_Project
does not yet contain any boards)StickerList
- specifies the actual list of stickers that should be shown (usually, its just theBoard.StickerList
)Placeholder
- specifies a text that is shown whenBoard
is not defined (ornull
)Mode
- inedit
mode, all stickers can be principally selected and layouted (unless they arelocked
or notvisible
). In 'run' mode, only the those stickers can be selected and layouted that supportbuiltinSelection
orbuiltinDragging
SelectionLimit
-SNS_BoardView
allows multiple stickers to be selected simultaneously. If you want to limit the number of selected stickers, just provide the limit hereselectedStickers
- specifies a callback with the signatureselectedStickers:SNS_Sticker[]
that is invoked (with the new list of selected stickers) whenever the list of selected stickers has changedonSelectionChange
- specifies a callback with the signatureSticker:SNS_Sticker
that is invoked whenever a sticker was deselectedonStickerSelected
- specifies a callback with the signatureSticker:SNS_Sticker
that is invoked whenever a sticker was selectedonStickerDeselected
- specifies a callback with the signatureSticker:SNS_Sticker
that is invoked whenever a sticker was deselectedSelectionFrameStyle
- specifies CSS settings to style selection frames (default isdotted 2px orangered
)SelectionHandleStyle
- specifies CSS settings to style selection handles (default isbackground:orangered; border:solid 1px darkgray
)LassoMode
- when set toenclose
the selection lasso has to fully enclose a sticker in order to select it, when set totouch
, the lasso only has to "touch" itonGeometryChange
- specifies a callback with the signatureStickerList:SNS_Sticker[], GeometryList:SNS_Geometry[]
that is invoked whenever theselectedStickers
where moved or sized by theSNS_BoardView
SnapToGrid
- when set totrue
,SNS_BoardView
constrains the position and size of visually layouted stickers to multiples ofGridWidth
in horizontal and multiples ofGridHeight
in vertical directionGridWidth
- specifies the horizontal distance between adjacent grid points whileSnapToGrid
istrue
GridHeight
- specifies the vertical distance between adjacent grid points whileSnapToGrid
istrue
Methods
Actually, SNS_BoardView
offers only one meaningful method:
rerender ()
- call this method whenever the specifiedBoard
, itsStickerList
or any of its contents have changed. preact will then take care that only those HTML elements will be rerendered that need to.
License
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago