polotno 4.12.0 → 4.12.1
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/README.md +57 -22
- package/blueprint/side-panel/select-video.d.ts +2 -2
- package/canvas/page.js +1 -1
- package/model/figure-model.d.ts +1 -1
- package/model/gif-model.d.ts +1 -1
- package/model/group-model.d.ts +8 -8
- package/model/image-model.d.ts +1 -1
- package/model/line-model.d.ts +1 -1
- package/model/page-model.d.ts +10 -10
- package/model/shape-model.d.ts +2 -2
- package/model/shape-model.js +1 -1
- package/model/store.d.ts +92 -92
- package/model/svg-model.d.ts +1 -1
- package/model/table-model.d.ts +1 -1
- package/model/text-model.d.ts +1 -1
- package/model/video-model.d.ts +1 -1
- package/package.json +26 -9
- package/polotno.bundle.js +139 -139
- package/side-panel/select-video.d.ts +2 -2
- package/utils/clipboard.d.ts +2 -2
- package/utils/rich-text-html.d.ts +0 -10
- package/utils/rich-text-html.js +1 -1
- package/utils/validate-key.js +1 -1
|
@@ -159,7 +159,7 @@ export declare const selectVideo: ({ src, droppedPos, targetElement, store, attr
|
|
|
159
159
|
} & {
|
|
160
160
|
readonly locked: boolean;
|
|
161
161
|
readonly a: import("../model/shape-model.js").AnimatedAttrs;
|
|
162
|
-
animated(attr:
|
|
162
|
+
animated(attr: string): any;
|
|
163
163
|
readonly timeRange: {
|
|
164
164
|
start: number;
|
|
165
165
|
end: number;
|
|
@@ -327,7 +327,7 @@ export declare const selectVideo: ({ src, droppedPos, targetElement, store, attr
|
|
|
327
327
|
} & {
|
|
328
328
|
readonly locked: boolean;
|
|
329
329
|
readonly a: import("../model/shape-model.js").AnimatedAttrs;
|
|
330
|
-
animated(attr:
|
|
330
|
+
animated(attr: string): any;
|
|
331
331
|
readonly timeRange: {
|
|
332
332
|
start: number;
|
|
333
333
|
end: number;
|
package/utils/clipboard.d.ts
CHANGED
|
@@ -161,7 +161,7 @@ export declare const insertTextElement: (store: StoreType, text: string, extra?:
|
|
|
161
161
|
} & {
|
|
162
162
|
readonly locked: boolean;
|
|
163
163
|
readonly a: import("../model/shape-model.js").AnimatedAttrs;
|
|
164
|
-
animated(attr:
|
|
164
|
+
animated(attr: string): any;
|
|
165
165
|
readonly timeRange: {
|
|
166
166
|
start: number;
|
|
167
167
|
end: number;
|
|
@@ -331,7 +331,7 @@ export declare const insertTextElement: (store: StoreType, text: string, extra?:
|
|
|
331
331
|
} & {
|
|
332
332
|
readonly locked: boolean;
|
|
333
333
|
readonly a: import("../model/shape-model.js").AnimatedAttrs;
|
|
334
|
-
animated(attr:
|
|
334
|
+
animated(attr: string): any;
|
|
335
335
|
readonly timeRange: {
|
|
336
336
|
start: number;
|
|
337
337
|
end: number;
|
|
@@ -5,16 +5,6 @@ export declare function quillHtmlToModelText(html: string, defaults: {
|
|
|
5
5
|
fontFamily: string;
|
|
6
6
|
}): string;
|
|
7
7
|
export declare function shrinkParagraphStrutForRaster(html: string): string;
|
|
8
|
-
export interface FontSpec {
|
|
9
|
-
family: string;
|
|
10
|
-
weight: string;
|
|
11
|
-
style: string;
|
|
12
|
-
}
|
|
13
|
-
export declare function extractFontSpecsFromHtml(html: string, defaults: {
|
|
14
|
-
fontFamily: string;
|
|
15
|
-
fontWeight: string | number;
|
|
16
|
-
fontStyle: string;
|
|
17
|
-
}): FontSpec[];
|
|
18
8
|
export declare function isClipGradientSpan(el: HTMLElement): boolean;
|
|
19
9
|
export declare function stripInlineFormat(html: string, format: string): string;
|
|
20
10
|
interface QuillDeltaLike {
|
package/utils/rich-text-html.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export*from"@polotno/core/rich-text-html";import{parseHtmlRoot as t,cleanupInlineWrappers as e,
|
|
1
|
+
export*from"@polotno/core/rich-text-html";import{parseHtmlRoot as t,cleanupInlineWrappers as e,extractFontFamiliesFromHtml as r,normalizeRichTextHtml as o}from"@polotno/core/rich-text-html";import{LRUCache as n}from"./lru-cache.js";const i=new n(500);export function htmlInflatesMinContentWidth(e){if(!e||!e.includes("<")){return!1}let r=i.get(e);if(void 0===r){r=!1;const o=t(e);if(o){if(o.querySelector("ol, ul")){r=!0}else{for(const t of o.querySelectorAll("[style]")){if(t.style.fontSize||t.style.letterSpacing){r=!0;break}}}}i.set(e,r)}return r}export function quillHtmlToModelText(t,e){return o(function(t){const e=(t||"").trim();if("<p><br></p>"===e||"<p></p>"===e){return""}if(e.startsWith("<p>")&&e.endsWith("</p>")){const t=e.slice(3,-4);if(!/(<\/?(p|div|h[1-6]|ul|ol|li|table|thead|tbody|tr|td|blockquote)\b)/i.test(t)){return t}}return t}(t),e)}export function shrinkParagraphStrutForRaster(e){var r;if(!e||!e.includes("<p")){return e}const o=t(e);if(!o){return e}for(const t of Array.from(o.querySelectorAll("p"))){let e=!1;const n=[],i=o.ownerDocument.createTreeWalker(t,NodeFilter.SHOW_TEXT);let l=i.nextNode();for(;l;){if((l.textContent||"").length>0){let o=l.parentElement,i=null;for(;o&&o!==t;){const t=null===(r=o.style)||void 0===r?void 0:r.fontSize;if(t){const e=parseFloat(t);if(!Number.isNaN(e)){i=e;break}}o=o.parentElement}if(null==i){e=!0;break}n.push(i)}l=i.nextNode()}!e&&n.length>0&&(t.style.fontSize=`${Math.min(...n)}px`)}return o.innerHTML}const l={bold:["STRONG","B"],italic:["EM","I"],underline:["U"],strike:["S","DEL"]};export function isClipGradientSpan(t){return!!(null==t?void 0:t.style)&&("text"===(t.style.getPropertyValue("-webkit-background-clip")||t.style.getPropertyValue("background-clip"))&&t.style.backgroundImage.includes("gradient"))}const s={bold:t=>t.style.removeProperty("font-weight"),italic:t=>t.style.removeProperty("font-style"),color:t=>{!function(t){if(isClipGradientSpan(t)){for(const e of["background-image","background-size","-webkit-background-clip","background-clip","-webkit-text-fill-color"]){t.style.removeProperty(e)}}}(t),t.style.removeProperty("color")},underline:t=>{const e=t.style.textDecoration.replace(/\bunderline\b/g,"").trim();e?t.style.textDecoration=e:t.style.removeProperty("text-decoration")},strike:t=>{const e=t.style.textDecoration.replace(/\bline-through\b/g,"").trim();e?t.style.textDecoration=e:t.style.removeProperty("text-decoration")}};export function stripInlineFormat(r,o){var n,i;if(!r||!r.includes("<")){return r}const c=t(r);if(!c){return r}const u=l[o]||[],f=s[o];for(const t of u){let e;for(;e=c.querySelector(t);){const t=e.parentNode;f&&f(e);const r=null===(n=e.getAttribute("style"))||void 0===n?void 0:n.trim();if(r){const o=c.ownerDocument.createElement("span");for(o.setAttribute("style",r);e.firstChild;){o.appendChild(e.firstChild)}t.insertBefore(o,e)}else{for(;e.firstChild;){t.insertBefore(e.firstChild,e)}}t.removeChild(e)}}if(f){for(const t of Array.from(c.querySelectorAll("[style]"))){f(t),(null===(i=t.getAttribute("style"))||void 0===i?void 0:i.trim())||t.removeAttribute("style")}}return e(c),c.innerHTML}const c=Symbol("unset");export function isQuillFormatMixed(t,e){var r;let o=c;for(const n of t.ops){if("string"!=typeof n.insert||"\n"===n.insert){continue}const t=null===(r=n.attributes)||void 0===r?void 0:r[e];if(o===c){o=t}else if(t!==o){return!0}}return!1}export function stripInlineFontSizes(r){var o;if(!r||!r.includes("font-size")){return r}const n=t(r);if(!n){return r}const i=n.querySelectorAll("[style]");for(let t=0;t<i.length;t++){const e=i[t];e.style.fontSize&&(e.style.removeProperty("font-size"),(null===(o=e.getAttribute("style"))||void 0===o?void 0:o.trim())||e.removeAttribute("style"))}return e(n),n.innerHTML}export function stripInlineFontFamilies(r){var o;if(!r||!r.includes("font-family")&&!r.includes("ql-font-")){return r}const n=t(r);if(!n){return r}for(const t of Array.from(n.querySelectorAll("[style]"))){t.style.fontFamily&&(t.style.removeProperty("font-family"),(null===(o=t.getAttribute("style"))||void 0===o?void 0:o.trim())||t.removeAttribute("style"))}for(const t of Array.from(n.querySelectorAll("[class]"))){const e=t.getAttribute("class")||"",r=e.split(/\s+/).filter(t=>t&&!t.startsWith("ql-font-"));r.length!==e.split(/\s+/).filter(Boolean).length&&(r.length?t.setAttribute("class",r.join(" ")):t.removeAttribute("class"))}return e(n),n.innerHTML}export function hasMultipleDistinctInlineFontSizes(e){if(!e||!e.includes("<")){return!1}const r=t(e);if(!r){return!1}const o=new Set;for(const t of r.querySelectorAll("[style]")){const e=t.style.fontSize;if(e){const t=e.match(/^(\d+(?:\.\d+)?)px$/i);if(t&&(o.add(parseFloat(t[1])),o.size>1)){return!0}}}return!1}export function listEffectiveFontFamilies(t,e){const o=[];e&&o.push(e),o.push(...r(t||""));const n=new Set,i=[];for(const r of o){n.has(r)||(n.add(r),i.push(r))}return i.sort((t,e)=>t.localeCompare(e,void 0,{sensitivity:"base"})),i}
|
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.12.
|
|
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.1"})});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()}
|