polotno 4.10.0 → 4.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/blueprint/side-panel/select-video.d.ts +4 -0
- package/canvas/crop-overlay.d.ts +42 -0
- package/canvas/crop-overlay.js +1 -0
- package/canvas/downscale-bands.d.ts +10 -0
- package/canvas/downscale-bands.js +1 -0
- package/canvas/downscale-kernel.d.ts +7 -0
- package/canvas/downscale-kernel.js +1 -0
- package/canvas/downscale-kernel.wasm.d.ts +1 -0
- package/canvas/downscale-kernel.wasm.js +1 -0
- package/canvas/downscale-passes.d.ts +7 -0
- package/canvas/downscale-passes.js +1 -0
- package/canvas/downscale.d.ts +22 -1
- package/canvas/downscale.js +1 -1
- package/canvas/drawing-layer.js +1 -1
- package/canvas/element.js +1 -1
- package/canvas/figure-element.js +1 -1
- package/canvas/gif-element.js +1 -1
- package/canvas/hotkeys.js +1 -1
- package/canvas/html-element.js +1 -1
- package/canvas/image-element.d.ts +24 -1
- package/canvas/image-element.js +1 -1
- package/canvas/line-element.js +1 -1
- package/canvas/page-controls.js +1 -1
- package/canvas/page.js +1 -1
- package/canvas/render-tag-element.js +1 -1
- package/canvas/rich-editor.js +3 -3
- package/canvas/table-element.js +1 -1
- package/canvas/text-element.js +1 -1
- package/canvas/tooltip.js +1 -1
- package/canvas/transform-box.d.ts +9 -0
- package/canvas/transform-box.js +1 -0
- package/canvas/use-image.d.ts +4 -0
- package/canvas/use-image.js +1 -0
- package/canvas/use-mediabunny-video.js +1 -1
- package/canvas/use-transformer-snap.js +1 -1
- package/canvas/video-element.js +1 -1
- package/canvas/workspace-canvas.d.ts +3 -1
- package/canvas/workspace-canvas.js +1 -1
- package/canvas/workspace-style.d.ts +4 -0
- package/canvas/workspace-style.js +1 -1
- package/model/crop-mode.d.ts +34 -0
- package/model/crop-mode.js +1 -0
- package/model/gif-model.d.ts +2 -0
- package/model/group-model.d.ts +13 -0
- package/model/image-model.d.ts +2 -0
- package/model/image-model.js +1 -1
- package/model/page-model.d.ts +13 -0
- package/model/store.d.ts +144 -5
- package/model/store.js +1 -1
- package/model/svg-model.d.ts +7 -0
- package/model/svg-model.js +1 -1
- package/model/video-model.d.ts +2 -0
- package/package.json +25 -23
- package/polotno.bundle.js +179 -192
- package/primitives/tooltip.js +1 -1
- package/side-panel/draw-panel.js +1 -1
- package/side-panel/select-image.js +1 -1
- package/side-panel/select-video.d.ts +4 -0
- package/side-panel/size-panel.js +1 -1
- package/toolbar/duplicate-button.js +1 -1
- package/toolbar/html-toolbar.js +2 -2
- package/toolbar/image-toolbar.d.ts +7 -2
- package/toolbar/image-toolbar.js +1 -1
- package/toolbar/lock-button.js +1 -1
- package/toolbar/opacity-picker.js +1 -1
- package/toolbar/remove-button.js +1 -1
- package/toolbar/svg-toolbar.js +1 -1
- package/toolbar/text-toolbar.js +1 -1
- package/toolbar/toolbar.js +1 -1
- package/utils/base64.d.ts +1 -1
- package/utils/canvas.d.ts +1 -0
- package/utils/canvas.js +1 -1
- package/utils/fonts.d.ts +1 -0
- package/utils/fonts.js +1 -1
- package/utils/html2canvas.js +1 -1
- package/utils/l10n.d.ts +4 -0
- package/utils/l10n.js +1 -1
- package/utils/path-to-svg.d.ts +0 -2
- package/utils/path-to-svg.js +1 -1
- package/utils/px.d.ts +21 -0
- package/utils/px.js +1 -1
- package/utils/validate-key.js +1 -1
package/utils/path-to-svg.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{svgToURL as t}from"@polotno/core/svg";
|
|
1
|
+
import{svgToURL as t}from"@polotno/core/svg";const n=t=>Math.round(100*t)/100,o=t=>{const n=[];for(let o=0;o<t.length-1;o++){const e=t[Math.max(0,o-1)],h=t[o],r=t[o+1],i=t[Math.min(t.length-1,o+2)];n.push([{x:h.x+(r.x-e.x)/6,y:h.y+(r.y-e.y)/6},{x:r.x-(i.x-h.x)/6,y:r.y-(i.y-h.y)/6},r])}return n};export function pointsToPathData(t){if(0===t.length){return""}const e=t=>`${n(t.x)},${n(t.y)}`,h=`M ${e(t[0])}`;return 1===t.length?`${h} l 0.1,0`:[h,...o(t).map(([t,n,o])=>`C ${e(t)} ${e(n)} ${e(o)}`)].join(" ")}export function getBoundingBox(t){if(0===t.length){return{x:0,y:0,width:0,height:0}}let n=t[0].x,o=t[0].y,e=t[0].x,h=t[0].y;for(const r of t){n=Math.min(n,r.x),o=Math.min(o,r.y),e=Math.max(e,r.x),h=Math.max(h,r.y)}return{x:n,y:o,width:e-n,height:h-o}}export function pathToSVG(n,e){if(0===n.length){throw new Error("Cannot create SVG from empty path")}const h=getBoundingBox([n[0],...o(n).flat()]),r=e.strokeWidth,i=h.x-r,x=h.y-r,a=h.width+2*r,s=h.height+2*r,g=`\n <svg xmlns="http://www.w3.org/2000/svg" width="${a}" height="${s}" viewBox="0 0 ${a} ${s}">\n <path\n d="${pointsToPathData(n.map(t=>({x:t.x-i,y:t.y-x})))}"\n stroke="${e.stroke}"\n stroke-width="${e.strokeWidth}"\n stroke-linecap="round"\n stroke-linejoin="round"\n fill="none"\n />\n </svg>\n `.trim();return{src:t(g),x:i,y:x,width:a,height:s}}
|
package/utils/px.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type Konva from 'konva';
|
|
2
2
|
export declare const roundEnabledPx: (value: number) => number;
|
|
3
|
+
export declare const MAIN_TRANSFORMER_NAME = "main-transformer";
|
|
3
4
|
export declare const activeAnchorOf: (node: Konva.Node) => string;
|
|
4
5
|
export declare const isCornerAnchor: (anchor: string) => boolean;
|
|
5
6
|
export declare const textMinResizeWidth: (startWidth: number, fontSize: number) => number;
|
|
@@ -40,6 +41,26 @@ export declare const scaledFontSizeAttrs: (element: TextStyleSource, fontSize: n
|
|
|
40
41
|
shadowOffsetX: number;
|
|
41
42
|
shadowOffsetY: number;
|
|
42
43
|
};
|
|
44
|
+
export declare const roundedGeometryPx: (value: number) => number;
|
|
45
|
+
export declare const roundedCropFraction: (value: number) => number;
|
|
46
|
+
export declare const roundedPosition: (node: Konva.Node) => {
|
|
47
|
+
x: number;
|
|
48
|
+
y: number;
|
|
49
|
+
};
|
|
50
|
+
type GeometrySource = {
|
|
51
|
+
x: number;
|
|
52
|
+
y: number;
|
|
53
|
+
width: number;
|
|
54
|
+
height: number;
|
|
55
|
+
rotation: number;
|
|
56
|
+
};
|
|
57
|
+
export declare const roundedGeometryAttrs: (element: GeometrySource) => {
|
|
58
|
+
x: number;
|
|
59
|
+
y: number;
|
|
60
|
+
width: number;
|
|
61
|
+
height: number;
|
|
62
|
+
rotation: number;
|
|
63
|
+
};
|
|
43
64
|
export declare const roundedFontSizeAttrs: (element: TextStyleSource, fontSize: number) => {
|
|
44
65
|
fontSize: number;
|
|
45
66
|
strokeWidth: number;
|
package/utils/px.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var t=this&&this.__rest||function(t,o){var e={};for(var r in t){Object.prototype.hasOwnProperty.call(t,r)&&o.indexOf(r)<0&&(e[r]=t[r])}if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(r=Object.getOwnPropertySymbols(t);n<r.length;n++){o.indexOf(r[n])<0&&Object.prototype.propertyIsEnumerable.call(t,r[n])&&(e[r[n]]=t[r[n]])}}return e};import{htmlInflatesMinContentWidth as o}from"./rich-text-html.js";export const roundEnabledPx=t=>t>0?Math.max(1,Math.round(t)):0;export const activeAnchorOf=t=>{var o,e;const r=null===(o=t.getStage())||void 0===o?void 0:o.findOne("
|
|
1
|
+
var t=this&&this.__rest||function(t,o){var e={};for(var r in t){Object.prototype.hasOwnProperty.call(t,r)&&o.indexOf(r)<0&&(e[r]=t[r])}if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(r=Object.getOwnPropertySymbols(t);n<r.length;n++){o.indexOf(r[n])<0&&Object.prototype.propertyIsEnumerable.call(t,r[n])&&(e[r[n]]=t[r[n]])}}return e};import{htmlInflatesMinContentWidth as o}from"./rich-text-html.js";export const roundEnabledPx=t=>t>0?Math.max(1,Math.round(t)):0;export const MAIN_TRANSFORMER_NAME="main-transformer";export const activeAnchorOf=t=>{var o,e;const r=null===(o=t.getStage())||void 0===o?void 0:o.findOne(".main-transformer");return null!==(e=null==r?void 0:r.getActiveAnchor())&&void 0!==e?e:""};export const isCornerAnchor=t=>!(t.includes("middle")||t.includes("center"));export const textMinResizeWidth=(t,o)=>t<o?1:o;export const textMinWidthIsMeasured=t=>{var e;return!!t.curveEnabled||0!==(null!==(e=t.letterSpacing)&&void 0!==e?e:0)||o(t.text)};export const scaledBoxStyleAttrs=(t,o)=>{var e;return{cornerRadius:(null!==(e=t.cornerRadius)&&void 0!==e?e:0)*o,shadowBlur:t.shadowBlur*o,shadowOffsetX:t.shadowOffsetX*o,shadowOffsetY:t.shadowOffsetY*o}};export const roundedBoxStyleAttrs=t=>{var o;return{cornerRadius:roundEnabledPx(null!==(o=t.cornerRadius)&&void 0!==o?o:0),shadowBlur:Math.round(t.shadowBlur),shadowOffsetX:Math.round(t.shadowOffsetX),shadowOffsetY:Math.round(t.shadowOffsetY)}};export const scaledFontSizeAttrs=(t,o)=>{const e=t.fontSize>0?o/t.fontSize:1;return{fontSize:o,strokeWidth:t.strokeWidth*e,shadowBlur:t.shadowBlur*e,shadowOffsetX:t.shadowOffsetX*e,shadowOffsetY:t.shadowOffsetY*e}};export const roundedGeometryPx=t=>Math.round(1e6*t)/1e6+0;export const roundedCropFraction=t=>Math.round(1e9*t)/1e9+0;export const roundedPosition=t=>({x:roundedGeometryPx(t.x()),y:roundedGeometryPx(t.y())});export const roundedGeometryAttrs=t=>({x:roundedGeometryPx(t.x),y:roundedGeometryPx(t.y),width:roundedGeometryPx(t.width),height:roundedGeometryPx(t.height),rotation:roundedGeometryPx(t.rotation)});export const roundedFontSizeAttrs=(t,o)=>{const e=scaledFontSizeAttrs(t,o);return{fontSize:Math.round(e.fontSize),strokeWidth:roundEnabledPx(e.strokeWidth),shadowBlur:Math.round(e.shadowBlur),shadowOffsetX:Math.round(e.shadowOffsetX),shadowOffsetY:Math.round(e.shadowOffsetY)}};export const roundedTextDecorationAttrs=o=>{const e=roundedFontSizeAttrs(o,o.fontSize),{fontSize:r}=e;return t(e,["fontSize"])};
|
package/utils/validate-key.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as e from"mobx";import{getAPI as o}from"./api.js";import{setRemoveBackgroundEnabled as t}from"./flags.js";const n=e.observable({value:!1}),a=e.observable({value:"v1"});export const ___=()=>a.value;const i=e.observable({value:0});export const ____=()=>i.value;export const isCreditVisible=()=>n.value;const r=e.action(()=>{n.value=!0});let s="";export const getKey=()=>s||"";export const setKey=e=>{s=e||""};let l="undefined"!=typeof window?window.location.origin:"";const c="undefined"!=typeof navigator&&navigator.userAgent.indexOf("Headless")>-1,d="undefined"!=typeof navigator&&navigator.userAgent.indexOf("Electron")>-1;"file://"===l&&c&&(l="headless"),"file://"===l&&d&&(l="electron");const p=`%cPolotno error! Current domain is not allowed. It may lead to unexpected behavior and stop working. Please add "${l}" here: https://polotno.com/cabinet`;let u=fetch;export const __=e=>{u=e};export async function isKeyPaid(n){for(let s=0;s<5;s++){try{const r=await u(o()+"/validate-key",{method:"POST",body:JSON.stringify({key:n,site:location.host,skdVersion:"4.
|
|
1
|
+
import*as e from"mobx";import{getAPI as o}from"./api.js";import{setRemoveBackgroundEnabled as t}from"./flags.js";const n=e.observable({value:!1}),a=e.observable({value:"v1"});export const ___=()=>a.value;const i=e.observable({value:0});export const ____=()=>i.value;export const isCreditVisible=()=>n.value;const r=e.action(()=>{n.value=!0});let s="";export const getKey=()=>s||"";export const setKey=e=>{s=e||""};let l="undefined"!=typeof window?window.location.origin:"";const c="undefined"!=typeof navigator&&navigator.userAgent.indexOf("Headless")>-1,d="undefined"!=typeof navigator&&navigator.userAgent.indexOf("Electron")>-1;"file://"===l&&c&&(l="headless"),"file://"===l&&d&&(l="electron");const p=`%cPolotno error! Current domain is not allowed. It may lead to unexpected behavior and stop working. Please add "${l}" here: https://polotno.com/cabinet`;let u=fetch;export const __=e=>{u=e};export async function isKeyPaid(n){for(let s=0;s<5;s++){try{const r=await u(o()+"/validate-key",{method:"POST",body:JSON.stringify({key:n,site:location.host,skdVersion:"4.12.0"})});if(e.runInAction(()=>{a.value=r.headers.get("x-api-version")||""}),!n){return console.error("Polotno API is initialized without API key. It may lead to unexpected behavior and stop working. Please create API key here: https://polotno.com/cabinet"),e.runInAction(()=>{i.value=1}),!1}if(200!==r.status){await new Promise(e=>setTimeout(e,3e3));continue}const s=await r.json();return s.is_valid||(console.error("Polotno API key is not valid. Please get new API key here: https://polotno.com/cabinet"),e.runInAction(()=>{i.value=1})),s.is_paid||(console.log("%cPolotno Free Version. For development usage only. https://polotno.com/","background: rgb(0, 161, 255); color: white; padding: 5px; margin: 5px;"),e.runInAction(()=>{0===i.value&&(i.value=2)})),s.is_domain_valid||console.log(p,"background: rgba(247, 101, 68, 1); color: white; padding: 5px; margin: 5px;"),t(s.remove_background_enabled),s.is_paid||!1}catch(r){await new Promise(e=>setTimeout(e,3e3))}}return console.error("Can not validate Polotno API key. Please report to anton@polotno.com immediately."),!0}export async function validateKey(e){await isKeyPaid(s)&&!e||r()}
|