polotno 3.12.1 → 3.14.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/canvas/context-menu/context-menu.d.ts +2 -2
- package/blueprint/canvas/page-controls.d.ts +14 -2
- package/blueprint/canvas/tooltip.d.ts +24 -2
- package/blueprint/pages-timeline/audio-track.d.ts +12 -2
- package/blueprint/pages-timeline/audios.d.ts +10 -2
- package/blueprint/pages-timeline/current-time.d.ts +2 -2
- package/blueprint/pages-timeline/element-track.d.ts +14 -2
- package/blueprint/pages-timeline/elements.d.ts +2 -2
- package/blueprint/pages-timeline/page-preview.d.ts +8 -2
- package/blueprint/pages-timeline/pages-timeline.d.ts +8 -2
- package/blueprint/pages-timeline/pages.d.ts +8 -2
- package/blueprint/pages-timeline/play-button.d.ts +2 -2
- package/blueprint/pages-timeline/time-ruler.d.ts +10 -2
- package/blueprint/side-panel/ai-images-panel.d.ts +6 -2
- package/blueprint/side-panel/animations-panel.d.ts +6 -2
- package/blueprint/side-panel/background-panel.d.ts +6 -2
- package/blueprint/side-panel/draw-panel.d.ts +6 -2
- package/blueprint/side-panel/effects-panel.d.ts +6 -2
- package/blueprint/side-panel/image-clip-panel.d.ts +6 -2
- package/blueprint/side-panel/layers-panel.d.ts +6 -2
- package/blueprint/side-panel/pages-panel.d.ts +6 -2
- package/blueprint/side-panel/select-video.d.ts +105 -36
- package/blueprint/side-panel/side-panel.d.ts +2 -2
- package/blueprint/side-panel/size-panel.d.ts +6 -2
- package/blueprint/side-panel/templates-panel.d.ts +6 -2
- package/blueprint/side-panel/text-panel.d.ts +6 -2
- package/blueprint/side-panel/videos-panel.d.ts +6 -2
- package/blueprint/toolbar/admin-button.d.ts +6 -2
- package/blueprint/toolbar/animations-picker.d.ts +18 -4
- package/blueprint/toolbar/copy-style.d.ts +6 -2
- package/blueprint/toolbar/download-button.d.ts +6 -2
- package/blueprint/toolbar/duplicate-button.d.ts +6 -2
- package/blueprint/toolbar/figure-toolbar.d.ts +8 -8
- package/blueprint/toolbar/filters-picker.d.ts +26 -6
- package/blueprint/toolbar/gif-toolbar.d.ts +2 -2
- package/blueprint/toolbar/group-button.d.ts +6 -2
- package/blueprint/toolbar/group-toolbar.d.ts +2 -2
- package/blueprint/toolbar/history-buttons.d.ts +6 -2
- package/blueprint/toolbar/html-toolbar.d.ts +10 -10
- package/blueprint/toolbar/image-remove-background-button.d.ts +10 -2
- package/blueprint/toolbar/image-toolbar.d.ts +28 -8
- package/blueprint/toolbar/line-toolbar.d.ts +14 -10
- package/blueprint/toolbar/lock-button.d.ts +6 -2
- package/blueprint/toolbar/many-toolbar.d.ts +2 -2
- package/blueprint/toolbar/opacity-picker.d.ts +6 -2
- package/blueprint/toolbar/page-toolbar.d.ts +2 -2
- package/blueprint/toolbar/position-picker.d.ts +6 -2
- package/blueprint/toolbar/remove-button.d.ts +6 -2
- package/blueprint/toolbar/svg-toolbar.d.ts +2 -2
- package/blueprint/toolbar/table-toolbar.d.ts +44 -14
- package/blueprint/toolbar/text-ai-write.d.ts +6 -2
- package/blueprint/toolbar/text-toolbar.d.ts +14 -14
- package/blueprint/toolbar/toolbar.d.ts +2 -2
- package/blueprint/toolbar/video-toolbar.d.ts +6 -6
- package/blueprint/toolbar/zoom-buttons.d.ts +4 -4
- package/canvas/apply-filters.js +1 -1
- package/canvas/audio.d.ts +3 -2
- package/canvas/context-menu/context-menu.d.ts +2 -2
- package/canvas/downscale.d.ts +4 -0
- package/canvas/downscale.js +1 -1
- package/canvas/drawing-layer.d.ts +2 -2
- package/canvas/element.d.ts +3 -3
- package/canvas/element.js +1 -1
- package/canvas/fade-overlay.d.ts +14 -0
- package/canvas/fade-overlay.js +1 -0
- package/canvas/figure-element.d.ts +2 -2
- package/canvas/figure-element.js +1 -1
- package/canvas/gif-element.d.ts +2 -2
- package/canvas/gif-element.js +1 -1
- package/canvas/highlighter.d.ts +6 -2
- package/canvas/html-element.d.ts +2 -2
- package/canvas/html-element.js +1 -1
- package/canvas/image-element.d.ts +5 -3
- package/canvas/image-element.js +1 -1
- package/canvas/line-element.d.ts +2 -2
- package/canvas/line-element.js +1 -1
- package/canvas/page-controls.d.ts +14 -2
- package/canvas/page.d.ts +2 -2
- package/canvas/page.js +1 -1
- package/canvas/paint-opacity.d.ts +12 -0
- package/canvas/paint-opacity.js +1 -0
- package/canvas/render-tag-element.d.ts +2 -2
- package/canvas/render-tag-element.js +1 -1
- package/canvas/rich-editor.js +11 -3
- package/canvas/rules.d.ts +2 -2
- package/canvas/table-element.d.ts +2 -2
- package/canvas/table-element.js +1 -1
- package/canvas/text-element/font-specs-loader.js +1 -1
- package/canvas/text-element.d.ts +2 -2
- package/canvas/text-element.js +1 -1
- package/canvas/tooltip.d.ts +24 -2
- package/canvas/use-filtered-source.js +1 -1
- package/canvas/video-element.d.ts +3 -2
- package/canvas/video-element.js +1 -1
- package/canvas/workspace-canvas.d.ts +2 -2
- package/canvas/workspace-canvas.js +1 -1
- package/hooks/use-fade-stop-focus.d.ts +2 -0
- package/hooks/use-fade-stop-focus.js +1 -0
- package/icons/registry.d.ts +106 -102
- package/model/audio-model.d.ts +54 -2
- package/model/figure-model.d.ts +65 -24
- package/model/gif-model.d.ts +65 -24
- package/model/group-model.d.ts +497 -182
- package/model/group-model.js +1 -1
- package/model/history.js +1 -1
- package/model/image-model.d.ts +65 -24
- package/model/line-model.d.ts +65 -24
- package/model/node-model.d.ts +65 -24
- package/model/node-model.js +1 -1
- package/model/page-model.d.ts +4369 -445
- package/model/page-model.js +1 -1
- package/model/shape-model.d.ts +65 -24
- package/model/store.d.ts +480 -18060
- package/model/store.js +1 -1
- package/model/svg-model.d.ts +64 -24
- package/model/table-model.d.ts +40 -12
- package/model/table-model.js +1 -1
- package/model/text-model.d.ts +64 -24
- package/model/text-model.js +1 -1
- package/model/video-model.d.ts +65 -24
- package/package.json +30 -33
- package/pages-timeline/audio-track.d.ts +14 -2
- package/pages-timeline/audio-track.js +1 -1
- package/pages-timeline/audios.d.ts +10 -2
- package/pages-timeline/current-time.d.ts +2 -2
- package/pages-timeline/current-time.js +1 -1
- package/pages-timeline/element-track.d.ts +14 -2
- package/pages-timeline/element-track.js +1 -1
- package/pages-timeline/elements.d.ts +2 -2
- package/pages-timeline/page-preview.d.ts +8 -2
- package/pages-timeline/page-preview.js +1 -1
- package/pages-timeline/pages-timeline.d.ts +8 -2
- package/pages-timeline/pages-timeline.js +1 -1
- package/pages-timeline/pages.d.ts +8 -2
- package/pages-timeline/play-button.d.ts +2 -2
- package/pages-timeline/time-ruler.d.ts +10 -2
- package/pages-timeline/time-ruler.js +1 -1
- package/polotno.bundle.js +181 -169
- package/primitives/panel-header.js +1 -1
- package/primitives/panel-scroll-area.d.ts +4 -0
- package/primitives/panel-scroll-area.js +1 -0
- package/primitives/select.js +1 -1
- package/side-panel/ai-images-panel.d.ts +6 -2
- package/side-panel/animations-panel.d.ts +6 -2
- package/side-panel/animations-panel.js +1 -1
- package/side-panel/background-panel.d.ts +6 -2
- package/side-panel/draw-panel.d.ts +6 -2
- package/side-panel/draw-panel.js +1 -1
- package/side-panel/effects-panel.d.ts +6 -2
- package/side-panel/effects-panel.js +1 -1
- package/side-panel/elements-panel.js +1 -1
- package/side-panel/image-clip-panel.d.ts +6 -2
- package/side-panel/image-clip-panel.js +1 -1
- package/side-panel/layers-panel.d.ts +6 -2
- package/side-panel/layers-panel.js +1 -1
- package/side-panel/pages-panel.d.ts +6 -2
- package/side-panel/select-video.d.ts +105 -36
- package/side-panel/side-panel.d.ts +2 -2
- package/side-panel/side-panel.js +1 -1
- package/side-panel/size-panel.d.ts +6 -2
- package/side-panel/size-panel.js +1 -1
- package/side-panel/templates-panel.d.ts +6 -2
- package/side-panel/text-panel.d.ts +6 -2
- package/side-panel/text-panel.js +1 -1
- package/side-panel/videos-panel.d.ts +6 -2
- package/toolbar/admin-button.d.ts +6 -2
- package/toolbar/animations-picker.d.ts +18 -4
- package/toolbar/color-picker.js +1 -1
- package/toolbar/copy-style.d.ts +6 -2
- package/toolbar/download-button.d.ts +6 -2
- package/toolbar/duplicate-button.d.ts +6 -2
- package/toolbar/figure-toolbar.d.ts +8 -8
- package/toolbar/filters-picker.d.ts +26 -6
- package/toolbar/gif-toolbar.d.ts +2 -2
- package/toolbar/group-button.d.ts +6 -2
- package/toolbar/group-toolbar.d.ts +2 -2
- package/toolbar/history-buttons.d.ts +6 -2
- package/toolbar/html-toolbar.d.ts +10 -10
- package/toolbar/html-toolbar.js +3 -3
- package/toolbar/image-remove-background-button.d.ts +10 -2
- package/toolbar/image-toolbar.d.ts +32 -10
- package/toolbar/line-toolbar.d.ts +14 -10
- package/toolbar/lock-button.d.ts +6 -2
- package/toolbar/many-toolbar.d.ts +2 -2
- package/toolbar/opacity-picker.d.ts +6 -2
- package/toolbar/opacity-picker.js +1 -1
- package/toolbar/page-toolbar.d.ts +2 -2
- package/toolbar/position-picker.d.ts +6 -2
- package/toolbar/remove-button.d.ts +6 -2
- package/toolbar/svg-toolbar.d.ts +2 -2
- package/toolbar/table-toolbar.d.ts +44 -14
- package/toolbar/text-ai-write.d.ts +6 -2
- package/toolbar/text-toolbar.d.ts +30 -18
- package/toolbar/text-toolbar.js +1 -1
- package/toolbar/toolbar.d.ts +2 -2
- package/toolbar/video-toolbar.d.ts +12 -6
- package/toolbar/video-toolbar.js +1 -1
- package/toolbar/zoom-buttons.d.ts +4 -4
- package/ui.css +1 -1
- package/utils/canvas.d.ts +0 -3
- package/utils/canvas.js +1 -1
- package/utils/clip-fade.d.ts +6 -0
- package/utils/clip-fade.js +1 -0
- package/utils/clipboard.d.ts +104 -36
- package/utils/fade-gradient.d.ts +33 -0
- package/utils/fade-gradient.js +1 -0
- package/utils/fade-overlay.d.ts +9 -0
- package/utils/fade-overlay.js +1 -0
- package/utils/fonts.js +1 -1
- package/utils/from-svg.js +1 -1
- package/utils/l10n.d.ts +40 -0
- package/utils/l10n.js +1 -1
- package/utils/pointer-drag.d.ts +6 -4
- package/utils/pointer-drag.js +1 -1
- package/utils/text-format-state.d.ts +3 -0
- package/utils/text-format-state.js +1 -1
- package/utils/validate-key.js +1 -1
package/model/group-model.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var e=this&&this.__rest||function(e,t){var o={};for(var i in e){Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(o[i]=e[i])}if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(e);r<i.length;r++){t.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(o[i[r]]=e[i[r]])}}return o};import{detach as t,isAlive as o,types as i}from"mobx-state-tree";import{nanoid as r}from"nanoid";import{
|
|
1
|
+
var e=this&&this.__rest||function(e,t){var o={};for(var i in e){Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(o[i]=e[i])}if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(e);r<i.length;r++){t.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(o[i[r]]=e[i[r]])}}return o};import{detach as t,isAlive as o,types as i}from"mobx-state-tree";import{nanoid as r}from"nanoid";import{GROUP_BLEND_MODES as n}from"@polotno/schema/defaults";import{Node as s}from"./node-model.js";import{Animation as l,Shape as a}from"./shape-model.js";import{animate as d}from"../utils/animations.js";import{polotnoError as c}from"@polotno/core/errors";import{getPlayheadLocalTime as p}from"../utils/timeline.js";import{getCenter as h,getTotalClientRect as m}from"../utils/math.js";import{TextElement as y}from"./text-model.js";import{ImageElement as f}from"./image-model.js";import{VideoElement as u}from"./video-model.js";import{LineElement as g}from"./line-model.js";import{SVGElement as E}from"./svg-model.js";import{FigureElement as b}from"./figure-model.js";import{GifElement as v}from"./gif-model.js";import{TableElement as x}from"./table-model.js";export const forEveryChild=(e,t)=>{if(e.children){for(const o of e.children){if(!0===t(o)){break}forEveryChild(o,t)}}};export{forEveryNode}from"@polotno/core/for-every-node";export function zIndexOps(e){const o=(t,o,i)=>{const r=t.map(t=>e.children.findIndex(e=>e.id===t)).filter(e=>-1!==e).sort((e,t)=>(t-e)*o);for(const n of r){const r=e.children[n+o];!r||t.indexOf(r.id)>=0||i(n)}},i=(e,t)=>{let i=!1;return o(e,t,()=>{i=!0}),i},r=(i,r)=>{o(i,r,o=>{const i=e.children[o];t(i),e.children.splice(o+r,0,i)})},n=(t,o)=>{const i=[],r=[];e.children.forEach(e=>{(t.indexOf(e.id)>=0?i:r).push(e)}),e.children.replace(o?r.concat(i):i.concat(r))};return{canMoveElementsUp:e=>i(e,1),canMoveElementsTop:e=>i(e,1),canMoveElementsDown:e=>i(e,-1),canMoveElementsBottom:e=>i(e,-1),moveElementsUp(e){r(e,1)},moveElementsDown(e){r(e,-1)},moveElementsTop(e){n(e,!0)},moveElementsBottom(e){n(e,!1)},setElementZIndex(o,i){const r=e.children.find(e=>e.id===o);r&&(t(r),e.children.remove(r),e.children.splice(i,0,r))}}}const w=[...new Array(20)].map((e,t)=>i.late(()=>M[t]));export const ElementTypes=i.union({dispatcher:e=>{const t=TYPES_MAP[e.type];if(!t){const t=`Unknown element type: "${e.type}"`;throw c("DESIGN_INVALID",t,{errors:[{path:"type",message:t}],knownTypes:Object.keys(TYPES_MAP)})}return t}},E,y,f,g,u,b,v,x,i.late(()=>GroupElement),...w);const j=Object.freeze({x:0,y:0,offsetX:0,offsetY:0,scaleX:1,scaleY:1,rotation:0,opacity:1});function O(e){return 1===e?j:Object.assign(Object.assign({},j),{opacity:e})}const P={x:0,y:0,width:0,height:0,rotation:0,opacity:1,fontSize:0,cropX:0,cropY:0,cropWidth:1,cropHeight:1},C=(e,t)=>"number"==typeof e&&isFinite(e)?e:t;function S(e,t,o,i){P.x=e.x,P.y=e.y,P.width=e.width,P.height=e.height,P.opacity=i;const r=d({element:P,animation:t,dTime:o})||{},n=C(r.width,e.width),s=C(r.height,e.height);return{x:C(r.x,e.x),y:C(r.y,e.y),width:n>0?n:e.width,height:s>0?s:e.height,rotation:C(r.rotation,0),opacity:C(r.opacity,i)}}export const GroupElement=s.named("Group").props({type:"group",blendMode:i.optional(i.enumeration([...n]),"pass-through"),children:i.array(ElementTypes),animations:i.array(l)}).views(e=>({get draggable(){let t=!0;return forEveryChild(e,e=>{e.draggable||(t=!1)}),t},get resizable(){let t=!0;return forEveryChild(e,e=>{e.resizable||(t=!1)}),t},get contentEditable(){let t=!0;return forEveryChild(e,e=>{e.contentEditable||(t=!1)}),t},get styleEditable(){let t=!0;return forEveryChild(e,e=>{e.styleEditable||(t=!1)}),t},get locked(){let t=!0;return forEveryChild(e,e=>{e.locked||(t=!1)}),t},get _restingBbox(){const t=[];if(forEveryChild(e,e=>{var o,i,r;if("group"===e.type){return}const n=e.width,s=e.height;!n||!s||n<=0||s<=0||t.push({x:null!==(o=e.x)&&void 0!==o?o:0,y:null!==(i=e.y)&&void 0!==i?i:0,width:n,height:s,rotation:null!==(r=e.rotation)&&void 0!==r?r:0})}),!t.length){return null}const o=m(t);return o.width<=0||o.height<=0?null:{x:o.x,y:o.y,width:o.width,height:o.height}},get a(){if(!o(e)){return j}const t=p(e);if(null===t){return O(e.opacity)}if(e.store.isEditingPaused&&this.isSelectedDirectly){return O(e.opacity)}const i=e.page,r=e.store.animatedElementsIds;if(r.length&&!r.includes(e.id)){return O(e.opacity)}let n,s,l;for(const o of e.animations){o.enabled&&("enter"===o.type?n=o:"exit"===o.type?s=o:"loop"===o.type&&(l=o))}const a=!!n&&t<n.delay,d=!!n&&t>=n.delay&&t<=n.delay+n.duration,c=!a&&!d&&!!s&&t>=i.duration-s.duration-s.delay&&t<=i.duration-s.delay,m=!!s&&t>=i.duration-s.delay;if(!(a||d||c||m||l)){return O(e.opacity)}const y=this._restingBbox;if(!y){return O(e.opacity)}let f={x:y.x,y:y.y,width:y.width,height:y.height,rotation:0,opacity:e.opacity};a&&(f.opacity=0),d&&(f=S(y,n,t-n.delay,e.opacity)),c&&(f=S(y,s,t-(i.duration-s.duration-s.delay),e.opacity)),m&&(f.opacity=0),l&&(f=S(f,l,t,f.opacity));const u=h(f);return{x:u.x,y:u.y,offsetX:y.x+y.width/2,offsetY:y.y+y.height/2,scaleX:f.width/y.width,scaleY:f.height/y.height,rotation:f.rotation,opacity:f.opacity}},get isSelectedDirectly(){return!!o(e)&&e.store.selectedElements.indexOf(e)>=0&&e.selectable},get active(){return!0}})).actions(t=>Object.assign(Object.assign({set(o){var{draggable:i,contentEditable:r,styleEditable:n,resizable:s}=o,l=e(o,["draggable","contentEditable","styleEditable","resizable"]);void 0!==i&&forEveryChild(t,e=>{e.set({draggable:i})}),void 0!==r&&forEveryChild(t,e=>{e.set({contentEditable:r})}),void 0!==n&&forEveryChild(t,e=>{e.set({styleEditable:n})}),void 0!==s&&forEveryChild(t,e=>{e.set({resizable:s})}),Object.assign(t,l)},addElement(e,{skipSelect:o=!1}={}){const i=TYPES_MAP[e.type];if(!i){return void console.error("Can not find model with type "+e.type)}e.children&&e.children.forEach(e=>{e.id=e.id||r(10)});const n=i.create(Object.assign({id:r(10)},e));return t.children.push(n),n.selectable&&!o&&t.store.selectElements([n.id]),n}},zIndexOps(t)),{setAnimation(e,o){const i=t.animations.find(t=>t.type===e);i?Object.assign(i,o):t.animations.push(Object.assign({type:e},o))}}));const M=[];export const TYPES_MAP={svg:E,text:y,image:f,group:GroupElement,line:g,video:u,figure:b,gif:v,table:x};export function registerShapeModel(e,t){const o=e.type;if(!o){throw new Error('You must pass "type" attribute to custom model.')}const i=a.named(o).props(e),r=t?t(i):i;TYPES_MAP[o]=r,M.push(r)}
|
package/model/history.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{types as t,resolvePath as e,onSnapshot as o,getSnapshot as a,applySnapshot as n}from"mobx-state-tree";import{deepEqual as r}from"../utils/deep-equal.js";Object.assign(t);export const UndoManager=t.model("UndoManager",{history:t.array(t.frozen()),undoIdx:-1,targetPath:""}).views(t=>({get canUndo(){return t.undoIdx>0},get canRedo(){return t.undoIdx<t.history.length-1}})).actions(t=>{let d,s,i=!1,c=null,u=0,h=0;const l=()=>h>0;function g(){const t=a(d);return{pages:t.pages,width:t.width,height:t.height,custom:t.custom,audios:t.audios}}function m(t){const e=d.pages.map(t=>t.id),o=t.pages.map(t=>t.id),a=!r(e,o),s=!r(d.custom,t.custom);a?n(d.pages,t.pages):d.pages.forEach((e,o)=>{n(e,t.pages[o])}),s&&d.set({custom:t.custom}),d.setSize(t.width,t.height)}const p={startTransaction(){h++},endTransaction(t){h--,t||p.requestAddState(g())},async ignore(t,e=!1,o=!1){o&&await new Promise(t=>setTimeout(t,10));const a=!!u;u&&p.addUndoState();let n=l();p.startTransaction();let r=h;try{await t()}catch(i){setTimeout(()=>{throw i})}const d=r!==h,s=!d;p.endTransaction(s),e||n&&!a||p.replaceState(),d||(clearTimeout(u),u=0)},async transaction(t){await p.ignore(t,!0),p.addUndoState()},requestAddState(t){c=t,u||l()||(i?i=!1:u=setTimeout(()=>{u=0,clearTimeout(u),l()||p.addUndoState()},100))},addUndoState(){if(i){return void(i=!1)}const e=t.history[t.undoIdx];!r(c,e)&&(clearTimeout(u),u=0,t.history.splice(t.undoIdx+1),t.history.push(c),t.undoIdx=t.history.length-1)},afterCreate(){if(d=e(t,".."),!d){throw new Error("Failed to find target store for UndoManager. Please provide `targetPath` property, or a `targetStore` in the environment")}s=o(d,()=>{p.requestAddState(g())}),0===t.history.length&&p.requestAddState(g())},clear(){clearTimeout(u),u=0,t.history.splice(0,t.history.length),t.undoIdx=-1,p.addUndoState()},beforeDestroy(){s()},undo(){u&&p.addUndoState(),l()
|
|
1
|
+
import{types as t,resolvePath as e,onSnapshot as o,getSnapshot as a,applySnapshot as n}from"mobx-state-tree";import{deepEqual as r}from"../utils/deep-equal.js";Object.assign(t);export const UndoManager=t.model("UndoManager",{history:t.array(t.frozen()),undoIdx:-1,targetPath:""}).views(t=>({get canUndo(){return t.undoIdx>0},get canRedo(){return t.undoIdx<t.history.length-1}})).actions(t=>{let d,s,i=!1,c=null,u=0,h=0;const l=()=>h>0;function g(){const t=a(d);return{pages:t.pages,width:t.width,height:t.height,custom:t.custom,audios:t.audios}}function m(t){const e=d.pages.map(t=>t.id),o=t.pages.map(t=>t.id),a=!r(e,o),s=!r(d.custom,t.custom);a?n(d.pages,t.pages):d.pages.forEach((e,o)=>{n(e,t.pages[o])}),s&&d.set({custom:t.custom}),d.setSize(t.width,t.height)}const p={startTransaction(){h++},endTransaction(t){h--,t||p.requestAddState(g())},async ignore(t,e=!1,o=!1){o&&await new Promise(t=>setTimeout(t,10));const a=!!u;u&&p.addUndoState();let n=l();p.startTransaction();let r=h;try{await t()}catch(i){setTimeout(()=>{throw i})}const d=r!==h,s=!d;p.endTransaction(s),e||n&&!a||p.replaceState(),d||(clearTimeout(u),u=0)},async transaction(t){await p.ignore(t,!0),p.addUndoState()},requestAddState(t){c=t,u||l()||(i?i=!1:u=setTimeout(()=>{u=0,clearTimeout(u),l()||p.addUndoState()},100))},addUndoState(){if(i){return void(i=!1)}const e=t.history[t.undoIdx];!r(c,e)&&(clearTimeout(u),u=0,t.history.splice(t.undoIdx+1),t.history.push(c),t.undoIdx=t.history.length-1)},afterCreate(){if(d=e(t,".."),!d){throw new Error("Failed to find target store for UndoManager. Please provide `targetPath` property, or a `targetStore` in the environment")}s=o(d,()=>{p.requestAddState(g())}),0===t.history.length&&p.requestAddState(g())},clear(){clearTimeout(u),u=0,t.history.splice(0,t.history.length),t.undoIdx=-1,p.addUndoState()},beforeDestroy(){s()},undo(){if(u&&p.addUndoState(),l()){const e=t.history[t.undoIdx];return void(e&&m(e))}t.canUndo?(t.undoIdx--,i=!0,m(t.history[t.undoIdx])):console.warn("No undo history. Please check `store.history.canUndo` before calling undo action.")},redo(){u&&p.addUndoState(),t.canRedo?(t.undoIdx++,i=!0,m(t.history[t.undoIdx])):console.warn("No redo history. Please check `store.history.canRedo` before calling redo action.")},replaceState(){t.history[t.undoIdx]=g()}};return p});export default UndoManager;
|
package/model/image-model.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export declare const ImageElement: import("mobx-state-tree").IModelType<{
|
|
|
4
4
|
type: import("mobx-state-tree").IType<string | undefined, string, string>;
|
|
5
5
|
name: import("mobx-state-tree").IType<string | undefined, string, string>;
|
|
6
6
|
opacity: import("mobx-state-tree").IType<number | undefined, number, number>;
|
|
7
|
+
blendMode: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<"normal" | "color" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "overlay" | "saturation" | "screen" | "soft-light">, [undefined]>;
|
|
7
8
|
custom: import("mobx-state-tree").IType<any, any, any>;
|
|
8
9
|
visible: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
|
|
9
10
|
selectable: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
|
|
@@ -73,6 +74,7 @@ export declare const ImageElement: import("mobx-state-tree").IModelType<{
|
|
|
73
74
|
type: import("mobx-state-tree").IType<string | undefined, string, string>;
|
|
74
75
|
name: import("mobx-state-tree").IType<string | undefined, string, string>;
|
|
75
76
|
opacity: import("mobx-state-tree").IType<number | undefined, number, number>;
|
|
77
|
+
blendMode: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<"normal" | "color" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "overlay" | "saturation" | "screen" | "soft-light">, [undefined]>;
|
|
76
78
|
custom: import("mobx-state-tree").IType<any, any, any>;
|
|
77
79
|
visible: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
|
|
78
80
|
selectable: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
|
|
@@ -84,6 +86,7 @@ export declare const ImageElement: import("mobx-state-tree").IModelType<{
|
|
|
84
86
|
type: import("mobx-state-tree").IType<string | undefined, string, string>;
|
|
85
87
|
name: import("mobx-state-tree").IType<string | undefined, string, string>;
|
|
86
88
|
opacity: import("mobx-state-tree").IType<number | undefined, number, number>;
|
|
89
|
+
blendMode: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<"normal" | "color" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "overlay" | "saturation" | "screen" | "soft-light">, [undefined]>;
|
|
87
90
|
custom: import("mobx-state-tree").IType<any, any, any>;
|
|
88
91
|
visible: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
|
|
89
92
|
selectable: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
|
|
@@ -95,24 +98,37 @@ export declare const ImageElement: import("mobx-state-tree").IModelType<{
|
|
|
95
98
|
type: string | undefined;
|
|
96
99
|
name: string | undefined;
|
|
97
100
|
opacity: number | undefined;
|
|
101
|
+
blendMode: "normal" | "color" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "overlay" | "saturation" | "screen" | "soft-light" | undefined;
|
|
98
102
|
custom: any;
|
|
99
103
|
visible: boolean | undefined;
|
|
100
104
|
selectable: boolean | undefined;
|
|
101
105
|
removable: boolean | undefined;
|
|
102
106
|
alwaysOnTop: boolean | undefined;
|
|
103
107
|
showInExport: boolean | undefined;
|
|
104
|
-
}>,
|
|
105
|
-
id:
|
|
106
|
-
type:
|
|
107
|
-
name:
|
|
108
|
-
opacity:
|
|
109
|
-
custom:
|
|
110
|
-
visible:
|
|
111
|
-
selectable:
|
|
112
|
-
removable:
|
|
113
|
-
alwaysOnTop:
|
|
114
|
-
showInExport:
|
|
115
|
-
}
|
|
108
|
+
}>, {
|
|
109
|
+
id: string;
|
|
110
|
+
type: string;
|
|
111
|
+
name: string;
|
|
112
|
+
opacity: number;
|
|
113
|
+
custom: any;
|
|
114
|
+
visible: boolean;
|
|
115
|
+
selectable: boolean;
|
|
116
|
+
removable: boolean;
|
|
117
|
+
alwaysOnTop: boolean;
|
|
118
|
+
showInExport: boolean;
|
|
119
|
+
} | {
|
|
120
|
+
blendMode: "normal" | "color" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "overlay" | "saturation" | "screen" | "soft-light";
|
|
121
|
+
id: string;
|
|
122
|
+
type: string;
|
|
123
|
+
name: string;
|
|
124
|
+
opacity: number;
|
|
125
|
+
custom: any;
|
|
126
|
+
visible: boolean;
|
|
127
|
+
selectable: boolean;
|
|
128
|
+
removable: boolean;
|
|
129
|
+
alwaysOnTop: boolean;
|
|
130
|
+
showInExport: boolean;
|
|
131
|
+
}>>;
|
|
116
132
|
readonly parent: any;
|
|
117
133
|
readonly zIndex: any;
|
|
118
134
|
} & {
|
|
@@ -127,6 +143,18 @@ export declare const ImageElement: import("mobx-state-tree").IModelType<{
|
|
|
127
143
|
removable: boolean;
|
|
128
144
|
alwaysOnTop: boolean;
|
|
129
145
|
showInExport: boolean;
|
|
146
|
+
} | {
|
|
147
|
+
blendMode: "normal" | "color" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "overlay" | "saturation" | "screen" | "soft-light";
|
|
148
|
+
id: string;
|
|
149
|
+
type: string;
|
|
150
|
+
name: string;
|
|
151
|
+
opacity: number;
|
|
152
|
+
custom: any;
|
|
153
|
+
visible: boolean;
|
|
154
|
+
selectable: boolean;
|
|
155
|
+
removable: boolean;
|
|
156
|
+
alwaysOnTop: boolean;
|
|
157
|
+
showInExport: boolean;
|
|
130
158
|
};
|
|
131
159
|
} & {
|
|
132
160
|
clone(attrs?: any, { skipSelect }?: {
|
|
@@ -165,22 +193,35 @@ export declare const ImageElement: import("mobx-state-tree").IModelType<{
|
|
|
165
193
|
type: string | undefined;
|
|
166
194
|
name: string | undefined;
|
|
167
195
|
opacity: number | undefined;
|
|
196
|
+
blendMode: "normal" | "color" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "overlay" | "saturation" | "screen" | "soft-light" | undefined;
|
|
168
197
|
custom: any;
|
|
169
198
|
visible: boolean | undefined;
|
|
170
199
|
selectable: boolean | undefined;
|
|
171
200
|
removable: boolean | undefined;
|
|
172
201
|
alwaysOnTop: boolean | undefined;
|
|
173
202
|
showInExport: boolean | undefined;
|
|
174
|
-
}>,
|
|
175
|
-
id:
|
|
176
|
-
type:
|
|
177
|
-
name:
|
|
178
|
-
opacity:
|
|
179
|
-
custom:
|
|
180
|
-
visible:
|
|
181
|
-
selectable:
|
|
182
|
-
removable:
|
|
183
|
-
alwaysOnTop:
|
|
184
|
-
showInExport:
|
|
185
|
-
}
|
|
203
|
+
}>, {
|
|
204
|
+
id: string;
|
|
205
|
+
type: string;
|
|
206
|
+
name: string;
|
|
207
|
+
opacity: number;
|
|
208
|
+
custom: any;
|
|
209
|
+
visible: boolean;
|
|
210
|
+
selectable: boolean;
|
|
211
|
+
removable: boolean;
|
|
212
|
+
alwaysOnTop: boolean;
|
|
213
|
+
showInExport: boolean;
|
|
214
|
+
} | {
|
|
215
|
+
blendMode: "normal" | "color" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "overlay" | "saturation" | "screen" | "soft-light";
|
|
216
|
+
id: string;
|
|
217
|
+
type: string;
|
|
218
|
+
name: string;
|
|
219
|
+
opacity: number;
|
|
220
|
+
custom: any;
|
|
221
|
+
visible: boolean;
|
|
222
|
+
selectable: boolean;
|
|
223
|
+
removable: boolean;
|
|
224
|
+
alwaysOnTop: boolean;
|
|
225
|
+
showInExport: boolean;
|
|
226
|
+
}>;
|
|
186
227
|
export type ImageElementType = Instance<typeof ImageElement>;
|
package/model/line-model.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export declare const LineElement: import("mobx-state-tree").IModelType<{
|
|
|
4
4
|
type: import("mobx-state-tree").IType<string | undefined, string, string>;
|
|
5
5
|
name: import("mobx-state-tree").IType<string | undefined, string, string>;
|
|
6
6
|
opacity: import("mobx-state-tree").IType<number | undefined, number, number>;
|
|
7
|
+
blendMode: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<"normal" | "color" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "overlay" | "saturation" | "screen" | "soft-light">, [undefined]>;
|
|
7
8
|
custom: import("mobx-state-tree").IType<any, any, any>;
|
|
8
9
|
visible: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
|
|
9
10
|
selectable: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
|
|
@@ -64,6 +65,7 @@ export declare const LineElement: import("mobx-state-tree").IModelType<{
|
|
|
64
65
|
type: import("mobx-state-tree").IType<string | undefined, string, string>;
|
|
65
66
|
name: import("mobx-state-tree").IType<string | undefined, string, string>;
|
|
66
67
|
opacity: import("mobx-state-tree").IType<number | undefined, number, number>;
|
|
68
|
+
blendMode: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<"normal" | "color" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "overlay" | "saturation" | "screen" | "soft-light">, [undefined]>;
|
|
67
69
|
custom: import("mobx-state-tree").IType<any, any, any>;
|
|
68
70
|
visible: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
|
|
69
71
|
selectable: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
|
|
@@ -75,6 +77,7 @@ export declare const LineElement: import("mobx-state-tree").IModelType<{
|
|
|
75
77
|
type: import("mobx-state-tree").IType<string | undefined, string, string>;
|
|
76
78
|
name: import("mobx-state-tree").IType<string | undefined, string, string>;
|
|
77
79
|
opacity: import("mobx-state-tree").IType<number | undefined, number, number>;
|
|
80
|
+
blendMode: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<"normal" | "color" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "overlay" | "saturation" | "screen" | "soft-light">, [undefined]>;
|
|
78
81
|
custom: import("mobx-state-tree").IType<any, any, any>;
|
|
79
82
|
visible: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
|
|
80
83
|
selectable: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
|
|
@@ -86,24 +89,37 @@ export declare const LineElement: import("mobx-state-tree").IModelType<{
|
|
|
86
89
|
type: string | undefined;
|
|
87
90
|
name: string | undefined;
|
|
88
91
|
opacity: number | undefined;
|
|
92
|
+
blendMode: "normal" | "color" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "overlay" | "saturation" | "screen" | "soft-light" | undefined;
|
|
89
93
|
custom: any;
|
|
90
94
|
visible: boolean | undefined;
|
|
91
95
|
selectable: boolean | undefined;
|
|
92
96
|
removable: boolean | undefined;
|
|
93
97
|
alwaysOnTop: boolean | undefined;
|
|
94
98
|
showInExport: boolean | undefined;
|
|
95
|
-
}>,
|
|
96
|
-
id:
|
|
97
|
-
type:
|
|
98
|
-
name:
|
|
99
|
-
opacity:
|
|
100
|
-
custom:
|
|
101
|
-
visible:
|
|
102
|
-
selectable:
|
|
103
|
-
removable:
|
|
104
|
-
alwaysOnTop:
|
|
105
|
-
showInExport:
|
|
106
|
-
}
|
|
99
|
+
}>, {
|
|
100
|
+
id: string;
|
|
101
|
+
type: string;
|
|
102
|
+
name: string;
|
|
103
|
+
opacity: number;
|
|
104
|
+
custom: any;
|
|
105
|
+
visible: boolean;
|
|
106
|
+
selectable: boolean;
|
|
107
|
+
removable: boolean;
|
|
108
|
+
alwaysOnTop: boolean;
|
|
109
|
+
showInExport: boolean;
|
|
110
|
+
} | {
|
|
111
|
+
blendMode: "normal" | "color" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "overlay" | "saturation" | "screen" | "soft-light";
|
|
112
|
+
id: string;
|
|
113
|
+
type: string;
|
|
114
|
+
name: string;
|
|
115
|
+
opacity: number;
|
|
116
|
+
custom: any;
|
|
117
|
+
visible: boolean;
|
|
118
|
+
selectable: boolean;
|
|
119
|
+
removable: boolean;
|
|
120
|
+
alwaysOnTop: boolean;
|
|
121
|
+
showInExport: boolean;
|
|
122
|
+
}>>;
|
|
107
123
|
readonly parent: any;
|
|
108
124
|
readonly zIndex: any;
|
|
109
125
|
} & {
|
|
@@ -118,6 +134,18 @@ export declare const LineElement: import("mobx-state-tree").IModelType<{
|
|
|
118
134
|
removable: boolean;
|
|
119
135
|
alwaysOnTop: boolean;
|
|
120
136
|
showInExport: boolean;
|
|
137
|
+
} | {
|
|
138
|
+
blendMode: "normal" | "color" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "overlay" | "saturation" | "screen" | "soft-light";
|
|
139
|
+
id: string;
|
|
140
|
+
type: string;
|
|
141
|
+
name: string;
|
|
142
|
+
opacity: number;
|
|
143
|
+
custom: any;
|
|
144
|
+
visible: boolean;
|
|
145
|
+
selectable: boolean;
|
|
146
|
+
removable: boolean;
|
|
147
|
+
alwaysOnTop: boolean;
|
|
148
|
+
showInExport: boolean;
|
|
121
149
|
};
|
|
122
150
|
} & {
|
|
123
151
|
clone(attrs?: any, { skipSelect }?: {
|
|
@@ -149,22 +177,35 @@ export declare const LineElement: import("mobx-state-tree").IModelType<{
|
|
|
149
177
|
type: string | undefined;
|
|
150
178
|
name: string | undefined;
|
|
151
179
|
opacity: number | undefined;
|
|
180
|
+
blendMode: "normal" | "color" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "overlay" | "saturation" | "screen" | "soft-light" | undefined;
|
|
152
181
|
custom: any;
|
|
153
182
|
visible: boolean | undefined;
|
|
154
183
|
selectable: boolean | undefined;
|
|
155
184
|
removable: boolean | undefined;
|
|
156
185
|
alwaysOnTop: boolean | undefined;
|
|
157
186
|
showInExport: boolean | undefined;
|
|
158
|
-
}>,
|
|
159
|
-
id:
|
|
160
|
-
type:
|
|
161
|
-
name:
|
|
162
|
-
opacity:
|
|
163
|
-
custom:
|
|
164
|
-
visible:
|
|
165
|
-
selectable:
|
|
166
|
-
removable:
|
|
167
|
-
alwaysOnTop:
|
|
168
|
-
showInExport:
|
|
169
|
-
}
|
|
187
|
+
}>, {
|
|
188
|
+
id: string;
|
|
189
|
+
type: string;
|
|
190
|
+
name: string;
|
|
191
|
+
opacity: number;
|
|
192
|
+
custom: any;
|
|
193
|
+
visible: boolean;
|
|
194
|
+
selectable: boolean;
|
|
195
|
+
removable: boolean;
|
|
196
|
+
alwaysOnTop: boolean;
|
|
197
|
+
showInExport: boolean;
|
|
198
|
+
} | {
|
|
199
|
+
blendMode: "normal" | "color" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "overlay" | "saturation" | "screen" | "soft-light";
|
|
200
|
+
id: string;
|
|
201
|
+
type: string;
|
|
202
|
+
name: string;
|
|
203
|
+
opacity: number;
|
|
204
|
+
custom: any;
|
|
205
|
+
visible: boolean;
|
|
206
|
+
selectable: boolean;
|
|
207
|
+
removable: boolean;
|
|
208
|
+
alwaysOnTop: boolean;
|
|
209
|
+
showInExport: boolean;
|
|
210
|
+
}>;
|
|
170
211
|
export type LineElementType = Instance<typeof LineElement>;
|
package/model/node-model.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export declare const Node: import("mobx-state-tree").IModelType<{
|
|
|
4
4
|
type: import("mobx-state-tree").IType<string | undefined, string, string>;
|
|
5
5
|
name: import("mobx-state-tree").IType<string | undefined, string, string>;
|
|
6
6
|
opacity: import("mobx-state-tree").IType<number | undefined, number, number>;
|
|
7
|
+
blendMode: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<"normal" | "color" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "overlay" | "saturation" | "screen" | "soft-light">, [undefined]>;
|
|
7
8
|
custom: import("mobx-state-tree").IType<any, any, any>;
|
|
8
9
|
visible: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
|
|
9
10
|
selectable: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
|
|
@@ -18,6 +19,7 @@ export declare const Node: import("mobx-state-tree").IModelType<{
|
|
|
18
19
|
type: import("mobx-state-tree").IType<string | undefined, string, string>;
|
|
19
20
|
name: import("mobx-state-tree").IType<string | undefined, string, string>;
|
|
20
21
|
opacity: import("mobx-state-tree").IType<number | undefined, number, number>;
|
|
22
|
+
blendMode: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<"normal" | "color" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "overlay" | "saturation" | "screen" | "soft-light">, [undefined]>;
|
|
21
23
|
custom: import("mobx-state-tree").IType<any, any, any>;
|
|
22
24
|
visible: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
|
|
23
25
|
selectable: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
|
|
@@ -29,6 +31,7 @@ export declare const Node: import("mobx-state-tree").IModelType<{
|
|
|
29
31
|
type: import("mobx-state-tree").IType<string | undefined, string, string>;
|
|
30
32
|
name: import("mobx-state-tree").IType<string | undefined, string, string>;
|
|
31
33
|
opacity: import("mobx-state-tree").IType<number | undefined, number, number>;
|
|
34
|
+
blendMode: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<"normal" | "color" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "overlay" | "saturation" | "screen" | "soft-light">, [undefined]>;
|
|
32
35
|
custom: import("mobx-state-tree").IType<any, any, any>;
|
|
33
36
|
visible: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
|
|
34
37
|
selectable: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
|
|
@@ -40,24 +43,37 @@ export declare const Node: import("mobx-state-tree").IModelType<{
|
|
|
40
43
|
type: string | undefined;
|
|
41
44
|
name: string | undefined;
|
|
42
45
|
opacity: number | undefined;
|
|
46
|
+
blendMode: "normal" | "color" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "overlay" | "saturation" | "screen" | "soft-light" | undefined;
|
|
43
47
|
custom: any;
|
|
44
48
|
visible: boolean | undefined;
|
|
45
49
|
selectable: boolean | undefined;
|
|
46
50
|
removable: boolean | undefined;
|
|
47
51
|
alwaysOnTop: boolean | undefined;
|
|
48
52
|
showInExport: boolean | undefined;
|
|
49
|
-
}>,
|
|
50
|
-
id:
|
|
51
|
-
type:
|
|
52
|
-
name:
|
|
53
|
-
opacity:
|
|
54
|
-
custom:
|
|
55
|
-
visible:
|
|
56
|
-
selectable:
|
|
57
|
-
removable:
|
|
58
|
-
alwaysOnTop:
|
|
59
|
-
showInExport:
|
|
60
|
-
}
|
|
53
|
+
}>, {
|
|
54
|
+
id: string;
|
|
55
|
+
type: string;
|
|
56
|
+
name: string;
|
|
57
|
+
opacity: number;
|
|
58
|
+
custom: any;
|
|
59
|
+
visible: boolean;
|
|
60
|
+
selectable: boolean;
|
|
61
|
+
removable: boolean;
|
|
62
|
+
alwaysOnTop: boolean;
|
|
63
|
+
showInExport: boolean;
|
|
64
|
+
} | {
|
|
65
|
+
blendMode: "normal" | "color" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "overlay" | "saturation" | "screen" | "soft-light";
|
|
66
|
+
id: string;
|
|
67
|
+
type: string;
|
|
68
|
+
name: string;
|
|
69
|
+
opacity: number;
|
|
70
|
+
custom: any;
|
|
71
|
+
visible: boolean;
|
|
72
|
+
selectable: boolean;
|
|
73
|
+
removable: boolean;
|
|
74
|
+
alwaysOnTop: boolean;
|
|
75
|
+
showInExport: boolean;
|
|
76
|
+
}>>;
|
|
61
77
|
readonly parent: any;
|
|
62
78
|
readonly zIndex: any;
|
|
63
79
|
} & {
|
|
@@ -72,6 +88,18 @@ export declare const Node: import("mobx-state-tree").IModelType<{
|
|
|
72
88
|
removable: boolean;
|
|
73
89
|
alwaysOnTop: boolean;
|
|
74
90
|
showInExport: boolean;
|
|
91
|
+
} | {
|
|
92
|
+
blendMode: "normal" | "color" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "overlay" | "saturation" | "screen" | "soft-light";
|
|
93
|
+
id: string;
|
|
94
|
+
type: string;
|
|
95
|
+
name: string;
|
|
96
|
+
opacity: number;
|
|
97
|
+
custom: any;
|
|
98
|
+
visible: boolean;
|
|
99
|
+
selectable: boolean;
|
|
100
|
+
removable: boolean;
|
|
101
|
+
alwaysOnTop: boolean;
|
|
102
|
+
showInExport: boolean;
|
|
75
103
|
};
|
|
76
104
|
} & {
|
|
77
105
|
clone(attrs?: any, { skipSelect }?: {
|
|
@@ -89,22 +117,35 @@ export declare const Node: import("mobx-state-tree").IModelType<{
|
|
|
89
117
|
type: string | undefined;
|
|
90
118
|
name: string | undefined;
|
|
91
119
|
opacity: number | undefined;
|
|
120
|
+
blendMode: "normal" | "color" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "overlay" | "saturation" | "screen" | "soft-light" | undefined;
|
|
92
121
|
custom: any;
|
|
93
122
|
visible: boolean | undefined;
|
|
94
123
|
selectable: boolean | undefined;
|
|
95
124
|
removable: boolean | undefined;
|
|
96
125
|
alwaysOnTop: boolean | undefined;
|
|
97
126
|
showInExport: boolean | undefined;
|
|
98
|
-
}>,
|
|
99
|
-
id:
|
|
100
|
-
type:
|
|
101
|
-
name:
|
|
102
|
-
opacity:
|
|
103
|
-
custom:
|
|
104
|
-
visible:
|
|
105
|
-
selectable:
|
|
106
|
-
removable:
|
|
107
|
-
alwaysOnTop:
|
|
108
|
-
showInExport:
|
|
109
|
-
}
|
|
127
|
+
}>, {
|
|
128
|
+
id: string;
|
|
129
|
+
type: string;
|
|
130
|
+
name: string;
|
|
131
|
+
opacity: number;
|
|
132
|
+
custom: any;
|
|
133
|
+
visible: boolean;
|
|
134
|
+
selectable: boolean;
|
|
135
|
+
removable: boolean;
|
|
136
|
+
alwaysOnTop: boolean;
|
|
137
|
+
showInExport: boolean;
|
|
138
|
+
} | {
|
|
139
|
+
blendMode: "normal" | "color" | "color-burn" | "color-dodge" | "darken" | "difference" | "exclusion" | "hard-light" | "hue" | "lighten" | "luminosity" | "multiply" | "overlay" | "saturation" | "screen" | "soft-light";
|
|
140
|
+
id: string;
|
|
141
|
+
type: string;
|
|
142
|
+
name: string;
|
|
143
|
+
opacity: number;
|
|
144
|
+
custom: any;
|
|
145
|
+
visible: boolean;
|
|
146
|
+
selectable: boolean;
|
|
147
|
+
removable: boolean;
|
|
148
|
+
alwaysOnTop: boolean;
|
|
149
|
+
showInExport: boolean;
|
|
150
|
+
}>;
|
|
110
151
|
export type NodeType = Instance<typeof Node>;
|
package/model/node-model.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{types as
|
|
1
|
+
var e=this&&this.__rest||function(e,t){var o={};for(var n in e){Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n])}if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(n=Object.getOwnPropertySymbols(e);r<n.length;r++){t.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(o[n[r]]=e[n[r]])}}return o};import{types as t,getParentOfType as o,getSnapshot as n,hasParentOfType as r,isAlive as s}from"mobx-state-tree";import{nanoid as i}from"nanoid";import{BLEND_MODES as l}from"@polotno/schema/defaults";import{Store as a}from"./store.js";import{Page as p}from"./page-model.js";import{GroupElement as d,forEveryNode as m}from"./group-model.js";export const Node=t.model("Node",{id:t.identifier,type:"none",name:"",opacity:1,blendMode:t.optional(t.enumeration([...l]),"normal"),custom:t.frozen(),visible:!0,selectable:!0,removable:!0,alwaysOnTop:!1,showInExport:!0}).preProcessSnapshot(e=>{for(var t in e){null===e[t]&&(e[t]=void 0)}return e}).postProcessSnapshot(t=>{const{blendMode:o}=t,n=e(t,["blendMode"]);for(const e in n){"_"===e[0]&&delete n[e]}return o===("group"===n.type?"pass-through":"normal")?n:Object.assign(Object.assign({},n),{blendMode:o})}).views(e=>({get page(){return s(e)?o(e,p):null},get store(){return s(e)?o(e,a):null},get top(){if(!s(e)){return e}let t=e;for(;;){if(!r(t,d)){return t}t=o(t,d)}},get parent(){if(!s(e)){return null}if(r(e,d)){const t=o(e,d);return t&&t.children&&t.children.length,t}if(r(e,p)){const t=o(e,p);return t&&t.children&&t.children.length,t}if(r(e,a)){const t=o(e,a);return t&&t.pages&&t.pages.length,t}return null},get zIndex(){return s(e)?e.parent.children.indexOf(e):-1}})).actions(e=>({toJSON:()=>Object.assign({},n(e))})).actions(e=>({clone(t={},{skipSelect:o=!1}={}){const n=JSON.parse(JSON.stringify(e.toJSON()));t.id=t.id||i(10);const r=new Map;return m(n,e=>{const t=e.id,o=i(10);r.set(t,o),e.id=o}),m(n,e=>{e.mergedInto&&r.has(e.mergedInto)&&(e.mergedInto=r.get(e.mergedInto))}),Object.assign(n,t),e.page.addElement(n,{skipSelect:o})},set(t){Object.assign(e,t)},moveUp(){var t;null===(t=e.parent)||void 0===t||t.moveElementsUp([e.id])},moveTop(){var t;null===(t=e.parent)||void 0===t||t.moveElementsTop([e.id])},moveDown(){var t;null===(t=e.parent)||void 0===t||t.moveElementsDown([e.id])},moveBottom(){var t;null===(t=e.parent)||void 0===t||t.moveElementsBottom([e.id])},setZIndex(t){e.parent.setElementZIndex(e.id,t)},beforeDestroy(){}}));
|