Skip to content

Commit 4797e47

Browse files
committed
feat: add createSummaryFrom method
1 parent 3fd8f9a commit 4797e47

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/summary.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,18 @@ export const createSummary = function (this: MindElixirInstance) {
189189
})
190190
}
191191

192+
export const createSummaryFrom = function (this: MindElixirInstance, summary: Omit<Summary, 'id'>) {
193+
// now I know the goodness of overloading
194+
const id = generateUUID()
195+
const newSummary = { ...summary, id }
196+
drawSummary(this, newSummary)
197+
this.summaries.push(newSummary)
198+
this.bus.fire('operation', {
199+
name: 'createSummary',
200+
obj: newSummary,
201+
})
202+
}
203+
192204
export const removeSummary = function (this: MindElixirInstance, id: string) {
193205
const index = this.summaries.findIndex(summary => summary.id === id)
194206
if (index > -1) {

0 commit comments

Comments
 (0)