import Editor from ".." ; import Block from "../../components/block" ; import { walkTree } from "../../util" ; class StoreManage { editor : Editor ; blockStore : { [ key ] : Block ; } = { } ; constructor ( editor ) { this . editor = editor ; } init ( ) { this . blockStore = { } ; walkTree ( this . editor . article , ( each ) => { this . blockStore [ each . id ] = each ; } ) ; this . editor . $on ( "blockCreated" , ( block ) => { this . blockStore [ block . id ] = block ; } ) ; } getBlockById ( id ) { return this . blockStore [ id ] ; } } export default StoreManage ;