Skip to content

Commit

Permalink
feat: Adds fromWithInlines for RichTextBlock (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
scottlovegrove authored Nov 9, 2022
1 parent c7d2a2f commit 725e732
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/ui-extensions-core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@doist/ui-extensions-core",
"version": "4.1.0",
"version": "4.1.1",
"description": "",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
13 changes: 13 additions & 0 deletions packages/ui-extensions-core/src/doist-card/card-elements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,4 +259,17 @@ export class RichTextBlock extends CardElement {
protected getJsonTypeName(): string {
return 'RichTextBlock'
}

static fromWithInlines<T extends RichTextBlock>(
this: new () => T,
props: Props<T> & { inlines?: Inline[] },
): T {
const o = new this()
const { inlines, ...rest } = props
Object.assign(o, rest)
if (inlines && inlines.length > 0) {
inlines.forEach((inline) => o.addInline(inline))
}
return o
}
}

0 comments on commit 725e732

Please sign in to comment.