polotno 4.12.0 → 4.13.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.
Files changed (176) hide show
  1. package/README.md +57 -22
  2. package/blueprint/canvas/context-menu/context-menu.d.ts +2 -2
  3. package/blueprint/canvas/page-controls.d.ts +14 -2
  4. package/blueprint/canvas/tooltip.d.ts +24 -2
  5. package/blueprint/pages-timeline/audio-track.d.ts +12 -2
  6. package/blueprint/pages-timeline/audios.d.ts +10 -2
  7. package/blueprint/pages-timeline/current-time.d.ts +2 -2
  8. package/blueprint/pages-timeline/element-track.d.ts +14 -2
  9. package/blueprint/pages-timeline/elements.d.ts +2 -2
  10. package/blueprint/pages-timeline/page-preview.d.ts +8 -2
  11. package/blueprint/pages-timeline/pages-timeline.d.ts +8 -2
  12. package/blueprint/pages-timeline/pages.d.ts +8 -2
  13. package/blueprint/pages-timeline/play-button.d.ts +2 -2
  14. package/blueprint/pages-timeline/time-ruler.d.ts +10 -2
  15. package/blueprint/side-panel/ai-images-panel.d.ts +6 -2
  16. package/blueprint/side-panel/animations-panel.d.ts +6 -2
  17. package/blueprint/side-panel/background-panel.d.ts +6 -2
  18. package/blueprint/side-panel/draw-panel.d.ts +6 -2
  19. package/blueprint/side-panel/effects-panel.d.ts +6 -2
  20. package/blueprint/side-panel/image-clip-panel.d.ts +6 -2
  21. package/blueprint/side-panel/layers-panel.d.ts +6 -2
  22. package/blueprint/side-panel/pages-panel.d.ts +6 -2
  23. package/blueprint/side-panel/select-video.d.ts +2 -2
  24. package/blueprint/side-panel/side-panel.d.ts +2 -2
  25. package/blueprint/side-panel/size-panel.d.ts +6 -2
  26. package/blueprint/side-panel/templates-panel.d.ts +6 -2
  27. package/blueprint/side-panel/text-panel.d.ts +6 -2
  28. package/blueprint/side-panel/videos-panel.d.ts +6 -2
  29. package/blueprint/toolbar/admin-button.d.ts +6 -2
  30. package/blueprint/toolbar/animations-picker.d.ts +18 -4
  31. package/blueprint/toolbar/copy-style.d.ts +6 -2
  32. package/blueprint/toolbar/download-button.d.ts +6 -2
  33. package/blueprint/toolbar/duplicate-button.d.ts +6 -2
  34. package/blueprint/toolbar/figure-toolbar.d.ts +8 -8
  35. package/blueprint/toolbar/filters-picker.d.ts +26 -6
  36. package/blueprint/toolbar/gif-toolbar.d.ts +2 -2
  37. package/blueprint/toolbar/group-button.d.ts +6 -2
  38. package/blueprint/toolbar/group-toolbar.d.ts +2 -2
  39. package/blueprint/toolbar/history-buttons.d.ts +6 -2
  40. package/blueprint/toolbar/html-toolbar.d.ts +10 -10
  41. package/blueprint/toolbar/image-remove-background-button.d.ts +10 -2
  42. package/blueprint/toolbar/image-toolbar.d.ts +28 -8
  43. package/blueprint/toolbar/line-toolbar.d.ts +14 -10
  44. package/blueprint/toolbar/lock-button.d.ts +6 -2
  45. package/blueprint/toolbar/many-toolbar.d.ts +2 -2
  46. package/blueprint/toolbar/opacity-picker.d.ts +6 -2
  47. package/blueprint/toolbar/page-toolbar.d.ts +2 -2
  48. package/blueprint/toolbar/position-picker.d.ts +6 -2
  49. package/blueprint/toolbar/remove-button.d.ts +6 -2
  50. package/blueprint/toolbar/svg-toolbar.d.ts +2 -2
  51. package/blueprint/toolbar/table-toolbar.d.ts +44 -14
  52. package/blueprint/toolbar/text-ai-write.d.ts +6 -2
  53. package/blueprint/toolbar/text-toolbar.d.ts +14 -14
  54. package/blueprint/toolbar/toolbar.d.ts +2 -2
  55. package/blueprint/toolbar/video-toolbar.d.ts +6 -6
  56. package/blueprint/toolbar/zoom-buttons.d.ts +4 -4
  57. package/canvas/audio.d.ts +3 -2
  58. package/canvas/context-menu/context-menu.d.ts +2 -2
  59. package/canvas/drawing-layer.d.ts +2 -2
  60. package/canvas/element.d.ts +2 -2
  61. package/canvas/fade-overlay.d.ts +14 -0
  62. package/canvas/fade-overlay.js +1 -0
  63. package/canvas/figure-element.d.ts +2 -2
  64. package/canvas/gif-element.d.ts +2 -2
  65. package/canvas/gif-element.js +1 -1
  66. package/canvas/highlighter.d.ts +6 -2
  67. package/canvas/html-element.d.ts +2 -2
  68. package/canvas/image-element.d.ts +5 -3
  69. package/canvas/image-element.js +1 -1
  70. package/canvas/line-element.d.ts +2 -2
  71. package/canvas/page-controls.d.ts +14 -2
  72. package/canvas/page.d.ts +2 -2
  73. package/canvas/page.js +1 -1
  74. package/canvas/render-tag-element.d.ts +2 -2
  75. package/canvas/render-tag-element.js +1 -1
  76. package/canvas/rich-editor.js +3 -3
  77. package/canvas/rules.d.ts +2 -2
  78. package/canvas/table-element.d.ts +2 -2
  79. package/canvas/text-element.d.ts +2 -2
  80. package/canvas/tooltip.d.ts +24 -2
  81. package/canvas/video-element.d.ts +3 -2
  82. package/canvas/video-element.js +1 -1
  83. package/canvas/workspace-canvas.d.ts +2 -2
  84. package/hooks/use-fade-stop-focus.d.ts +2 -0
  85. package/hooks/use-fade-stop-focus.js +1 -0
  86. package/icons/registry.d.ts +106 -102
  87. package/model/figure-model.d.ts +1 -1
  88. package/model/gif-model.d.ts +1 -1
  89. package/model/group-model.d.ts +8 -8
  90. package/model/image-model.d.ts +1 -1
  91. package/model/line-model.d.ts +1 -1
  92. package/model/page-model.d.ts +10 -10
  93. package/model/shape-model.d.ts +2 -2
  94. package/model/shape-model.js +1 -1
  95. package/model/store.d.ts +92 -92
  96. package/model/svg-model.d.ts +1 -1
  97. package/model/table-model.d.ts +1 -1
  98. package/model/text-model.d.ts +1 -1
  99. package/model/video-model.d.ts +1 -1
  100. package/package.json +52 -38
  101. package/pages-timeline/audio-track.d.ts +14 -2
  102. package/pages-timeline/audio-track.js +1 -1
  103. package/pages-timeline/audios.d.ts +10 -2
  104. package/pages-timeline/current-time.d.ts +2 -2
  105. package/pages-timeline/current-time.js +1 -1
  106. package/pages-timeline/element-track.d.ts +14 -2
  107. package/pages-timeline/element-track.js +1 -1
  108. package/pages-timeline/elements.d.ts +2 -2
  109. package/pages-timeline/page-preview.d.ts +8 -2
  110. package/pages-timeline/page-preview.js +1 -1
  111. package/pages-timeline/pages-timeline.d.ts +8 -2
  112. package/pages-timeline/pages-timeline.js +1 -1
  113. package/pages-timeline/pages.d.ts +8 -2
  114. package/pages-timeline/play-button.d.ts +2 -2
  115. package/pages-timeline/time-ruler.d.ts +10 -2
  116. package/pages-timeline/time-ruler.js +1 -1
  117. package/polotno.bundle.js +167 -166
  118. package/side-panel/ai-images-panel.d.ts +6 -2
  119. package/side-panel/animations-panel.d.ts +6 -2
  120. package/side-panel/background-panel.d.ts +6 -2
  121. package/side-panel/draw-panel.d.ts +6 -2
  122. package/side-panel/effects-panel.d.ts +6 -2
  123. package/side-panel/effects-panel.js +1 -1
  124. package/side-panel/image-clip-panel.d.ts +6 -2
  125. package/side-panel/layers-panel.d.ts +6 -2
  126. package/side-panel/pages-panel.d.ts +6 -2
  127. package/side-panel/select-video.d.ts +2 -2
  128. package/side-panel/side-panel.d.ts +2 -2
  129. package/side-panel/size-panel.d.ts +6 -2
  130. package/side-panel/templates-panel.d.ts +6 -2
  131. package/side-panel/text-panel.d.ts +6 -2
  132. package/side-panel/videos-panel.d.ts +6 -2
  133. package/toolbar/admin-button.d.ts +6 -2
  134. package/toolbar/animations-picker.d.ts +18 -4
  135. package/toolbar/copy-style.d.ts +6 -2
  136. package/toolbar/download-button.d.ts +6 -2
  137. package/toolbar/duplicate-button.d.ts +6 -2
  138. package/toolbar/figure-toolbar.d.ts +8 -8
  139. package/toolbar/filters-picker.d.ts +26 -6
  140. package/toolbar/gif-toolbar.d.ts +2 -2
  141. package/toolbar/group-button.d.ts +6 -2
  142. package/toolbar/group-toolbar.d.ts +2 -2
  143. package/toolbar/history-buttons.d.ts +6 -2
  144. package/toolbar/html-toolbar.d.ts +10 -10
  145. package/toolbar/image-remove-background-button.d.ts +10 -2
  146. package/toolbar/image-toolbar.d.ts +32 -10
  147. package/toolbar/line-toolbar.d.ts +14 -10
  148. package/toolbar/lock-button.d.ts +6 -2
  149. package/toolbar/many-toolbar.d.ts +2 -2
  150. package/toolbar/opacity-picker.d.ts +6 -2
  151. package/toolbar/page-toolbar.d.ts +2 -2
  152. package/toolbar/position-picker.d.ts +6 -2
  153. package/toolbar/remove-button.d.ts +6 -2
  154. package/toolbar/svg-toolbar.d.ts +2 -2
  155. package/toolbar/table-toolbar.d.ts +44 -14
  156. package/toolbar/text-ai-write.d.ts +6 -2
  157. package/toolbar/text-toolbar.d.ts +30 -18
  158. package/toolbar/toolbar.d.ts +2 -2
  159. package/toolbar/video-toolbar.d.ts +12 -6
  160. package/toolbar/video-toolbar.js +1 -1
  161. package/toolbar/zoom-buttons.d.ts +4 -4
  162. package/ui.css +1 -1
  163. package/utils/clip-fade.d.ts +6 -0
  164. package/utils/clip-fade.js +1 -0
  165. package/utils/clipboard.d.ts +2 -2
  166. package/utils/fade-gradient.d.ts +33 -0
  167. package/utils/fade-gradient.js +1 -0
  168. package/utils/fade-overlay.d.ts +9 -0
  169. package/utils/fade-overlay.js +1 -0
  170. package/utils/l10n.d.ts +19 -0
  171. package/utils/l10n.js +1 -1
  172. package/utils/pointer-drag.d.ts +6 -4
  173. package/utils/pointer-drag.js +1 -1
  174. package/utils/rich-text-html.d.ts +0 -10
  175. package/utils/rich-text-html.js +1 -1
  176. package/utils/validate-key.js +1 -1
