kritzel-stencil 0.1.80 → 0.1.82
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/dist/cjs/index.cjs.js +1 -1
- package/dist/cjs/kritzel-active-users_42.cjs.entry.js +30 -37
- package/dist/cjs/{workspace.migrations-DUXtSb7C.js → workspace.migrations-4HATwIMK.js} +46 -58
- package/dist/collection/classes/core/core.class.js +6 -6
- package/dist/collection/classes/core/store.class.js +0 -12
- package/dist/collection/classes/objects/base-object.class.js +1 -1
- package/dist/collection/classes/objects/custom-element.class.js +1 -1
- package/dist/collection/classes/objects/group.class.js +1 -1
- package/dist/collection/classes/objects/image.class.js +1 -1
- package/dist/collection/classes/objects/line.class.js +1 -1
- package/dist/collection/classes/objects/path.class.js +1 -1
- package/dist/collection/classes/objects/selection-box.class.js +1 -1
- package/dist/collection/classes/objects/selection-group.class.js +1 -1
- package/dist/collection/classes/objects/shape.class.js +15 -21
- package/dist/collection/classes/objects/text.class.js +24 -30
- package/dist/collection/components/core/kritzel-engine/kritzel-engine.js +21 -16
- package/dist/collection/constants/version.js +1 -1
- package/dist/components/index.js +1 -1
- package/dist/components/kritzel-awareness-cursors.js +1 -1
- package/dist/components/kritzel-controls.js +1 -1
- package/dist/components/kritzel-editor.js +1 -1
- package/dist/components/kritzel-engine.js +1 -1
- package/dist/components/kritzel-settings.js +1 -1
- package/dist/components/kritzel-tool-config.js +1 -1
- package/dist/components/{p-xYCbKFih.js → p-B4h_tGG1.js} +1 -1
- package/dist/components/{p-BcwZ36sO.js → p-BPQOTise.js} +1 -1
- package/dist/components/{p-B-Gej_Ak.js → p-C35iuSnC.js} +1 -1
- package/dist/components/{p-BzQmBVwr.js → p-CgtykATT.js} +2 -2
- package/dist/components/{p-C_fSm7T4.js → p-DK_d3fKa.js} +1 -1
- package/dist/components/p-DQK_4lkI.js +1 -0
- package/dist/components/{p-CvyE2Wg-.js → p-DsfD4pGR.js} +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/kritzel-active-users_42.entry.js +30 -37
- package/dist/esm/{workspace.migrations-OzSSw5kt.js → workspace.migrations-Be65cOkQ.js} +46 -58
- package/dist/stencil/index.esm.js +1 -1
- package/dist/stencil/p-Be65cOkQ.js +1 -0
- package/dist/stencil/p-f318b7d5.entry.js +9 -0
- package/dist/stencil/stencil.esm.js +1 -1
- package/dist/types/classes/core/store.class.d.ts +0 -8
- package/dist/types/classes/objects/shape.class.d.ts +0 -1
- package/dist/types/classes/objects/text.class.d.ts +0 -1
- package/dist/types/components/core/kritzel-engine/kritzel-engine.d.ts +1 -0
- package/dist/types/constants/version.d.ts +1 -1
- package/package.json +1 -1
- package/dist/components/p-C8WnYSHi.js +0 -1
- package/dist/stencil/p-OzSSw5kt.js +0 -1
- package/dist/stencil/p-f7be06a8.entry.js +0 -9
|
@@ -1 +1 @@
|
|
|
1
|
-
import{p as e,H as t,c as s,h as i,d as o,t as n}from"./p-BWj1eE2b.js";import{a,C as l}from"./p-CW-VyJgK.js";import{d as r}from"./p-BjPmEs5A.js";import{d as c}from"./p-Gm5hSQ-e.js";import{d as h}from"./p-BaaFG0p-.js";import{d}from"./p-DUQmBcTy.js";import{d as g}from"./p-CfEGaTaV.js";const p="kritzel-settings",u=-1/0,m=1/0,f=-1/0,b=1/0,k={showViewportInfo:!1,showObjectInfo:!1,showSyncProviderInfo:!0,showMigrationInfo:!0},v=[{id:"general",label:"General",icon:"settings"},{id:"viewport",label:"Viewport",icon:"viewport"},{id:"shortcuts",label:"Keyboard Shortcuts",icon:"command"},{id:"developer",label:"Developer Options",icon:"braces"},{id:"about",label:"About",icon:"info"}],y=e(class extends t{constructor(e){super(),!1!==e&&this.__registerHost(),this.__attachShadow(),this.settingsChange=s(this,"settingsChange")}get host(){return this}shortcuts=[];editorId;isDialogOpen=!1;selectedCategoryId=v[0].id;scaleMin=1e-4;scaleMax=1e3;lockDrawingScale=!0;currentTheme="light";viewportBoundaryLeft=u;viewportBoundaryRight=m;viewportBoundaryTop=f;viewportBoundaryBottom=b;debugInfo={...k};settingsChange;componentWillLoad(){this.loadSettings()}get storageKey(){return this.editorId?`${p}-${this.editorId}`:p}loadSettings(){const e=localStorage.getItem(this.storageKey);if(e)try{const t=JSON.parse(e);"number"==typeof t.scaleMin&&(this.scaleMin=t.scaleMin),"number"==typeof t.scaleMax&&(this.scaleMax=t.scaleMax),"boolean"==typeof t.lockDrawingScale&&(this.lockDrawingScale=t.lockDrawingScale),"light"!==t.theme&&"dark"!==t.theme||(this.currentTheme=t.theme),"number"==typeof t.viewportBoundaryLeft&&(this.viewportBoundaryLeft=t.viewportBoundaryLeft),"number"==typeof t.viewportBoundaryRight&&(this.viewportBoundaryRight=t.viewportBoundaryRight),"number"==typeof t.viewportBoundaryTop&&(this.viewportBoundaryTop=t.viewportBoundaryTop),"number"==typeof t.viewportBoundaryBottom&&(this.viewportBoundaryBottom=t.viewportBoundaryBottom),t.debugInfo&&(this.debugInfo={...k,...t.debugInfo})}catch{}}saveSettings(){const e={scaleMin:this.scaleMin,scaleMax:this.scaleMax,lockDrawingScale:this.lockDrawingScale,theme:this.currentTheme,viewportBoundaryLeft:this.viewportBoundaryLeft,viewportBoundaryRight:this.viewportBoundaryRight,viewportBoundaryTop:this.viewportBoundaryTop,viewportBoundaryBottom:this.viewportBoundaryBottom,debugInfo:this.debugInfo};localStorage.setItem(this.storageKey,JSON.stringify(e)),this.settingsChange.emit(e)}handleScaleMinChange=e=>{this.scaleMin=e.detail,this.saveSettings()};handleScaleMaxChange=e=>{this.scaleMax=e.detail,this.saveSettings()};handleLockDrawingScaleChange=e=>{this.lockDrawingScale=e.detail,this.saveSettings()};handleThemeChange=e=>{this.currentTheme=e.detail?"dark":"light",this.saveSettings()};handleViewportBoundaryLeftChange=e=>{this.viewportBoundaryLeft=e.detail??u,this.saveSettings()};handleViewportBoundaryRightChange=e=>{this.viewportBoundaryRight=e.detail??m,this.saveSettings()};handleViewportBoundaryTopChange=e=>{this.viewportBoundaryTop=e.detail??f,this.saveSettings()};handleViewportBoundaryBottomChange=e=>{this.viewportBoundaryBottom=e.detail??b,this.saveSettings()};handleDebugInfoChange=e=>t=>{this.debugInfo={...this.debugInfo,[e]:t.detail},this.saveSettings()};async open(){this.isDialogOpen=!0}closeDialog=()=>{this.isDialogOpen=!1};handleCategorySelect=e=>{this.selectedCategoryId=e.detail.item.id};formatKeyCombo(e){const t=[];return e.ctrl&&t.push("Ctrl"),e.shift&&t.push("Shift"),t.push(this.formatKey(e.key)),t.join("+")}formatKey(e){return{Escape:"Esc",Delete:"Del"," ":"Space"}[e]??e.toUpperCase()}groupShortcutsByCategory(){const e=new Map;for(const t of this.shortcuts){const s=e.get(t.category)||[];s.push(t),e.set(t.category,s)}return e}renderCategoryContent(){switch(this.selectedCategoryId){case"general":return i("div",{class:"settings-content"},i("h3",null,"General Settings"),i("div",{class:"settings-group"},i("div",{class:"settings-item"},i("label",{class:"settings-label"},"Dark Mode"),i("p",{class:"settings-description"},"Toggle between light and dark color themes for the editor interface."),i("kritzel-slide-toggle",{checked:"dark"===this.currentTheme,label:"Dark Mode",onCheckedChange:this.handleThemeChange})),i("div",{class:"settings-item"},i("label",{class:"settings-label"},"Lock Drawing Scale"),i("p",{class:"settings-description"},"When enabled, drawn objects maintain a fixed visual size regardless of the current zoom level."),i("kritzel-slide-toggle",{checked:this.lockDrawingScale,label:"Lock Drawing Scale",onCheckedChange:this.handleLockDrawingScaleChange}))));case"viewport":return i("div",{class:"settings-content"},i("h3",null,"Viewport Settings"),i("div",{class:"settings-group"},i("div",{class:"settings-item"},i("label",{class:"settings-label"},"Minimum Zoom Level"),i("p",{class:"settings-description"},"Sets the minimum zoom level. Lower values allow zooming out further to see more of the canvas."),i("kritzel-numeric-input",{value:this.scaleMin,min:1e-4,max:1,step:1e-4,onValueChange:this.handleScaleMinChange})),i("div",{class:"settings-item"},i("label",{class:"settings-label"},"Maximum Zoom Level"),i("p",{class:"settings-description"},"Sets the maximum zoom level. Higher values allow zooming in closer for detailed work."),i("kritzel-numeric-input",{value:this.scaleMax,min:1,max:1e3,step:1,onValueChange:this.handleScaleMaxChange})),i("div",{class:"settings-item"},i("label",{class:"settings-label"},"Viewport Boundary Left"),i("p",{class:"settings-description"},"Left boundary in world coordinates. Set to limit how far left the viewport can pan."),i("kritzel-numeric-input",{value:this.viewportBoundaryLeft,step:100,placeholder:"Infinite",onValueChange:this.handleViewportBoundaryLeftChange})),i("div",{class:"settings-item"},i("label",{class:"settings-label"},"Viewport Boundary Right"),i("p",{class:"settings-description"},"Right boundary in world coordinates. Set to limit how far right the viewport can pan."),i("kritzel-numeric-input",{value:this.viewportBoundaryRight,step:100,placeholder:"Infinite",onValueChange:this.handleViewportBoundaryRightChange})),i("div",{class:"settings-item"},i("label",{class:"settings-label"},"Viewport Boundary Top"),i("p",{class:"settings-description"},"Top boundary in world coordinates. Set to limit how far up the viewport can pan."),i("kritzel-numeric-input",{value:this.viewportBoundaryTop,step:100,placeholder:"Infinite",onValueChange:this.handleViewportBoundaryTopChange})),i("div",{class:"settings-item"},i("label",{class:"settings-label"},"Viewport Boundary Bottom"),i("p",{class:"settings-description"},"Bottom boundary in world coordinates. Set to limit how far down the viewport can pan."),i("kritzel-numeric-input",{value:this.viewportBoundaryBottom,step:100,placeholder:"Infinite",onValueChange:this.handleViewportBoundaryBottomChange}))));case"shortcuts":return i("div",{class:"settings-content"},i("h3",null,"Keyboard Shortcuts"),i("div",{class:"shortcuts-list"},Array.from(this.groupShortcutsByCategory()).map((([e,t])=>i("div",{class:"shortcuts-category",key:e},i("h4",{class:"shortcuts-category-title"},e),i("div",{class:"shortcuts-group"},t.map((e=>i("div",{class:"shortcut-item",key:e.key+e.label},i("span",{class:"shortcut-label"},e.label),i("kbd",{class:"shortcut-key"},this.formatKeyCombo(e)))))))))));case"developer":return i("div",{class:"settings-content"},i("h3",null,"Developer Options"),i("div",{class:"settings-group"},i("div",{class:"settings-item"},i("label",{class:"settings-label"},"Show Viewport Info"),i("p",{class:"settings-description"},"Display viewport debug information such as position, zoom level, and boundaries."),i("kritzel-slide-toggle",{checked:this.debugInfo.showViewportInfo,label:"Show Viewport Info",onCheckedChange:this.handleDebugInfoChange("showViewportInfo")})),i("div",{class:"settings-item"},i("label",{class:"settings-label"},"Show Object Info"),i("p",{class:"settings-description"},"Display debug information about objects on the canvas."),i("kritzel-slide-toggle",{checked:this.debugInfo.showObjectInfo,label:"Show Object Info",onCheckedChange:this.handleDebugInfoChange("showObjectInfo")})),i("div",{class:"settings-item"},i("label",{class:"settings-label"},"Show Sync Provider Info"),i("p",{class:"settings-description"},"Display debug information about the sync provider connection status."),i("kritzel-slide-toggle",{checked:this.debugInfo.showSyncProviderInfo,label:"Show Sync Provider Info",onCheckedChange:this.handleDebugInfoChange("showSyncProviderInfo")})),i("div",{class:"settings-item"},i("label",{class:"settings-label"},"Show Migration Info"),i("p",{class:"settings-description"},"Display debug information about data migrations."),i("kritzel-slide-toggle",{checked:this.debugInfo.showMigrationInfo,label:"Show Migration Info",onCheckedChange:this.handleDebugInfoChange("showMigrationInfo")}))));case"about":return i("div",{class:"settings-content"},i("h3",null,"About"),i("p",null,"Kritzel - A drawing application"),i("p",{class:"version-info"},"Version ","0.1.80"),i("p",{class:"version-info"},"App-State Schema v",l),i("p",{class:"version-info"},"Workspace Schema v",a));default:return null}}render(){return i(o,{key:"0d4cd5ad565a1ff1140f308765ff887ba68ba6c8"},i("kritzel-dialog",{key:"170a15a41d18f56981a99aae266026625d7fe644",isOpen:this.isDialogOpen,dialogTitle:"Settings",size:"large",onDialogClose:this.closeDialog},i("kritzel-master-detail",{key:"6569f351fdef57dd189af63f7d6c4d98ce815c1b",items:v,selectedItemId:this.selectedCategoryId,onItemSelect:this.handleCategorySelect},this.renderCategoryContent())))}static get style(){return":host{display:contents}kritzel-dialog{--kritzel-dialog-body-padding:0;--kritzel-dialog-width-large:800px;--kritzel-dialog-height-large:500px}.footer-button{padding:8px 16px;border-radius:6px;cursor:pointer;font-size:14px}.cancel-button{border:1px solid #ebebeb;background:#fff;color:inherit}.cancel-button:hover{background:#f5f5f5}.settings-content{padding:0}.settings-content h3{margin:0 0 16px 0;font-size:18px;font-weight:600;color:var(--kritzel-settings-content-heading-color, #333333)}.settings-content p{margin:0;font-size:14px;color:var(--kritzel-settings-content-text-color, #666666);line-height:1.5}.settings-group{display:flex;flex-direction:column;gap:24px}.settings-item{display:flex;flex-direction:column;gap:8px}.settings-row{display:flex;align-items:center;justify-content:space-between;gap:16px}.settings-label{font-size:14px;font-weight:600;color:var(--kritzel-settings-label-color, #333333);margin:0 0 4px 0}.settings-description{font-size:12px;color:var(--kritzel-settings-description-color, #888888);margin:0;line-height:1.4}.shortcuts-list{display:flex;flex-direction:column;gap:24px}.shortcuts-category{display:flex;flex-direction:column;gap:8px}.shortcuts-category-title{font-size:14px;font-weight:600;color:var(--kritzel-settings-label-color, #333333);margin:0 0 4px 0}.shortcuts-group{display:flex;flex-direction:column;gap:4px}.shortcut-item{display:flex;justify-content:space-between;align-items:center;padding:6px 8px;border-radius:4px;background:var(--kritzel-settings-shortcut-item-bg, rgba(0, 0, 0, 0.02))}.shortcut-label{font-size:14px;color:var(--kritzel-settings-content-text-color, #666666)}.shortcut-key{font-family:monospace;font-size:12px;padding:2px 8px;border-radius:4px;background:var(--kritzel-settings-shortcut-key-bg, #f0f0f0);color:var(--kritzel-settings-shortcut-key-color, #333333);border:1px solid var(--kritzel-settings-shortcut-key-border, #ddd)}"}},[513,"kritzel-settings",{shortcuts:[16],editorId:[1,"editor-id"],isDialogOpen:[32],selectedCategoryId:[32],scaleMin:[32],scaleMax:[32],lockDrawingScale:[32],currentTheme:[32],viewportBoundaryLeft:[32],viewportBoundaryRight:[32],viewportBoundaryTop:[32],viewportBoundaryBottom:[32],debugInfo:[32],open:[64]}]);function w(){"undefined"!=typeof customElements&&["kritzel-settings","kritzel-dialog","kritzel-icon","kritzel-master-detail","kritzel-numeric-input","kritzel-slide-toggle"].forEach((e=>{switch(e){case"kritzel-settings":customElements.get(n(e))||customElements.define(n(e),y);break;case"kritzel-dialog":customElements.get(n(e))||r();break;case"kritzel-icon":customElements.get(n(e))||c();break;case"kritzel-master-detail":customElements.get(n(e))||h();break;case"kritzel-numeric-input":customElements.get(n(e))||d();break;case"kritzel-slide-toggle":customElements.get(n(e))||g()}}))}export{y as K,w as d}
|
|
1
|
+
import{p as e,H as t,c as s,h as i,d as o,t as n}from"./p-BWj1eE2b.js";import{a,C as l}from"./p-CW-VyJgK.js";import{d as r}from"./p-BjPmEs5A.js";import{d as c}from"./p-Gm5hSQ-e.js";import{d as h}from"./p-BaaFG0p-.js";import{d}from"./p-DUQmBcTy.js";import{d as g}from"./p-CfEGaTaV.js";const p="kritzel-settings",u=-1/0,m=1/0,f=-1/0,b=1/0,k={showViewportInfo:!1,showObjectInfo:!1,showSyncProviderInfo:!0,showMigrationInfo:!0},v=[{id:"general",label:"General",icon:"settings"},{id:"viewport",label:"Viewport",icon:"viewport"},{id:"shortcuts",label:"Keyboard Shortcuts",icon:"command"},{id:"developer",label:"Developer Options",icon:"braces"},{id:"about",label:"About",icon:"info"}],y=e(class extends t{constructor(e){super(),!1!==e&&this.__registerHost(),this.__attachShadow(),this.settingsChange=s(this,"settingsChange")}get host(){return this}shortcuts=[];editorId;isDialogOpen=!1;selectedCategoryId=v[0].id;scaleMin=1e-4;scaleMax=1e3;lockDrawingScale=!0;currentTheme="light";viewportBoundaryLeft=u;viewportBoundaryRight=m;viewportBoundaryTop=f;viewportBoundaryBottom=b;debugInfo={...k};settingsChange;componentWillLoad(){this.loadSettings()}get storageKey(){return this.editorId?`${p}-${this.editorId}`:p}loadSettings(){const e=localStorage.getItem(this.storageKey);if(e)try{const t=JSON.parse(e);"number"==typeof t.scaleMin&&(this.scaleMin=t.scaleMin),"number"==typeof t.scaleMax&&(this.scaleMax=t.scaleMax),"boolean"==typeof t.lockDrawingScale&&(this.lockDrawingScale=t.lockDrawingScale),"light"!==t.theme&&"dark"!==t.theme||(this.currentTheme=t.theme),"number"==typeof t.viewportBoundaryLeft&&(this.viewportBoundaryLeft=t.viewportBoundaryLeft),"number"==typeof t.viewportBoundaryRight&&(this.viewportBoundaryRight=t.viewportBoundaryRight),"number"==typeof t.viewportBoundaryTop&&(this.viewportBoundaryTop=t.viewportBoundaryTop),"number"==typeof t.viewportBoundaryBottom&&(this.viewportBoundaryBottom=t.viewportBoundaryBottom),t.debugInfo&&(this.debugInfo={...k,...t.debugInfo})}catch{}}saveSettings(){const e={scaleMin:this.scaleMin,scaleMax:this.scaleMax,lockDrawingScale:this.lockDrawingScale,theme:this.currentTheme,viewportBoundaryLeft:this.viewportBoundaryLeft,viewportBoundaryRight:this.viewportBoundaryRight,viewportBoundaryTop:this.viewportBoundaryTop,viewportBoundaryBottom:this.viewportBoundaryBottom,debugInfo:this.debugInfo};localStorage.setItem(this.storageKey,JSON.stringify(e)),this.settingsChange.emit(e)}handleScaleMinChange=e=>{this.scaleMin=e.detail,this.saveSettings()};handleScaleMaxChange=e=>{this.scaleMax=e.detail,this.saveSettings()};handleLockDrawingScaleChange=e=>{this.lockDrawingScale=e.detail,this.saveSettings()};handleThemeChange=e=>{this.currentTheme=e.detail?"dark":"light",this.saveSettings()};handleViewportBoundaryLeftChange=e=>{this.viewportBoundaryLeft=e.detail??u,this.saveSettings()};handleViewportBoundaryRightChange=e=>{this.viewportBoundaryRight=e.detail??m,this.saveSettings()};handleViewportBoundaryTopChange=e=>{this.viewportBoundaryTop=e.detail??f,this.saveSettings()};handleViewportBoundaryBottomChange=e=>{this.viewportBoundaryBottom=e.detail??b,this.saveSettings()};handleDebugInfoChange=e=>t=>{this.debugInfo={...this.debugInfo,[e]:t.detail},this.saveSettings()};async open(){this.isDialogOpen=!0}closeDialog=()=>{this.isDialogOpen=!1};handleCategorySelect=e=>{this.selectedCategoryId=e.detail.item.id};formatKeyCombo(e){const t=[];return e.ctrl&&t.push("Ctrl"),e.shift&&t.push("Shift"),t.push(this.formatKey(e.key)),t.join("+")}formatKey(e){return{Escape:"Esc",Delete:"Del"," ":"Space"}[e]??e.toUpperCase()}groupShortcutsByCategory(){const e=new Map;for(const t of this.shortcuts){const s=e.get(t.category)||[];s.push(t),e.set(t.category,s)}return e}renderCategoryContent(){switch(this.selectedCategoryId){case"general":return i("div",{class:"settings-content"},i("h3",null,"General Settings"),i("div",{class:"settings-group"},i("div",{class:"settings-item"},i("label",{class:"settings-label"},"Dark Mode"),i("p",{class:"settings-description"},"Toggle between light and dark color themes for the editor interface."),i("kritzel-slide-toggle",{checked:"dark"===this.currentTheme,label:"Dark Mode",onCheckedChange:this.handleThemeChange})),i("div",{class:"settings-item"},i("label",{class:"settings-label"},"Lock Drawing Scale"),i("p",{class:"settings-description"},"When enabled, drawn objects maintain a fixed visual size regardless of the current zoom level."),i("kritzel-slide-toggle",{checked:this.lockDrawingScale,label:"Lock Drawing Scale",onCheckedChange:this.handleLockDrawingScaleChange}))));case"viewport":return i("div",{class:"settings-content"},i("h3",null,"Viewport Settings"),i("div",{class:"settings-group"},i("div",{class:"settings-item"},i("label",{class:"settings-label"},"Minimum Zoom Level"),i("p",{class:"settings-description"},"Sets the minimum zoom level. Lower values allow zooming out further to see more of the canvas."),i("kritzel-numeric-input",{value:this.scaleMin,min:1e-4,max:1,step:1e-4,onValueChange:this.handleScaleMinChange})),i("div",{class:"settings-item"},i("label",{class:"settings-label"},"Maximum Zoom Level"),i("p",{class:"settings-description"},"Sets the maximum zoom level. Higher values allow zooming in closer for detailed work."),i("kritzel-numeric-input",{value:this.scaleMax,min:1,max:1e3,step:1,onValueChange:this.handleScaleMaxChange})),i("div",{class:"settings-item"},i("label",{class:"settings-label"},"Viewport Boundary Left"),i("p",{class:"settings-description"},"Left boundary in world coordinates. Set to limit how far left the viewport can pan."),i("kritzel-numeric-input",{value:this.viewportBoundaryLeft,step:100,placeholder:"Infinite",onValueChange:this.handleViewportBoundaryLeftChange})),i("div",{class:"settings-item"},i("label",{class:"settings-label"},"Viewport Boundary Right"),i("p",{class:"settings-description"},"Right boundary in world coordinates. Set to limit how far right the viewport can pan."),i("kritzel-numeric-input",{value:this.viewportBoundaryRight,step:100,placeholder:"Infinite",onValueChange:this.handleViewportBoundaryRightChange})),i("div",{class:"settings-item"},i("label",{class:"settings-label"},"Viewport Boundary Top"),i("p",{class:"settings-description"},"Top boundary in world coordinates. Set to limit how far up the viewport can pan."),i("kritzel-numeric-input",{value:this.viewportBoundaryTop,step:100,placeholder:"Infinite",onValueChange:this.handleViewportBoundaryTopChange})),i("div",{class:"settings-item"},i("label",{class:"settings-label"},"Viewport Boundary Bottom"),i("p",{class:"settings-description"},"Bottom boundary in world coordinates. Set to limit how far down the viewport can pan."),i("kritzel-numeric-input",{value:this.viewportBoundaryBottom,step:100,placeholder:"Infinite",onValueChange:this.handleViewportBoundaryBottomChange}))));case"shortcuts":return i("div",{class:"settings-content"},i("h3",null,"Keyboard Shortcuts"),i("div",{class:"shortcuts-list"},Array.from(this.groupShortcutsByCategory()).map((([e,t])=>i("div",{class:"shortcuts-category",key:e},i("h4",{class:"shortcuts-category-title"},e),i("div",{class:"shortcuts-group"},t.map((e=>i("div",{class:"shortcut-item",key:e.key+e.label},i("span",{class:"shortcut-label"},e.label),i("kbd",{class:"shortcut-key"},this.formatKeyCombo(e)))))))))));case"developer":return i("div",{class:"settings-content"},i("h3",null,"Developer Options"),i("div",{class:"settings-group"},i("div",{class:"settings-item"},i("label",{class:"settings-label"},"Show Viewport Info"),i("p",{class:"settings-description"},"Display viewport debug information such as position, zoom level, and boundaries."),i("kritzel-slide-toggle",{checked:this.debugInfo.showViewportInfo,label:"Show Viewport Info",onCheckedChange:this.handleDebugInfoChange("showViewportInfo")})),i("div",{class:"settings-item"},i("label",{class:"settings-label"},"Show Object Info"),i("p",{class:"settings-description"},"Display debug information about objects on the canvas."),i("kritzel-slide-toggle",{checked:this.debugInfo.showObjectInfo,label:"Show Object Info",onCheckedChange:this.handleDebugInfoChange("showObjectInfo")})),i("div",{class:"settings-item"},i("label",{class:"settings-label"},"Show Sync Provider Info"),i("p",{class:"settings-description"},"Display debug information about the sync provider connection status."),i("kritzel-slide-toggle",{checked:this.debugInfo.showSyncProviderInfo,label:"Show Sync Provider Info",onCheckedChange:this.handleDebugInfoChange("showSyncProviderInfo")})),i("div",{class:"settings-item"},i("label",{class:"settings-label"},"Show Migration Info"),i("p",{class:"settings-description"},"Display debug information about data migrations."),i("kritzel-slide-toggle",{checked:this.debugInfo.showMigrationInfo,label:"Show Migration Info",onCheckedChange:this.handleDebugInfoChange("showMigrationInfo")}))));case"about":return i("div",{class:"settings-content"},i("h3",null,"About"),i("p",null,"Kritzel - A drawing application"),i("p",{class:"version-info"},"Version ","0.1.82"),i("p",{class:"version-info"},"App-State Schema v",l),i("p",{class:"version-info"},"Workspace Schema v",a));default:return null}}render(){return i(o,{key:"0d4cd5ad565a1ff1140f308765ff887ba68ba6c8"},i("kritzel-dialog",{key:"170a15a41d18f56981a99aae266026625d7fe644",isOpen:this.isDialogOpen,dialogTitle:"Settings",size:"large",onDialogClose:this.closeDialog},i("kritzel-master-detail",{key:"6569f351fdef57dd189af63f7d6c4d98ce815c1b",items:v,selectedItemId:this.selectedCategoryId,onItemSelect:this.handleCategorySelect},this.renderCategoryContent())))}static get style(){return":host{display:contents}kritzel-dialog{--kritzel-dialog-body-padding:0;--kritzel-dialog-width-large:800px;--kritzel-dialog-height-large:500px}.footer-button{padding:8px 16px;border-radius:6px;cursor:pointer;font-size:14px}.cancel-button{border:1px solid #ebebeb;background:#fff;color:inherit}.cancel-button:hover{background:#f5f5f5}.settings-content{padding:0}.settings-content h3{margin:0 0 16px 0;font-size:18px;font-weight:600;color:var(--kritzel-settings-content-heading-color, #333333)}.settings-content p{margin:0;font-size:14px;color:var(--kritzel-settings-content-text-color, #666666);line-height:1.5}.settings-group{display:flex;flex-direction:column;gap:24px}.settings-item{display:flex;flex-direction:column;gap:8px}.settings-row{display:flex;align-items:center;justify-content:space-between;gap:16px}.settings-label{font-size:14px;font-weight:600;color:var(--kritzel-settings-label-color, #333333);margin:0 0 4px 0}.settings-description{font-size:12px;color:var(--kritzel-settings-description-color, #888888);margin:0;line-height:1.4}.shortcuts-list{display:flex;flex-direction:column;gap:24px}.shortcuts-category{display:flex;flex-direction:column;gap:8px}.shortcuts-category-title{font-size:14px;font-weight:600;color:var(--kritzel-settings-label-color, #333333);margin:0 0 4px 0}.shortcuts-group{display:flex;flex-direction:column;gap:4px}.shortcut-item{display:flex;justify-content:space-between;align-items:center;padding:6px 8px;border-radius:4px;background:var(--kritzel-settings-shortcut-item-bg, rgba(0, 0, 0, 0.02))}.shortcut-label{font-size:14px;color:var(--kritzel-settings-content-text-color, #666666)}.shortcut-key{font-family:monospace;font-size:12px;padding:2px 8px;border-radius:4px;background:var(--kritzel-settings-shortcut-key-bg, #f0f0f0);color:var(--kritzel-settings-shortcut-key-color, #333333);border:1px solid var(--kritzel-settings-shortcut-key-border, #ddd)}"}},[513,"kritzel-settings",{shortcuts:[16],editorId:[1,"editor-id"],isDialogOpen:[32],selectedCategoryId:[32],scaleMin:[32],scaleMax:[32],lockDrawingScale:[32],currentTheme:[32],viewportBoundaryLeft:[32],viewportBoundaryRight:[32],viewportBoundaryTop:[32],viewportBoundaryBottom:[32],debugInfo:[32],open:[64]}]);function w(){"undefined"!=typeof customElements&&["kritzel-settings","kritzel-dialog","kritzel-icon","kritzel-master-detail","kritzel-numeric-input","kritzel-slide-toggle"].forEach((e=>{switch(e){case"kritzel-settings":customElements.get(n(e))||customElements.define(n(e),y);break;case"kritzel-dialog":customElements.get(n(e))||r();break;case"kritzel-icon":customElements.get(n(e))||c();break;case"kritzel-master-detail":customElements.get(n(e))||h();break;case"kritzel-numeric-input":customElements.get(n(e))||d();break;case"kritzel-slide-toggle":customElements.get(n(e))||g()}}))}export{y as K,w as d}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{O as t}from"./p-BAN5dnHX.js";import{a as i}from"./p-CjazGGq3.js";class s{static doPolygonsIntersect(t,i){const s=[t.bottomLeft,t.bottomRight,t.topRight,t.topLeft],h=[i.bottomLeft,i.bottomRight,i.topRight,i.topLeft];for(const t of s)if(this.isPointInPolygon(t,h))return!0;for(const t of h)if(this.isPointInPolygon(t,s))return!0;for(let t=0;t<s.length;t++){const i=s[t],n=s[(t+1)%s.length];for(let t=0;t<h.length;t++)if(this.intersectLines(i,n,h[t],h[(t+1)%h.length]))return!0}return!1}static isPointInPolygon(t,i){let s=!1;for(let h=0,n=i.length-1;h<i.length;n=h++){const e=i[h].x,r=i[h].y,o=i[n].y;r>t.y!=o>t.y&&t.x<(i[n].x-e)*(t.y-r)/(o-r)+e&&(s=!s)}return s}static intersectLines(t,i,s,h){const n=(i.x-t.x)*(h.y-s.y)-(i.y-t.y)*(h.x-s.x);if(0===n)return!1;const e=((s.x-t.x)*(h.y-s.y)-(s.y-t.y)*(h.x-s.x))/n,r=-((t.x-s.x)*(i.y-t.y)-(t.y-s.y)*(i.x-t.x))/n;return e>=0&&e<=1&&r>=0&&r<=1}static getLineIntersectionPoint(t,i,s,h){const n=(i.x-t.x)*(h.y-s.y)-(i.y-t.y)*(h.x-s.x);if(0===n)return null;const e=((s.x-t.x)*(h.y-s.y)-(s.y-t.y)*(h.x-s.x))/n,r=-((t.x-s.x)*(i.y-t.y)-(t.y-s.y)*(i.x-t.x))/n;return e>=0&&e<=1&&r>=0&&r<=1?{x:t.x+e*(i.x-t.x),y:t.y+e*(i.y-t.y)}:null}static getLinePolygonIntersection(t,i,s){const h=[s.topLeft,s.topRight,s.bottomRight,s.bottomLeft];let n=null,e=1/0;for(let s=0;s<h.length;s++){const r=this.getLineIntersectionPoint(t,i,h[s],h[(s+1)%h.length]);if(r){const i=Math.sqrt(Math.pow(r.x-t.x,2)+Math.pow(r.y-t.y,2));i<e&&(e=i,n=r)}}return n}static getEllipsePolygonApproximation(t,i,s,h,n=32,e=0){const r=[],o=Math.cos(e),a=Math.sin(e);for(let e=0;e<n;e++){const u=2*Math.PI*e/n,c=s*Math.cos(u),l=h*Math.sin(u);r.push({x:t+c*o-l*a,y:i+c*a+l*o})}return r}static getLinePointsArrayIntersection(t,i,s){let h=null,n=1/0;for(let e=0;e<s.length;e++){const r=this.getLineIntersectionPoint(t,i,s[e],s[(e+1)%s.length]);if(r){const i=Math.sqrt(Math.pow(r.x-t.x,2)+Math.pow(r.y-t.y,2));i<n&&(n=i,h=r)}}return h}static isPointInPolygonPoints(t,i){return this.isPointInPolygon(t,i)}}class h{__class__="KritzelBaseObject";_core;_elementRef;id;workspaceId;x;y;translateX;translateY;height;width;backgroundColor;borderColor;borderWidth=0;opacity=1;padding=0;scale;resizing=!1;rotation=0;markedForRemoval=!1;zIndex=0;userId;isVisible=!0;isSelected=!1;isHovered=!1;isMounted=!1;isEditable=!1;isInteractive=!1;isDebugInfoVisible=!1;get totalWidth(){return this.width+2*this.padding}get totalHeight(){return this.height+2*this.padding}set elementRef(t){this._elementRef=t}get elementRef(){return this._elementRef}get boundingBox(){return{x:this.translateX,y:this.translateY,z:this.scale,width:this.totalWidth/this.scale,height:this.totalHeight/this.scale}}get rotatedBoundingBox(){const t=this.rotatedPolygon,i=[t.topLeft.x,t.topRight.x,t.bottomRight.x,t.bottomLeft.x],s=[t.topLeft.y,t.topRight.y,t.bottomRight.y,t.bottomLeft.y],h=Math.min(...i),n=Math.max(...i),e=Math.min(...s),r=Math.max(...s);return{x:h,y:e,z:this.scale,width:n-h,height:r-e}}get rotatedPolygon(){const t=this.translateX+this.totalWidth/2/this.scale,i=this.translateY+this.totalHeight/2/this.scale,s=this.rotation,h=Math.cos(s),n=Math.sin(s),e=this.translateX,r=this.translateY,o=e+this.totalWidth/this.scale,a=r+this.totalHeight/this.scale,u=(s,e)=>({x:h*(s-t)-n*(e-i)+t,y:n*(s-t)+h*(e-i)+i});return{topLeft:u(e,r),topRight:u(o,r),bottomRight:u(o,a),bottomLeft:u(e,a)}}get minXRotated(){return Math.min(this.rotatedPolygon.topLeft.x,this.rotatedPolygon.topRight.x,this.rotatedPolygon.bottomRight.x,this.rotatedPolygon.bottomLeft.x)}get minYRotated(){return Math.min(this.rotatedPolygon.topLeft.y,this.rotatedPolygon.topRight.y,this.rotatedPolygon.bottomRight.y,this.rotatedPolygon.bottomLeft.y)}get maxXRotated(){return Math.max(this.rotatedPolygon.topLeft.x,this.rotatedPolygon.topRight.x,this.rotatedPolygon.bottomRight.x,this.rotatedPolygon.bottomLeft.x)}get maxYRotated(){return Math.max(this.rotatedPolygon.topLeft.y,this.rotatedPolygon.topRight.y,this.rotatedPolygon.bottomRight.y,this.rotatedPolygon.bottomLeft.y)}get transformationMatrix(){const t=1/this.scale;return`matrix(${t}, 0, 0, ${t}, ${this.translateX}, ${this.translateY})`}get rotationDegrees(){return this.rotation*(180/Math.PI)}get centerX(){return this.translateX+this.totalWidth/2/this.scale}get centerY(){return this.translateY+this.totalHeight/2/this.scale}constructor(){this.id=this.generateId()}static create(t){const i=new h;return i._core=t,i.zIndex=t.store.currentZIndex,i.workspaceId=t.store.state.activeWorkspace.id,i.userId=t.user?.id,i}mount(t){this.isMounted||(this.elementRef=t,this.isMounted=!0)}generateId(){return t.generateUUID()}isInViewport(){const t=this._core.store.state.scale;if(this.boundingBox.width*t*(this.boundingBox.height*t)<.5)return!1;const i=-this._core.store.state.translateX/this._core.store.state.scale,s=-this._core.store.state.translateY/this._core.store.state.scale;return this.rotatedBoundingBox.x<i+this._core.store.state.viewportWidth/this._core.store.state.scale&&this.rotatedBoundingBox.x+this.rotatedBoundingBox.width>i&&this.rotatedBoundingBox.y<s+this._core.store.state.viewportHeight/this._core.store.state.scale&&this.rotatedBoundingBox.y+this.rotatedBoundingBox.height>s}centerInViewport(){const{viewportWidth:t,viewportHeight:i,translateX:s,translateY:h,scale:n}=this._core.store.state,{x:e,y:r,width:o,height:a}=this.rotatedBoundingBox;this.updatePosition(this.translateX+((t/2-s)/n-(e+o/2)),this.translateY+((i/2-h)/n-(r+a/2)))}update(){this._core.store.objects.update(this)}move(t,i,s,h){const n=(i-h)/this._core.store.state.scale;this.translateX+=(t-s)/this._core.store.state.scale,this.translateY+=n,this._core.store.objects.update(this)}resize(t,i,s,h){s<=1||h<=1||(this.width=s,this.height=h,this.translateX=t,this.translateY=i,this._core.store.objects.update(this),this._core.anchorManager.updateAnchorsForObject(this.id))}rotate(t){this.rotation=t,this._core.store.objects.update(this)}clone(){const t=Object.create(Object.getPrototypeOf(this));return Object.assign(t,this),t.id=this.id,t}copy(){const t=Object.create(Object.getPrototypeOf(this));return Object.assign(t,this),t.id=this.generateId(),t.isMounted=!1,t}serialize(){const{_core:t,_elementRef:i,element:s,totalWidth:h,totalHeight:n,...e}=this,r=structuredClone(e);return s&&"object"==typeof s&&"nodeType"in s&&1===s.nodeType&&(r.element=s.cloneNode(!0)),r}deserialize(t){return Object.assign(this,t),this}isClass(t){return this.__class__===t}edit(t){}onAfterUpdate(t){}hitTest(t,i){return!0}hitTestPolygon(t){return s.doPolygonsIntersect(this.rotatedPolygon,t)}updatePosition(t,i){this.translateX=t,this.translateY=i,this._core.store.objects.update(this)}}var n,e={},r=(n||(n=1,function(t){Object.defineProperties(t,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const{PI:i}=Math,s=i+1e-4,h=[1,1];function n(t,i,s,h=t=>t){return t*h(.5-i*(.5-s))}const{min:e}=Math;function r(t,i,s){let h=e(1,i/s);return e(1,t+(e(1,1-h)-t)*(.275*h))}function o(t,i){return[t[0]+i[0],t[1]+i[1]]}function a(t,i,s){return t[0]=i[0]+s[0],t[1]=i[1]+s[1],t}function u(t,i){return[t[0]-i[0],t[1]-i[1]]}function c(t,i,s){return t[0]=i[0]-s[0],t[1]=i[1]-s[1],t}function l(t,i){return[t[0]*i,t[1]*i]}function f(t,i,s){return t[0]=i[0]*s,t[1]=i[1]*s,t}function d(t){return[t[1],-t[0]]}function M(t,i){let s=i[0];return t[0]=i[1],t[1]=-s,t}function g(t,i){return t[0]*i[0]+t[1]*i[1]}function m(t,i){return t[0]===i[0]&&t[1]===i[1]}function p(t,i){let s=t[0]-i[0],h=t[1]-i[1];return s*s+h*h}function x(t){return function(t,i){return[t[0]/i,t[1]/i]}(t,function(t){return Math.hypot(t[0],t[1])}(t))}function y(t,i){return Math.hypot(t[1]-i[1],t[0]-i[0])}function v(t,i,s){let h=Math.sin(s),n=Math.cos(s),e=t[0]-i[0],r=t[1]-i[1];return[e*n-r*h+i[0],e*h+r*n+i[1]]}function P(t,i,s,h){let n=Math.sin(h),e=Math.cos(h),r=i[0]-s[0],o=i[1]-s[1],a=r*n+o*e;return t[0]=r*e-o*n+s[0],t[1]=a+s[1],t}function $(t,i,s){return o(t,l(u(i,t),s))}function b(t,i,s,h){let n=s[1]-i[1];return t[0]=i[0]+(s[0]-i[0])*h,t[1]=i[1]+n*h,t}function w(t,i,s){return o(t,l(i,s))}const L=[0,0],I=[0,0],X=[0,0];function _(t,i){let h=w(t,x(d(u(t,o(t,[1,1])))),-i),n=[],e=1/13;for(let i=e;i<=1;i+=e)n.push(v(h,t,2*s*i));return n}function z(t,i,h){let n=[],e=1/h;for(let h=e;h<=1;h+=e)n.push(v(i,t,s*h));return n}function Y(t,i,s){let h=u(i,s),n=l(h,.5),e=l(h,.51);return[u(t,n),u(t,e),o(t,e),o(t,n)]}function j(t,i,h,n){let e=[],r=w(t,i,h),o=1/n;for(let i=o;i<1;i+=o)e.push(v(r,t,3*s*i));return e}function k(t,i,s){return[o(t,l(i,s)),o(t,l(i,.99*s)),u(t,l(i,.99*s)),u(t,l(i,s))]}function A(t,i,s){return!1===t||void 0===t?0:!0===t?Math.max(i,s):t}function B(t,i={}){let{size:h=16,smoothing:e=.5,thinning:l=.5,simulatePressure:m=!0,easing:x=t=>t,start:y={},end:v={},last:$=!1}=i,{cap:w=!0,easing:B=t=>t*(2-t)}=y,{cap:R=!0,easing:C=t=>--t*t*t+1}=v;if(0===t.length||h<=0)return[];let S,T=t[t.length-1].runningLength,O=A(y.taper,h,T),D=A(v.taper,h,T),V=(h*e)**2,W=[],H=[],E=function(t,i,s){return t.slice(0,10).reduce(((t,h)=>{let n=h.pressure;return i&&(n=r(t,h.distance,s)),(t+n)/2}),t[0].pressure)}(t,m,h),F=n(h,l,t[t.length-1].pressure,x),K=t[0].vector,G=t[0].point,Q=G,U=G,q=Q,N=!1;for(let i=0;i<t.length;i++){let{pressure:e}=t[i],{point:d,vector:y,distance:v,runningLength:$}=t[i],w=i===t.length-1;if(!w&&T-$<3)continue;l?(m&&(e=r(E,v,h)),F=n(h,l,e,x)):F=h/2,void 0===S&&(S=F);let _=$<O?B($/O):1,z=T-$<D?C((T-$)/D):1;F=Math.max(.01,F*Math.min(_,z));let Y=(w?t[i]:t[i+1]).vector,j=w?1:g(y,Y),k=null!==j&&j<0;if(g(y,K)<0&&!N||k){M(L,K),f(L,L,F);for(let t=0;t<=1;t+=.07692307692307693)c(I,d,L),P(I,I,d,s*t),U=[I[0],I[1]],W.push(U),a(X,d,L),P(X,X,d,s*-t),q=[X[0],X[1]],H.push(q);G=U,Q=q,k&&(N=!0)}else N=!1,w?(M(L,y),f(L,L,F),W.push(u(d,L)),H.push(o(d,L))):(b(L,Y,y,j),M(L,L),f(L,L,F),c(I,d,L),U=[I[0],I[1]],(i<=1||p(G,U)>V)&&(W.push(U),G=U),a(X,d,L),q=[X[0],X[1]],(i<=1||p(Q,q)>V)&&(H.push(q),Q=q),E=e,K=y)}let Z=[t[0].point[0],t[0].point[1]],J=t.length>1?[t[t.length-1].point[0],t[t.length-1].point[1]]:o(t[0].point,[1,1]),tt=[],it=[];if(1===t.length){if(!O&&!D||$)return _(Z,S||F)}else{O||D&&1===t.length||(w?tt.push(...z(Z,H[0],13)):tt.push(...Y(Z,W[0],H[0])));let i=d(function(t){return[-t[0],-t[1]]}(t[t.length-1].vector));D||O&&1===t.length?it.push(J):R?it.push(...j(J,i,F,29)):it.push(...k(J,i,F))}return W.concat(it,H.reverse(),tt)}const R=[0,0];function C(t){return null!=t&&t>=0}function S(t,i={}){let{streamline:s=.5,size:n=16,last:e=!1}=i;if(0===t.length)return[];let r=.15+.85*(1-s),a=Array.isArray(t[0])?t:t.map((({x:t,y:i,pressure:s=.5})=>[t,i,s]));if(2===a.length){let t=a[1];a=a.slice(0,-1);for(let i=1;i<5;i++)a.push($(a[0],t,i/4))}1===a.length&&(a=[...a,[...o(a[0],h),...a[0].slice(2)]]);let u=[{point:[a[0][0],a[0][1]],pressure:C(a[0][2])?a[0][2]:.25,vector:[...h],distance:0,runningLength:0}],l=!1,f=0,d=u[0],M=a.length-1;for(let t=1;t<a.length;t++){let i=e&&t===M?[a[t][0],a[t][1]]:$(d.point,a[t],r);if(m(d.point,i))continue;let s=y(i,d.point);if(f+=s,t<M&&!l){if(f<n)continue;l=!0}c(R,d.point,i),d={point:i,pressure:C(a[t][2])?a[t][2]:.5,vector:x(R),distance:s,runningLength:f},u.push(d)}return u[0].vector=u[1]?.vector||[0,0],u}function T(t,i={}){return B(S(t,i),i)}t.default=T,t.getStroke=T,t.getStrokeOutlinePoints=B,t.getStrokePoints=S}(e)),e);class o{static average(t,i){return(t+i)/2}}class a extends h{__class__="KritzelPath";points;d;stroke={light:"none",dark:"none"};strokeWidth;lineSlack=.5;fill;x=0;y=0;height=0;width=0;scale=1;options;isVisible=!0;isDebugInfoVisible=!0;isCompleted=!1;_adjustedPoints=null;get viewBox(){return`${this.x} ${this.y} ${this.width} ${this.height}`}constructor(t){super(),this.options=t,this.points=t?.points??[],this.translateX=t?.translateX??0,this.translateY=t?.translateY??0,this.scale=t?.scale??1,this.strokeWidth=t?.strokeWidth??8,this.fill=t?.fill??{light:"#000000",dark:"#ffffff"},this.d=this.generateSvgPath(),this.updateDimensions()}static create(t,i){const s=new a;return s._core=t,s.id=s.generateId(),s.workspaceId=t.store.state.activeWorkspace.id,s.userId=t.user?.id,s.options=i,s.points=i?.points??[],s.translateX=i?.translateX??0,s.translateY=i?.translateY??0,s.scale=i?.scale??1,s.strokeWidth=i?.strokeWidth??8,s.fill=i?.fill??{light:"#000000",dark:"#ffffff"},s.opacity=i?.opacity??1,s.zIndex=t.store.currentZIndex,s.d=s.generateSvgPath(),s.updateDimensions(),s}copy(){const t=super.copy();return this.points&&(t.points=this.points.map((t=>[...t]))),t}resize(t,i,s,h){if(s<=1||h<=1)return;const n=s/this.width,e=h/this.height;if(this.width=s,this.height=h,1===this.points.length){const t=this.points[0],i=Math.max(0,s-this.strokeWidth)/n,r=Math.max(0,h-this.strokeWidth)/e;this.points.push([t[0]+i,t[1]+r])}this.points=this.points.map((([t,i])=>[t*n,i*e])),this.d=this.generateSvgPath(),this.width=Math.max(...this.points.map((t=>t[0])))-Math.min(...this.points.map((t=>t[0])))+this.strokeWidth,this.height=Math.max(...this.points.map((t=>t[1])))-Math.min(...this.points.map((t=>t[1])))+this.strokeWidth,this.x=Math.min(...this.points.map((t=>t[0])))-this.strokeWidth/2,this.y=Math.min(...this.points.map((t=>t[1])))-this.strokeWidth/2,this.translateX=t,this.translateY=i,this._adjustedPoints=null,this._core.store.objects.update(this)}rotate(t){this.rotation=t,this._adjustedPoints=null,this._core.store.objects.update(this)}move(t,i,s,h){const n=(i-h)/this._core.store.state.scale;this.translateX+=(t-s)/this._core.store.state.scale,this.translateY+=n,this._adjustedPoints=null,this._core.store.objects.update(this)}hitTest(t,i){const s=this.strokeWidth/this.scale/2;if(null===this._adjustedPoints&&(this._adjustedPoints=this.computeAdjustedPoints()),1===this._adjustedPoints.length){const h=this._adjustedPoints[0];return this.pointToLineSegmentDistance(t,i,h[0],h[1],h[0],h[1])<=s}for(let h=0;h<this._adjustedPoints.length-1;h++){const n=this._adjustedPoints[h],e=this._adjustedPoints[h+1];if(this.pointToLineSegmentDistance(t,i,n[0],n[1],e[0],e[1])<=s)return!0}return!1}hitTestPolygon(t){const i=this.strokeWidth/this.scale/2;null===this._adjustedPoints&&(this._adjustedPoints=this.computeAdjustedPoints());const h=[{x:t.bottomLeft.x,y:t.bottomLeft.y},{x:t.bottomRight.x,y:t.bottomRight.y},{x:t.topRight.x,y:t.topRight.y},{x:t.topLeft.x,y:t.topLeft.y}];for(const[t,i]of this._adjustedPoints)if(s.isPointInPolygon({x:t,y:i},h))return!0;for(const t of h)if(this.hitTest(t.x,t.y))return!0;for(let t=0;t<this._adjustedPoints.length-1;t++){const i={x:this._adjustedPoints[t][0],y:this._adjustedPoints[t][1]},n={x:this._adjustedPoints[t+1][0],y:this._adjustedPoints[t+1][1]};for(let t=0;t<h.length;t++)if(s.intersectLines(i,n,h[t],h[(t+1)%h.length]))return!0}for(let t=0;t<this._adjustedPoints.length-1;t++){const s=this._adjustedPoints[t],n=this._adjustedPoints[t+1];for(let t=0;t<h.length;t++){const e=h[t],r=h[(t+1)%h.length],o=this.pointToLineSegmentDistance(e.x,e.y,s[0],s[1],n[0],n[1]),a=this.pointToLineSegmentDistance(r.x,r.y,s[0],s[1],n[0],n[1]),u=this.pointToLineSegmentDistance(s[0],s[1],e.x,e.y,r.x,r.y),c=this.pointToLineSegmentDistance(n[0],n[1],e.x,e.y,r.x,r.y);if(Math.min(o,a,u,c)<=i)return!0}}return!1}updatePosition(t,i){this.translateX=t,this.translateY=i,this._adjustedPoints=null,this._core.store.objects.update(this)}onAfterUpdate(t){t.includes("strokeWidth")&&(this.d=this.generateSvgPath(),this.updateBoundingBox(),this._adjustedPoints=null)}computeAdjustedPoints(){if(!this.points?.length)return[];const t=this.rotation,i=Math.cos(t),s=Math.sin(t),h=this.points.map((t=>t[0])),n=this.points.map((t=>t[1])),e={x:(Math.min(...h)+Math.max(...h))/2,y:(Math.min(...n)+Math.max(...n))/2},{x:r,y:o}=e;return this.points.map((([t,h])=>{const n=t-r,e=h-o;return[r+n*i-e*s,o+n*s+e*i]})).map((([t,i])=>[Math.abs(t-this.x)/this.scale+this.translateX,Math.abs(i-this.y)/this.scale+this.translateY]))}pointToLineSegmentDistance(t,i,s,h,n,e){const r=n-s,o=e-h,a=r*r+o*o;let u,c,l=-1;0!==a&&(l=((t-s)*r+(i-h)*o)/a),l<0?(u=s,c=h):l>1?(u=n,c=e):(u=s+l*r,c=h+l*o);const f=t-u,d=i-c;return Math.sqrt(f*f+d*d)}updateDimensions(){const t=this.points.map((([t,i])=>[t*Math.cos(this.rotation)-i*Math.sin(this.rotation),t*Math.sin(this.rotation)+i*Math.cos(this.rotation)])),i=Math.min(...t.map((t=>t[0]-this.strokeWidth/2))),s=Math.min(...t.map((t=>t[1]-this.strokeWidth/2))),h=Math.max(...t.map((t=>t[0]+this.strokeWidth/2))),n=Math.max(...t.map((t=>t[1]+this.strokeWidth/2)));this.width=h-i+this.lineSlack,this.height=n-s+this.lineSlack,this.x=i,this.y=s,this.translateX=(this.x+this.translateX)/this.scale,this.translateY=(this.y+this.translateY)/this.scale}updateBoundingBox(){const t=Math.min(...this.points.map((t=>t[0])))-this.strokeWidth/2,i=Math.min(...this.points.map((t=>t[1])))-this.strokeWidth/2,s=Math.max(...this.points.map((t=>t[0])))+this.strokeWidth/2,h=Math.max(...this.points.map((t=>t[1])))+this.strokeWidth/2;this.width=s-t+this.lineSlack,this.height=h-i+this.lineSlack,this.x=t,this.y=i}generateSvgPath(){const t=this.getStrokeFromPoints(this.points,this.strokeWidth);return this.getSvgPathFromStroke(t)}getStrokeFromPoints(t,i){return r.getStroke(t,{size:i,thinning:.5,smoothing:.5,streamline:.5,easing:t=>t,simulatePressure:!0,last:!0,start:{cap:!0,taper:0,easing:t=>t},end:{cap:!0,taper:0,easing:t=>t}})}getSvgPathFromStroke(t,i=!0){const s=t.length;if(s<4)return"";let h=t[0],n=t[1];const e=t[2];let r=`M${h[0].toFixed(2)},${h[1].toFixed(2)} Q${n[0].toFixed(2)},${n[1].toFixed(2)} ${o.average(n[0],e[0]).toFixed(2)},${o.average(n[1],e[1]).toFixed(2)} T`;for(let i=2,e=s-1;i<e;i++)h=t[i],n=t[i+1],r+=`${o.average(h[0],n[0]).toFixed(2)},${o.average(h[1],n[1]).toFixed(2)} `;return i&&(r+="Z"),r}isLowRes(){if(!this._core)return!1;const t=this._core.store.state.scale;return this.boundingBox.width*t*(this.boundingBox.height*t)<500}getClipPoint(t){const i=this.centerX,s=this.centerY,h=this.strokeWidth/this.scale/2;if(null===this._adjustedPoints&&(this._adjustedPoints=this.computeAdjustedPoints()),this._adjustedPoints.length<1)return null;let n=!0;for(let e=1;e<=32;e++){const r=e/32,o=t.x+(i-t.x)*r,a=t.y+(s-t.y)*r;let u=1/0;if(1===this._adjustedPoints.length){const t=this._adjustedPoints[0],i=o-t[0],s=a-t[1];u=Math.sqrt(i*i+s*s)}else for(let t=0;t<this._adjustedPoints.length-1;t++){const i=this._adjustedPoints[t],s=this._adjustedPoints[t+1],h=this.pointToLineSegmentDistance(o,a,i[0],i[1],s[0],s[1]);h<u&&(u=h)}const c=u<=h;if(n&&c){let n=(e-1)/32,o=r;for(let e=0;e<8;e++){const e=(n+o)/2,r=t.x+(i-t.x)*e,a=t.y+(s-t.y)*e;let u=1/0;if(1===this._adjustedPoints.length){const t=this._adjustedPoints[0],i=r-t[0],s=a-t[1];u=Math.sqrt(i*i+s*s)}else for(let t=0;t<this._adjustedPoints.length-1;t++){const i=this._adjustedPoints[t],s=this._adjustedPoints[t+1],h=this.pointToLineSegmentDistance(r,a,i[0],i[1],s[0],s[1]);h<u&&(u=h)}u<=h?o=e:n=e}const a=(n+o)/2;return{x:t.x+(i-t.x)*a,y:t.y+(s-t.y)*a}}n=!c}return null}}class u extends h{__class__="KritzelLine";startX;startY;endX;endY;controlX;controlY;stroke;strokeWidth;scale=1;options;startAnchor;endAnchor;arrows;isVisible=!0;isDebugInfoVisible=!0;isCompleted=!1;_adjustedPoints=null;_clipInfo=null;get d(){return void 0!==this.controlX&&void 0!==this.controlY?`M ${this.startX} ${this.startY} Q ${this.controlX} ${this.controlY} ${this.endX} ${this.endY}`:`M ${this.startX} ${this.startY} L ${this.endX} ${this.endY}`}get viewBox(){return`${this.x} ${this.y} ${this.width} ${this.height}`}constructor(t){super(),this.options=t,this.startX=t?.startX??0,this.startY=t?.startY??0,this.endX=t?.endX??0,this.endY=t?.endY??0,this.controlX=t?.controlX,this.controlY=t?.controlY,this.translateX=t?.translateX??0,this.translateY=t?.translateY??0,this.scale=t?.scale??1,this.strokeWidth=t?.strokeWidth??4,this.stroke=t?.stroke??{light:"#000000",dark:"#ffffff"},this.startAnchor=t?.startAnchor,this.endAnchor=t?.endAnchor,this.arrows=t?.arrows,this.updateDimensions()}static create(t,i){const s=new u;return s._core=t,s.id=s.generateId(),s.workspaceId=t.store.state.activeWorkspace.id,s.userId=t.user?.id,s.options=i,s.startX=i?.startX??0,s.startY=i?.startY??0,s.endX=i?.endX??0,s.endY=i?.endY??0,s.controlX=i?.controlX,s.controlY=i?.controlY,s.translateX=i?.translateX??0,s.translateY=i?.translateY??0,s.scale=i?.scale??1,s.strokeWidth=i?.strokeWidth??4,s.stroke=i?.stroke??{light:"#000000",dark:"#ffffff"},s.opacity=i?.opacity??1,s.startAnchor=i?.startAnchor,s.endAnchor=i?.endAnchor,s.arrows=i?.arrows,s.zIndex=t.store.currentZIndex,s.updateDimensions(),s}resize(t,i,s,h){if(s<=1||h<=1)return;const n=s/this.width,e=h/this.height;this.startX=this.startX*n,this.startY=this.startY*e,this.endX=this.endX*n,this.endY=this.endY*e,void 0!==this.controlX&&void 0!==this.controlY&&(this.controlX=this.controlX*n,this.controlY=this.controlY*e);const{minX:r,minY:o,maxX:a,maxY:u}=this.calculateBoundingBox();this.width=a-r,this.height=u-o,this.x=r,this.y=o,this.translateX=t,this.translateY=i,this._adjustedPoints=null,this._clipInfo=null,this._core.store.objects.update(this),this._core.anchorManager.updateAnchorsForObject(this.id),this.startAnchor&&this._core.anchorManager.updateAnchorsForObject(this.startAnchor.objectId),this.endAnchor&&this._core.anchorManager.updateAnchorsForObject(this.endAnchor.objectId)}rotate(t){this.rotation=t,this._adjustedPoints=null,this._clipInfo=null,this._core.store.objects.update(this)}move(t,i,s,h){const n=(i-h)/this._core.store.state.scale;this.translateX+=(t-s)/this._core.store.state.scale,this.translateY+=n,this.startAnchor&&this._core.anchorManager.updateAnchorsForObject(this.startAnchor.objectId),this.endAnchor&&this._core.anchorManager.updateAnchorsForObject(this.endAnchor.objectId),this._adjustedPoints=null,this._clipInfo=null,this._core.store.objects.update(this)}hitTest(t,i){const s=Math.max(this.strokeWidth,20)/this.scale/2;if(null===this._adjustedPoints&&(this._adjustedPoints=this.computeAdjustedPoints()),void 0!==this.controlX&&void 0!==this.controlY){const h=this.getClipInfo();return this.pointToBezierDistance(t,i,h.start?.t??0,h.end?.t??1)<=s}const h=this.getClipInfo(),n=h.start?[h.start.x,h.start.y]:this._adjustedPoints[0],e=h.end?[h.end.x,h.end.y]:this._adjustedPoints[1];return this.pointToLineSegmentDistance(t,i,n[0],n[1],e[0],e[1])<=s}hitTestPolygon(t){const i=this.strokeWidth/this.scale/2;null===this._adjustedPoints&&(this._adjustedPoints=this.computeAdjustedPoints());const h=this.getClipInfo(),n=[{x:t.bottomLeft.x,y:t.bottomLeft.y},{x:t.bottomRight.x,y:t.bottomRight.y},{x:t.topRight.x,y:t.topRight.y},{x:t.topLeft.x,y:t.topLeft.y}],e=h.start?[h.start.x,h.start.y]:this._adjustedPoints[0],r=h.end?[h.end.x,h.end.y]:this._adjustedPoints[1],o=[e,r];for(const[t,i]of o)if(s.isPointInPolygon({x:t,y:i},n))return!0;for(const t of n)if(this.hitTest(t.x,t.y))return!0;if(void 0!==this.controlX&&void 0!==this.controlY){const t=this._adjustedPoints[0],e=this._adjustedPoints[1],r=this.computeAdjustedControlPoint(),o=h.start?.t??0,a=h.end?.t??1,u=20;for(let h=0;h<=u;h++){const c=o+h/u*(a-o),l=1-c,f=l*l*t[0]+2*l*c*r[0]+c*c*e[0],d=l*l*t[1]+2*l*c*r[1]+c*c*e[1];if(s.isPointInPolygon({x:f,y:d},n))return!0;for(let t=0;t<n.length;t++){const s=n[t],h=n[(t+1)%n.length];if(this.pointToLineSegmentDistance(f,d,s.x,s.y,h.x,h.y)<=i)return!0}}return!1}const a={x:e[0],y:e[1]},u={x:r[0],y:r[1]};for(let t=0;t<n.length;t++){const h=n[t],e=n[(t+1)%n.length];if(s.intersectLines(a,u,h,e))return!0;const r=this.pointToLineSegmentDistance(h.x,h.y,a.x,a.y,u.x,u.y),o=this.pointToLineSegmentDistance(e.x,e.y,a.x,a.y,u.x,u.y),c=this.pointToLineSegmentDistance(a.x,a.y,h.x,h.y,e.x,e.y),l=this.pointToLineSegmentDistance(u.x,u.y,h.x,h.y,e.x,e.y);if(Math.min(r,o,c,l)<=i)return!0}return!1}updatePosition(t,i){this.translateX=t,this.translateY=i,this._adjustedPoints=null,this._clipInfo=null,this._core.store.objects.update(this)}updateEndpoint(t,i,s){"start"===t?(this.startX=i,this.startY=s):(this.endX=i,this.endY=s);const h=this.width,n=this.height,{minX:e,minY:r,maxX:o,maxY:a}=this.calculateBoundingBox(),u=e-this.x,c=r-this.y,l=o-e,f=a-r,d=(l-h)/2,M=(f-n)/2;this.x=e,this.y=r,this.width=l,this.height=f;const g=Math.cos(this.rotation),m=Math.sin(this.rotation),p=u+d,x=c+M,y=p*m+x*g-M;this.translateX+=(p*g-x*m-d)/this.scale,this.translateY+=y/this.scale,this._adjustedPoints=null,this._clipInfo=null,this._core.store.objects.update(this)}updateControlPoint(t,i){this.controlX=t,this.controlY=i;const s=this.width,h=this.height,{minX:n,minY:e,maxX:r,maxY:o}=this.calculateBoundingBox(),a=n-this.x,u=e-this.y,c=r-n,l=o-e,f=(c-s)/2,d=(l-h)/2;this.x=n,this.y=e,this.width=c,this.height=l;const M=Math.cos(this.rotation),g=Math.sin(this.rotation),m=a+f,p=u+d,x=m*g+p*M-d;this.translateX+=(m*M-p*g-f)/this.scale,this.translateY+=x/this.scale,this._adjustedPoints=null,this._clipInfo=null,this._core.store.objects.update(this)}computeAdjustedPoints(){const t=[[this.startX,this.startY],[this.endX,this.endY]],i=this.rotation,s=Math.cos(i),h=Math.sin(i),n=t.map((t=>t[0])),e=t.map((t=>t[1])),r={x:(Math.min(...n)+Math.max(...n))/2,y:(Math.min(...e)+Math.max(...e))/2},{x:o,y:a}=r;return t.map((([t,i])=>{const n=t-o,e=i-a;return[o+n*s-e*h,a+n*h+e*s]})).map((([t,i])=>[(t-this.x)/this.scale+this.translateX,(i-this.y)/this.scale+this.translateY]))}pointToLineSegmentDistance(t,i,s,h,n,e){const r=n-s,o=e-h,a=r*r+o*o;let u,c,l=-1;0!==a&&(l=((t-s)*r+(i-h)*o)/a),l<0?(u=s,c=h):l>1?(u=n,c=e):(u=s+l*r,c=h+l*o);const f=t-u,d=i-c;return Math.sqrt(f*f+d*d)}pointToBezierDistance(t,i,s=0,h=1){null===this._adjustedPoints&&(this._adjustedPoints=this.computeAdjustedPoints());const n=this._adjustedPoints[0],e=this._adjustedPoints[1],r=this.computeAdjustedControlPoint();let o=1/0;for(let a=0;a<=20;a++){const u=s+a/20*(h-s),c=1-u,l=t-(c*c*n[0]+2*c*u*r[0]+u*u*e[0]),f=i-(c*c*n[1]+2*c*u*r[1]+u*u*e[1]),d=Math.sqrt(l*l+f*f);d<o&&(o=d)}return o}getClipInfo(){if(this._clipInfo)return this._clipInfo;const t=this.endAnchor,i={};if(this.startAnchor){const t=this._core.anchorManager.findAnchorTarget(this,"start");if(t){const s=this._core.anchorManager.computeAnchorClipInfo(this,"start",t);s&&(i.start={x:s.worldX,y:s.worldY,t:s.t})}}if(t){const t=this._core.anchorManager.findAnchorTarget(this,"end");if(t){const s=this._core.anchorManager.computeAnchorClipInfo(this,"end",t);s&&(i.end={x:s.worldX,y:s.worldY,t:s.t})}}return this._clipInfo=i,i}computeAdjustedControlPoint(){if(void 0===this.controlX||void 0===this.controlY)return[(this.startX+this.endX)/2,(this.startY+this.endY)/2];const t=this.rotation,i=Math.cos(t),s=Math.sin(t),h=[this.startX,this.endX],n=[this.startY,this.endY],e={x:(Math.min(...h)+Math.max(...h))/2,y:(Math.min(...n)+Math.max(...n))/2},{x:r,y:o}=e,a=this.controlX-r,u=this.controlY-o;return[(r+a*i-u*s-this.x)/this.scale+this.translateX,(o+a*s+u*i-this.y)/this.scale+this.translateY]}get rotatedPolygon(){const t=this.padding,{minX:i,minY:s,maxX:h,maxY:n}=u.calculateBoundingBox(this.startX,this.startY,this.endX,this.endY,this.controlX,this.controlY,this.strokeWidth),e=i-this.x+t,r=s-this.y+t,o=h-this.x+t,a=n-this.y+t,c={x:e,y:r},l={x:o,y:r},f={x:o,y:a},d={x:e,y:a},M=this.totalWidth/2,g=this.totalHeight/2,m=this.rotation,p=Math.cos(m),x=Math.sin(m),y=t=>({x:((t.x-M)*p-(t.y-g)*x+M)/this.scale+this.translateX,y:((t.x-M)*x+(t.y-g)*p+g)/this.scale+this.translateY});return{topLeft:y(c),topRight:y(l),bottomRight:y(f),bottomLeft:y(d)}}static calculateBoundingBox(t,i,s,h,n,e,r){let o=Math.min(t,s),a=Math.min(i,h),u=Math.max(t,s),c=Math.max(i,h);if(void 0!==n&&void 0!==e){const r=t-2*n+s;if(0!==r){const i=(t-n)/r;if(i>0&&i<1){const h=(1-i)*(1-i)*t+2*(1-i)*i*n+i*i*s;o=Math.min(o,h),u=Math.max(u,h)}}const l=i-2*e+h;if(0!==l){const t=(i-e)/l;if(t>0&&t<1){const s=(1-t)*(1-t)*i+2*(1-t)*t*e+t*t*h;a=Math.min(a,s),c=Math.max(c,s)}}}const l=r/2;return{minX:o-l,minY:a-l,maxX:u+l,maxY:c+l}}calculateBoundingBox(){return u.calculateBoundingBox(this.startX,this.startY,this.endX,this.endY,this.controlX,this.controlY,this.strokeWidth)}updateDimensions(){const{minX:t,minY:i,maxX:s,maxY:h}=this.calculateBoundingBox();this.width=s-t,this.height=h-i,this.x=t,this.y=i,this.translateX=(this.x+this.translateX)/this.scale,this.translateY=(this.y+this.translateY)/this.scale}get startMarkerId(){return`arrow-start-${this.id}`}get endMarkerId(){return`arrow-end-${this.id}`}getArrowSize(t){const i="start"===t?this.arrows?.start:this.arrows?.end;return i?.size??3*this.strokeWidth}getArrowFill(t){const s="start"===t?this.arrows?.start:this.arrows?.end;return i.resolveThemeColor(s?.fill??this.stroke)}getArrowPath(t="triangle"){switch(t){case"triangle":default:return"M 0 0 L 10 5 L 0 10 z";case"open":return"M 0 0 L 10 5 L 0 10";case"diamond":return"M 0 5 L 5 0 L 10 5 L 5 10 z";case"circle":return"M 5,0 A 5,5 0 1,1 5,10 A 5,5 0 1,1 5,0"}}get hasStartArrow(){return!0===this.arrows?.start?.enabled}get hasEndArrow(){return!0===this.arrows?.end?.enabled}}export{a as K,u as a,s as b,h as c}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{p as e,H as t,c as s,h as i,d as o,t as r}from"./p-BWj1eE2b.js";import{h as a,d as l,e as n,g as h,f as p}from"./p-
|
|
1
|
+
import{p as e,H as t,c as s,h as i,d as o,t as r}from"./p-BWj1eE2b.js";import{h as a,d as l,e as n,g as h,f as p}from"./p-BPQOTise.js";import{a as c}from"./p-CjazGGq3.js";import{d}from"./p-BZ8bK8qT.js";import{d as m}from"./p-Brwz_Dpb.js";import{d as f}from"./p-cjeDomsc.js";import{d as y}from"./p-CS7r-zhx.js";import{d as g}from"./p-D7pwbRUy.js";import{d as u}from"./p-DkT0KZCm.js";import{d as z}from"./p-Gm5hSQ-e.js";import{d as k}from"./p-1ppb4M65.js";import{d as C}from"./p-CJKsuQun.js";import{d as x}from"./p-CM7rYf9A.js";import{d as b}from"./p-VxgCvVox.js";class v{static getToolConfig(e){return e instanceof a?e.getToolConfig():e instanceof l?{type:"brush",colorProperty:"color",sizeProperty:"size",opacityProperty:"opacity",paletteSource:"palette",controls:[{type:"stroke-size",propertyName:"size"}]}:e instanceof n?{type:"line",colorProperty:"color",sizeProperty:"size",opacityProperty:"opacity",paletteSource:"palette",controls:[{type:"stroke-size",propertyName:"size"},{type:"line-endings",propertyName:"arrows",additionalProps:{}}]}:e instanceof h?{type:"shape",colorProperty:"strokeColor",sizeProperty:"strokeWidth",opacityProperty:"opacity",paletteSource:"palette",controls:[{type:"stroke-size",propertyName:"strokeWidth"},{type:"shape-fill",propertyName:"fillColor",additionalProps:{}}]}:e instanceof p?{type:"text",colorProperty:"fontColor",sizeProperty:"fontSize",opacityProperty:"opacity",paletteSource:"palette",controls:[{type:"font-size",propertyName:"fontSize",additionalProps:{}},{type:"font-family",propertyName:"fontFamily"}]}:null}}const E=e(class extends t{constructor(e){super(),!1!==e&&this.__registerHost(),this.__attachShadow(),this.toolChange=s(this,"toolChange"),this.displayValuesChange=s(this,"displayValuesChange")}tool;handleToolChange(e,t){const s=v.getToolConfig(e);if(t&&e&&"shape"===s?.type){const i=v.getToolConfig(t);"shape"===i?.type&&[s.colorProperty,s.sizeProperty,s.opacityProperty,"fillColor"].forEach((s=>{s&&void 0!==t[s]&&(e[s]=t[s])}))}this.config=s,this.config&&(this.updatePalette(),this.currentOpacity=e[this.config.opacityProperty]??1,this.emitDisplayValues())}isExpanded=!1;theme;onThemeChange(){this.emitDisplayValues()}toolChange;displayValuesChange;config;palette=[];currentOpacity=1;updateTrigger=0;handleSelectionChange(){this.tool instanceof a&&(this.config=v.getToolConfig(this.tool),this.config&&(this.updatePalette(),this.currentOpacity=this.tool[this.config.opacityProperty]??1,this.emitDisplayValues()))}componentWillLoad(){this.config=v.getToolConfig(this.tool),this.config&&(this.updatePalette(),this.currentOpacity=this.tool[this.config.opacityProperty]??1,this.emitDisplayValues())}emitDisplayValues(){if(!this.config)return;const e=this.tool[this.config.sizeProperty],t={color:c.applyOpacity(this.tool[this.config.colorProperty],this.currentOpacity,this.theme),size:e};this.tool instanceof p&&(t.fontFamily=this.tool.fontFamily),this.displayValuesChange.emit(t)}updatePalette(){this.config&&(this.palette="none"===this.config.paletteSource?[]:this.tool.palette||[])}handleToggleExpand=()=>{this.isExpanded=!this.isExpanded};handleColorChange=e=>{if(this.tool[this.config.colorProperty]=e.detail,"shape"===this.config.type||"selection"===this.config.type){const t=this.tool;("string"==typeof t.fillColor?"transparent"===t.fillColor:"transparent"===t.fillColor.light&&"transparent"===t.fillColor.dark)||(t.fillColor=e.detail)}this.emitDisplayValues(),this.toolChange.emit(this.tool),this.updateTrigger++};handleSizeChange=e=>{this.tool[this.config.sizeProperty]=e.detail,this.emitDisplayValues(),this.toolChange.emit(this.tool),this.updateTrigger++};handleOpacityChange=e=>{this.tool[this.config.opacityProperty]=e.detail,this.currentOpacity=e.detail,this.emitDisplayValues(),this.toolChange.emit(this.tool)};handlePropertyChange=(e,t)=>{if("shape"!==this.config.type&&"selection"!==this.config.type||"fillColor"!==e)this.tool[e]=t,"fontFamily"===e&&this.emitDisplayValues();else{const e="filled"===t?this.tool[this.config.colorProperty]:{light:"transparent",dark:"transparent"};this.tool.fillColor=e,"filled"===t&&(this.tool[this.config.colorProperty]=e)}this.toolChange.emit(this.tool),this.updateTrigger++};getShapeFillValue(){const e=this.tool.fillColor;return("string"==typeof e?"transparent"===e:"transparent"===e.light&&"transparent"===e.dark)?"transparent":"filled"}renderControl(e){const t=this.tool[e.propertyName];switch(e.type){case"stroke-size":return i("kritzel-stroke-size",{key:e.type,selectedSize:t,onSizeChange:this.handleSizeChange});case"font-size":return i("kritzel-font-size",{key:e.type,selectedSize:t,fontFamily:this.tool.fontFamily,onSizeChange:this.handleSizeChange});case"line-endings":return i("kritzel-line-endings",{key:e.type,value:t,onValueChange:t=>this.handlePropertyChange(e.propertyName,t.detail)});case"shape-fill":return i("kritzel-shape-fill",{key:e.type,value:this.getShapeFillValue(),onValueChange:t=>this.handlePropertyChange(e.propertyName,t.detail)});case"font-family":return i("kritzel-font-family",{key:e.type,selectedFontFamily:t,onFontFamilyChange:t=>this.handlePropertyChange(e.propertyName,t.detail)});default:return null}}render(){if(!this.config)return null;const e=this.palette.length>6||"text"===this.config.type,t=this.palette.length>0,s=this.config.controls.find((e=>"stroke-size"===e.type||"font-size"===e.type)),r=this.config.controls.filter((e=>"stroke-size"!==e.type&&"font-size"!==e.type));return i(o,null,i("div",{style:{display:"flex",flexDirection:"row",gap:"8px",width:"100%"}},i("div",{style:{display:"flex",flexDirection:"column",gap:"12px",flex:"1"}},t&&i("kritzel-color-palette",{colors:this.palette,selectedColor:this.tool[this.config.colorProperty],isExpanded:this.isExpanded,isOpaque:!0,opacity:this.currentOpacity,theme:this.theme,onColorChange:this.handleColorChange}),s&&this.renderControl(s),i("kritzel-opacity-slider",{value:this.tool[this.config.opacityProperty],previewColor:this.tool[this.config.colorProperty],onValueChange:this.handleOpacityChange}),r.map((e=>[i("div",{class:"divider"}),this.renderControl(e)]))),e&&i("div",{style:{display:"flex",alignItems:"flex-start"}},i("button",{class:"expand-toggle",onClick:this.handleToggleExpand,title:this.isExpanded?"Collapse":"Expand"},i("kritzel-icon",{name:this.isExpanded?"chevron-up":"chevron-down"})))))}static get watchers(){return{tool:[{handleToolChange:0}],theme:[{onThemeChange:0}]}}static get style(){return".expand-toggle{background:none;border:none;cursor:var(--kritzel-global-pointer-cursor, pointer);padding:0;margin:0;display:flex;align-items:center;justify-content:center;width:32px;height:32px;color:var(--kritzel-icon-color, currentColor);transition:transform 0.2s ease}.expand-toggle:hover{opacity:0.7}.expand-toggle:focus{outline:none}.expand-toggle:focus-visible{outline:2px solid var(--kritzel-focus-color, #007acc);outline-offset:2px}.expand-toggle:active{transform:scale(0.95)}.divider{height:1px;background-color:var(--kritzel-divider-color, #e0e0e0);margin:4px 0;width:100%}"}},[513,"kritzel-tool-config",{tool:[1040],isExpanded:[1028,"is-expanded"],theme:[1],config:[32],palette:[32],currentOpacity:[32],updateTrigger:[32]},[[4,"objectsSelectionChange","handleSelectionChange"]],{tool:[{handleToolChange:0}],theme:[{onThemeChange:0}]}]);function j(){"undefined"!=typeof customElements&&["kritzel-tool-config","kritzel-color","kritzel-color-palette","kritzel-dropdown","kritzel-font","kritzel-font-family","kritzel-font-size","kritzel-icon","kritzel-line-endings","kritzel-opacity-slider","kritzel-shape-fill","kritzel-stroke-size"].forEach((e=>{switch(e){case"kritzel-tool-config":customElements.get(r(e))||customElements.define(r(e),E);break;case"kritzel-color":customElements.get(r(e))||d();break;case"kritzel-color-palette":customElements.get(r(e))||m();break;case"kritzel-dropdown":customElements.get(r(e))||f();break;case"kritzel-font":customElements.get(r(e))||y();break;case"kritzel-font-family":customElements.get(r(e))||g();break;case"kritzel-font-size":customElements.get(r(e))||u();break;case"kritzel-icon":customElements.get(r(e))||z();break;case"kritzel-line-endings":customElements.get(r(e))||k();break;case"kritzel-opacity-slider":customElements.get(r(e))||C();break;case"kritzel-shape-fill":customElements.get(r(e))||x();break;case"kritzel-stroke-size":customElements.get(r(e))||b()}}))}export{v as K,E as a,j as d}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { A as APP_STATE_MIGRATIONS, C as CURRENT_APP_STATE_SCHEMA_VERSION, v as CURRENT_WORKSPACE_SCHEMA_VERSION, D as DEFAULT_BRUSH_CONFIG, r as DEFAULT_LINE_TOOL_CONFIG, q as DEFAULT_TEXT_CONFIG, H as HocuspocusSyncProvider, I as IndexedDBSyncProvider, u as KritzelAlignment, o as KritzelAnchorManager, f as KritzelBrushTool, l as KritzelCursorHelper, h as KritzelEraserTool, d as KritzelGroup, b as KritzelImage, i as KritzelImageTool, c as KritzelLine, g as KritzelLineTool, a as KritzelPath, m as KritzelSelectionTool, e as KritzelShape, k as KritzelShapeTool, K as KritzelText, j as KritzelTextTool, p as KritzelThemeManager, n as KritzelWorkspace, S as ShapeType, W as WORKSPACE_EXPORT_VERSION, x as WORKSPACE_MIGRATIONS, t as darkTheme, s as lightTheme, w as runMigrations } from './workspace.migrations-
|
|
1
|
+
export { A as APP_STATE_MIGRATIONS, C as CURRENT_APP_STATE_SCHEMA_VERSION, v as CURRENT_WORKSPACE_SCHEMA_VERSION, D as DEFAULT_BRUSH_CONFIG, r as DEFAULT_LINE_TOOL_CONFIG, q as DEFAULT_TEXT_CONFIG, H as HocuspocusSyncProvider, I as IndexedDBSyncProvider, u as KritzelAlignment, o as KritzelAnchorManager, f as KritzelBrushTool, l as KritzelCursorHelper, h as KritzelEraserTool, d as KritzelGroup, b as KritzelImage, i as KritzelImageTool, c as KritzelLine, g as KritzelLineTool, a as KritzelPath, m as KritzelSelectionTool, e as KritzelShape, k as KritzelShapeTool, K as KritzelText, j as KritzelTextTool, p as KritzelThemeManager, n as KritzelWorkspace, S as ShapeType, W as WORKSPACE_EXPORT_VERSION, x as WORKSPACE_MIGRATIONS, t as darkTheme, s as lightTheme, w as runMigrations } from './workspace.migrations-Be65cOkQ.js';
|
|
2
2
|
import * as Y from 'yjs';
|
|
3
3
|
import { WebsocketProvider } from 'y-websocket';
|
|
4
4
|
import 'y-indexeddb';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { r as registerInstance, h, H as Host, c as createEvent, g as getElement } from './index-D9HaikfQ.js';
|
|
2
|
-
import { a as KritzelPath, c as KritzelLine, y as KritzelColorHelper, m as KritzelSelectionTool, f as KritzelBrushTool, g as KritzelLineTool, k as KritzelShapeTool, j as KritzelTextTool, z as KritzelDevicesHelper, B as KritzelMouseButton, E as DEFAULT_COLOR_PALETTE, S as ShapeType, D as DEFAULT_BRUSH_CONFIG, h as KritzelEraserTool, r as DEFAULT_LINE_TOOL_CONFIG, q as DEFAULT_TEXT_CONFIG, i as KritzelImageTool, u as KritzelAlignment, H as HocuspocusSyncProvider, I as IndexedDBSyncProvider, F as KritzelSelectionGroup, G as KritzelSelectionBox, J as KritzelIconRegistry, L as KritzelKeyboardHelper, M as KritzelBaseHandler, N as KritzelToolRegistry, O as KritzelBaseObject, n as KritzelWorkspace, d as KritzelGroup, b as KritzelImage, e as KritzelShape, K as KritzelText, w as runMigrations, v as CURRENT_WORKSPACE_SCHEMA_VERSION, x as WORKSPACE_MIGRATIONS, C as CURRENT_APP_STATE_SCHEMA_VERSION, A as APP_STATE_MIGRATIONS, P as ObjectHelper, l as KritzelCursorHelper, o as KritzelAnchorManager, p as KritzelThemeManager, Q as KritzelClassHelper, R as KritzelEventHelper, T as KritzelBaseTool, W as WORKSPACE_EXPORT_VERSION } from './workspace.migrations-
|
|
2
|
+
import { a as KritzelPath, c as KritzelLine, y as KritzelColorHelper, m as KritzelSelectionTool, f as KritzelBrushTool, g as KritzelLineTool, k as KritzelShapeTool, j as KritzelTextTool, z as KritzelDevicesHelper, B as KritzelMouseButton, E as DEFAULT_COLOR_PALETTE, S as ShapeType, D as DEFAULT_BRUSH_CONFIG, h as KritzelEraserTool, r as DEFAULT_LINE_TOOL_CONFIG, q as DEFAULT_TEXT_CONFIG, i as KritzelImageTool, u as KritzelAlignment, H as HocuspocusSyncProvider, I as IndexedDBSyncProvider, F as KritzelSelectionGroup, G as KritzelSelectionBox, J as KritzelIconRegistry, L as KritzelKeyboardHelper, M as KritzelBaseHandler, N as KritzelToolRegistry, O as KritzelBaseObject, n as KritzelWorkspace, d as KritzelGroup, b as KritzelImage, e as KritzelShape, K as KritzelText, w as runMigrations, v as CURRENT_WORKSPACE_SCHEMA_VERSION, x as WORKSPACE_MIGRATIONS, C as CURRENT_APP_STATE_SCHEMA_VERSION, A as APP_STATE_MIGRATIONS, P as ObjectHelper, l as KritzelCursorHelper, o as KritzelAnchorManager, p as KritzelThemeManager, Q as KritzelClassHelper, R as KritzelEventHelper, T as KritzelBaseTool, W as WORKSPACE_EXPORT_VERSION } from './workspace.migrations-Be65cOkQ.js';
|
|
3
3
|
import * as Y from 'yjs';
|
|
4
4
|
import 'y-websocket';
|
|
5
5
|
import 'y-indexeddb';
|
|
@@ -20737,7 +20737,7 @@ class KritzelCustomElement extends KritzelBaseObject {
|
|
|
20737
20737
|
const object = new KritzelCustomElement(config);
|
|
20738
20738
|
object._core = core;
|
|
20739
20739
|
object.id = object.generateId();
|
|
20740
|
-
object.workspaceId = core.store.activeWorkspace.id;
|
|
20740
|
+
object.workspaceId = core.store.state.activeWorkspace.id;
|
|
20741
20741
|
object.userId = core.user?.id;
|
|
20742
20742
|
return object;
|
|
20743
20743
|
}
|
|
@@ -22265,18 +22265,6 @@ class KritzelStore {
|
|
|
22265
22265
|
}
|
|
22266
22266
|
return this._state.objects;
|
|
22267
22267
|
}
|
|
22268
|
-
/**
|
|
22269
|
-
* Gets the currently active workspace.
|
|
22270
|
-
* Throws an error if no active workspace is set, as it is required for workspace-bound operations.
|
|
22271
|
-
* @returns The current active KritzelWorkspace
|
|
22272
|
-
* @throws Error if no active workspace is set in the state
|
|
22273
|
-
*/
|
|
22274
|
-
get activeWorkspace() {
|
|
22275
|
-
if (!this._state.activeWorkspace) {
|
|
22276
|
-
throw new Error('Active workspace is not set.');
|
|
22277
|
-
}
|
|
22278
|
-
return this._state.activeWorkspace;
|
|
22279
|
-
}
|
|
22280
22268
|
/**
|
|
22281
22269
|
* Gets the host element for the Kritzel editor.
|
|
22282
22270
|
* Throws an error if the host is not set, as it is required for many operations.
|
|
@@ -23459,7 +23447,7 @@ class KritzelCore {
|
|
|
23459
23447
|
workspace.updatedAt = new Date();
|
|
23460
23448
|
this.saveWorkspaceToAppState(workspace);
|
|
23461
23449
|
// Keep metadata map in sync when the active workspace's name changes
|
|
23462
|
-
if (this._store.activeWorkspace?.id === workspace.id) {
|
|
23450
|
+
if (this._store.state.activeWorkspace?.id === workspace.id) {
|
|
23463
23451
|
this._store.objects?.setWorkspaceName(workspace.name);
|
|
23464
23452
|
}
|
|
23465
23453
|
const workspaces = this._store.state.workspaces;
|
|
@@ -23477,7 +23465,7 @@ class KritzelCore {
|
|
|
23477
23465
|
*/
|
|
23478
23466
|
deleteWorkspace(workspace) {
|
|
23479
23467
|
// If deleting the active workspace, need to handle ObjectMap cleanup
|
|
23480
|
-
if (this._store.activeWorkspace?.id === workspace.id) {
|
|
23468
|
+
if (this._store.state.activeWorkspace?.id === workspace.id) {
|
|
23481
23469
|
this.engine.viewport?.cancelPendingUpdates();
|
|
23482
23470
|
this._store.objects?.destroy();
|
|
23483
23471
|
}
|
|
@@ -23498,7 +23486,7 @@ class KritzelCore {
|
|
|
23498
23486
|
* @param scale - The zoom scale of the viewport
|
|
23499
23487
|
*/
|
|
23500
23488
|
updateWorkspaceViewport(translateX, translateY, scale) {
|
|
23501
|
-
const activeWorkspace = this._store.activeWorkspace;
|
|
23489
|
+
const activeWorkspace = this._store.state.activeWorkspace;
|
|
23502
23490
|
if (!activeWorkspace) {
|
|
23503
23491
|
return;
|
|
23504
23492
|
}
|
|
@@ -23521,7 +23509,7 @@ class KritzelCore {
|
|
|
23521
23509
|
* @returns True if the workspace is public, false otherwise
|
|
23522
23510
|
*/
|
|
23523
23511
|
getIsPublic() {
|
|
23524
|
-
return this._store.activeWorkspace?.isPublic ?? false;
|
|
23512
|
+
return this._store.state.activeWorkspace?.isPublic ?? false;
|
|
23525
23513
|
}
|
|
23526
23514
|
// ═══════════════════════════════════════════════════════════════════════════
|
|
23527
23515
|
// Object Management Methods
|
|
@@ -23713,7 +23701,7 @@ class KritzelCore {
|
|
|
23713
23701
|
if (!copiedObjects || copiedObjects.length === 0) {
|
|
23714
23702
|
return;
|
|
23715
23703
|
}
|
|
23716
|
-
const activeWorkspace = this._store.activeWorkspace;
|
|
23704
|
+
const activeWorkspace = this._store.state.activeWorkspace;
|
|
23717
23705
|
const originalIdMapping = this._store.state.copiedObjectIdMapping;
|
|
23718
23706
|
// Check if we're pasting from a different workspace
|
|
23719
23707
|
const isDifferentWorkspace = copiedObjects.some(obj => obj.workspaceId !== activeWorkspace.id);
|
|
@@ -24229,7 +24217,7 @@ class KritzelCore {
|
|
|
24229
24217
|
// saving the old workspace's viewport to the new workspace
|
|
24230
24218
|
this._kritzelEngine.viewport?.cancelPendingUpdates();
|
|
24231
24219
|
// Immediately save the current workspace's viewport before switching
|
|
24232
|
-
const currentWorkspace = this._store.activeWorkspace;
|
|
24220
|
+
const currentWorkspace = this._store.state.activeWorkspace;
|
|
24233
24221
|
if (currentWorkspace) {
|
|
24234
24222
|
this.updateWorkspaceViewport(this._store.state.translateX, this._store.state.translateY, this._store.state.scale);
|
|
24235
24223
|
}
|
|
@@ -25584,13 +25572,13 @@ const KritzelEngine = class {
|
|
|
25584
25572
|
}
|
|
25585
25573
|
// Let batched prop updates settle, then perform an idempotent re-check.
|
|
25586
25574
|
await Promise.resolve();
|
|
25587
|
-
const currentWorkspaceId = this.core.store.activeWorkspace?.id;
|
|
25575
|
+
const currentWorkspaceId = this.core.store.state.activeWorkspace?.id;
|
|
25588
25576
|
if (currentWorkspaceId === newWorkspaceId) {
|
|
25589
25577
|
return;
|
|
25590
25578
|
}
|
|
25591
25579
|
this.core.beforeWorkspaceChange();
|
|
25592
25580
|
await this.initializeWorkspaceIfNeeded(newWorkspace);
|
|
25593
|
-
this.activeWorkspaceChange.emit(this.core.store.activeWorkspace);
|
|
25581
|
+
this.activeWorkspaceChange.emit(this.core.store.state.activeWorkspace);
|
|
25594
25582
|
}
|
|
25595
25583
|
/** Optional unique identifier for namespacing storage keys across multiple editor instances. */
|
|
25596
25584
|
editorId;
|
|
@@ -25608,8 +25596,11 @@ const KritzelEngine = class {
|
|
|
25608
25596
|
this._syncConfigRevision++;
|
|
25609
25597
|
// Keep core config in sync immediately so late prop updates are not lost.
|
|
25610
25598
|
this.core.setSyncConfig(newValue);
|
|
25611
|
-
// If syncConfig arrives after componentDidLoad, initialize Yjs now
|
|
25612
|
-
|
|
25599
|
+
// If syncConfig arrives after componentDidLoad, initialize Yjs now.
|
|
25600
|
+
// Guard on _isViewportReady to avoid restoring viewport state before
|
|
25601
|
+
// viewportWidth/viewportHeight are set (they default to 0 until the
|
|
25602
|
+
// KritzelViewport constructor runs inside componentDidLoad's timeout).
|
|
25603
|
+
if (newValue && !this._isYjsInitialized && this._isViewportReady) {
|
|
25613
25604
|
await this.initializeSyncAndWorkspace();
|
|
25614
25605
|
}
|
|
25615
25606
|
}
|
|
@@ -26042,7 +26033,7 @@ const KritzelEngine = class {
|
|
|
26042
26033
|
object._core = this.core;
|
|
26043
26034
|
object.scale = this.core.store.state.scale;
|
|
26044
26035
|
object.zIndex = this.core.store.currentZIndex;
|
|
26045
|
-
object.workspaceId = this.core.store.activeWorkspace.id;
|
|
26036
|
+
object.workspaceId = this.core.store.state.activeWorkspace.id;
|
|
26046
26037
|
// Handle KritzelText: recreate the editor now that _core is available
|
|
26047
26038
|
// The editor's dispatchTransaction callback needs _core for persisting changes
|
|
26048
26039
|
if (KritzelClassHelper.isInstanceOf(object, 'KritzelText')) {
|
|
@@ -26063,7 +26054,7 @@ const KritzelEngine = class {
|
|
|
26063
26054
|
child._core = this.core;
|
|
26064
26055
|
child.scale = this.core.store.state.scale;
|
|
26065
26056
|
child.zIndex = this.core.store.currentZIndex;
|
|
26066
|
-
child.workspaceId = this.core.store.activeWorkspace.id;
|
|
26057
|
+
child.workspaceId = this.core.store.state.activeWorkspace.id;
|
|
26067
26058
|
idRemapping.set(oldId, child.id);
|
|
26068
26059
|
object.childIds.push(child.id);
|
|
26069
26060
|
});
|
|
@@ -26264,7 +26255,7 @@ const KritzelEngine = class {
|
|
|
26264
26255
|
// Save critical state before screenshot to restore after
|
|
26265
26256
|
const savedState = {
|
|
26266
26257
|
objects: this.core.store.objects,
|
|
26267
|
-
activeWorkspace: this.core.store.activeWorkspace,
|
|
26258
|
+
activeWorkspace: this.core.store.state.activeWorkspace,
|
|
26268
26259
|
workspaces: this.core.store.state.workspaces,
|
|
26269
26260
|
activeTool: this.core.store.state.activeTool,
|
|
26270
26261
|
isReady: this.core.store.state.isReady,
|
|
@@ -26462,7 +26453,7 @@ const KritzelEngine = class {
|
|
|
26462
26453
|
* @returns A JSON string representing the complete workspace state.
|
|
26463
26454
|
*/
|
|
26464
26455
|
async exportAsJson() {
|
|
26465
|
-
const workspace = this.core.store.activeWorkspace;
|
|
26456
|
+
const workspace = this.core.store.state.activeWorkspace;
|
|
26466
26457
|
if (!workspace) {
|
|
26467
26458
|
throw new Error('Cannot export workspace: no active workspace is loaded');
|
|
26468
26459
|
}
|
|
@@ -26538,7 +26529,7 @@ const KritzelEngine = class {
|
|
|
26538
26529
|
if (data.version && data.version !== WORKSPACE_EXPORT_VERSION) {
|
|
26539
26530
|
console.warn(`Workspace version mismatch: expected ${WORKSPACE_EXPORT_VERSION}, got ${data.version}`);
|
|
26540
26531
|
}
|
|
26541
|
-
const activeWorkspace = this.core.store.activeWorkspace;
|
|
26532
|
+
const activeWorkspace = this.core.store.state.activeWorkspace;
|
|
26542
26533
|
if (!activeWorkspace) {
|
|
26543
26534
|
throw new Error('Cannot load objects: no active workspace is loaded');
|
|
26544
26535
|
}
|
|
@@ -26678,7 +26669,7 @@ const KritzelEngine = class {
|
|
|
26678
26669
|
}
|
|
26679
26670
|
/** Returns the currently active workspace. */
|
|
26680
26671
|
async getActiveWorkspace() {
|
|
26681
|
-
const activeWorkspace = this.core.store.activeWorkspace;
|
|
26672
|
+
const activeWorkspace = this.core.store.state.activeWorkspace;
|
|
26682
26673
|
if (!activeWorkspace) {
|
|
26683
26674
|
throw new Error('No active workspace is loaded');
|
|
26684
26675
|
}
|
|
@@ -26711,7 +26702,7 @@ const KritzelEngine = class {
|
|
|
26711
26702
|
this.workspacesChange.emit(this.core.store.state.workspaces);
|
|
26712
26703
|
this.core.beforeWorkspaceChange();
|
|
26713
26704
|
await this.initializeWorkspaceIfNeeded(workspace);
|
|
26714
|
-
this.activeWorkspaceChange.emit(this.core.store.activeWorkspace);
|
|
26705
|
+
this.activeWorkspaceChange.emit(this.core.store.state.activeWorkspace);
|
|
26715
26706
|
}
|
|
26716
26707
|
/**
|
|
26717
26708
|
* Reinitializes sync by performing a full teardown and re-initialization.
|
|
@@ -26733,6 +26724,7 @@ const KritzelEngine = class {
|
|
|
26733
26724
|
keyHandler;
|
|
26734
26725
|
contextMenuElement = null;
|
|
26735
26726
|
_lastHadSelectionGroup = false;
|
|
26727
|
+
_isViewportReady = false;
|
|
26736
26728
|
_isYjsInitialized = false;
|
|
26737
26729
|
_isResolvingActiveWorkspaceId = false;
|
|
26738
26730
|
_stateChangeListenersRegistered = false;
|
|
@@ -26806,6 +26798,7 @@ const KritzelEngine = class {
|
|
|
26806
26798
|
this.contextMenuHandler = new KritzelContextMenuHandler(this.core, this.globalContextMenuItems, this.objectContextMenuItems);
|
|
26807
26799
|
this.keyHandler = new KritzelKeyHandler(this.core);
|
|
26808
26800
|
this.viewport = new KritzelViewport(this.core, this.host);
|
|
26801
|
+
this._isViewportReady = true;
|
|
26809
26802
|
// Initialize cursor manager with target element and shadow root
|
|
26810
26803
|
this.core.cursorManager.setTargetElement(this.cursorTarget || document.body);
|
|
26811
26804
|
if (this.host.shadowRoot) {
|
|
@@ -26871,7 +26864,7 @@ const KritzelEngine = class {
|
|
|
26871
26864
|
await this.initializeWorkspaceIfNeeded(startupWorkspace);
|
|
26872
26865
|
}
|
|
26873
26866
|
// Emit initial active workspace once startup initialization has completed
|
|
26874
|
-
const initialActiveWorkspace = this.core.store.activeWorkspace;
|
|
26867
|
+
const initialActiveWorkspace = this.core.store.state.activeWorkspace;
|
|
26875
26868
|
if (initialActiveWorkspace) {
|
|
26876
26869
|
this.activeWorkspaceChange.emit(initialActiveWorkspace);
|
|
26877
26870
|
}
|
|
@@ -26900,7 +26893,7 @@ const KritzelEngine = class {
|
|
|
26900
26893
|
if (!this.activeWorkspaceId || this._isResolvingActiveWorkspaceId) {
|
|
26901
26894
|
return;
|
|
26902
26895
|
}
|
|
26903
|
-
if (this.core.store.activeWorkspace?.id === this.activeWorkspaceId) {
|
|
26896
|
+
if (this.core.store.state.activeWorkspace?.id === this.activeWorkspaceId) {
|
|
26904
26897
|
return;
|
|
26905
26898
|
}
|
|
26906
26899
|
this._isResolvingActiveWorkspaceId = true;
|
|
@@ -26916,17 +26909,17 @@ const KritzelEngine = class {
|
|
|
26916
26909
|
}
|
|
26917
26910
|
return;
|
|
26918
26911
|
}
|
|
26919
|
-
if (this.core.store.activeWorkspace?.id === workspace.id) {
|
|
26912
|
+
if (this.core.store.state.activeWorkspace?.id === workspace.id) {
|
|
26920
26913
|
return;
|
|
26921
26914
|
}
|
|
26922
26915
|
this.core.beforeWorkspaceChange();
|
|
26923
26916
|
await this.initializeWorkspaceIfNeeded(workspace);
|
|
26924
|
-
this.activeWorkspaceChange.emit(this.core.store.activeWorkspace);
|
|
26917
|
+
this.activeWorkspaceChange.emit(this.core.store.state.activeWorkspace);
|
|
26925
26918
|
}
|
|
26926
26919
|
async initializeWorkspaceIfNeeded(workspace, options) {
|
|
26927
26920
|
const targetWorkspaceId = workspace?.id ?? null;
|
|
26928
26921
|
const targetKey = targetWorkspaceId ?? (options?.skipFallbackCreation ? '__NO_FALLBACK__' : '__AUTO__');
|
|
26929
|
-
if (targetWorkspaceId && this.core.store.activeWorkspace?.id === targetWorkspaceId) {
|
|
26922
|
+
if (targetWorkspaceId && this.core.store.state.activeWorkspace?.id === targetWorkspaceId) {
|
|
26930
26923
|
return;
|
|
26931
26924
|
}
|
|
26932
26925
|
if (this._workspaceInitializationPromise && this._workspaceInitializationTargetKey === targetKey) {
|
|
@@ -28693,7 +28686,7 @@ const KritzelPortal = class {
|
|
|
28693
28686
|
* This file is auto-generated by the version bump scripts.
|
|
28694
28687
|
* Do not modify manually.
|
|
28695
28688
|
*/
|
|
28696
|
-
const KRITZEL_VERSION = '0.1.
|
|
28689
|
+
const KRITZEL_VERSION = '0.1.82';
|
|
28697
28690
|
|
|
28698
28691
|
const kritzelSettingsCss = () => `:host{display:contents}kritzel-dialog{--kritzel-dialog-body-padding:0;--kritzel-dialog-width-large:800px;--kritzel-dialog-height-large:500px}.footer-button{padding:8px 16px;border-radius:6px;cursor:pointer;font-size:14px}.cancel-button{border:1px solid #ebebeb;background:#fff;color:inherit}.cancel-button:hover{background:#f5f5f5}.settings-content{padding:0}.settings-content h3{margin:0 0 16px 0;font-size:18px;font-weight:600;color:var(--kritzel-settings-content-heading-color, #333333)}.settings-content p{margin:0;font-size:14px;color:var(--kritzel-settings-content-text-color, #666666);line-height:1.5}.settings-group{display:flex;flex-direction:column;gap:24px}.settings-item{display:flex;flex-direction:column;gap:8px}.settings-row{display:flex;align-items:center;justify-content:space-between;gap:16px}.settings-label{font-size:14px;font-weight:600;color:var(--kritzel-settings-label-color, #333333);margin:0 0 4px 0}.settings-description{font-size:12px;color:var(--kritzel-settings-description-color, #888888);margin:0;line-height:1.4}.shortcuts-list{display:flex;flex-direction:column;gap:24px}.shortcuts-category{display:flex;flex-direction:column;gap:8px}.shortcuts-category-title{font-size:14px;font-weight:600;color:var(--kritzel-settings-label-color, #333333);margin:0 0 4px 0}.shortcuts-group{display:flex;flex-direction:column;gap:4px}.shortcut-item{display:flex;justify-content:space-between;align-items:center;padding:6px 8px;border-radius:4px;background:var(--kritzel-settings-shortcut-item-bg, rgba(0, 0, 0, 0.02))}.shortcut-label{font-size:14px;color:var(--kritzel-settings-content-text-color, #666666)}.shortcut-key{font-family:monospace;font-size:12px;padding:2px 8px;border-radius:4px;background:var(--kritzel-settings-shortcut-key-bg, #f0f0f0);color:var(--kritzel-settings-shortcut-key-color, #333333);border:1px solid var(--kritzel-settings-shortcut-key-border, #ddd)}`;
|
|
28699
28692
|
|