Doc
Doc
Extends
Constructors
new Doc()
new Doc():
Doc
Returns
Overrides
Source
packages/core/src/shapes.ts:1189
Properties
children
children:
Obj[]
Inherited from
Source
packages/core/src/core/obj.ts:14
id
id:
string
Inherited from
Source
packages/core/src/core/obj.ts:11
parent
parent:
null|Obj
Inherited from
Source
packages/core/src/core/obj.ts:13
type
type:
string
Inherited from
Source
packages/core/src/core/obj.ts:12
version
version:
number
Source
packages/core/src/shapes.ts:1187
Methods
find()
find(
pred):null|Obj
Find an shape in breath-first order
Parameters
• pred
Returns
null | Obj
Inherited from
Source
packages/core/src/core/obj.ts:372
findDepthFirst()
findDepthFirst(
pred):null|Obj
Find an shape in depth-first order
Parameters
• pred
Returns
null | Obj
Inherited from
Source
packages/core/src/core/obj.ts:385
findParent()
findParent(
pred):null|Obj
Find a shape along with the parent-chain
Parameters
• pred
Returns
null | Obj
Inherited from
Source
packages/core/src/core/obj.ts:398
fromJSON()
fromJSON(
json):void
Parameters
• json: any
Returns
void
Overrides
Source
packages/core/src/shapes.ts:1205
isDescendant()
isDescendant(
obj):boolean
Test whether the given shape is a descendant
Parameters
• obj: Obj
Returns
boolean
Inherited from
Source
packages/core/src/core/obj.ts:408
readAny()
readAny(
json,field,defaultValue):any
Read an any value from the JSON object, return defaultValue if the field is undefined.
Parameters
• json: any
• field: string
• defaultValue: any
Returns
any
Inherited from
Source
packages/core/src/core/obj.ts:54
readArrayAny()
readArrayAny(
json,field,defaultValue):any[]
Read an array of any value from the JSON object, return defaultValue if the field is not an array.
Parameters
• json: any
• field: string
• defaultValue: any[]
Returns
any[]
Inherited from
Source
packages/core/src/core/obj.ts:65
readArrayBoolean()
readArrayBoolean(
json,field,defaultValue,length?):boolean[]
Read an array of boolean from the JSON object, return defaultValue if the field is not an array of boolean.
Parameters
• json: any
• field: string
• defaultValue: boolean[]
• length?: number
Returns
boolean[]
Inherited from
Source
packages/core/src/core/obj.ts:148
readArrayNumber()
readArrayNumber(
json,field,defaultValue,length?):number[]
Read a number field from the JSON object, return defaultValue if the field is not a number.
Parameters
• json: any
• field: string
• defaultValue: number[]
• length?: number
Returns
number[]
Inherited from
Source
packages/core/src/core/obj.ts:87
readArrayPoint()
readArrayPoint(
json,field,defaultValue): [number,number][]
Read a, array of point value from the JSON object, return defaultValue if the field is not an array of point.
Parameters
• json: any
• field: string
• defaultValue: [number, number][]
Returns
[number, number][]
Inherited from
Source
packages/core/src/core/obj.ts:259
readArrayString()
readArrayString(
json,field,defaultValue):string[]
Read an array of string from the JSON object, return defaultValue if the field is not an array of string.
Parameters
• json: any
• field: string
• defaultValue: string[]
Returns
string[]
Inherited from
Source
packages/core/src/core/obj.ts:123
readBoolean()
readBoolean(
json,field,defaultValue):boolean
Read a boolean field from the JSON object, return defaultValue if the field is not a boolean.
Parameters
• json: any
• field: string
• defaultValue: boolean
Returns
boolean
Inherited from
Source
packages/core/src/core/obj.ts:137
readColor()
readColor(
json,field,defaultValue):string
Read a color field from the JSON object, return defaultValue if the field is not a string or not a valid color.
Parameters
• json: any
• field: string
• defaultValue: string
Returns
string
Inherited from
Source
packages/core/src/core/obj.ts:170
readEnum()
readEnum(
json,field,enumType,defaultValue):string
Read an enum value from the JSON object, return defaultValue if the field is not a valid enum value.
Parameters
• json: any
• field: string
• enumType: any
• defaultValue: string
Returns
string
Inherited from
Source
packages/core/src/core/obj.ts:185
readNumber()
readNumber(
json,field,defaultValue):number
Read a number field from the JSON object, return defaultValue if the field is not a number.
Parameters
• json: any
• field: string
• defaultValue: number
Returns
number
Inherited from
Source
packages/core/src/core/obj.ts:76
readPoint()
readPoint(
json,field,defaultValue): [number,number]
Read a point value from the JSON object, return defaultValue if the field is not a point.
Parameters
• json: any
• field: string
• defaultValue: [number, number]
Returns
[number, number]
Inherited from
Source
packages/core/src/core/obj.ts:216
readPointOrNull()
readPointOrNull(
json,field,defaultValue):null| [number,number]
Read a point or null value from the JSON object, return defaultValue if the field is not a point or null.
Parameters
• json: any
• field: string
• defaultValue: null | [number, number]
Returns
null | [number, number]
Inherited from
Source
packages/core/src/core/obj.ts:236
readRef()
readRef(
json,field):null|string|Obj
Read a reference to object from the JSON object, return defaultValue if the field is not string (obj’s id) or null.
Parameters
• json: any
• field: string
Returns
null | string | Obj
Inherited from
Source
packages/core/src/core/obj.ts:202
readString()
readString(
json,field,defaultValue):string
Read a string field from the JSON object, return defaultValue if the field is not a string.
Parameters
• json: any
• field: string
• defaultValue: string
Returns
string
Inherited from
Source
packages/core/src/core/obj.ts:112
resolveRefs()
resolveRefs(
idMap,nullIfNotFound):void
Resolve references
Parameters
• idMap: Record<string, Obj>
id to object map
• nullIfNotFound: boolean= false
assign null if not found
Returns
void
Inherited from
Source
packages/core/src/core/obj.ts:313
setJson()
setJson(
json,field,value,defaultValue,enforce):void
Set a field in the JSON object only if the value is defined and not equal to the default value.
Parameters
• json: any
The JSON object to set the field in.
• field: string
The field name to set.
• value: any
The value to set.
• defaultValue: any
The default value to compare against.
• enforce: boolean= false
If true, the field will be set even if it is equal to the default value.
Returns
void
Inherited from
Source
packages/core/src/core/obj.ts:31
toJSON()
toJSON(
recursive,keepRefs,enforce):any
Serialize to JSON object
Parameters
• recursive: boolean= false
recursively serialize children
• keepRefs: boolean= false
keep references as object (for undo-redo)
• enforce: boolean= false
Returns
any
Overrides
Source
packages/core/src/shapes.ts:1195
traverse()
traverse(
fun,parent):void
Traverse all objects in breath-first order
Parameters
• fun
• parent: null | Obj= null
Returns
void
Inherited from
Source
packages/core/src/core/obj.ts:326
traverseDepthFirst()
traverseDepthFirst(
fun,parent):void
Traverse all shapes in depth-first order
Parameters
• fun
• parent: null | Obj= null
Returns
void
Inherited from
Source
packages/core/src/core/obj.ts:340
traverseDepthFirstSequence()
traverseDepthFirstSequence():
Obj[]
Returns an array of shapes in order of traverse sequence.
Returns
Obj[]
Inherited from
Obj.traverseDepthFirstSequence
Source
packages/core/src/core/obj.ts:363
traverseSequence()
traverseSequence():
Obj[]
Returns an array of shapes in order of traverse sequence.
Returns
Obj[]