From 77f7e9b2de566f92e9ed9b98d63b7fa997799f6c Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Thu, 19 Oct 2023 17:06:20 +0200 Subject: [PATCH] wait #6061 @2 --- .../config/supervisor/download-worker.conf | 2 +- .../supervisor/fluidbook-process-worker.conf | 2 +- .docker/config/supervisor/ws2-worker.conf | 2 +- .../linkeditor/js/linkeditor.clipboard.js | 2 +- resources/linkeditor/js/linkeditor.form.js | 2 +- resources/linkeditor/js/linkeditor.layers.js | 18 ++++- resources/linkeditor/js/linkeditor.links.js | 32 ++++++++- .../linkeditor/js/linkeditor.links.lock.js | 60 +++++++++++++++++ resources/linkeditor/js/linkeditor.loader.js | 2 +- resources/linkeditor/js/linkeditor.panels.js | 2 +- resources/linkeditor/js/linkeditor.popup.js | 2 +- resources/linkeditor/js/linkeditor.resize.js | 2 +- resources/linkeditor/js/linkeditor.rulers.js | 2 +- resources/linkeditor/js/linkeditor.save.js | 2 +- .../linkeditor/js/linkeditor.settings.js | 2 +- resources/linkeditor/js/linkeditor.toolbar.js | 2 +- resources/linkeditor/js/linkeditor.undo.js | 2 +- resources/linkeditor/js/linkeditor.utils.js | 7 +- .../linkeditor/js/linkeditor.versions.js | 2 +- resources/linkeditor/js/linkeditor.zoom.js | 2 +- resources/linkeditor/style/inc/_layers.sass | 67 ++++++++++++++----- resources/linkeditor/style/inc/_links.sass | 5 ++ .../link_editor.blade.php | 1 + .../link_editor_icons.blade.php | 7 +- 24 files changed, 188 insertions(+), 41 deletions(-) create mode 100644 resources/linkeditor/js/linkeditor.links.lock.js diff --git a/.docker/config/supervisor/download-worker.conf b/.docker/config/supervisor/download-worker.conf index 0fea922e6..81015be6a 100644 --- a/.docker/config/supervisor/download-worker.conf +++ b/.docker/config/supervisor/download-worker.conf @@ -5,7 +5,7 @@ autostart=true autorestart=true user=toolbox group=www-data -numprocs=24 +numprocs=6 redirect_stderr=true stdout_logfile=/proc/self/fd/2 stopwaitsecs=3600 diff --git a/.docker/config/supervisor/fluidbook-process-worker.conf b/.docker/config/supervisor/fluidbook-process-worker.conf index a69514a85..2d5633c56 100644 --- a/.docker/config/supervisor/fluidbook-process-worker.conf +++ b/.docker/config/supervisor/fluidbook-process-worker.conf @@ -5,7 +5,7 @@ autostart=true autorestart=true user=toolbox group=www-data -numprocs=144 +numprocs=48 redirect_stderr=true stdout_logfile=/proc/self/fd/2 stopwaitsecs=3600 diff --git a/.docker/config/supervisor/ws2-worker.conf b/.docker/config/supervisor/ws2-worker.conf index 930d29fb3..3ca86be92 100644 --- a/.docker/config/supervisor/ws2-worker.conf +++ b/.docker/config/supervisor/ws2-worker.conf @@ -5,7 +5,7 @@ autostart=true autorestart=true user=toolbox group=www-data -numprocs=12 +numprocs=6 redirect_stderr=true stdout_logfile=/proc/self/fd/2 stopwaitsecs=3600 diff --git a/resources/linkeditor/js/linkeditor.clipboard.js b/resources/linkeditor/js/linkeditor.clipboard.js index 2bdd603b3..d7ba4e4b2 100644 --- a/resources/linkeditor/js/linkeditor.clipboard.js +++ b/resources/linkeditor/js/linkeditor.clipboard.js @@ -112,4 +112,4 @@ LinkeditorClipboard.prototype = { }, } -module.exports = LinkeditorClipboard; +export default LinkeditorClipboard; diff --git a/resources/linkeditor/js/linkeditor.form.js b/resources/linkeditor/js/linkeditor.form.js index f2e987e14..acda0312a 100644 --- a/resources/linkeditor/js/linkeditor.form.js +++ b/resources/linkeditor/js/linkeditor.form.js @@ -331,4 +331,4 @@ LinkeditorForm.prototype = { } }; -module.exports = LinkeditorForm; +export default LinkeditorForm; diff --git a/resources/linkeditor/js/linkeditor.layers.js b/resources/linkeditor/js/linkeditor.layers.js index afadaecc1..ddbca2148 100644 --- a/resources/linkeditor/js/linkeditor.layers.js +++ b/resources/linkeditor/js/linkeditor.layers.js @@ -9,6 +9,12 @@ LinkeditorLayers.prototype = { this.container = $("#linkeditor-panel-layers"); this.maskCheckEvents = false; + $(document).on('click', '#linkeditor-panel-layers a.lock', function () { + let uid = $(this).closest('.layer').find('input').attr('name'); + $this.linkeditor.links.locks.toggleLock(uid); + return false; + }); + $(document).on('click', "#linkeditor-panel-layers label", function (e) { if ($this.maskCheckEvents) { return false; @@ -60,7 +66,14 @@ LinkeditorLayers.prototype = { if (dest === '') { dest = '' + TRANSLATIONS.empty + ''; } - var l = ''; + var l = '
'; + l += ''; + l += ''; + l += '
'; let d = parseInt($(this).attr('fb-calc-depth')); var m = 1; if (d >= 30 && d < 50) { @@ -88,6 +101,7 @@ LinkeditorLayers.prototype = { this.updateSelection(); this.linkeditor.initTooltips(); + this.linkeditor.initIcons(); }, updateSelection() { @@ -111,4 +125,4 @@ LinkeditorLayers.prototype = { }, }; -module.exports = LinkeditorLayers; +export default LinkeditorLayers; diff --git a/resources/linkeditor/js/linkeditor.links.js b/resources/linkeditor/js/linkeditor.links.js index 3066f65b8..3040f4b2b 100644 --- a/resources/linkeditor/js/linkeditor.links.js +++ b/resources/linkeditor/js/linkeditor.links.js @@ -1,3 +1,5 @@ +import LinkeditorLinksLock from './linkeditor.links.lock'; + var LinkeditorLinks = function (linkeditor) { this.linkeditor = linkeditor; @@ -17,6 +19,8 @@ var LinkeditorLinks = function (linkeditor) { this.dropTypes = [4, 6, 7, 12, 15, 16, 17, 18, 25, 30, 31]; + this.locks = new LinkeditorLinksLock(linkeditor); + this.init(); } @@ -81,7 +85,7 @@ LinkeditorLinks.prototype = { }); this.key('ctrl+a', function () { - $this.selectAll(); + $this.selectAllExceptLocked(); return false; }); @@ -234,7 +238,7 @@ LinkeditorLinks.prototype = { isHtmlName: true, name: TRANSLATIONS.select_all + ' Ctrl+A', callback: function () { - $this.selectAll(); + $this.selectAllExceptLocked(); }, } }; @@ -258,6 +262,16 @@ LinkeditorLinks.prototype = { }; } } + if (hasSelection) { + res.items.sep_lock = '---------'; + res.items.lock = { + isHtmlName: true, + name: TRANSLATIONS.lock + ' Ctrl+L', + callback: function () { + $this.locks.lockSelection(); + }, + }; + } if (hasSelection || hasClipboard) { res.items.sep_clipboard = '---------'; if (hasSelection) { @@ -481,6 +495,10 @@ LinkeditorLinks.prototype = { return !this.linkeditor.utils.isfocusOnFormItem(); }, + getLinkById: function (uid) { + return $('.link[fb-uid="' + uid + '"]'); + }, + openImageLink: function () { let selection = $(".link.selected").eq(0); @@ -1033,6 +1051,14 @@ LinkeditorLinks.prototype = { this.updateSelection(); }, + selectAllExceptLocked: function () { + let $this = this; + $('.link:not([data-locked="1"])').each(function () { + $this.selectLink($(this)); + }); + this.updateSelection(); + }, + updateSelection: function () { $("#linkeditor").attr('data-selection-count', this.getCurrentSelection().length); this.linkeditor.layers.updateSelection(); @@ -1531,4 +1557,4 @@ LinkeditorLinks.prototype = { }, }; -module.exports = LinkeditorLinks; +export default LinkeditorLinks; diff --git a/resources/linkeditor/js/linkeditor.links.lock.js b/resources/linkeditor/js/linkeditor.links.lock.js new file mode 100644 index 000000000..6b43396df --- /dev/null +++ b/resources/linkeditor/js/linkeditor.links.lock.js @@ -0,0 +1,60 @@ +function LinkeditorLinksLock(linkeditor) { + this.linkeditor = linkeditor; + this.locked = []; +} + +LinkeditorLinksLock.prototype = { + isLocked: function (uid) { + return this.locked.indexOf(uid) >= 0; + }, + + toggleLock: function (uid) { + if (this.isLocked(uid)) { + this.unlock([uid]); + } else { + this.lock([uid]); + } + }, + + lock: function (uid) { + for (let i in uid) { + this.locked.push(uid[i]); + } + this.locked = this.linkeditor.utils.array_unique(this.locked); + this.update(); + }, + + unlock: function (uid) { + for (let i in uid) { + let u = this.locked.splice(this.locked.indexOf(uid[i]), 1); + } + this.locked = this.linkeditor.utils.array_unique(this.locked); + this.update(); + }, + + lockSelection: function () { + let uid = []; + $('.link.selected').each(function () { + uid.push($(this).attr('fb-uid')); + }); + this.lock(uid); + }, + + update: function () { + // Unlock layers + $('#linkeditor-panel-layers [data-locked="1"]').attr('data-locked', '0'); + $('#linkeditor-links .link[data-locked="1"]').attr('data-locked', '0'); + + for (let i in this.locked) { + let uid = this.locked[i]; + // Lock layer + $('input[name="' + uid + '"]').closest('[data-locked]').attr('data-locked', '1'); + // Unselect link + let link = this.linkeditor.links.getLinkById(uid); + this.linkeditor.links.deselectLink(link); + link.attr('data-locked', '1'); + } + }, +} + +module.exports = LinkeditorLinksLock; diff --git a/resources/linkeditor/js/linkeditor.loader.js b/resources/linkeditor/js/linkeditor.loader.js index 2fab79bd4..09fdaa928 100644 --- a/resources/linkeditor/js/linkeditor.loader.js +++ b/resources/linkeditor/js/linkeditor.loader.js @@ -93,4 +93,4 @@ LinkeditorLoader.prototype = { $(container).html(c); }, } -module.exports = LinkeditorLoader; +export default LinkeditorLoader; diff --git a/resources/linkeditor/js/linkeditor.panels.js b/resources/linkeditor/js/linkeditor.panels.js index db324a7dd..66c6d5ef4 100644 --- a/resources/linkeditor/js/linkeditor.panels.js +++ b/resources/linkeditor/js/linkeditor.panels.js @@ -166,4 +166,4 @@ LinkeditorPanels.prototype = { }, }; -module.exports = LinkeditorPanels; +export default LinkeditorPanels; diff --git a/resources/linkeditor/js/linkeditor.popup.js b/resources/linkeditor/js/linkeditor.popup.js index 44c80f414..923c48ef5 100644 --- a/resources/linkeditor/js/linkeditor.popup.js +++ b/resources/linkeditor/js/linkeditor.popup.js @@ -50,4 +50,4 @@ LinkeditorPopup.prototype = { }) } }; -module.exports = LinkeditorPopup; +export default LinkeditorPopup; diff --git a/resources/linkeditor/js/linkeditor.resize.js b/resources/linkeditor/js/linkeditor.resize.js index e60cbe579..78912165a 100644 --- a/resources/linkeditor/js/linkeditor.resize.js +++ b/resources/linkeditor/js/linkeditor.resize.js @@ -114,4 +114,4 @@ LinkeditorResize.prototype = { $("#linkeditor-fluidbook").css({left: left, top: top, transform: 'scale(' + this.linkeditor.fs + ')'}); }, }; -module.exports = LinkeditorResize; +export default LinkeditorResize; diff --git a/resources/linkeditor/js/linkeditor.rulers.js b/resources/linkeditor/js/linkeditor.rulers.js index d7ea4a22c..4de32bdae 100644 --- a/resources/linkeditor/js/linkeditor.rulers.js +++ b/resources/linkeditor/js/linkeditor.rulers.js @@ -248,4 +248,4 @@ LinkeditorRulers.prototype = { $('#linkeditor-editor .ruler').remove(); }, }; -module.exports = LinkeditorRulers; +export default LinkeditorRulers; diff --git a/resources/linkeditor/js/linkeditor.save.js b/resources/linkeditor/js/linkeditor.save.js index c17759656..6f9dbc96e 100644 --- a/resources/linkeditor/js/linkeditor.save.js +++ b/resources/linkeditor/js/linkeditor.save.js @@ -87,4 +87,4 @@ LinkeditorSave.prototype = { }, }; -module.exports = LinkeditorSave; +export default LinkeditorSave; diff --git a/resources/linkeditor/js/linkeditor.settings.js b/resources/linkeditor/js/linkeditor.settings.js index df0fe596a..1ba80adbc 100644 --- a/resources/linkeditor/js/linkeditor.settings.js +++ b/resources/linkeditor/js/linkeditor.settings.js @@ -37,4 +37,4 @@ LinkeditorSettings.prototype = { }, 3000); } }; -module.exports = LinkeditorSettings; +export default LinkeditorSettings; diff --git a/resources/linkeditor/js/linkeditor.toolbar.js b/resources/linkeditor/js/linkeditor.toolbar.js index 1b95af675..b363b05f3 100644 --- a/resources/linkeditor/js/linkeditor.toolbar.js +++ b/resources/linkeditor/js/linkeditor.toolbar.js @@ -82,4 +82,4 @@ LinkeditorToolbar.prototype = { } }, }; -module.exports = LinkeditorToolbar; +export default LinkeditorToolbar; diff --git a/resources/linkeditor/js/linkeditor.undo.js b/resources/linkeditor/js/linkeditor.undo.js index 0189f092a..bbbbf24e1 100644 --- a/resources/linkeditor/js/linkeditor.undo.js +++ b/resources/linkeditor/js/linkeditor.undo.js @@ -127,4 +127,4 @@ LinkeditorUndo.prototype = { } -module.exports = LinkeditorUndo; +export default LinkeditorUndo; diff --git a/resources/linkeditor/js/linkeditor.utils.js b/resources/linkeditor/js/linkeditor.utils.js index 514068600..05a3efd64 100644 --- a/resources/linkeditor/js/linkeditor.utils.js +++ b/resources/linkeditor/js/linkeditor.utils.js @@ -12,6 +12,11 @@ LinkeditorUtils.prototype = { }, + + array_unique:function(arr){ + return arr.filter((value, index, array) => array.indexOf(value) === index); + }, + isSpecialPage: function (page) { if (page === undefined) { page = this.linkeditor.currentPage; @@ -161,4 +166,4 @@ LinkeditorUtils.prototype = { } }; -module.exports = LinkeditorUtils; +export default LinkeditorUtils; diff --git a/resources/linkeditor/js/linkeditor.versions.js b/resources/linkeditor/js/linkeditor.versions.js index 762d12350..4b9888e07 100644 --- a/resources/linkeditor/js/linkeditor.versions.js +++ b/resources/linkeditor/js/linkeditor.versions.js @@ -78,4 +78,4 @@ LinkeditorVersions.prototype = { }; -module.exports = LinkeditorVersions; +export default LinkeditorVersions; diff --git a/resources/linkeditor/js/linkeditor.zoom.js b/resources/linkeditor/js/linkeditor.zoom.js index 54f88cf95..57dc66f92 100644 --- a/resources/linkeditor/js/linkeditor.zoom.js +++ b/resources/linkeditor/js/linkeditor.zoom.js @@ -140,4 +140,4 @@ LinkeditorZoom.prototype = { this.resetZoomDrag(); }, }; -module.exports = LinkeditorZoom; +export default LinkeditorZoom; diff --git a/resources/linkeditor/style/inc/_layers.sass b/resources/linkeditor/style/inc/_layers.sass index b4d8b89b1..4ce410a4c 100644 --- a/resources/linkeditor/style/inc/_layers.sass +++ b/resources/linkeditor/style/inc/_layers.sass @@ -17,27 +17,58 @@ background-color: rgba(255, 255, 255, 0.45) color: $color - label - display: block - border-bottom: 1px solid currentColor - padding: 5px 10px - cursor: pointer + .layer position: relative - span - display: inline-block + label + display: block + border-bottom: 1px solid currentColor + padding: 5px 10px + cursor: pointer + + + span + display: inline-block + position: absolute + right: 28px + background-color: rgba(255, 255, 255, 0.5) + color: #000 + border-radius: 2px + padding: 2px + font-family: "Courier New", Courier, monospace + + input + color: #fff + position: relative + top: 2px + + &::before + border: 0 + + &[data-locked="1"] + label + pointer-events: none + + a.lock + svg + display: block + + a.lock + display: block position: absolute - right: 4px - background-color: rgba(255, 255, 255, 0.5) - color: #000 + top: 5px + right: 6px border-radius: 2px - padding: 2px - font-family: "Courier New", Courier, monospace + width: 16px + height: 16px + padding: 3px 4px 0 + color: rgba(0, 0, 0, 0.6) + background-color: rgba(0, 0, 0, 0.15) + + @include dark-theme + color: rgba(255, 255, 255, 0.8) + background-color: rgba(255, 255, 255, 0.25) - input - color: #fff - position: relative - top: 2px - &::before - border: 0 + svg + display: none diff --git a/resources/linkeditor/style/inc/_links.sass b/resources/linkeditor/style/inc/_links.sass index 52bed531b..24c38cd6d 100644 --- a/resources/linkeditor/style/inc/_links.sass +++ b/resources/linkeditor/style/inc/_links.sass @@ -2,8 +2,13 @@ #linkeditor-links .link + + &[data-locked="1"] + pointer-events: none + #linkeditor-main.grab & pointer-events: none + box-sizing: border-box position: absolute border: currentColor solid 1px diff --git a/resources/views/fluidbook_publication/link_editor.blade.php b/resources/views/fluidbook_publication/link_editor.blade.php index 2e2d66ae2..4d01bcc3d 100644 --- a/resources/views/fluidbook_publication/link_editor.blade.php +++ b/resources/views/fluidbook_publication/link_editor.blade.php @@ -97,6 +97,7 @@ 'n_links_cut'=>__('%nb% liens coupés'), 'click_to_copy_id'=>__('Cliquer pour copier l\'identifiant du lien'), 'id_copied'=>__('Identifiant copié !'), + 'lock'=>__('Vérouiller'), ]; $rulers=!count($rulers)?'{}':json_encode($rulers); diff --git a/resources/views/fluidbook_publication/link_editor_icons.blade.php b/resources/views/fluidbook_publication/link_editor_icons.blade.php index 07217eb45..9c32d64c6 100644 --- a/resources/views/fluidbook_publication/link_editor_icons.blade.php +++ b/resources/views/fluidbook_publication/link_editor_icons.blade.php @@ -1,5 +1,10 @@ {{-- __('!! Editeur de liens') --}} - +{{-- + +Downloaded from https://toolbox.fluidbook.com/tool-sprite/3/download +Edit here : https://toolbox.fluidbook.com/tool-sprite/3/edit + +--}} @push('linkeditor_scripts')