-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: issue displaying preview when embedding content with enhanced im…
…age field
- Loading branch information
Florian ALEXANDRE
committed
May 29, 2024
1 parent
a782027
commit e2b6c97
Showing
5 changed files
with
67 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
15
src/bundle/Resources/encore/ibexa.richtext.config.manager.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'), | ||
}); | ||
} |
29 changes: 29 additions & 0 deletions
29
src/bundle/Resources/public/js/CKEditor/embed/image/embed-image-editing.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |