This commit is contained in:
Oliver Geer 2026-09-09 14:57:54 +02:00 committed by GitHub
commit 93f307e65d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -4,31 +4,32 @@
( function() {
const mediaTagCss = (
'media-tag{' +
'display:inline-block;' +
'border-style: solid;' +
'border-color: black;' +
'border-width: 0;' +
'}' +
'media-tag.selected{' +
'border: 1px solid black;' +
'}' +
'media-tag iframe{' +
'border: 6px solid #eee;' +
'}' +
'media-tag img{' +
'vertical-align: top;' +
'}' +
'media-tag *{' +
'width:100%; height:100%;' +
'}');
CKEDITOR.plugins.add( 'mediatag', {
requires: 'dialog,widget',
//icons: 'image',
//hidpi: true,
onLoad: function () {
CKEDITOR.addCss(
'media-tag{' +
'display:inline-block;' +
'border-style: solid;' +
'border-color: black;' +
'border-width: 0;' +
'}' +
'media-tag.selected{' +
'border: 1px solid black;' +
'}' +
'media-tag iframe{' +
'border: 6px solid #eee;' +
'}' +
'media-tag img{' +
'vertical-align: top;' +
'}' +
'media-tag *{' +
'width:100%; height:100%;' +
'}');
CKEDITOR.addCss(mediaTagCss);
},
init: function( editor ) {
var pluginName = 'mediatag';
@ -131,6 +132,16 @@
});
}
// Add CSS style to print preview, so media like images are sized the same
// as their enclosing `media-tag` elements, in other words sized correctly.
// Inspired by https://github.com/ckeditor/ckeditor4/blob/c7e59ec199298b6b23f4aa7a7668f18572385bac/plugins/mathjax/plugin.js#L136-L141
editor.on( 'contentPreview', function( evt ) {
evt.data.dataValue = evt.data.dataValue.replace(
/<\/head>/,
'<style>'+mediaTagCss+'<\/style><\/head>'
);
} );
},
} );