From: Vincent Vanwaelscappel Date: Mon, 12 Jun 2023 17:11:49 +0000 (+0200) Subject: wip #6020 @1.5 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=ba32a7eab92981db0741a6a99e926b66aaf3b192;p=fluidbook-toolbox.git wip #6020 @1.5 --- diff --git a/resources/linkeditor/js/linkeditor.js b/resources/linkeditor/js/linkeditor.js index c16fba7f4..dee434660 100644 --- a/resources/linkeditor/js/linkeditor.js +++ b/resources/linkeditor/js/linkeditor.js @@ -232,7 +232,7 @@ LinkEditor.prototype = { // Check if the user is not clicking the scrollbar if ($this.mx < $this.canvasRect.right - 20 && $this.my < $this.canvasRect.bottom - 20) { $this.zoom.resetZoomDrag(); - $this.links.createLinkDrag(); + $this.links.mouseDown(); deselectAll = false; } } diff --git a/resources/linkeditor/js/linkeditor.links.js b/resources/linkeditor/js/linkeditor.links.js index 373f03918..64b45f923 100644 --- a/resources/linkeditor/js/linkeditor.links.js +++ b/resources/linkeditor/js/linkeditor.links.js @@ -13,6 +13,7 @@ var LinkeditorLinks = function (linkeditor) { this.contextMenuPosition = null; this.rectSelection = null; + this.shapeMode = 'rectangle'; this.dropTypes = [4, 6, 7, 12, 15, 16, 17, 18, 25, 30, 31]; @@ -21,7 +22,7 @@ var LinkeditorLinks = function (linkeditor) { LinkeditorLinks.prototype = { init: function () { - + this.updateShapeMode(); }, initEvents: function () { @@ -526,13 +527,6 @@ LinkeditorLinks.prototype = { return allLinks.eq(n); }, - mouseUp: function () { - this.endRectSelection(); - this.stopDragLink(); - this.stopResizeLink(); - this.cleanPendingCreateLink(); - }, - cleanPendingCreateLink() { $('.pendingCreate').remove(); }, @@ -1322,6 +1316,86 @@ LinkeditorLinks.prototype = { this.linkeditor.save.saveIfUnsavedChanges(TRANSLATIONS.before_import_links_from_pdf, false, callback); }, + mouseUp: function () { + this.endRectSelection(); + this.stopDragLink(); + this.endPolygonLine(); + this.stopResizeLink(); + this.cleanPendingCreateLink(); + }, + + mouseDown: function () { + if (this.shapeMode === 'rectangle') { + this.createLinkDrag(); + } else { + this.beginPolygonLine(); + } + }, + + toggleShape: function (shape) { + if (this.shapeMode === shape) { + return; + } + this.shapeMode = shape; + this.updateShapeMode(); + }, + + updateShapeMode: function () { + $('[data-icon^="shape"]').removeClass('active'); + $('[data-icon="shape-' + this.shapeMode + '"]').addClass('active'); + }, + + beginPolygonLine: function () { + var link; + var pos = this.linkeditor.globalToFluidbook(this.linkeditor.mx, this.linkeditor.my, this.linkeditor.single); + if ($('.pendingPolygonCreate').length === 0) { + link = this.duplicateLinkDrag({width: 0, height: 0, left: pos.x, top: pos.y}); + $(link).addClass('pendingPolygonCreate'); + $(link).data('points', [pos]); + } else { + link = $('.pendingPolygonCreate'); + $(link).data('points').push(pos); + } + this.selectLink($(link)); + this.updatePolygonLink(link); + this.linkeditor.hasChanged(); + }, + + updatePolygonLink: function (link) { + let minx = Number.MAX_VALUE; + let maxx = Number.MIN_VALUE; + let miny = Number.MAX_VALUE; + let maxy = Number.MIN_VALUE; + + $.each($(link).data('points'), function (k, pos) { + minx = Math.min(minx, pos.x); + miny = Math.min(miny, pos.y); + maxx = Math.max(maxx, pos.x); + maxy = Math.max(maxy, pos.y); + }); + + let w = maxx - minx; + let h = maxy - miny; + + $(link).attr('fb-width', w); + $(link).attr('fb-height', h); + $(link).attr('fb-left', minx); + $(link).attr('fb-top', miny); + + let svg = ''; + $(link).html(svg); + + + }, + + endPolygonLine: function () { + + }, }; module.exports = LinkeditorLinks; diff --git a/resources/views/fluidbook_publication/link_editor.blade.php b/resources/views/fluidbook_publication/link_editor.blade.php index b14fc69f6..4b45531ed 100644 --- a/resources/views/fluidbook_publication/link_editor.blade.php +++ b/resources/views/fluidbook_publication/link_editor.blade.php @@ -168,6 +168,11 @@ data-tooltip="{{__('Rétablir la derière modification')}} (Ctrl+Maj+Z)" data-key="ctrl+shift+z" data-key-skipintextfields>
+ + +
diff --git a/resources/views/fluidbook_publication/link_editor_icons.blade.php b/resources/views/fluidbook_publication/link_editor_icons.blade.php index ded913075..8ac2ac38d 100644 --- a/resources/views/fluidbook_publication/link_editor_icons.blade.php +++ b/resources/views/fluidbook_publication/link_editor_icons.blade.php @@ -1,5 +1,5 @@ {{-- __('!! Editeur de liens') --}} - + @push('linkeditor_scripts')