mirror of https://github.com/xwiki-labs/cryptpad
Fix background image in slides
This commit is contained in:
parent
04fe289bf8
commit
03e6c8dacc
|
@ -26,6 +26,17 @@ define([
|
||||||
// Cache of the avatars outer html (including <media-tag>)
|
// Cache of the avatars outer html (including <media-tag>)
|
||||||
var avatars = {};
|
var avatars = {};
|
||||||
|
|
||||||
|
MT.getMediaTag = function (common, data) {
|
||||||
|
var metadataMgr = common.getMetadataMgr();
|
||||||
|
var privateDat = metadataMgr.getPrivateData();
|
||||||
|
var origin = privateDat.fileHost || privateDat.origin;
|
||||||
|
var src = data.src = data.src.slice(0,1) === '/' ? origin + data.src : data.src;
|
||||||
|
return h('media-tag', {
|
||||||
|
src: src,
|
||||||
|
'data-crypto-key': 'cryptpad:'+data.key
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
MT.getCursorAvatar = function (cursor) {
|
MT.getCursorAvatar = function (cursor) {
|
||||||
var html = '<span class="cp-cursor-avatar">';
|
var html = '<span class="cp-cursor-avatar">';
|
||||||
html += (cursor.avatar && avatars[cursor.avatar]) || '';
|
html += (cursor.avatar && avatars[cursor.avatar]) || '';
|
||||||
|
|
|
@ -106,6 +106,7 @@ define([
|
||||||
funcs.addMentions = callWithCommon(UIElements.addMentions);
|
funcs.addMentions = callWithCommon(UIElements.addMentions);
|
||||||
funcs.importMediaTagMenu = callWithCommon(MT.importMediaTagMenu);
|
funcs.importMediaTagMenu = callWithCommon(MT.importMediaTagMenu);
|
||||||
funcs.getMediaTagPreview = callWithCommon(MT.getMediaTagPreview);
|
funcs.getMediaTagPreview = callWithCommon(MT.getMediaTagPreview);
|
||||||
|
funcs.getMediaTag = callWithCommon(MT.getMediaTag);
|
||||||
|
|
||||||
// Thumb
|
// Thumb
|
||||||
funcs.displayThumbnail = callWithCommon(Thumb.displayThumbnail);
|
funcs.displayThumbnail = callWithCommon(Thumb.displayThumbnail);
|
||||||
|
|
|
@ -12,12 +12,13 @@
|
||||||
@color: @colortheme_slide-color
|
@color: @colortheme_slide-color
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@slide-default-bg: #e3e3e3;
|
||||||
|
|
||||||
// body
|
// body
|
||||||
font-size: unset;
|
font-size: unset;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-flow: column;
|
flex-flow: column;
|
||||||
|
|
||||||
@slide-default-bg: #000;
|
|
||||||
.size (@n) {
|
.size (@n) {
|
||||||
// font-size: @n * 1vmin;
|
// font-size: @n * 1vmin;
|
||||||
// line-height: @n * 1.1vmin;
|
// line-height: @n * 1.1vmin;
|
||||||
|
@ -124,7 +125,7 @@
|
||||||
&> img {
|
&> img {
|
||||||
width: 50vw;
|
width: 50vw;
|
||||||
height: 28.125vw;
|
height: 28.125vw;
|
||||||
max-height: ~"calc(100vh - 96px)";
|
max-height: ~"calc(100vh - 96px)" !important;
|
||||||
max-width: ~"calc(16 / 9 * (100vh - 96px))";
|
max-width: ~"calc(16 / 9 * (100vh - 96px))";
|
||||||
position: absolute;
|
position: absolute;
|
||||||
left: 0;
|
left: 0;
|
||||||
|
|
|
@ -130,7 +130,6 @@ define([
|
||||||
|
|
||||||
// Flag to check if a file from the filepicker is a mediatag for the slides or a background image
|
// Flag to check if a file from the filepicker is a mediatag for the slides or a background image
|
||||||
var Background = {
|
var Background = {
|
||||||
isBackground: false
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var mkSlideOptionsButton = function (framework, slideOptions) {
|
var mkSlideOptionsButton = function (framework, slideOptions) {
|
||||||
|
@ -208,7 +207,6 @@ define([
|
||||||
style: 'font-size: 17px',
|
style: 'font-size: 17px',
|
||||||
id: 'cp-app-slide-options-bg'
|
id: 'cp-app-slide-options-bg'
|
||||||
}).click(function () {
|
}).click(function () {
|
||||||
Background.isBackground = true;
|
|
||||||
var pickerCfg = {
|
var pickerCfg = {
|
||||||
types: ['file'],
|
types: ['file'],
|
||||||
where: ['root'],
|
where: ['root'],
|
||||||
|
@ -216,7 +214,12 @@ define([
|
||||||
fileType: ['image/']
|
fileType: ['image/']
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
common.openFilePicker(pickerCfg);
|
common.openFilePicker(pickerCfg, function (data) {
|
||||||
|
if (data.type === 'file') {
|
||||||
|
data.mt = common.getMediaTag(data).outerHTML;
|
||||||
|
Background.todo(data);
|
||||||
|
}
|
||||||
|
});
|
||||||
}).text(Messages.printBackgroundButton).appendTo($p);
|
}).text(Messages.printBackgroundButton).appendTo($p);
|
||||||
}
|
}
|
||||||
$p.append($('<br>'));
|
$p.append($('<br>'));
|
||||||
|
@ -330,7 +333,7 @@ define([
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
var mkColorConfiguration = function (framework, $modal) {
|
var mkColorConfiguration = function (framework, $modal, slideOptions) {
|
||||||
var textColor;
|
var textColor;
|
||||||
var backColor;
|
var backColor;
|
||||||
var metadataMgr = framework._.cpNfInner.metadataMgr;
|
var metadataMgr = framework._.cpNfInner.metadataMgr;
|
||||||
|
@ -341,11 +344,13 @@ define([
|
||||||
$modal.css('color', text);
|
$modal.css('color', text);
|
||||||
$modal.css('border-color', text);
|
$modal.css('border-color', text);
|
||||||
$('#' + SLIDE_COLOR_ID).find('i').css('color', text);
|
$('#' + SLIDE_COLOR_ID).find('i').css('color', text);
|
||||||
|
slideOptions.textColor = text;
|
||||||
}
|
}
|
||||||
if (back) {
|
if (back) {
|
||||||
backColor = back;
|
backColor = back;
|
||||||
$modal.css('background-color', back);
|
//$modal.css('background-color', back);
|
||||||
$('#' + SLIDE_BACKCOLOR_ID).find('i').css('color', back);
|
$('#' + SLIDE_BACKCOLOR_ID).find('i').css('color', back);
|
||||||
|
slideOptions.bgColor = back;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
var updateLocalColors = function (text, back) {
|
var updateLocalColors = function (text, back) {
|
||||||
|
@ -411,14 +416,6 @@ define([
|
||||||
|
|
||||||
var mkFilePicker = function (framework, editor) {
|
var mkFilePicker = function (framework, editor) {
|
||||||
framework.setMediaTagEmbedder(function (mt, data) {
|
framework.setMediaTagEmbedder(function (mt, data) {
|
||||||
if (Background.isBackground) {
|
|
||||||
if (data.type === 'file') {
|
|
||||||
data.mt = mt[0].outerHTML;
|
|
||||||
Background.todo(data);
|
|
||||||
}
|
|
||||||
Background.isBackground = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
editor.replaceSelection($(mt)[0].outerHTML);
|
editor.replaceSelection($(mt)[0].outerHTML);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -477,7 +474,7 @@ define([
|
||||||
mkThemeButton(framework);
|
mkThemeButton(framework);
|
||||||
mkPrintButton(framework, editor, $content, $print);
|
mkPrintButton(framework, editor, $content, $print);
|
||||||
mkSlideOptionsButton(framework, slideOptions, $toolbarDrawer);
|
mkSlideOptionsButton(framework, slideOptions, $toolbarDrawer);
|
||||||
var colors = mkColorConfiguration(framework, $modal);
|
var colors = mkColorConfiguration(framework, $modal, slideOptions);
|
||||||
mkFilePicker(framework, editor);
|
mkFilePicker(framework, editor);
|
||||||
mkSlidePreviewPane(framework, $contentContainer);
|
mkSlidePreviewPane(framework, $contentContainer);
|
||||||
|
|
||||||
|
|
|
@ -93,7 +93,11 @@ define([
|
||||||
if (options.background && options.background.mt) {
|
if (options.background && options.background.mt) {
|
||||||
mediatagBg = options.background.mt;
|
mediatagBg = options.background.mt;
|
||||||
}
|
}
|
||||||
var m = '<span class="cp-app-slide-container">' + mediatagBg + '<span class="'+slideClass+'">'+DiffMd.render(c).replace(separatorReg, '</span></span><span class="cp-app-slide-container">' + mediatagBg + '<span class="'+slideClass+'">')+'</span></span>';
|
var bgColor = '';
|
||||||
|
if (options.bgColor && !mediatagBg) {
|
||||||
|
bgColor = 'style="background-color:'+options.bgColor+';"';
|
||||||
|
}
|
||||||
|
var m = '<span class="cp-app-slide-container">' + mediatagBg + '<span class="'+slideClass+'" '+bgColor+'>'+DiffMd.render(c).replace(separatorReg, '</span></span><span class="cp-app-slide-container">' + mediatagBg + '<span class="'+slideClass+'" '+bgColor+'>')+'</span></span>';
|
||||||
|
|
||||||
try { DiffMd.apply(m, $content, Common); } catch (e) { return console.error(e); }
|
try { DiffMd.apply(m, $content, Common); } catch (e) { return console.error(e); }
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue