Matches the actual Gitea repo location at block/core. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
33 lines
956 B
Go
33 lines
956 B
Go
package plugin
|
|
|
|
import (
|
|
"io/fs"
|
|
|
|
"git.dev.alexdunmow.com/block/core/blocks"
|
|
)
|
|
|
|
// PluginBlockRegistry wraps a BlockRegistry to auto-prefix block keys with the plugin name.
|
|
type PluginBlockRegistry struct {
|
|
inner blocks.BlockRegistry
|
|
prefix string
|
|
}
|
|
|
|
// NewPluginBlockRegistry creates a block registry that auto-prefixes keys.
|
|
func NewPluginBlockRegistry(inner blocks.BlockRegistry, pluginName string) *PluginBlockRegistry {
|
|
return &PluginBlockRegistry{inner: inner, prefix: pluginName}
|
|
}
|
|
|
|
func (r *PluginBlockRegistry) Register(meta blocks.BlockMeta, fn blocks.BlockFunc) {
|
|
meta.Key = r.prefix + ":" + meta.Key
|
|
meta.Source = r.prefix
|
|
r.inner.Register(meta, fn)
|
|
}
|
|
|
|
func (r *PluginBlockRegistry) RegisterTemplateOverride(templateKey, blockKey string, fn blocks.BlockFunc) {
|
|
r.inner.RegisterTemplateOverride(templateKey, blockKey, fn)
|
|
}
|
|
|
|
func (r *PluginBlockRegistry) LoadSchemasFromFS(fsys fs.FS) error {
|
|
return r.inner.LoadSchemasFromFS(fsys)
|
|
}
|