aboutsummaryrefslogtreecommitdiff
path: root/resources/vue/components/courseware/plugin-manager.js
blob: 5326fd992617128bfed8ba55b09121fd5028aa48 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { useBlockCategoryManager } from '../../composables/courseware/useBlockCategoryManager.js';

const { addCategory } = useBlockCategoryManager();

class PluginManager {
    constructor() {
        this.blocks = [];
        this.containers = [];
    }

    addBlock(name, block) {
        this.blocks[name] = block;
    }

    addCategory(title, type) {
        addCategory(title, type);
    }

    addContainer(name, container) {
        this.containers[name] = container;
    }

    registerComponentsLocally(component) {
        for (const [name, block] of Object.entries(this.blocks)) {
            component.$options.components[name] = block;
        }
        for (const [name, container] of Object.entries(this.containers)) {
            component.$options.components[name] = container;
        }
    }
}

export default PluginManager;