Skip to content

Commit

Permalink
fetchPlugin, imagePlugin and i18nPlugin can be activated on a per-sit…
Browse files Browse the repository at this point in the history
…e basis in the website settings
  • Loading branch information
lexoyo committed Jun 5, 2024
1 parent 33eaa76 commit 5c23ed5
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions src/client/blocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import { EleventyPluginOptions } from '../client'

export default function(config: ClientConfig, opts: EleventyPluginOptions): void {
// After the editor is ready
// And the website is loaded (because we need its settings)
config.on('silex:startup:end', () => {
config.on('silex:grapesjs:end', () => {
const editor = config.getEditor()
// **
// Shortcode
Expand Down Expand Up @@ -125,22 +124,10 @@ export default function(config: ClientConfig, opts: EleventyPluginOptions): void
},
},
})
// **
// Image web component
if(opts.imagePlugin || config.getEditor().getModel().get('settings').eleventyImage) {
// Add an attribute for the webc version
const attributes = opts.imagePlugin === 'webc' ? { 'webc:is': 'eleventy-image' } : {}
// Add the block
editor.BlockManager.add('eleventy-img', {
label: 'eleventy-img',
category: 'Eleventy',
attributes: { class: 'fa fa-image' },
id: 'eleventy-img',
content: { type: 'eleventy-img' },
// The component `image` is activatable (shows the Asset Manager).
activate: true,
// select: true, // Default with `activate: true`
})
// Add the component type
editor.DomComponents.addType('eleventy-img', {
extend: 'image',
Expand All @@ -161,4 +148,22 @@ export default function(config: ClientConfig, opts: EleventyPluginOptions): void
})
}
})
// After the website is loaded (because we need its settings)
config.on('silex:startup:end', () => {
const editor = config.getEditor()
// Image web component
if(opts.imagePlugin || config.getEditor().getModel().get('settings').eleventyImage) {
// Add the block
editor.BlockManager.add('eleventy-img', {
label: 'eleventy-img',
category: 'Eleventy',
attributes: { class: 'fa fa-image' },
id: 'eleventy-img',
content: { type: 'eleventy-img' },
// The component `image` is activatable (shows the Asset Manager).
activate: true,
// select: true, // Default with `activate: true`
})
}
})
}

0 comments on commit 5c23ed5

Please sign in to comment.