From 4384a28f395fee6fde31d1a8e43a0c2b44a14518 Mon Sep 17 00:00:00 2001 From: pklaschka Date: Mon, 17 Dec 2018 13:56:00 +0100 Subject: [PATCH 1/6] Added the viewport module (see https://adobexdplatform.com/plugin-docs/reference/viewport.html#viewport) --- types/viewport.d.ts | 60 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 types/viewport.d.ts diff --git a/types/viewport.d.ts b/types/viewport.d.ts new file mode 100644 index 0000000..f23b811 --- /dev/null +++ b/types/viewport.d.ts @@ -0,0 +1,60 @@ +/** + * The `viewport` module represents the current UI view of the XD document's content. + * Since: XD 14 + */ +import {SceneNode} from "./scenegraph"; + +declare class viewport { + /** + * The current viewport bounds expressed in global coordinates. + */ + public static readonly bounds: {x:number,y:number,width:number,height:number}; + + /** + * The current viewport zoom factor (where 1.0 = 100% zoom, 0.5 = 50% zoom, etc.). + */ + public static readonly zoomFactor: number; + + /** + * Smoothly pan the viewport to bring the entire given region into view. If the region is already fully in view, does nothing. If the given region is too large to fit entirely in view, it is simply centered (zoom remains unchanged). + * The region can be defined by passing a {@link SceneNode}, or by explicitly specifying a rectangle in global coordinates. + * @param {!SceneNode} node The node that gets scrolled into view + */ + public static scrollIntoView(node: SceneNode): void; + + /** + * Smoothly pan the viewport to bring the entire given region into view. If the region is already fully in view, does nothing. If the given region is too large to fit entirely in view, it is simply centered (zoom remains unchanged). + * The region can be defined by passing a {@link SceneNode}, or by explicitly specifying a rectangle in global coordinates. + * @param x + * @param y + * @param width + * @param height + */ + public static scrollIntoView(x: number, y:number, width:number, height:number): void; + + /** + * Smoothly pan the viewport to center on a specific point in the document's global coordinates. Even if the point is already in view, the view pans until it is centered. + * @param {number} x The x-coordinate of the centered point (in the document's global coordinates) + * @param {number} y The y-coordinate of the centered point (in the document's global coordinates) + */ + public static scrollToCenter(x: number, y:number): void; + + /** + * Zoom & pan the view as needed so the given region fills the viewport (with some padding). If the region is large, zooms out as needed so it fits entirely in view. If the region is smaller, zooms in so the region fills the entire viewport - may zoom in past 100% to achieve this. + * The region can be defined by passing a {@link SceneNode}, or by explicitly specifying a rectangle in global coordinates. + * @param {!SceneNode} node + */ + public static zoomToRect(node: SceneNode): void; + + /** + * Zoom & pan the view as needed so the given region fills the viewport (with some padding). If the region is large, zooms out as needed so it fits entirely in view. If the region is smaller, zooms in so the region fills the entire viewport - may zoom in past 100% to achieve this. + * The region can be defined by passing a {@link SceneNode}, or by explicitly specifying a rectangle in global coordinates. + * @param {number} x + * @param {number} y + * @param {number} width + * @param {number} height + */ + public static zoomToRect(x: number, y:number, width:number, height:number): void; +} + +export = viewport; From 02e96544631c676ebd6843c5d88c8983a16697d9 Mon Sep 17 00:00:00 2001 From: pklaschka Date: Mon, 17 Dec 2018 14:13:35 +0100 Subject: [PATCH 2/6] Updated corenerRadii docs and added scene node metadata (`pluginData`) --- types/scenegraph.d.ts | 21 +++++++++++++++++---- types/viewport.d.ts | 4 ++++ 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/types/scenegraph.d.ts b/types/scenegraph.d.ts index a252654..430b752 100644 --- a/types/scenegraph.d.ts +++ b/types/scenegraph.d.ts @@ -509,6 +509,16 @@ declare abstract class SceneNode { */ public readonly hasLinkedContent: boolean; + /** + * **Since:** XD 14 + * Metadata specific to your plugin. Must be a value which can be converted to a JSON string, or undefined to clear the stored metadata on this node. + * + * Metadata is persisted with the document when it is saved. Duplicating a node (including across documents, via copy-paste) will duplicate the metadata with it. If the node lies within a Symbol or Repeat Grid, all instances of the node will have identical metadata (changes in one copy will automatically be synced to the other copy). Metadata stored by this plugin cannot be accessed by other plugins - each plugin has its own isolated metadata storage. + * + * To store general metadata for the document overall, set pluginData on the root node of the scenegraph. Metadata on the root node can be changed from any edit context. + */ + public pluginData: any; + /** * Remove this node from its parent, effectively deleting it from the document. */ @@ -713,7 +723,9 @@ declare class Rectangle extends GraphicsNode { public height: number; /** - * To set all corners to the same value, use setAllCornerRadii. + * Default: `{topLeft:0, topRight:0, bottomRight:0, bottomLeft:0}` + * The actual corner radius that is rendered is capped based on the size of the rectangle even if the radius value set here is higher (see {@link effectiveCornerRadii}) + * To set all corners to the same value, use {@link setAllCornerRadii} */ public cornerRadii: { topLeft: number; @@ -726,8 +738,9 @@ declare class Rectangle extends GraphicsNode { * True if any of the Rectangle’s four corners is rounded (corner radius > 0). */ public readonly hasRoundedCorners: boolean; + /** - * The actual corner radius that is rendered may be capped by the size of the rectangle. Returns the actual radii that are currently in effect, which may be smaller than the cornerRadii values as a result. + * The actual corner radius that is rendered may be capped by the size of the rectangle. Returns the actual radii that are currently in effect, which may be smaller than the {@link cornerRadii} values as a result. */ public effectiveCornerRadii: { topLeft: number; @@ -737,8 +750,8 @@ declare class Rectangle extends GraphicsNode { }; /** - * Set the rounding radius of all four corners of the Rectangle to the same value. To set the corners to different radius values, use cornerRadii. - * @param {number} radius New radius of all corners + * Set the rounding radius of all four corners of the Rectangle to the same value. The actual corner radius that is rendered is capped based on the size of the rectangle even if the radius value set here is higher (see {@link effectiveCornerRadii}) + * To set the corners to different radius values, use {@link cornerRadii}. */ public setAllCornerRadii(radius: number): void; } diff --git a/types/viewport.d.ts b/types/viewport.d.ts index f23b811..2afb941 100644 --- a/types/viewport.d.ts +++ b/types/viewport.d.ts @@ -17,6 +17,7 @@ declare class viewport { /** * Smoothly pan the viewport to bring the entire given region into view. If the region is already fully in view, does nothing. If the given region is too large to fit entirely in view, it is simply centered (zoom remains unchanged). + * * The region can be defined by passing a {@link SceneNode}, or by explicitly specifying a rectangle in global coordinates. * @param {!SceneNode} node The node that gets scrolled into view */ @@ -24,6 +25,7 @@ declare class viewport { /** * Smoothly pan the viewport to bring the entire given region into view. If the region is already fully in view, does nothing. If the given region is too large to fit entirely in view, it is simply centered (zoom remains unchanged). + * * The region can be defined by passing a {@link SceneNode}, or by explicitly specifying a rectangle in global coordinates. * @param x * @param y @@ -41,6 +43,7 @@ declare class viewport { /** * Zoom & pan the view as needed so the given region fills the viewport (with some padding). If the region is large, zooms out as needed so it fits entirely in view. If the region is smaller, zooms in so the region fills the entire viewport - may zoom in past 100% to achieve this. + * * The region can be defined by passing a {@link SceneNode}, or by explicitly specifying a rectangle in global coordinates. * @param {!SceneNode} node */ @@ -48,6 +51,7 @@ declare class viewport { /** * Zoom & pan the view as needed so the given region fills the viewport (with some padding). If the region is large, zooms out as needed so it fits entirely in view. If the region is smaller, zooms in so the region fills the entire viewport - may zoom in past 100% to achieve this. + * * The region can be defined by passing a {@link SceneNode}, or by explicitly specifying a rectangle in global coordinates. * @param {number} x * @param {number} y From 35ef694e19cbb409c9ab9c748af652411fc1fffc Mon Sep 17 00:00:00 2001 From: pklaschka Date: Mon, 17 Dec 2018 14:16:44 +0100 Subject: [PATCH 3/6] Added selection and root to `scenegraph` --- types/scenegraph.d.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/types/scenegraph.d.ts b/types/scenegraph.d.ts index 430b752..ada6404 100644 --- a/types/scenegraph.d.ts +++ b/types/scenegraph.d.ts @@ -1113,6 +1113,18 @@ declare class RootNode extends SceneNode { public removeAllChildren(): void; } +/** + * **Since:** XD 14 + * Object representing the current selection state and edit context. Also available as the first argument passed to your plugin command handler function. + */ +const selection: Selection; + +/** + * **Since:** XD 14 + * Root node of the current document's scenegraph. Also available as the second argument passed to your plugin command handler function. + */ +const root: RootNode; + export { RootNode, SceneNode, @@ -1133,5 +1145,7 @@ export { LinearGradientFill, Matrix, Shadow, - Blur + Blur, + selection, + root } From 80283c429d2e144fa28de3d26d07741faa7f571d Mon Sep 17 00:00:00 2001 From: pklaschka Date: Mon, 17 Dec 2018 14:38:47 +0100 Subject: [PATCH 4/6] Added cloud module --- types/application.d.ts | 1 - types/cloud.ts | 105 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 105 insertions(+), 1 deletion(-) create mode 100644 types/cloud.ts diff --git a/types/application.d.ts b/types/application.d.ts index 8140ff4..bf44d17 100644 --- a/types/application.d.ts +++ b/types/application.d.ts @@ -1,5 +1,4 @@ import {Color, SceneNode} from "./scenegraph"; -import {} from "uxp"; /** * All rendition settings fields are required (for a given rendition type) unless otherwise specified. diff --git a/types/cloud.ts b/types/cloud.ts new file mode 100644 index 0000000..fa10a8c --- /dev/null +++ b/types/cloud.ts @@ -0,0 +1,105 @@ +export module cloud { + /** + * Interactive prototype view generated via "Share for Review." + */ + type PrototypeArtifact = { + /** + * Set to ArtifactType.PROTOTYPE + */ + type: ArtifactType.PROTOTYPE, + /** + * URL to view in browser + */ + url: string, + /** + * Name of shared artifact (often, but not always, matches the document name) + */ + name: string, + /** + * Level of access protection + */ + accessLevel: AccessLevel, + /** + * True if stakeholders can post comments on this artifact + */ + allowComments: boolean, + /** + * URL for embedding a view of the prototype inside an iframe (compact view with minimal surrounding UI) + */ + embedURL: string, + /** + * iframe width needed to display embedURL. May include room for navigation UI in addition to the prototype's content itself. + */ + embedWidth: number, + /** + * iframe height needed to display embedURL. May include room for navigation UI in addition to the prototype's content itself. + */ + embedHeight: number, + /** + * True if prototype defaults to a view that fills the entire page, with no surrounding UI visible for navigation, commenting, etc. + */ + fullscreenInPage: boolean, + /** + * True if clicking in non-interactive parts of the prototype flashes visual hints indicating the interactive spots + */ + hotspotHints: boolean + } + + /** + * Developer-oriented specs view generated via "Share for Development." + */ + type SpecsArtifact = { + type: ArtifactType.SPECS, + /** + * URL to view in browser + */ + url: string, + /** + * Name of shared artifact (often, but not always, matches the document name) + */ + name: string, + /** + * Level of access protection + */ + accessLevel: AccessLevel, + /** + * True if stakeholders can post comments on this artifact + */ + allowComments: boolean, + /** + * Target platform. Determines which information and measurement units are shown by default. + */ + targetPlatform: TargetPlatform + } + + /** + * Type of shared artifact: interactive prototype or developer-focused specs view + */ + export enum ArtifactType { + PROTOTYPE, + SPECS + } + + /** + * Target platform for published design specs + */ + export enum TargetPlatform { + WEB, IOS, ANDROID + } + + /** + * Access level of the shared link: accessible to anyone with the link, anyone with the link + password, or only specific Creative Cloud user accounts + */ + export enum AccessLevel { + LINKABLE, PASSWORD_PROTECTED, INVITE_ONLY + } + + /** + * Get a list of recently shared artifacts generated from this document. Older artifacts may not be included even if the shared links are still live. Shared links that have been deleted from the server (File > Manage Published Links) may still be listed here, as this API only provides a record of recent share actions from XD - not what the links' current status on the server may be. + * + * The list may contain a mix of PrototypeArtifact and/or SpecsArtifact, and items are listed in no particular order. If nothing has been shared from this document, an empty array is returned. + * + * @return {!Array} + */ + declare function getSharedArtifacts(): Array; +} \ No newline at end of file From 0431e1ae9b754c5a1d29f8f950db4318d955eefe Mon Sep 17 00:00:00 2001 From: pklaschka Date: Mon, 17 Dec 2018 14:41:19 +0100 Subject: [PATCH 5/6] =?UTF-8?q?Updated=20package.json=20(now=20also=20refl?= =?UTF-8?q?ecting=20the=20contribution=20amount=20by=20the=20position=20in?= =?UTF-8?q?=20the=20contributors=20list=20=E2=80=93=20that=20has=20to=20st?= =?UTF-8?q?ay=20up=20to=20date=20when=20it=20changes,=20though)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index 12e76b0..0a78ee1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@adobexd/typings", - "version": "1.0.1", + "version": "14.0.0", "typings": "./types/index.d.ts", "description": "Typings for Adobe XD CC", "repository": { @@ -8,9 +8,13 @@ "url": "git@github.com:AdobeXD/typings.git" }, "keywords": [ - "Typings", - "for", - "adobexd" + "typescript", + "adobe-xd", + "xd", + "adobexd", + "plugins", + "typings", + "typescript definitions" ], "license": "MIT", "bugs": { @@ -18,11 +22,6 @@ }, "homepage": "https://github.com/AdobeXD/typings#readme", "contributors": [ - { - "name": "Jonathan Fontanez", - "email": "fontanezj1@gmail.com", - "url": "https://github.com/tato123" - }, { "name": "Pablo Klaschka", "email": "xdplugins@pabloklaschka.de", @@ -32,6 +31,11 @@ "name": "Kerri Shotts", "email": "kerrishotts@gmail.com", "url": "https://github.com/kerrishotts" + }, + { + "name": "Jonathan Fontanez", + "email": "fontanezj1@gmail.com", + "url": "https://github.com/tato123" } ] } From 10070208a48821a31176656b5a06a96ea119b66d Mon Sep 17 00:00:00 2001 From: pklaschka Date: Mon, 17 Dec 2018 14:54:46 +0100 Subject: [PATCH 6/6] Updated scenegraph.Text docs --- types/scenegraph.d.ts | 77 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 74 insertions(+), 3 deletions(-) diff --git a/types/scenegraph.d.ts b/types/scenegraph.d.ts index ada6404..933a64a 100644 --- a/types/scenegraph.d.ts +++ b/types/scenegraph.d.ts @@ -886,7 +886,61 @@ declare class Text extends GraphicsNode { public flipY: boolean; /** - * Horizontal alignment: Text.ALIGN_LEFT, ALIGN_CENTER, or ALIGN_RIGHT. This setting affects the layout of multiline text, and it also affects what direction text grows when edited on canvas. + * **Since:** XD 14 + * Set the font family across all style ranges, or get the font family of the last style range (font family of all the text if one range covers all the text). Plugins should not assume any particular default value for fontFamily. + */ + public fontFamily: string; + + /** + * **Since:** XD 14 + * Set the font style across all style ranges, or get the font style of the last style range (font style of all the text if one range covers all the text). + * @default non-italic normal weight style + */ + public fontStyle: string; + + /** + * **Since:** XD 14 + * Font size in document pixels. Set the font size across all style ranges, or get the font size of the last style range (font size of all the text if one range covers all the text). Plugins should not assume any particular default value for fontSize. + */ + public fontSize: number; + + /** + * Set the text color across all style ranges, or get the color of the last style range (color of all the text if one range covers all the text). Unlike most other nodes, text only allows a solid color fill - gradients and image fills are not supported. + * @default null + */ + public fill: Color | null; + + /** + * **Since:** XD 14 + * Character spacing in increments of 1/1000th of the fontSize, in addition to the font's default character kerning. May be negative. + * + * Set the character spacing across all style ranges, or get the character spacing of the last style range (character spacing of all the text if one range covers all the text). + * @default 0 + */ + public charSpacing: number; + + /** + * **Since:** XD 14 + * Set underline across all style ranges, or get the underline of the last style range (underline of all the text if one range covers all the text). + * @default false + */ + public underline: boolean; + + public static readonly ALIGN_LEFT: string; + public static readonly ALIGN_CENTER: string; + public static readonly ALIGN_RIGHT: string; + + /** + * Horizontal alignment: Text.ALIGN_LEFT, ALIGN_CENTER, or ALIGN_RIGHT. This setting affects the layout of multiline text, and for point text it also affects how the text is positioned relative to its anchor point (x=0 in local coordinates) and what direction the text grows when edited by the user. + * + * Changing textAlign on existing point text will cause it to shift horizontally. To change textAlign while keeping the text in a fixed position, shift the text horizontally (moving its anchor point) to compensate: + * @example ```javascript + * let originalBounds = textNode.localBounds; + * textNode.textAlign = newAlignValue; + * let newBounds = textNode.localBounds; + * textNode.moveInParentCoordinates(originalBounds.x - newBounds.x, 0); + * + * @default Text.ALIGN_LEFT */ public textAlign: string; @@ -894,13 +948,30 @@ declare class Text extends GraphicsNode { * Distance between baselines in multiline text, in document pixels. The special value 0 causes XD to use the default line spacing defined by the font given the current font size & style. * * This property is not automatically adjusted when fontSize changes, if line spacing is not set to 0, the line spacing will stay fixed while the font size changes, shifting the spacing’s proportional relationship to font size. If the value is 0, then the rendered line spacing will change to match the new font size, since 0 means the spacing is dynamically calculated from the current font settings. + * + * @default 0 */ public lineSpacing: number; /** - * Null for point text. For area text, specifies the size of the rectangle within which text is wrapped and clipped. + * **Since:** XD 14 + * + * Additional distance between paragraphs, in document pixels, added to the lineSpacing amount (soft line breaks in area text are separated only by lineSpacing, while hard line breaks are separated by lineSpacing + paragraphSpacing). Unlike lineSpacing, 0 is not a special value; it just means no added spacing. + * + * Similar to {@link lineSpacing}, this property is not automatically adjusted when fontSize changes. The paragraph spacing amount will stay fixed while the font size changes, shifting the spacing's proportional relationship to font size. + * + * @default 0 + */ + public paragraphSpacing: number; + + /** + * `Null` for point text. For area text, specifies the size of the rectangle within which text is wrapped and clipped. + * + * Changing point text to area text or vice versa will change the origin / anchor point of the text, thus changing its localBounds, but it will also automatically change the node's transform so its globalBounds and boundsInParent origins remain unchanged. + * + * Changing area text to point text will also automatically insert hard line breaks ("\n") into the text to match the previous line wrapping's appearance exactly. */ - public readonly areaBox: null | { width: number; height: number }; + public areaBox: null | { width: number; height: number }; /** * Always false for point text. For area text, true if the text does not fit in the content box and its bottom is being clipped.