Skip to content

Commit

Permalink
[Fix] [WRS-1500] Fix onSelectedFrameContentChanged typing (#394)
Browse files Browse the repository at this point in the history
* [Fix] Fix onSelectedFrameContentChanged typing

* Fix subscriber controller test
  • Loading branch information
alexandraFlavia9 authored Nov 29, 2023
1 parent 6aac8d8 commit b2fa88a
Show file tree
Hide file tree
Showing 28 changed files with 64 additions and 113 deletions.
2 changes: 1 addition & 1 deletion packages/sdk/src/controllers/ActionController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export class ActionController {

/**
* This method stores the state of action type errors to the document
*
*
* Those errors states can be read back from the usual getters or the
* `onActionsChanged` stream
* @param id the id of a specific action
Expand Down
4 changes: 3 additions & 1 deletion packages/sdk/src/controllers/CharacterStyleController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ export class CharacterStyleController {
*/
rename = async (characterStyleId: Id, characterStyleName: string) => {
const res = await this.#editorAPI;
return res.renameCharacterStyle(characterStyleId, characterStyleName).then((result) => getEditorResponseData<null>(result));
return res
.renameCharacterStyle(characterStyleId, characterStyleName)
.then((result) => getEditorResponseData<null>(result));
};
}
1 change: 0 additions & 1 deletion packages/sdk/src/controllers/ColorConversionController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,4 @@ export class ColorConversionController {
const res = await this.#editorAPI;
return res.colorToRgb(color).then((result) => getEditorResponseData<RGBColor>(result));
};

}
4 changes: 3 additions & 1 deletion packages/sdk/src/controllers/ColorStyleController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ export class ColorStyleController {
*/
update = async (id: string, newColorProperties: ColorUpdate) => {
const res = await this.#editorAPI;
return res.updateColor(id, JSON.stringify(newColorProperties)).then((result) => getEditorResponseData<null>(result));
return res
.updateColor(id, JSON.stringify(newColorProperties))
.then((result) => getEditorResponseData<null>(result));
};

/**
Expand Down
30 changes: 8 additions & 22 deletions packages/sdk/src/controllers/FrameController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,7 @@ export class FrameController {
*/
setHeight = async (id: Id, height: string) => {
const res = await this.#editorAPI;
return res
.setFrameHeight(id, height)
.then((result) => getEditorResponseData<null>(result));
return res.setFrameHeight(id, height).then((result) => getEditorResponseData<null>(result));
};

/**
Expand All @@ -195,9 +193,7 @@ export class FrameController {
*/
setRotation = async (id: Id, rotation: string) => {
const res = await this.#editorAPI;
return res
.setFrameRotation(id, rotation)
.then((result) => getEditorResponseData<null>(result));
return res.setFrameRotation(id, rotation).then((result) => getEditorResponseData<null>(result));
};

/**
Expand All @@ -208,9 +204,7 @@ export class FrameController {
*/
setWidth = async (id: Id, width: string) => {
const res = await this.#editorAPI;
return res
.setFrameWidth(id, width)
.then((result) => getEditorResponseData<null>(result));
return res.setFrameWidth(id, width).then((result) => getEditorResponseData<null>(result));
};

/**
Expand All @@ -221,9 +215,7 @@ export class FrameController {
*/
setX = async (id: Id, XValue: string) => {
const res = await this.#editorAPI;
return res
.setFrameX(id, XValue)
.then((result) => getEditorResponseData<null>(result));
return res.setFrameX(id, XValue).then((result) => getEditorResponseData<null>(result));
};

/**
Expand All @@ -234,9 +226,7 @@ export class FrameController {
*/
setY = async (id: Id, YValue: string) => {
const res = await this.#editorAPI;
return res
.setFrameY(id, YValue)
.then((result) => getEditorResponseData<null>(result));
return res.setFrameY(id, YValue).then((result) => getEditorResponseData<null>(result));
};

/**
Expand Down Expand Up @@ -321,7 +311,7 @@ export class FrameController {

/**
* @deprecated Use `setIsVisible` instead.
*
*
* This method will set the visibility property of a specified frame. If set to false the frame will be invisible and vice versa.
* @param id the id of the frame that needs to get updated
* @param value True means the frame gets visible, false means the frame gets invisible
Expand Down Expand Up @@ -473,9 +463,7 @@ export class FrameController {
*/
setMinCopyfitting = async (id: Id, value: string) => {
const res = await this.#editorAPI;
return res
.setMinCopyfitting(id, value)
.then((result) => getEditorResponseData<null>(result));
return res.setMinCopyfitting(id, value).then((result) => getEditorResponseData<null>(result));
};

/**
Expand All @@ -486,9 +474,7 @@ export class FrameController {
*/
setMaxCopyfitting = async (id: Id, value: string) => {
const res = await this.#editorAPI;
return res
.setMaxCopyfitting(id, value)
.then((result) => getEditorResponseData<null>(result));
return res.setMaxCopyfitting(id, value).then((result) => getEditorResponseData<null>(result));
};

/**
Expand Down
18 changes: 6 additions & 12 deletions packages/sdk/src/controllers/LayoutController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,7 @@ export class LayoutController {
*/
setHeight = async (id: Id, height: string) => {
const res = await this.#editorAPI;
return res
.setLayoutHeight(id, height)
.then((result) => getEditorResponseData<null>(result));
return res.setLayoutHeight(id, height).then((result) => getEditorResponseData<null>(result));
};

/**
Expand All @@ -142,24 +140,20 @@ export class LayoutController {
*/
setWidth = async (id: Id, width: string) => {
const res = await this.#editorAPI;
return res
.setLayoutWidth(id, width)
.then((result) => getEditorResponseData<null>(result));
return res.setLayoutWidth(id, width).then((result) => getEditorResponseData<null>(result));
};

/**
* This method will set the unit of the layout to a specific value
*
*
* @param id The id of a specific layout
* @param unit the unit that will be used for the layout. All values in this layout will now be reported in this unit
* @returns
* @returns
*/
setUnit = async (id: Id, unit: MeasurementUnit) => {
const res = await this.#editorAPI;
return res
.setLayoutUnit(id, unit)
.then((result) => getEditorResponseData<null>(result));
}
return res.setLayoutUnit(id, unit).then((result) => getEditorResponseData<null>(result));
};

