X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/b35b62d59ff057ce5cfbc5fb463431b086f5c830..refs/pull/5676/head:/resources/js/services/components.ts diff --git a/resources/js/services/components.ts b/resources/js/services/components.ts index c19939e92..0e13cd0a0 100644 --- a/resources/js/services/components.ts +++ b/resources/js/services/components.ts @@ -139,8 +139,8 @@ export class ComponentStore { /** * Get all the components of the given name. */ - public get(name: string): Component[] { - return this.components[name] || []; + public get(name: string): T[] { + return (this.components[name] || []) as T[]; } /** @@ -150,4 +150,9 @@ export class ComponentStore { const elComponents = this.elementComponentMap.get(element) || {}; return elComponents[name] || null; } + + public allWithinElement(element: HTMLElement, name: string): T[] { + const components = this.get(name); + return components.filter(c => element.contains(c.$el)); + } }