Skip to content

Commit

Permalink
fix: issue displaying preview when embedding content with enhanced im…
Browse files Browse the repository at this point in the history
…age field
  • Loading branch information
Florian ALEXANDRE committed May 29, 2024
1 parent a782027 commit e2b6c97
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/bundle/Resources/encore/ibexa.config.manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,23 @@

const path = require('path');

module.exports = (eZConfig, eZConfigManager) => {
eZConfigManager.add({
eZConfig,
module.exports = (ibexaConfig, ibexaConfigManager) => {
ibexaConfigManager.add({
eZConfig: ibexaConfig,
entryName: 'ezplatform-admin-ui-location-view-css',
newItems: [path.resolve(__dirname, '../public/css/focuspoint.scss')]
});
eZConfigManager.add({
eZConfig,
ibexaConfigManager.add({
eZConfig: ibexaConfig,
entryName: 'ezplatform-admin-ui-content-edit-parts-css',
newItems: [
path.resolve(__dirname, '../public/css/focuspoint.scss'),
path.resolve(__dirname, '../public/css/enhancedimage-field.scss'),
path.resolve(__dirname, '../public/css/enhancedimage.scss')
]
});
eZConfigManager.add({
eZConfig,
ibexaConfigManager.add({
eZConfig: ibexaConfig,
entryName: 'ezplatform-admin-ui-content-edit-parts-js',
newItems: [
path.resolve(__dirname, '../public/js/enhancedimage.js'),
Expand Down
7 changes: 7 additions & 0 deletions src/bundle/Resources/encore/ibexa.config.setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const path = require('path');

module.exports = (Encore) => {
Encore.addAliases({
'@ibexa-richtext': path.resolve('./vendor/ibexa/fieldtype-richtext'),
});
};
15 changes: 15 additions & 0 deletions src/bundle/Resources/encore/ibexa.richtext.config.manager.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const path = require('path')

module.exports = (ibexaConfig, ibexaConfigManager) => {
ibexaConfigManager.add({
ibexaConfig,
entryName: 'ibexa-richtext-onlineeditor-js',
newItems: [
path.resolve(__dirname, '../public/js/CKEditor/extraconfig.js')
]
})

Object.assign(ibexaConfig.resolve.alias, {
'@ibexa-richtext': path.resolve('./vendor/ibexa/fieldtype-richtext'),
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import IbexaEmbedImageEditing from '@ibexa-richtext/src/bundle/Resources/public/js/CKEditor/embed/image/embed-image-editing.js'
import IbexaEmbedImageCommand from '@ibexa-richtext/src/bundle/Resources/public/js/CKEditor/embed/image/embed-image-command.js'
import { findContent } from '@ibexa-richtext/src/bundle/Resources/public/js/CKEditor/services/content-service.js';
import Widget from '@ckeditor/ckeditor5-widget/src/widget';
class EnhancedImageEmbedImageEditing extends IbexaEmbedImageEditing {
loadImagePreview(modelElement) {
const contentId = modelElement.getAttribute('contentId');
const token = document.querySelector('meta[name="CSRF-Token"]').content;
const siteaccess = document.querySelector('meta[name="SiteAccess"]').content;

findContent({ token, siteaccess, contentId }, (contents) => {
const fields = contents[0].CurrentVersion.Version.Fields.field;
const fieldImage = fields.find((field) => ['enhancedimage', 'ezimage'].includes(field.fieldTypeIdentifier));
const size = modelElement.getAttribute('size');
const variationHref = fieldImage.fieldValue.variations[size].href;

this.loadImageVariation(modelElement, variationHref);
});
}

init() {
this.defineConverters();

this.editor.commands.add('insertIbexaEmbedImage', new IbexaEmbedImageCommand(this.editor));
}
}


export default EnhancedImageEmbedImageEditing;
9 changes: 9 additions & 0 deletions src/bundle/Resources/public/js/CKEditor/extraconfig.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import EnhancedImageEmbedImageEditing from "./embed/image/embed-image-editing";

(function (ibexa) {

ibexa.addConfig('richText.CKEditor.extraPlugins', [
EnhancedImageEmbedImageEditing
], true);

})(window.ibexa);

0 comments on commit e2b6c97

Please sign in to comment.