/**
* This method will reset the height of a specific layout to its original value
Expand Down
8 changes: 7 additions & 1 deletion packages/sdk/src/controllers/MediaConnectorController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,13 @@ export class MediaConnectorController {
) as MediaDownloadType;
const res = await this.#blobAPI;
return res
.mediaConnectorDownload(id, mediaId, compatibleDownloadType, MediaDownloadIntent.web, JSON.stringify(context))
.mediaConnectorDownload(
id,
mediaId,
compatibleDownloadType,
MediaDownloadIntent.web,
JSON.stringify(context),
)
.then((result) => (result as Uint8Array) ?? (result as EditorResponse<null>));
};

Expand Down
8 changes: 2 additions & 6 deletions packages/sdk/src/controllers/PageController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ export class PageController {
*/
setWidth = async (id: Id, width: string) => {
const res = await this.#editorAPI;
return res
.setPageWidth(id, width)
.then((result) => getEditorResponseData<null>(result));
return res.setPageWidth(id, width).then((result) => getEditorResponseData<null>(result));
};

/**
Expand All @@ -61,8 +59,6 @@ export class PageController {
*/
setHeight = async (id: Id, height: string) => {
const res = await this.#editorAPI;
return res
.setPageHeight(id, height)
.then((result) => getEditorResponseData<null>(result));
return res.setPageHeight(id, height).then((result) => getEditorResponseData<null>(result));
};
}
4 changes: 1 addition & 3 deletions packages/sdk/src/controllers/ParagraphStyleController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@ export class ParagraphStyleController {
*/
getById = async (id: Id) => {
const res = await this.#editorAPI;
return res
.getParagraphStyleById(id)
.then((result) => getEditorResponseData<ParagraphStyle>(result));
return res.getParagraphStyleById(id).then((result) => getEditorResponseData<ParagraphStyle>(result));
};

/**
Expand Down
4 changes: 1 addition & 3 deletions packages/sdk/src/controllers/ShapeController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,7 @@ export class ShapeController {
*/
private setShapeCorners = async (id: Id, radius: CornerRadiusUpdateModel) => {
const res = await this.#editorAPI;
return res
.setShapeCorners(id, JSON.stringify(radius))
.then((result) => getEditorResponseData<null>(result));
return res.setShapeCorners(id, JSON.stringify(radius)).then((result) => getEditorResponseData<null>(result));
};

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk/src/controllers/SubscriberController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export class SubscriberController {
multiFrameCallBack && multiFrameCallBack(frames);

const singleFrameCallBack = this.config.onSelectedFrameContentChanged;
singleFrameCallBack && singleFrameCallBack(frames.length > 1 ? undefined : frames[0]);
singleFrameCallBack && singleFrameCallBack(frames.length > 1 ? null : frames[0]);
};

/**
Expand Down
20 changes: 8 additions & 12 deletions packages/sdk/src/controllers/UndoManagerController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ export class UndoManagerController {

/**
* Record any operations in the current scope. This will automatically begin
* the undo operation. Once you leave the record scope, it will end the undo operation.
* Even if you throw an exception inside the record scope it will still end it properly.
* the undo operation. Once you leave the record scope, it will end the undo operation.
* Even if you throw an exception inside the record scope it will still end it properly.
* @returns
*/
record = async (operationName: string, undoOperationCallback: (sdk: SDK) => void) => {
Expand All @@ -54,8 +54,7 @@ export class UndoManagerController {
await undoOperationCallback(this.#sdk);
} catch (error) {
throw error;
}
finally {
} finally {
await this.#advanced.end();
}
};
Expand All @@ -75,7 +74,7 @@ export class AdvancedUndoManagerController {
}

/**
* This will start a new undo operation.
* This will start a new undo operation.
* This will throw an exception when there is already an undo operation recording.
* @returns
*/
Expand All @@ -85,25 +84,22 @@ export class AdvancedUndoManagerController {
};

/**
* This will start a new undo operation if there is no other undo operation recording.
* This does not throw.
* This will start a new undo operation if there is no other undo operation recording.
* This does not throw.
* @returns
*/
beginIfNoneActive = async (operationName: string) => {
const res = await this.#editorAPI;
return res.beginIfNoneActive(operationName).then((result) => getEditorResponseData<null>(result));
};


/**
* Ends the currently active recording operation.
* If there is no recording operation currently running this will throw an exception.
* Ends the currently active recording operation.
* If there is no recording operation currently running this will throw an exception.
* @returns
*/
end = async () => {
const res = await this.#editorAPI;
return res.end().then((result) => getEditorResponseData<null>(result));
};

}

1 change: 0 additions & 1 deletion packages/sdk/src/controllers/UtilsController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { EnvironmentType } from '../utils/enums';
* Methods inside this controller can be called by `window.SDK.utils.{method-name}`
*/
export class UtilsController {

/**
* This method can round a value to a certain precision, default is 2
* @param val the value that needs to be rounded
Expand Down
17 changes: 7 additions & 10 deletions packages/sdk/src/controllers/VariableController.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { EditorAPI, Id } from '../types/CommonTypes';
import { ConnectorRegistration } from '../types/ConnectorTypes';
import {
Variable,
VariableType,
} from '../types/VariableTypes';
import { Variable, VariableType } from '../types/VariableTypes';
import { getEditorResponseData } from '../utils/EditorResponseData';

/**
Expand Down Expand Up @@ -65,7 +62,7 @@ export class VariableController {

/**
* This method removes a list of variables.
*
*
* All connectors linked to the variables will be unregistered.
* @param ids list of the variables to be removed
* @returns
Expand Down Expand Up @@ -185,9 +182,7 @@ export class VariableController {
*/
moveVariables = async (order: number, ids: string[], parentId: string) => {
const res = await this.#editorAPI;
return res
.moveVariables(ids, parentId, order)
.then((result) => getEditorResponseData<null>(result));
return res.moveVariables(ids, parentId, order).then((result) => getEditorResponseData<null>(result));
};

/**
Expand All @@ -201,7 +196,7 @@ export class VariableController {

/**
* @deprecated Use `setIsVisible` instead.
*
*
* This method sets isHidden flag for a variable
* @returns
*/
Expand Down Expand Up @@ -248,7 +243,9 @@ export class VariableController {
*/
setImageVariableConnector = async (id: string, registration: ConnectorRegistration) => {
const res = await this.#editorAPI;
return res.setImageVariableConnector(id, JSON.stringify(registration)).then((result) => getEditorResponseData<Id>(result));
return res
.setImageVariableConnector(id, JSON.stringify(registration))
.then((result) => getEditorResponseData<Id>(result));
};

/**
Expand Down
Loading

0 comments on commit b2fa88a

Please sign in to comment.