@fabwcie/free-drawing / components/LayersPanel
components/LayersPanel
Classes
LayersPanel
Defined in: packages/free-drawing/src/components/LayersPanel/LayersPanel.ts:84
Panel listing drawing shapes, top one first, shapes of groups under them (expanded): select them (Shift adds), rename (double click, F2), reorder in their group (drag handle, Alt + arrows), hide, lock and delete them, group and ungroup selection
Constructors
Constructor
new LayersPanel(
drawer):LayersPanel
Defined in: packages/free-drawing/src/components/LayersPanel/LayersPanel.ts:120
Add the header button and the hidden panel, listen to drawing, selection, read only and language changes
Parameters
drawer
Drawer whose shapes are listed
Returns
Properties
$button
$button:
HTMLButtonElement
Defined in: packages/free-drawing/src/components/LayersPanel/LayersPanel.ts:90
Header button showing / hiding the panel (Alt+L)
$buttonContainer
$buttonContainer:
HTMLDivElement
Defined in: packages/free-drawing/src/components/LayersPanel/LayersPanel.ts:88
Container of the header button, added after the settings menu (hidden in zen mode)
$closeButton
$closeButton:
HTMLButtonElement
Defined in: packages/free-drawing/src/components/LayersPanel/LayersPanel.ts:98
Header button closing the panel, focus back on the panel button
$empty
$empty:
HTMLParagraphElement
Defined in: packages/free-drawing/src/components/LayersPanel/LayersPanel.ts:102
Message shown when the drawing has no shapes
$groupButton
$groupButton:
HTMLButtonElement
Defined in: packages/free-drawing/src/components/LayersPanel/LayersPanel.ts:94
Header button grouping selected shapes (Ctrl+G), enabled when they can be grouped
$hint
$hint:
HTMLParagraphElement
Defined in: packages/free-drawing/src/components/LayersPanel/LayersPanel.ts:104
Shortcuts selecting several rows
$list
$list:
HTMLUListElement
Defined in: packages/free-drawing/src/components/LayersPanel/LayersPanel.ts:100
List of rows of shapes, top one first (arrow keys move between names)
$panel
$panel:
HTMLDivElement
Defined in: packages/free-drawing/src/components/LayersPanel/LayersPanel.ts:92
Panel element (region named by its title): header, list of rows, empty message, hint
$ungroupButton
$ungroupButton:
HTMLButtonElement
Defined in: packages/free-drawing/src/components/LayersPanel/LayersPanel.ts:96
Header button ungrouping selected groups (Ctrl+Shift+G), enabled when a group is selected
drawer
drawer:
Drawer
Defined in: packages/free-drawing/src/components/LayersPanel/LayersPanel.ts:86
Drawer whose shapes are listed
Methods
_close()
private_close():void
Defined in: packages/free-drawing/src/components/LayersPanel/LayersPanel.ts:245
Hides the panel, focus back on its header button (close button, Escape)
Returns
void
_createAction()
private_createAction(part,icon,label,pressed,action):HTMLButtonElement
Defined in: packages/free-drawing/src/components/LayersPanel/LayersPanel.ts:509
Action of a row, toggle when pressed is a boolean
Parameters
part
string
data-part of the button (visibility, lock, delete): focus kept on it after update
icon
string
SVG markup of the icon
label
string
Accessible name, already translated
pressed
boolean | null
State of a toggle, null for a plain button
action
() => void
Run on click
Returns
HTMLButtonElement
Action button, disabled in read only
_createHeaderButton()
private_createHeaderButton(icon,label,shortcut,action):HTMLButtonElement
Defined in: packages/free-drawing/src/components/LayersPanel/LayersPanel.ts:258
Icon button of the panel header, named by its translated label, shortcut in tooltip (if any)
Parameters
icon
string
SVG markup of the icon
label
"drawer.label" | "language.auto" | "toast.collaborationUnavailable" | "toast.collaborationFull" | "toast.collaborationTooBig" | "toast.canDraw" | "toast.viewOnly" | "toast.joinedViewOnly" | "toast.presentationStarted" | "toast.presentationEnded" | "toast.requestSent" | "toast.requestReceived" | "toast.requestRefused" | "toast.saveFailed" | "toast.saved" | "toast.styleCopied" | "toast.libraryImported" | "toast.libraryNotSaved" | "toast.loadFailed" | "toast.invalidFile" | "toast.linkCopied" | "toast.linkNotCopied" | "toast.invalidLink" | "toast.invalidShapeLink" | "toast.clipboardUnavailable" | "toast.exportFailed" | "toast.imageCopied" | "toast.storageCleared" | "toast.imageNotCopied" | "error.clipboardUnavailable" | "error.nothingToExport" | "error.notDrawingFile" | "error.notImage" | "error.damagedLink" | "error.drawingTooBig" | "error.imageNotCreated" | "error.serverUnreachable" | "error.notAllowed" | "error.storageFull" | "error.notLibraryFile" | "error.noDrawingInImage" | "error.insecurePage" | "error.roomKey" | "error.encryptionUnsupported" | "toast.selectionTool" | "modal.close" | "confirm.message" | "confirm.clearCanvas" | "confirm.clearStorage" | "confirm.stopCollaboration" | "confirm.leaveCollaboration" | "confirm.cancel" | "confirm.confirm" | "menu.label" | "menu.open" | "menu.saveAs" | "menu.save" | "menu.unsaved" | "menu.copyLink" | "menu.collaboration" | "menu.collaborationOn" | "menu.collaborationUsers" | "menu.export" | "menu.clearCanvas" | "menu.showGrid" | "menu.zenMode" | "menu.darkMode" | "menu.github" | "menu.githubLabel" | "menu.clearStorage" | "menu.background" | "menu.language" | "menu.commands" | "menu.preferences" | "preferences.title" | "preferences.autoSave" | "preferences.shapeRecognition" | "grid.style" | "grid.squares" | "grid.dots" | "grid.lines" | "grid.isometric" | "grid.styleCommand" | "preferences.wheel" | "wheel.zoom" | "wheel.pan" | "wheel.command" | "help.spaceDrag" | "help.wheelDrag" | "preferences.save" | "preferences.appearance" | "preferences.theme" | "preferences.light" | "preferences.dark" | "preferences.system" | "preferences.drawing" | "commands.search" | "commands.empty" | "commands.file" | "commands.language" | "color.white" | "color.lightGray" | "color.lightBlue" | "color.lightYellow" | "color.lightBeige" | "color.lightRed" | "color.lightGreen" | "color.black" | "color.red" | "color.green" | "color.blue" | "color.orange" | "color.yellow" | "color.pink" | "color.transparent" | "color.custom" | "color.pick" | "help.title" | "help.documentation" | "help.issue" | "help.shortcuts" | "help.tools" | "help.editor" | "help.view" | "help.or" | "help.selectAll" | "help.deleteSelection" | "help.duplicate" | "help.group" | "help.selectInGroup" | "help.constrainDrawing" | "help.whileDrawing" | "help.cancelDrawing" | "help.arrowUnlinked" | "help.constrainSelection" | "help.whileTransforming" | "help.move" | "help.forwardBackward" | "help.frontBack" | "help.lock" | "help.paste" | "help.open" | "help.save" | "help.export" | "help.grid" | "help.layers" | "help.layersSelect" | "help.snap" | "help.zoom" | "help.toolsConstrain" | "key.delete" | "key.arrows" | "key.click" | "key.space" | "key.wheel" | "key.ctrl" | "key.shift" | "key.alt" | "key.escape" | "key.enter" | "key.tab" | "key.home" | "key.end" | "key.backspace" | "toolbar.label" | "toolbar.moreTools" | "toolbar.keepTool" | "tools.pan" | "tools.selection" | "tools.brush" | "tools.eraser" | "tools.text" | "tools.note" | "tools.line" | "tools.square" | "tools.circle" | "tools.arrow" | "tools.image" | "tools.triangle" | "tools.diamond" | "tools.laser" | "tools.frame" | "zoom.label" | "zoom.out" | "zoom.in" | "zoom.reset" | "zoom.fit" | "zoom.selection" | "zoom.to100" | "history.label" | "history.undo" | "history.redo" | "position.label" | "position.recenter" | "context.paste" | "context.snap" | "context.lock" | "context.unlock" | "selectionMenu.label" | "action.duplicate" | "action.copyStyle" | "action.pasteStyle" | "library.title" | "library.add" | "library.empty" | "library.hint" | "library.insert" | "library.remove" | "library.import" | "library.export" | "library.close" | "library.shapes" | "search.label" | "search.count" | "search.none" | "slideshow.start" | "slideshow.presentFrom" | "slideshow.label" | "slideshow.previous" | "slideshow.next" | "slideshow.stop" | "slideshow.count" | "slideshow.slide" | "slideshow.slideTitled" | "slideshow.noFrames" | "slideshow.nextPrevious" | "slideshow.firstLast" | "slideshow.whilePresenting" | "replay.start" | "replay.label" | "replay.play" | "replay.pause" | "replay.restart" | "replay.speed" | "replay.stop" | "replay.count" | "replay.empty" | "replay.finished" | "replay.playPause" | "replay.step" | "replay.firstLast" | "replay.whileReplaying" | "navigation.description" | "navigation.text" | "navigation.shapes" | "navigation.from" | "navigation.to" | "navigation.link" | "navigation.locked" | "navigation.in" | "navigation.index" | "navigation.left" | "navigation.nextPrevious" | "navigation.enter" | "navigation.parent" | "navigation.leave" | "navigation.onDrawing" | "search.previous" | "search.next" | "search.close" | "action.group" | "action.ungroup" | "action.sendToBack" | "action.sendBackward" | "action.bringForward" | "action.bringToFront" | "action.delete" | "action.rotateRight" | "action.rotateLeft" | "action.flipHorizontal" | "action.flipVertical" | "action.insertImage" | "toast.imageFailed" | "action.alignLeft" | "action.alignCenter" | "action.alignRight" | "action.alignTop" | "action.alignMiddle" | "action.alignBottom" | "action.distributeHorizontal" | "action.distributeVertical" | "action.stackHorizontal" | "action.stackVertical" | "action.fitTextWidth" | "action.copyPng" | "action.copySvg" | "action.link" | "overlay.tool" | "overlay.selection" | "overlay.shape" | "overlay.brush" | "overlay.recognizeShapes" | "overlay.recognizeShapesHint" | "overlay.note" | "overlay.text" | "overlay.stroke" | "overlay.color" | "overlay.background" | "overlay.strokeWidth" | "overlay.strokeStyle" | "overlay.edges" | "overlay.arrowType" | "overlay.startHead" | "overlay.endHead" | "overlay.opacity" | "overlay.layers" | "overlay.align" | "overlay.distribute" | "overlay.actions" | "link.address" | "link.placeholder" | "link.open" | "link.remove" | "width.thin" | "width.medium" | "width.thick" | "width.extraThick" | "style.solid" | "style.dashed" | "style.dotted" | "edges.sharp" | "edges.round" | "edges.radius" | "edges.auto" | "arrow.straight" | "arrow.curved" | "arrow.elbow" | "arrowhead.none" | "arrowhead.arrow" | "arrowhead.triangle" | "arrowhead.dot" | "arrowhead.bar" | "text.fontFamily" | "text.fontSize" | "text.small" | "text.medium" | "text.large" | "text.extraLarge" | "text.style" | "text.bold" | "text.italic" | "text.underline" | "text.strikethrough" | "text.align" | "text.alignLeft" | "text.alignCenter" | "text.alignRight" | "layers.title" | "layers.group" | "layers.close" | "layers.empty" | "layers.drag" | "layers.shapesOf" | "layers.hide" | "layers.lock" | "layers.delete" | "layers.name" | "layers.toggle" | "layers.range" | "shapes.freehand" | "shapes.line" | "shapes.rect" | "shapes.ellipse" | "shapes.arrow" | "shapes.triangle" | "shapes.diamond" | "shapes.heart" | "shapes.cloud" | "shapes.star" | "shapes.hexagon" | "shapes.blockArrow" | "shapes.bubble" | "shapes.checkbox" | "shapes.shape" | "shapes.highlighter" | "shapes.frame" | "shapes.frameName" | "shapes.text" | "shapes.note" | "shapes.group" | "shapes.image" | "export.title" | "export.empty" | "export.options" | "export.selected" | "export.background" | "export.dark" | "export.withDrawing" | "export.scale" | "export.saveAs" | "export.saveFile" | "export.copy" | "export.preview" | "collab.title" | "collab.intro" | "collab.introInvited" | "collab.introJoined" | "collab.introJoinedOf" | "collab.name" | "collab.anonymous" | "collab.link" | "collab.copy" | "collab.qrCode" | "collab.start" | "collab.join" | "collab.stop" | "collab.leave" | "collab.live" | "collab.liveState" | "collab.connected" | "collab.connecting" | "collab.you" | "collab.invitedBy" | "collab.canDrawLabel" | "collab.canDraw" | "collab.newUsersCanDraw" | "collab.encrypted" | "collab.notEncrypted" | "collab.owner" | "collab.viewOnly" | "collab.present" | "collab.presenting" | "collab.follow" | "collab.followPresentation" | "collab.following" | "collab.youCanDraw" | "collab.youViewOnly" | "collab.requestEdit" | "collab.requestSent" | "collab.requests" | "collab.requestsCount" | "collab.accept" | "collab.refuse" | "collab.acceptLabel" | "collab.refuseLabel" | "collab.users" | "collab.settings"
Key of the accessible name (translated again when language changes)
shortcut
string
Keys of the same action (Ctrl+G), shown in tooltip and aria-keyshortcuts, empty for none
action
() => void
Run on click
Returns
HTMLButtonElement
Header button, to add to the header actions
_createItem()
private_createItem(shape,depth):HTMLLIElement
Defined in: packages/free-drawing/src/components/LayersPanel/LayersPanel.ts:414
Row of a shape, indented by depth: drag handle, expand button (groups), name with type icon (selects, renames), hide, lock and delete buttons
Parameters
shape
Shape of the row, recorded in #shapes
depth
number
Nesting level of the shape (0 in drawing)
Returns
HTMLLIElement
Row of the shape
_createItems()
private_createItems(shapes,depth):HTMLLIElement[]
Defined in: packages/free-drawing/src/components/LayersPanel/LayersPanel.ts:394
Rows of shapes, top one first, followed by rows of shapes of expanded groups
Parameters
shapes
Shapes of the drawing or of a group, bottom one first (stacking order)
depth
number
Nesting level of the shapes (0 in drawing), indents their rows
Returns
HTMLLIElement[]
Rows in list order
_drag()
private_drag(e,shape,$item):void
Defined in: packages/free-drawing/src/components/LayersPanel/LayersPanel.ts:708
Drag of a row by its handle, among rows of the same group: drop place shown between rows
Parameters
e
PointerEvent
Pointer down on the handle (main button only)
shape
Shape of the dragged row, moved on drop
$item
HTMLElement
Dragged row
Returns
void
_getItem()
private_getItem(shape):HTMLElement|undefined
Defined in: packages/free-drawing/src/components/LayersPanel/LayersPanel.ts:527
Row of a shape
Parameters
shape
Shape listed in the panel
Returns
HTMLElement | undefined
Its row, undefined when it is not listed (collapsed group)
_getRange()
private_getRange(shape):DrawingShape[] |null
Defined in: packages/free-drawing/src/components/LayersPanel/LayersPanel.ts:614
Selectable shapes of rows from anchor to this one, in same group (null without anchor in it)
Parameters
shape
Shape of the row ending the range
Returns
DrawingShape[] | null
Visible shapes of the range in list order, null when the anchor is missing or in another group
_onNameKeydown()
private_onNameKeydown(e,shape,$name):void
Defined in: packages/free-drawing/src/components/LayersPanel/LayersPanel.ts:538
Keys of a row name: F2 renames, Shift + arrows select a range, Ctrl + Space adds or removes, Alt + arrows reorder, Right / Left expand / collapse a group (Left then goes to its group), Delete or Backspace deletes
Parameters
e
KeyboardEvent
Keydown of the name button, stopped when handled
shape
Shape of the row
$name
HTMLButtonElement
Name button of the row (replaced by a field to rename)
Returns
void
_onSelectionChange()
private_onSelectionChange():void
Defined in: packages/free-drawing/src/components/LayersPanel/LayersPanel.ts:357
Groups of shapes selected in a group (Ctrl + click on canvas) expanded
Returns
void
_rename()
private_rename(shape,$name):void
Defined in: packages/free-drawing/src/components/LayersPanel/LayersPanel.ts:633
Name field instead of name of a row: Enter or leaving it saves, Escape cancels, empty gives back default name
Parameters
shape
Shape renamed (its label)
$name
HTMLButtonElement
Name button of the row, replaced by the field
Returns
void
_select()
private_select(shape,mode):void
Defined in: packages/free-drawing/src/components/LayersPanel/LayersPanel.ts:589
Select shape of a row with selection tool (hidden shapes are not, locked ones only without others): one alone, toggle added or removed (Ctrl + click, Ctrl + Space), range with rows from anchor (Shift + click, Shift + arrows)
Parameters
shape
Shape of the row
mode
"toggle" | "range" | "one"
How the selection changes: one, toggle or range
Returns
void
_setCurrent()
private_setCurrent($current):void
Defined in: packages/free-drawing/src/components/LayersPanel/LayersPanel.ts:380
Row reached with Tab (roving tab index), others with arrows
Parameters
$current
Element | null | undefined
Row whose buttons are in tab order, none when not a row
Returns
void
isVisible()
isVisible():
boolean
Defined in: packages/free-drawing/src/components/LayersPanel/LayersPanel.ts:220
Whether the panel is shown
Returns
boolean
True while the panel is shown
moveShape()
moveShape(
shape,index):boolean
Defined in: packages/free-drawing/src/components/LayersPanel/LayersPanel.ts:677
Move a shape to a place of its group (or drawing): 0 is top. A shape and its text move together, its text just above it (else hidden under a note or a filled shape)
Parameters
shape
Shape moved among the shapes of its parent
index
number
Place from the top (row order), clamped to the shapes of the parent
Returns
boolean
true if it moved (change saved)
setExpanded()
setExpanded(
group,expanded):void
Defined in: packages/free-drawing/src/components/LayersPanel/LayersPanel.ts:277
Expand or collapse a group
Parameters
group
Group
Group (or frame) whose shapes are listed under its row
expanded
boolean
True to list its shapes, false to hide them
Returns
void
toggle()
toggle(
show?):void
Defined in: packages/free-drawing/src/components/LayersPanel/LayersPanel.ts:228
Show or hide panel (the library panel, at the same place, is hidden)
Parameters
show?
boolean = ...
Toggle by default
Returns
void
update()
update():
void
Defined in: packages/free-drawing/src/components/LayersPanel/LayersPanel.ts:286
List shapes again (after drawing changes), focus kept on same control
Returns
void
updateSelection()
updateSelection():
void
Defined in: packages/free-drawing/src/components/LayersPanel/LayersPanel.ts:322
Rows of selected shapes highlighted, first one scrolled into view, group buttons enabled
Returns
void