// SPDX-FileCopyrightText: 2023 XWiki CryptPad Team and contributors // // SPDX-License-Identifier: AGPL-3.0-or-later define([ 'jquery', 'json.sortify', '/components/nthen/index.js', '/common/sframe-common.js', '/slide/slide.js', '/common/sframe-app-framework.js', '/common/sframe-common-codemirror.js', '/common/common-util.js', '/common/common-hash.js', '/common/common-interface.js', '/common/hyperscript.js', '/customize/messages.js', 'cm/lib/codemirror', '/common/common-ui-elements.js', 'css!/components/bootstrap/dist/css/bootstrap.min.css', 'css!/components/components-font-awesome/css/font-awesome.min.css', 'css!/customize/src/print-landscape.css', 'less!/slide/app-slide.less', 'css!cm/lib/codemirror.css', 'css!cm/addon/dialog/dialog.css', 'css!cm/addon/fold/foldgutter.css', 'cm/mode/markdown/markdown', 'cm/addon/mode/loadmode', 'cm/mode/meta', 'cm/addon/mode/overlay', 'cm/addon/mode/multiplex', 'cm/addon/mode/simple', 'cm/addon/edit/closebrackets', 'cm/addon/edit/matchbrackets', 'cm/addon/edit/trailingspace', 'cm/addon/selection/active-line', 'cm/addon/search/search', 'cm/addon/search/match-highlighter', 'cm/addon/search/searchcursor', 'cm/addon/dialog/dialog', 'cm/addon/fold/foldcode', 'cm/addon/fold/foldgutter', 'cm/addon/fold/brace-fold', 'cm/addon/fold/xml-fold', 'cm/addon/fold/markdown-fold', 'cm/addon/fold/comment-fold', 'cm/addon/display/placeholder', ], function ( $, JSONSortify, nThen, SFCommon, Slide, Framework, SFCodeMirror, Util, Hash, UI, h, Messages, CMeditor, UIElements) { window.CodeMirror = CMeditor; var SLIDE_BACKCOLOR_ID = "cp-app-slide-toolbar-backcolor"; var SLIDE_COLOR_ID = "cp-app-slide-toolbar-color"; var mkLess = function (less) { return ( '#cp-app-slide-print .cp-app-slide-frame, ' + '#cp-app-slide-modal #cp-app-slide-modal-content .cp-app-slide-frame {\r\n' + less + '\r\n}' ); }; var mkSlidePreviewPane = function (framework, $contentContainer) { var $previewButton = framework._.sfCommon.createButton('preview', true); $previewButton.click(function () { var $c = $contentContainer; if ($c.hasClass('cp-app-slide-preview')) { framework._.sfCommon.setPadAttribute('previewMode', false, function (e) { if (e) { return console.log(e); } }); $previewButton.removeClass('cp-toolbar-button-active'); return void $c.removeClass('cp-app-slide-preview'); } framework._.sfCommon.setPadAttribute('previewMode', true, function (e) { if (e) { return console.log(e); } }); $c.addClass('cp-app-slide-preview'); $previewButton.addClass('cp-toolbar-button-active'); Slide.updateFontSize(); }); framework._.toolbar.$bottomM.append($previewButton); framework._.sfCommon.getPadAttribute('previewMode', function (e, data) { if (e) { return void console.error(e); } if (data !== false && $previewButton) { $previewButton.click(); } }); }; var mkThemeButton = function (framework) { const $drawer = UIElements.createDropdown({ text: Messages.toolbar_theme, options: [], common: framework._.sfCommon, iconCls: 'cptools cptools-palette' }); framework._.toolbar.$theme = $drawer.find('ul.cp-dropdown-content'); framework._.toolbar.$bottomL.append($drawer); $drawer.addClass('cp-toolbar-appmenu'); }; var mkPrintButton = function (framework, editor, $content, $print) { var $printButton = framework._.sfCommon.createButton('print', true); $printButton.click(function () { Slide.update(editor.getValue(), true); $print.html($content.html()); window.focus(); window.print(); framework.feedback('PRINT_SLIDES'); UI.clearTooltipsDelay(); }); var $printEntry = UIElements.getEntryFromButton($printButton); framework._.toolbar.$drawer.append($printEntry); }; // Flag to check if a file from the filepicker is a mediatag for the slides or a background image var Background = { }; var mkSlideOptionsButton = function (framework, slideOptions) { var metadataMgr = framework._.cpNfInner.metadataMgr; var updateSlideOptions = function (newOpt) { if (JSONSortify(newOpt) !== JSONSortify(slideOptions)) { $.extend(true, slideOptions, newOpt); // TODO: manage realtime + cursor in the "options" modal ?? Slide.updateOptions(); } }; var updateLocalOptions = function (newOpt) { updateSlideOptions(newOpt); var metadata = JSON.parse(JSON.stringify(metadataMgr.getMetadata())); metadata.slideOptions = slideOptions; metadataMgr.updateMetadata(metadata); framework.localChange(); }; var common = framework._.sfCommon; var createPrintDialog = function (invalidStyle) { var slideOptionsTmp = { title: false, slide: false, date: false, background: false, transition: true, style: '', styleLess: '' }; $.extend(true, slideOptionsTmp, slideOptions); var $container = $('
'); var $container2 = $('
').appendTo($container); var $div = $('
').appendTo($container2); var $p = $('

', {'class': 'msg'}).appendTo($div); $('').text(Messages.printOptions).appendTo($p); $p.append($('
')); // Slide number var cbox = UI.createCheckbox('cp-app-slide-options-number', Messages.printSlideNumber, slideOptionsTmp.slide); $(cbox).appendTo($p).find('input').on('change', function () { var c = this.checked; slideOptionsTmp.slide = c; }).css('width', 'auto'); // Date var cboxDate = UI.createCheckbox('cp-app-slide-options-date', Messages.printDate, slideOptionsTmp.date); $(cboxDate).appendTo($p).find('input').on('change', function () { var c = this.checked; slideOptionsTmp.date = c; }).css('width', 'auto'); // Title var cboxTitle = UI.createCheckbox('cp-app-slide-options-title', Messages.printTitle, slideOptionsTmp.title); $(cboxTitle).appendTo($p).find('input').on('change', function () { var c = this.checked; slideOptionsTmp.title = c; }).css('width', 'auto'); // Transition var cboxTransition = UI.createCheckbox('cp-app-slide-options-transition', Messages.printTransition, slideOptionsTmp.transition); $(cboxTransition).appendTo($p).find('input').on('change', function () { var c = this.checked; slideOptionsTmp.transition = c; }).css('width', 'auto'); $p.append($('
')); // Background image $('