From e262302e55460496f5191ea14dbe5c075aa5c922 Mon Sep 17 00:00:00 2001 From: Kevin Meaney Date: Wed, 22 Nov 2023 10:09:23 +0000 Subject: [PATCH] Applying SketchAPI changes to public repo. --- .eslintrc | 2 +- .../xcschemes/Sketch API.xcscheme | 2 +- Source/dom/models/DataOverride.js | 2 +- Source/dom/models/__tests__/Override.test.js | 27 ++++++++++++++----- Source/settings/Settings.js | 2 +- 5 files changed, 24 insertions(+), 11 deletions(-) diff --git a/.eslintrc b/.eslintrc index b80427d09..29f125ed6 100644 --- a/.eslintrc +++ b/.eslintrc @@ -53,7 +53,7 @@ "MSDocumentData": "readonly", "MSSymbolMaster": "readonly", "MSSymbolInstance": "readonly", - "MSAvailableOverride": "readonly", + "MSOverridePoint": "readonly", "MSAssetLibrary": "readonly", "MSDocument": "readonly", "NSURL": "readonly", diff --git a/SketchAPI.xcodeproj/xcshareddata/xcschemes/Sketch API.xcscheme b/SketchAPI.xcodeproj/xcshareddata/xcschemes/Sketch API.xcscheme index 6e6cffee4..9332b68d4 100644 --- a/SketchAPI.xcodeproj/xcshareddata/xcschemes/Sketch API.xcscheme +++ b/SketchAPI.xcodeproj/xcshareddata/xcschemes/Sketch API.xcscheme @@ -1,6 +1,6 @@ { // add the instance to the page document.selectedPage.layers = document.selectedPage.layers.concat(instance) - expect(instance.overrides.length).toBe(1) - expect(instance.overrides[0].property).toBe('image') + expect(instance.overrides.length).toBe(2) + + // check image resize behavior + expect(instance.overrides[0].property).toBe('imageResizeBehavior') expect(instance.overrides[0].isDefault).toBe(true) - expect(instance.overrides[0].value.type).toBe('ImageData') + expect(instance.overrides[0].value).toBe('Original') - instance.overrides[0].value = { + instance.overrides[0].value = '1' + + expect(instance.overrides[0].property).toBe('imageResizeBehavior') + expect(instance.overrides[0].isDefault).toBe(false) + expect(instance.overrides[0].value).toBe('1') + + // check image + expect(instance.overrides[1].property).toBe('image') + expect(instance.overrides[1].isDefault).toBe(true) + expect(instance.overrides[1].value.type).toBe('ImageData') + + instance.overrides[1].value = { base64: base64Image2, } - expect(instance.overrides[0].property).toBe('image') - expect(instance.overrides[0].isDefault).toBe(false) - expect(instance.overrides[0].value.type).toBe('ImageData') + expect(instance.overrides[1].property).toBe('image') + expect(instance.overrides[1].isDefault).toBe(false) + expect(instance.overrides[1].value.type).toBe('ImageData') }) test('hidden layers should not be editable', (_context, document) => { diff --git a/Source/settings/Settings.js b/Source/settings/Settings.js index c82d5bd26..6e7f73826 100644 --- a/Source/settings/Settings.js +++ b/Source/settings/Settings.js @@ -91,7 +91,7 @@ function getNativeStorageObject(layer) { if (!layer._isWrappedObject) { object = layer } else if (layer.type === 'DataOverride') { - object = layer.sketchObject.availableOverride().overrideValue() + object = layer.sketchObject.overridePoint().overrideValue() } else if (layer.type === 'Override') { object = layer.sketchObject.overrideValue() } else {