APIs Missing: Data supplier
matteogratton opened this issue · 0 comments
It is currently pretty hard to add Data Suppliers to Sketch via plugin.
There are several issues:
-
the path URL of the JSON/TXT file should be managed with NSURL:
const url = NSURL.fileURLWithPath(filePath);
-
the dataSupplyManager should be called with internal code:
const dataManager = AppController.sharedInstance().dataSupplierManager();
-
the script should control if the dataSupplyManager could be added and if so add it with other native funcions:
if (dataManager.canAddLocalDataGroupWithURL(url)) {
const dataSupplierGroup =
MSLocalDataSupplierGroup.localDataSupplierGroupFromFileSystemURL_dataSupplierDelegate_error_(
url,
dataManager,
nil
);
if (dataSupplierGroup) {
dataManager.addLocalDataSupplierGroup(dataSupplierGroup);
}
}
it would be nice to have an API that just need the path of the document to be added and makes all the check and add them. Something like:
let dataManager = sketch.DataManager.add(filePath)
Also the option to remove them:
sketch.DataManager.remove(filePath)
or, if the variable exists:
dataManager.remove()
It would also be nice to be abe to add their icon in some ways:
sketch.DataManager.add(filePath, iconFilePath)
or if already created
datamanager.icon = iconfilePath