@fabwcie/free-drawing / components/Collaboration
components/Collaboration
Classes
Collaboration
Defined in: packages/free-drawing/src/components/Collaboration/Collaboration.ts:123
Real time collaboration in a room: changes of drawing (any tool, undo...) are sent shape by shape to other users of the room, through a socket.io server (see apps/server), so concurrent drawings are merged
Constructors
Constructor
new Collaboration(
drawer,socket,__namedParameters):Collaboration
Defined in: packages/free-drawing/src/components/Collaboration/Collaboration.ts:253
Listen to the socket (join on connect, changes, users, pointers) and to the pointer on the stage
Parameters
drawer
Drawer whose drawing is shared
socket
Socket connected to the collaboration server
__namedParameters
Returns
Properties
cipher
readonlycipher:RoomCipher|null
Defined in: packages/free-drawing/src/components/Collaboration/Collaboration.ts:162
Encryption of an encrypted room (key of its links): shapes, image files, background, pointers and views are encrypted before they are sent, the server never reads them; null for a room in clear
drawer
privatereadonlydrawer:Drawer
Defined in: packages/free-drawing/src/components/Collaboration/Collaboration.ts:164
Drawer whose drawing is shared
following
following:
boolean=true
Defined in: packages/free-drawing/src/components/Collaboration/Collaboration.ts:145
This user follows the presented view: stops when they move or zoom theirs, see follow
invitedBy?
readonlyoptionalinvitedBy?:string
Defined in: packages/free-drawing/src/components/Collaboration/Collaboration.ts:157
Id of the user who shared the link used to join, sent on join (the server gives their name to the owner)
members
members:
CollaborationMember[] =[]
Defined in: packages/free-drawing/src/components/Collaboration/Collaboration.ts:137
Users of the room with their rights, this one included
name
name:
string
Defined in: packages/free-drawing/src/components/Collaboration/Collaboration.ts:133
Name shown to other users
newUsersCanEdit
newUsersCanEdit:
boolean=false
Defined in: packages/free-drawing/src/components/Collaboration/Collaboration.ts:139
Users coming for the first time can draw (setting of the owner), else they view only (by default)
ownerKey?
readonlyoptionalownerKey?:string
Defined in: packages/free-drawing/src/components/Collaboration/Collaboration.ts:155
Secret of the owner of the room, sent on join: the server makes this user its owner
presentedView
presentedView:
PresentedView|null=null
Defined in: packages/free-drawing/src/components/Collaboration/Collaboration.ts:143
Area shown by the owner presenting it, null without presentation
presenting
presenting:
boolean=false
Defined in: packages/free-drawing/src/components/Collaboration/Collaboration.ts:141
This user (owner) presents their view: other users follow it, see present
requested
requested:
boolean=false
Defined in: packages/free-drawing/src/components/Collaboration/Collaboration.ts:147
This user (viewer) asked for the right to draw, waiting for the answer of the owner
requests
requests:
AccessRequest[] =[]
Defined in: packages/free-drawing/src/components/Collaboration/Collaboration.ts:149
Viewers asking the owner (this user) for the right to draw, waiting for its answer
room
readonlyroom:string
Defined in: packages/free-drawing/src/components/Collaboration/Collaboration.ts:131
Id of the room
socket
readonlysocket:CollaborationSocket
Defined in: packages/free-drawing/src/components/Collaboration/Collaboration.ts:129
Socket connected to the collaboration server, disconnected by stop
userId
userId:
string
Defined in: packages/free-drawing/src/components/Collaboration/Collaboration.ts:151
Id of this user: given by drawer, then by server when it joins (e.g. id of logged in account)
userKey?
readonlyoptionaluserKey?:string
Defined in: packages/free-drawing/src/components/Collaboration/Collaboration.ts:153
Secret of the browser of this user, sent on join with its id: nobody else gets this id from the server
users
users:
string[] =[]
Defined in: packages/free-drawing/src/components/Collaboration/Collaboration.ts:135
Names of users of the room, this one included
maxMessageSize
staticmaxMessageSize:number
Defined in: packages/free-drawing/src/components/Collaboration/Collaboration.ts:125
Largest message sent to the server (bytes), a bigger one would close the connection: maxMessageSize of the protocol
retryDelay
staticretryDelay:number=1000
Defined in: packages/free-drawing/src/components/Collaboration/Collaboration.ts:127
Time before a change refused beyond the rate of messages of the server is sent again (ms), lowered by tests
Accessors
canEdit
Get Signature
get canEdit():
boolean
Defined in: packages/free-drawing/src/components/Collaboration/Collaboration.ts:741
This user can draw (given by owner of the room)
Returns
boolean
isOwner
Get Signature
get isOwner():
boolean
Defined in: packages/free-drawing/src/components/Collaboration/Collaboration.ts:731
This user created the room: gives or removes the right to draw
Returns
boolean
Methods
_apply()
private_apply(change,kept?,merge?):void
Defined in: packages/free-drawing/src/components/Collaboration/Collaboration.ts:1655
Apply a change of another client: shapes removed, updated (groups replaced, selection kept) or added, stacking order applied. Shapes are recorded as synced, so the change is not sent back. Only drawing shapes are created, as from files: other nodes (stage, layers...) and invalid shapes are ignored
Parameters
change
Change received (or drawing of the room merged)
kept?
(id) => boolean
Tells the shapes kept as they are here (changed here, sent next): neither updated nor removed
merge?
(shape, state, json) => ShapeMerge | null
Merge of a group or frame kept with the state received (null: kept as it is), see _mergeOf
Returns
void
_applyBackground()
private_applyBackground(background,room?):void
Defined in: packages/free-drawing/src/components/Collaboration/Collaboration.ts:1809
Background color of another user, or of the room (whole drawing): shown and known as synced, not sent back. A room without background gets the one of this user (sent next)
Parameters
background
unknown
Color received (checked)
room?
boolean = false
Background of the room (whole drawing): none means the room has none
Returns
void
_applyReceived()
private_applyReceived(change,bases?):void
Defined in: packages/free-drawing/src/components/Collaboration/Collaboration.ts:1310
Change of another user applied, but to the shapes and background this user changed and did not send yet (end of a pointer action, encryption of a change): sent next, the server applies them after it. Groups and frames changed by both users are merged (_mergeOf: shapes added in them by each one kept), also the ones of changes of this user not acknowledged when it came; the merge is sent next. A viewer sends nothing: the whole change is applied
Parameters
change
Change received from the server
bases?
Map<string, string> = ...
JSON known by the room before the changes of this user not acknowledged when it came, of the shapes they changed (see _withoutUnconfirmed)
Returns
void
_color()
private_color(id):string
Defined in: packages/free-drawing/src/components/Collaboration/Collaboration.ts:678
Color of a user: their cursor and laser
Parameters
id
string
Id of the user
Returns
string
Color of cursorColors picked from the id, the same on every client
_createCursor()
private_createCursor(id):Group
Defined in: packages/free-drawing/src/components/Collaboration/Collaboration.ts:687
Cursor of another user in their color: arrow pointing to their position and label of their name
Parameters
id
string
Id of the user, gives the color
Returns
Group
Group of the cursor (not listening), scaled to the zoom, not added to a layer yet
_dropped()
private_dropped(part):void
Defined in: packages/free-drawing/src/components/Collaboration/Collaboration.ts:1531
Part of a change dropped by the server, beyond the rate of messages of this client: refused as by REJECTED (changes of others left out for it applied), its shapes, files and background sent again after a while (retryDelay)
Parameters
part
Part dropped
Returns
void
_emitChange()
private_emitChange(change,sent,volatile?,tooBig?,acknowledged?):void|Promise<void>
Defined in: packages/free-drawing/src/components/Collaboration/Collaboration.ts:506
Change sent to the server (encrypted in an encrypted room), unless too big for it: nothing is marked as sent then
Parameters
change
Change to send
sent
() => void
Marks its content as known by the room, called just before it is sent
volatile?
boolean = false
Live preview: dropped rather than delayed when the connection is slow
tooBig?
() => void
Called when it is not sent, too big for the server
acknowledged?
(answer) => void
Called once the server received it with its answer (refusal beyond its rate; servers of previous versions: never called)
Returns
void | Promise<void>
Promise while it is encrypted (sent unless the connection was lost meanwhile)
_emitData()
private_emitData(event,value,volatile?):void|Promise<void>
Defined in: packages/free-drawing/src/components/Collaboration/Collaboration.ts:481
Position or view sent to the server: encrypted in an encrypted room ({ data }, sent once encrypted unless the connection was lost meanwhile), as it is in a room in clear
Parameters
event
string
POINTER or VIEW
value
unknown
Pointer position (null out of the drawer), area of the view
volatile?
boolean = false
Dropped rather than delayed when the connection is slow
Returns
void | Promise<void>
Promise while it is encrypted
_fits()
private_fits(change):boolean
Defined in: packages/free-drawing/src/components/Collaboration/Collaboration.ts:1176
Change small enough for the server: a bigger message would close the connection, and the reconnection would send it again (loop). Told as a drawing too big
Parameters
change
DrawingChange | EncryptedChange
Change to send (encrypted in an encrypted room)
Returns
boolean
True when it can be sent
_forgetLeftOut()
private_forgetLeftOut(part):void
Defined in: packages/free-drawing/src/components/Collaboration/Collaboration.ts:1548
Part of a change of this user acknowledged: applied by the server after the changes of others left out for it, which are forgotten (unless a change of this user not acknowledged yet changed their shapes too)
Parameters
part
Part acknowledged
Returns
void
_inOrder()
private_inOrder(operation):void
Defined in: packages/free-drawing/src/components/Collaboration/Collaboration.ts:435
Operation run in order with the messages of the room: at once, unless messages of an encrypted room are being encrypted or decrypted (asynchronous), then after them, so messages are sent and handled in the order they come (whole drawing of the room before its users...). Nothing runs once the session is stopped
Parameters
operation
() => void | Promise<void>
Sends or handles a message, returns a promise while it encrypts or decrypts
Returns
void
_keepSynced()
private_keepSynced():void
Defined in: packages/free-drawing/src/components/Collaboration/Collaboration.ts:1584
Shapes known by the room kept in browser (hashes of their JSON), once changed: a page reloaded in the room knows which of its shapes the room has (_merge). Kept for the rooms used last
Returns
void
_listen()
private_listen<T>(event,handle):void
Defined in: packages/free-drawing/src/components/Collaboration/Collaboration.ts:460
Messages of an event of the server handled in order (see _inOrder)
Type Parameters
T
T
Parameters
event
string
Event of the server
handle
(message) => void | Promise<void>
Handles a message, returns a promise while it decrypts it
Returns
void
_merge()
private_merge(change):void
Defined in: packages/free-drawing/src/components/Collaboration/Collaboration.ts:1396
Drawing of the room merged with this one once joined: shapes added or changed here since the last sync are kept (sent next), others take their state in the room, shapes removed by other users meanwhile are removed (unless changed here). On first join, the shapes known by the room in a previous visit of this browser are known again (#restored), other shapes of the room take their state there (a copy of them is not newer), shapes only here are added to the room. A room without drawing (new, last user gone, server restarted: not kept) gets the whole drawing, with its image files; a room emptied by its users is merged as any other
Parameters
change
Whole drawing of the room (full)
Returns
void
_mergeOf()
private_mergeOf(shape,base,theirs,synced):ShapeMerge|null
Defined in: packages/free-drawing/src/components/Collaboration/Collaboration.ts:1352
Group or frame changed here and by another user: the change of this user applied over the one of the other user (mergeState: shapes added in it by each one kept, attributes and shapes changed here kept)
Parameters
shape
Group or frame of the drawing
base
string
JSON known by the room before both changes
theirs
State of the other user (checked)
synced
string
JSON known by the room once the merge is applied
Returns
ShapeMerge | null
The merge, null for another kind of shape (kept as it is here)
_onChange()
private_onChange(change):void
Defined in: packages/free-drawing/src/components/Collaboration/Collaboration.ts:537
Change of another user (decrypted in an encrypted room): whole drawing of the room merged after a reconnection, else applied
Parameters
change
Change received from the server
Returns
void
_readSynced()
private_readSynced():Map<string,string>
Defined in: packages/free-drawing/src/components/Collaboration/Collaboration.ts:1602
Shapes known by the room in a previous visit of this browser, see _keepSynced; the room is now the one used last
Returns
Map<string, string>
Hashes of their JSON by id, empty when none were kept
_receiveFiles()
private_receiveFiles(files):void
Defined in: packages/free-drawing/src/components/Collaboration/Collaboration.ts:1640
Image files received from the room: added to the drawing (valid ones), known by the room
Parameters
files
unknown
Files of a change (not trusted)
Returns
void
_receiveRequest()
private_receiveRequest(message):void
Defined in: packages/free-drawing/src/components/Collaboration/Collaboration.ts:896
Request of a viewer (owner: told in a toast, answered from the panel of the session), or refusal of the request of this user
Parameters
message
Request (userId, name) or answer (accepted), checked
Returns
void
_receiveView()
private_receiveView(message):void
Defined in: packages/free-drawing/src/components/Collaboration/Collaboration.ts:845
View of the owner presenting it: followed (unless this user moved theirs), told when a presentation starts or stops
Parameters
message
unknown
Area shown by the owner, null when the presentation stops (other values ignored)
Returns
void
_refuse()
private_refuse(upsert,remove):void
Defined in: packages/free-drawing/src/components/Collaboration/Collaboration.ts:1500
Change refused by the server (drawing too big, right to draw removed meanwhile): its shapes are not known by the room (_unsync, sent again later). Changes of other users left out for it are applied: the server applied them, not this one; later ones too while its shapes are not changed here (#refused)
Parameters
upsert
unknown
Ids of its shapes added or updated (not trusted)
remove
unknown
Ids of its removed shapes (not trusted)
Returns
void
_rejoin()
private_rejoin(change):void
Defined in: packages/free-drawing/src/components/Collaboration/Collaboration.ts:1374
Room joined (first time, or again after a disconnection): drawing of the room merged with this one, after the current pointer action
Parameters
change
Whole drawing of the room (full)
Returns
void
_removeCursors()
private_removeCursors():void
Defined in: packages/free-drawing/src/components/Collaboration/Collaboration.ts:940
Cursors and laser trails of other users removed
Returns
void
_scaleCursor()
private_scaleCursor(cursor):void
Defined in: packages/free-drawing/src/components/Collaboration/Collaboration.ts:715
Cursor scaled by inverse of zoom: same size on screen whatever zoom
Parameters
cursor
Group
Cursor of another user
Returns
void
_schedule()
private_schedule(key,send):void
Defined in: packages/free-drawing/src/components/Collaboration/Collaboration.ts:547
Send a message after live interval at most (latest state is read when sent)
Parameters
key
string
Kind of message (pointer, live): one timer and one last sent time per kind
send
() => void
Sends the message, called once the interval elapsed (ignored when one is already waiting)
Returns
void
_send()
private_send():void|Promise<void>
Defined in: packages/free-drawing/src/components/Collaboration/Collaboration.ts:959
Shapes changed since last sync sent, see send
Returns
void | Promise<void>
Promise while the change is encrypted
_sendPointer()
private_sendPointer(position):void
Defined in: packages/free-drawing/src/components/Collaboration/Collaboration.ts:563
Pointer position in drawing (null: out of drawer) and laser state sent to other users, at live interval at most
Parameters
position
Vector2d | null
Pointer position in drawing coordinates (rounded), null when it left the drawer
Returns
void
_sendView()
private_sendView():void
Defined in: packages/free-drawing/src/components/Collaboration/Collaboration.ts:784
View of the presenting owner sent to other users, at live interval at most (latest view when sent): the slide shown during a slideshow (seen alone), else its view
Returns
void
_showCursor()
private_showCursor(__namedParameters):void
Defined in: packages/free-drawing/src/components/Collaboration/Collaboration.ts:639
Cursor of another user with name, created on first position
Parameters
__namedParameters
Returns
void
_showView()
private_showView():void
Defined in: packages/free-drawing/src/components/Collaboration/Collaboration.ts:826
Presented area shown in the view of this user (not a move of theirs): a slide alone (around it masked)
Returns
void
_split()
private_split(shapes,current,remove,order,background,used):ChangePart[]
Defined in: packages/free-drawing/src/components/Collaboration/Collaboration.ts:1089
Change cut into messages small enough for the server (encrypted ones are bigger): shapes with the image files the room does not have yet, a shape and its files too big together apart, then other files of the drawing the room does not have (images read later); removals and background in the first one, stacking order in the last one
Parameters
shapes
Shapes to send, in stacking order
current
Map<string, string>
JSON of the shapes of the drawing by id
remove
string[]
Ids of removed shapes
order
false | string[]
Ids of all shapes from bottom to top when stacking order changed, else false
background
string | undefined
Background color when changed
used
Set<string>
Ids of the image files of the drawing
Returns
Parts to send in order, none when nothing changed
_stopWith()
private_stopWith(error):void
Defined in: packages/free-drawing/src/components/Collaboration/Collaboration.ts:468
Session stopped by an error told in a toast (key of the room, server)
Parameters
error
"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 text of the error
Returns
void
_syncKey()
private_syncKey(room):string
Defined in: packages/free-drawing/src/components/Collaboration/Collaboration.ts:1632
Key of localStorage keeping the shapes known by a room
Parameters
room
string
Id of the room
Returns
string
Key of the drawer for this room
_tellTooBig()
private_tellTooBig():void
Defined in: packages/free-drawing/src/components/Collaboration/Collaboration.ts:1189
Drawing too big for the session (changes not shared) told, again after a while
Returns
void
_unconfirm()
private_unconfirm():void
Defined in: packages/free-drawing/src/components/Collaboration/Collaboration.ts:1564
Connection lost: parts of changes sent while it was lost unseen (not acknowledged, sent in the time a lost connection takes to be seen) are unsynced, sent again once joined: the merge with the drawing of the room keeps them (else shapes drawn meanwhile would be removed, changes reverted)
Returns
void
_unsync()
private_unsync(upsert,remove):void
Defined in: packages/free-drawing/src/components/Collaboration/Collaboration.ts:1478
Change refused by the server (drawing too big, right to draw removed meanwhile) or lost with the connection: its shapes are not known by the room, sent again with a next change (with their image files), or their removal when they were removed since (the room may have an older state)
Parameters
upsert
unknown
Ids of its shapes added or updated (not trusted)
remove
unknown
Ids of its removed shapes (not trusted)
Returns
void
_update()
private_update(node,state):boolean
Defined in: packages/free-drawing/src/components/Collaboration/Collaboration.ts:1759
Node of the drawing updated to the state of another user, in place: groups and frames keep their nodes, matched by id (selection, text being edited, drags of their shapes kept); nodes new in the state are created, missing ones removed, in the order of the state
Parameters
node
Node
Node of the drawing with the id of the state
state
State of another user (checked)
Returns
boolean
false when the node is of another class: to replace
_withoutUnconfirmed()
private_withoutUnconfirmed(change): [DrawingChange,Map<string,string>]
Defined in: packages/free-drawing/src/components/Collaboration/Collaboration.ts:1250
Change of another user received before the server acknowledged changes of this user: the server applied it before them, their shapes (added, changed, removed), background and stacking order are left out of it (else this user would keep the version of the other user, the room and the other users the one of this user): kept in #leftOut, applied if the change of this user is refused. Groups and frames they changed are kept with the state the room had before them: merged by _applyReceived (shapes the other user added in them kept). Servers of previous versions acknowledge nothing: changes applied as they are
Parameters
change
Change received from the server
Returns
[DrawingChange, Map<string, string>]
The change without the parts changed by the changes not acknowledged, and the JSON known by the room before them of the shapes kept in it, by id
answerRequest()
answerRequest(
userId,accepted):void
Defined in: packages/free-drawing/src/components/Collaboration/Collaboration.ts:885
Answer the request of a viewer (owner): accepted gives them the right to draw, a refusal is told to them
Parameters
userId
string
Id of the user asking
accepted
boolean
True to let them draw
Returns
void
discardLive()
discardLive(
shape):void
Defined in: packages/free-drawing/src/components/Collaboration/Collaboration.ts:623
Shape being drawn discarded (simple click: nothing drawn): its live preview, if sent, is removed for everyone (the server keeps previews in the drawing of the room)
Parameters
shape
Shape removed from the drawing without change
Returns
void
flush()
flush():
boolean
Defined in: packages/free-drawing/src/components/Collaboration/Collaboration.ts:1225
Apply changes received during a pointer action
Returns
boolean
true if a change was applied
follow()
follow():
void
Defined in: packages/free-drawing/src/components/Collaboration/Collaboration.ts:815
Follow the presented view again, after moving or zooming theirs
Returns
void
onViewChange()
onViewChange():
void
Defined in: packages/free-drawing/src/components/Collaboration/Collaboration.ts:801
View moved or zoomed (Drawer._update): sent while presenting it, moved by this user while following a presentation: no longer followed (follow again)
Returns
void
present()
present(
on):void
Defined in: packages/free-drawing/src/components/Collaboration/Collaboration.ts:766
Present the view of this user (owner): other users follow its zoom and moves, until they move theirs
Parameters
on
boolean
True to present, false to stop
Returns
void
receive()
receive(
change):void
Defined in: packages/free-drawing/src/components/Collaboration/Collaboration.ts:1200
Apply change of another client, after current pointer action (not to alter shape being drawn)
Parameters
change
Change received from the server (live previews are applied at once)
Returns
void
requestEdit()
requestEdit():
void
Defined in: packages/free-drawing/src/components/Collaboration/Collaboration.ts:871
Ask the owner for the right to draw (viewer), once until it answers
Returns
void
send()
send():
void
Defined in: packages/free-drawing/src/components/Collaboration/Collaboration.ts:951
Send shapes changed since last sync, called on drawer change (in an encrypted room, after the messages being encrypted or decrypted: changes found then)
Returns
void
sendLive()
sendLive(
shapes):void
Defined in: packages/free-drawing/src/components/Collaboration/Collaboration.ts:590
Shapes being drawn or moved shown to other users while drawing, final state is sent by send on change. Not before the drawing of the room is merged (joining again): a preview would make the room keep it as its drawing
Parameters
shapes
Shapes being drawn or moved (shapes of groups send their whole group)
Returns
void
setLaser()
setLaser(
on):void
Defined in: packages/free-drawing/src/components/Collaboration/Collaboration.ts:577
Laser used (pressed) by this user: its trail is shown to other users with pointer
Parameters
on
boolean
Laser pressed (trail shown), false when released
Returns
void
setName()
setName(
name):void
Defined in: packages/free-drawing/src/components/Collaboration/Collaboration.ts:919
Change name shown to other users
Parameters
name
string
New name, sent to the server
Returns
void
setNewUsersCanEdit()
setNewUsersCanEdit(
canEdit):void
Defined in: packages/free-drawing/src/components/Collaboration/Collaboration.ts:758
Let users coming for the first time draw, or make them view only (owner only, checked by server)
Parameters
canEdit
boolean
True to let them draw, false to make them view only until the owner gives them the right
Returns
void
setRight()
setRight(
userId,canEdit):void
Defined in: packages/free-drawing/src/components/Collaboration/Collaboration.ts:750
Give or remove the right to draw to a user of the room (owner only, checked by server)
Parameters
userId
string
Id of the user of the room
canEdit
boolean
True to let them draw, false to make them view only
Returns
void
stop()
stop():
void
Defined in: packages/free-drawing/src/components/Collaboration/Collaboration.ts:927
Leave room, cursors of other users removed
Returns
void
updateCursors()
updateCursors():
void
Defined in: packages/free-drawing/src/components/Collaboration/Collaboration.ts:724
Cursors size kept after zoom
Returns
void