mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-06-22 21:51:50 +08:00
Comments: Addressed a range of edge cases and ux issues for references
Handles only display and handling references when they're in the active tab, while handling proper removal when made not visible.
This commit is contained in:
@ -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<T extends Component>(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<T extends Component>(element: HTMLElement, name: string): T[] {
|
||||
const components = this.get<T>(name);
|
||||
return components.filter(c => element.contains(c.$el));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user