From: Vincent Vanwaelscappel Date: Mon, 20 Feb 2023 19:02:15 +0000 (+0100) Subject: wip #5646 @1 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=55939d9d4bedaec6e18d203ddc4455db0c5e289b;p=fluidbook-toolbox.git wip #5646 @1 --- diff --git a/resources/linkeditor/js/linkeditor.links.js b/resources/linkeditor/js/linkeditor.links.js index fc535b2c8..fcc70c1ed 100644 --- a/resources/linkeditor/js/linkeditor.links.js +++ b/resources/linkeditor/js/linkeditor.links.js @@ -75,6 +75,19 @@ LinkeditorLinks.prototype = { $this.selectAll(); return false; }); + + this.key('ctrl+c', function () { + $this.copy(); + return false; + }); + this.key('ctrl+x', function () { + $this.cut(); + return false; + }); + this.key('ctrl+v', function () { + $this.pasteInPlace(); + return false; + }); this.key('del', function () { $this.deleteSelection(); }); @@ -145,6 +158,7 @@ LinkeditorLinks.prototype = { var selection = $(".link.selected"); var multiple = selection.length > 1; var hasSelection = selection.length > 0; + var hasClipboard = $("#linkeditor-clipboard").find('.link').length > 0; res.items = { 'select_all': { @@ -175,6 +189,41 @@ LinkeditorLinks.prototype = { }; } } + if (hasSelection || hasClipboard) { + res.items.sep_clipboard = '---------'; + if (hasSelection) { + res.items.copy_to_clipboad = { + isHtmlName: true, + name: TRANSLATIONS.copy + ' Ctrl+C', + callback: function () { + $this.copy(); + }, + }; + res.items.cut_to_clipboad = { + isHtmlName: true, + name: TRANSLATIONS.cut + ' Ctrl+X', + callback: function () { + $this.cut(); + }, + }; + } + if (hasClipboard) { + res.items.paste_here = { + isHtmlName: true, + name: TRANSLATIONS.paste_here, + callback: function () { + $this.pasteHere(); + }, + }; + res.items.paste_in_place = { + isHtmlName: true, + name: TRANSLATIONS.paste_in_place + ' Ctrl+V', + callback: function () { + $this.pasteInPlace(); + }, + }; + } + } if (hasSelection) { res.items = $.extend(res.items, { 'sep0': '---------', @@ -205,6 +254,57 @@ LinkeditorLinks.prototype = { }) }, + copy: function () { + this.copySelectionToClipboard(true); + }, + + cut: function () { + this.copySelectionToClipboard(false); + }, + + pasteInPlace: function () { + var linksInClipboard = $("#linkeditor-clipboard .link"); + if (!linksInClipboard.length) { + return; + } + var $this = this; + + $(linksInClipboard).each(function () { + var item = $(this).clone(); + if ($this.hasUIDLink($(item).attr('fb-uid'))) { + var uid = $this.linkeditor.utils.generateUID(); + $(item).attr('fb-uid', uid); + } + $("#linkeditor-links").append(item); + }); + }, + + pasteHere: function () { + this.pasteInPlace(); + }, + + hasUIDLink: function (uid) { + return true; + }, + + copySelectionToClipboard: function (clone) { + var selection = this.getCurrentSelection(); + if (selection.length === 0) { + return; + } + this.emptyClipboard(); + $.each(selection, function () { + var item = $(this); + if (clone) { + item = $(item).clone(); + } + $("#linkeditor-clipboard").append(item); + }); + }, + + emptyClipboard: function () { + $("#linkeditor-clipboard").html(''); + }, fixDriftedLinks: function () { var $this = this; diff --git a/resources/linkeditor/style/inc/_contextmenu.sass b/resources/linkeditor/style/inc/_contextmenu.sass index 6194be854..30c658236 100644 --- a/resources/linkeditor/style/inc/_contextmenu.sass +++ b/resources/linkeditor/style/inc/_contextmenu.sass @@ -1,5 +1,5 @@ .context-menu-list - z-index: 100000 !important + z-index: 1000001 !important .context-menu-item kbd diff --git a/resources/linkeditor/style/style.sass b/resources/linkeditor/style/style.sass index be8d89153..ffbdf7152 100644 --- a/resources/linkeditor/style/style.sass +++ b/resources/linkeditor/style/style.sass @@ -130,7 +130,7 @@ body, #linkeditor, html #linkeditor-page-right display: none -#linkeditor-preload +#linkeditor-preload, #linkeditor-clipboard display: none @import "inc/_panels" diff --git a/resources/views/fluidbook_publication/link_editor.blade.php b/resources/views/fluidbook_publication/link_editor.blade.php index 9fd7f4299..c2804b6eb 100644 --- a/resources/views/fluidbook_publication/link_editor.blade.php +++ b/resources/views/fluidbook_publication/link_editor.blade.php @@ -51,6 +51,10 @@ 'copy_link_id'=>__('Copier l\'identifiant unique'), 'level'=>__('Niveau'), 'before_fix_drifted'=>__('Sauvegarde avant la correction de la dérive des liens'), + 'copy'=>__('Copier'), + 'cut'=>__('Couper'), + 'paste_here'=>__('Coller ici'), + 'paste_in_place'=>__('Coller en place'), ]; $rulers=!count($rulers)?'{}':json_encode($rulers); @@ -224,6 +228,7 @@
+
@foreach(\App\SubForms\Link\Base::types() as $f)