Sketch

Sketch

This class represents the sketch file and all this content.

Constructor

new Sketch()

Source:
Properties:
Name Type Description
repo JSZip The instance of JSZip containing the raw data
document Node The document data
meta Node The meta data
user Node The user data
pages Array.<Page> Array with all pages of the document
symbolsPage Page | undefined The "Symbols" page if exists
symbols Array.<Node> Array with all local symbols (symbols stored in any page of the document)
foreignSymbols Array.<Node> Array with all foreign symbols used in the document (symbols loaded from libraries)
layerStyles Array.<SharedStyle> Array with all shared styles of the document
foreignLayerStyles Array.<SharedStyle> Array with all shared styles used and loaded from external libraries
textStyles Array.<SharedStyle> Array with all text styles of the document
foreignTextStyles Array.<SharedStyle> Array with all text styles used and loaded from external libraries
colors Array.<Node> Array with the document color palette
colorAssets Array.<Node> Array with the document color palette with names
gradients Array.<Node> Array with the document gradients palette
gradientAssets Array.<Node> Array with the document gradients palette with names

Methods

exportPreviews(dir)

Source:
Exports the file previews to other location
Example
//Export all document previews to a directory
sketch.exportPreviews('/path/to/export');
Parameters:
Name Type Description
dir string The directory path of the exported file.

exportTextPreviews(dir)

Source:
Exports the file previews to other location
Example
//Export all text previews to a directory
sketch.exportTextPreviews('/path/to/export');
Parameters:
Name Type Description
dir string The directory path of the exported file.

save(file) → {Promise}

Source:
Save the document as a sketch file
Example
ns.read('input.sketch').then((sketch) => {

 //modify the sketch data

 sketch.save('output.sketch')
})
Parameters:
Name Type Description
file string The file path
Returns:
Type
Promise

saveDir(dir) → {Promise}

Source:
Save the document into a directory with pretty json Useful to inspect the json scheme of a sketch file
Parameters:
Name Type Description
dir string [description]
Returns:
Type
Promise