]> _ Git - fluidbook-toolbox.git/commitdiff
wip #6960 @6:00
authorsoufiane <soufiane@cubedesigners.com>
Thu, 27 Jun 2024 15:29:28 +0000 (17:29 +0200)
committersoufiane <soufiane@cubedesigners.com>
Thu, 27 Jun 2024 15:29:28 +0000 (17:29 +0200)
resources/linkeditor/js/linkeditor.links.js

index a9f42e25b2cd0cd36b002534c257826f0b73dd1a..6be556a206b15207d2f3cb2ffbbfb7e68f02c6ee 100644 (file)
@@ -1637,26 +1637,23 @@ LinkeditorLinks.prototype = {
                 })
                 this.updateFontSize(link)
             } else if (linkData.type === '39') {
-                $("[data-id-preview=" + linkData.uid + "]").html('<canvas id="canvas'+ linkData.uid+'" width="'+linkData.width* this.linkeditor.zoom.zoom+'" height="'+linkData.height* this.linkeditor.zoom.zoom+'"></canvas>')
-
-                const canvas = $('#canvas'+ linkData.uid).get(0),
-                    ctx = canvas.getContext('2d'),
-                    xLink = linkData.left,
-                    yLink = linkData.top,
-                    wLink = linkData.width,
-                    hLink = linkData.height;
-                var image = new Image();
-                image.src = $(".contents .images").attr('src')
-
-                const image_image = $(".contents .images").get(0);
-                const coord = image_image.getBoundingClientRect()
-                const image_texts = $(".contents .texts").attr("src");
-
-                console.log("pw",this.linkeditor.ph,hLink,yLink)
-                const $this = this
-                image.onload = function() {
-                    ctx.drawImage(image,-(xLink - $this.linkeditor.pw) * $this.linkeditor.zoom.zoom,-yLink* $this.linkeditor.zoom.zoom,$this.linkeditor.pw * $this.linkeditor.zoom.zoom,$this.linkeditor.ph * $this.linkeditor.zoom.zoom);
+                $("[data-id-preview=" + linkData.uid + "]").parent().css("overflow","hidden")
+                $("[data-id-preview=" + linkData.uid + "]").html("<div class='canvas' style='height:100%;clip-path:inset(0 0 0 0);'></div>")
+
+                if($("[data-id-preview=" + linkData.uid + "] .canvas img").length < 1) {
+                    $("#linkeditor-page-right .contents .images").clone().appendTo("[data-id-preview=" + linkData.uid + "] .canvas")
                 }
+
+                const   wp = $(".linkeditor-page").get(0).getBoundingClientRect().width,
+                        pageRightRect = $("#linkeditor-page-right").get(0).getBoundingClientRect()
+
+                $('[data-id-preview="' + linkData.uid + '"] .canvas img').css({
+                    'position': 'fixed',
+                    'width': wp,
+                    'left': pageRightRect.x,
+                    'top': pageRightRect.y,
+                })
+
             }
 
             if (linkData.type === '10') {
@@ -1750,29 +1747,6 @@ LinkeditorLinks.prototype = {
     clearPreview: function() {
       $("[data-id-preview]").remove()
     },
-
-    convertAnimationStringToObject: function(anim) {
-        let anims = anim.split('---')
-        let o = []
-
-        if(anim !== "" && anim !== "none") {
-            anims.forEach(function (anim_) {
-                let arr = anim_.split('\n')
-                let o_ = {}
-                arr.forEach(function (pair) {
-                    let parts = pair.split("=");
-                    if (parts[0].length > 0 && parts[1].length > 0) {
-                        let k = parts[0];
-                        let v = parts[1];
-                        o_[k] = v;
-                    }
-                })
-                o.push(o_)
-            })
-        }
-
-        return o
-    },
 };
 
 export default LinkeditorLinks;