@@ -1,13 +1,15 @@
1
- import type React from 'react';
2
- type PointerDragOptions = {
1
+ import React from 'react';
2
+ import { IAnyStateTreeNode } from 'mobx-state-tree';
3
+ export type PointerDragOptions = {
3
4
  slopX?: number;
4
5
  onMove: (event: PointerEvent) => void;
5
6
  onEnd?: (info: {
6
7
  moved: boolean;
7
8
  cancelled: boolean;
8
9
  }) => void;
10
+ node?: IAnyStateTreeNode;
9
11
  };
10
12
  export declare const DRAG_SLOP_PX = 4;
11
13
  export declare const isPrimaryDrag: (event: React.PointerEvent) => boolean;
12
- export declare const startPointerDrag: (event: React.PointerEvent, { slopX, onMove, onEnd }: PointerDragOptions) => void;
13
- export {};
14
+ export declare const startPointerDrag: (event: React.PointerEvent, { slopX, onMove, onEnd, node }: PointerDragOptions) => () => void;
15
+ export declare const usePointerDrag: () => (event: React.PointerEvent, options: PointerDragOptions) => void;
@@ -1 +1 @@
1
- export const DRAG_SLOP_PX=4;export const isPrimaryDrag=e=>0===e.button&&e.isPrimary;export const startPointerDrag=(e,{slopX:n=0,onMove:t,onEnd:o})=>{e.preventDefault();const{pointerId:r}=e,i=e.clientX;let d=0===n,p=!1;const s=e=>{if(e.pointerId===r){if(!d){if(Math.abs(e.clientX-i)<n){return}d=!0}p=!0,t(e)}},a=e=>{e.pointerId===r&&(window.removeEventListener("pointermove",s),window.removeEventListener("pointerup",a),window.removeEventListener("pointercancel",a),null==o||o({moved:p,cancelled:"pointercancel"===e.type}))};window.addEventListener("pointermove",s),window.addEventListener("pointerup",a),window.addEventListener("pointercancel",a)};
1
+ import e from"react";import{isAlive as t}from"mobx-state-tree";export const DRAG_SLOP_PX=4;export const isPrimaryDrag=e=>0===e.button&&e.isPrimary;export const startPointerDrag=(e,{slopX:n=0,onMove:r,onEnd:o,node:i})=>{e.preventDefault();const{pointerId:a}=e,c=e.clientX;let l=0===n,s=!1;const d=()=>{window.removeEventListener("pointermove",p),window.removeEventListener("pointerup",u),window.removeEventListener("pointercancel",u)},p=e=>{if(e.pointerId===a){if(!i||t(i)){if(!l){if(Math.abs(e.clientX-c)<n){return}l=!0}s=!0,r(e)}else{d()}}},u=e=>{e.pointerId===a&&(d(),null==o||o({moved:s,cancelled:"pointercancel"===e.type}))};return window.addEventListener("pointermove",p),window.addEventListener("pointerup",u),window.addEventListener("pointercancel",u),d};export const usePointerDrag=()=>{const t=e.useRef(null);return e.useEffect(()=>()=>{var e;return null===(e=t.current)||void 0===e?void 0:e.call(t)},[]),e.useCallback((e,n)=>{var r;null===(r=t.current)||void 0===r||r.call(t),t.current=startPointerDrag(e,n)},[])};
@@ -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 {
@@ -1 +1 @@
1
- export*from"@polotno/core/rich-text-html";import{parseHtmlRoot as t,cleanupInlineWrappers as e,parsePrimaryFontFamily as r,toNumericWeight as o,extractFontFamiliesFromHtml as n,qlClassToFontFamilyName as i,normalizeRichTextHtml as l}from"@polotno/core/rich-text-html";import{LRUCache as s}from"./lru-cache.js";const c=new s(500);export function htmlInflatesMinContentWidth(e){if(!e||!e.includes("<")){return!1}let r=c.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}}}}c.set(e,r)}return r}export function quillHtmlToModelText(t,e){return l(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}export function extractFontSpecsFromHtml(e,n){const l=n.fontFamily,s=String(o(n.fontWeight)),c="italic"===n.fontStyle?"italic":"normal",f=new Map,u=(t,e,r)=>{const o=`${t}\0${e}\0${r}`;f.has(o)||f.set(o,{family:t,weight:e,style:r})};if(u(l,s,c),e&&e.includes("<")){const n=t(e);if(n){const t=n.ownerDocument.createTreeWalker(n,NodeFilter.SHOW_TEXT);let e=t.nextNode();for(;e;){if((e.textContent||"").trim().length>0){let t="",f="",a="",y=e.parentElement;for(;y&&y!==n;){if(!t){if(y.style.fontFamily){t=r(y.style.fontFamily)||""}else{const e=(y.getAttribute("class")||"").split(/\s+/).find(t=>t.startsWith("ql-font-"));e&&(t=i(e))}}f||(y.style.fontWeight?f=String(o(y.style.fontWeight)):"STRONG"!==y.tagName&&"B"!==y.tagName||(f="700")),a||(y.style.fontStyle?a=y.style.fontStyle:"EM"!==y.tagName&&"I"!==y.tagName||(a="italic")),y=y.parentElement}u(t||l,f||s,a||c)}e=t.nextNode()}}}return[...f.values()]}const f={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 u={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 l=t(r);if(!l){return r}const s=f[o]||[],c=u[o];for(const t of s){let e;for(;e=l.querySelector(t);){const t=e.parentNode;c&&c(e);const r=null===(n=e.getAttribute("style"))||void 0===n?void 0:n.trim();if(r){const o=l.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(c){for(const t of Array.from(l.querySelectorAll("[style]"))){c(t),(null===(i=t.getAttribute("style"))||void 0===i?void 0:i.trim())||t.removeAttribute("style")}}return e(l),l.innerHTML}const a=Symbol("unset");export function isQuillFormatMixed(t,e){var r;let o=a;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===a){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 r=[];e&&r.push(e),r.push(...n(t||""));const o=new Set,i=[];for(const n of r){o.has(n)||(o.add(n),i.push(n))}return i.sort((t,e)=>t.localeCompare(e,void 0,{sensitivity:"base"})),i}
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}
@@ -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.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()}
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.13.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()}