kritzel-stencil 0.3.24 → 0.3.25
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_45.cjs.entry.js +55 -36
- package/dist/cjs/{schema.constants-D8JoUfNc.js → schema.constants-Np7j2Gz4.js} +13 -2
- package/dist/collection/classes/managers/anchor.manager.js +13 -2
- package/dist/collection/classes/managers/clipboard.manager.js +7 -0
- package/dist/collection/components/core/kritzel-engine/kritzel-engine.js +46 -34
- package/dist/collection/constants/version.js +1 -1
- package/dist/components/index.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/p-6_95PFq4.js +9 -0
- package/dist/components/{p-Bz_zj6dQ.js → p-DF0S4FqL.js} +1 -1
- package/dist/esm/index.js +2 -2
- package/dist/esm/kritzel-active-users_45.entry.js +55 -36
- package/dist/esm/{schema.constants-B3IqnD8l.js → schema.constants-1SDhlkfS.js} +13 -2
- package/dist/stencil/index.esm.js +1 -1
- package/dist/stencil/{p-B3IqnD8l.js → p-1SDhlkfS.js} +1 -1
- package/dist/stencil/{p-63bc234f.entry.js → p-7ba7df62.entry.js} +2 -2
- package/dist/stencil/stencil.esm.js +1 -1
- package/dist/types/classes/managers/anchor.manager.d.ts +4 -1
- package/dist/types/constants/version.d.ts +1 -1
- package/package.json +1 -1
- package/dist/components/p-on11Z8cZ.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-B43upypT.js";import{a,C as l}from"./p-CW-VyJgK.js";import{d as r}from"./p-DX2nriaq.js";import{d as c}from"./p-Df3BwVGy.js";import{d as h}from"./p-CdR76C4L.js";import{d as g}from"./p-D0v9WP5w.js";import{d}from"./p-BrAeYciD.js";import{d as p}from"./p-D0RYktBV.js";const u=-1/0,b=1/0,m=-1/0,f=1/0,v={showViewportInfo:!1,showObjectInfo:!1,showSyncProviderInfo:!0,showMigrationInfo:!0,showAssetResolverInfo:!1},w=["general","viewport","shortcuts","developer","about"],y=e(class extends t{constructor(e){super(),!1!==e&&this.__registerHost(),this.__attachShadow(),this.settingsChange=s(this,"settingsChange")}get host(){return this}availableThemes=["light","dark"];availableLocales=[];shortcuts=[];terms={};settings;onSettingsPropChange(e){e&&this.applySettings(e)}isDialogOpen=!1;selectedCategoryId=w[0];scaleMin=1e-4;scaleMax=1e3;lockDrawingScale=!0;theme="light";locale="en";viewportBoundaryLeft=u;viewportBoundaryRight=b;viewportBoundaryTop=m;viewportBoundaryBottom=f;debugInfo={...v};settingsChange;componentWillLoad(){this.settings&&this.applySettings(this.settings)}applySettings(e){"number"==typeof e.scaleMin&&(this.scaleMin=e.scaleMin),"number"==typeof e.scaleMax&&(this.scaleMax=e.scaleMax),"boolean"==typeof e.lockDrawingScale&&(this.lockDrawingScale=e.lockDrawingScale),"string"==typeof e.theme&&(this.theme=e.theme),"string"==typeof e.locale&&(this.locale=e.locale),"number"==typeof e.viewportBoundaryLeft&&(this.viewportBoundaryLeft=e.viewportBoundaryLeft),"number"==typeof e.viewportBoundaryRight&&(this.viewportBoundaryRight=e.viewportBoundaryRight),"number"==typeof e.viewportBoundaryTop&&(this.viewportBoundaryTop=e.viewportBoundaryTop),"number"==typeof e.viewportBoundaryBottom&&(this.viewportBoundaryBottom=e.viewportBoundaryBottom),e.debugInfo&&(this.debugInfo={...v,...e.debugInfo})}emitSettings(){this.settingsChange.emit({scaleMin:this.scaleMin,scaleMax:this.scaleMax,lockDrawingScale:this.lockDrawingScale,theme:this.theme,locale:this.locale,viewportBoundaryLeft:this.viewportBoundaryLeft,viewportBoundaryRight:this.viewportBoundaryRight,viewportBoundaryTop:this.viewportBoundaryTop,viewportBoundaryBottom:this.viewportBoundaryBottom,debugInfo:this.debugInfo})}handleScaleMinChange=e=>{this.scaleMin=e.detail,this.emitSettings()};handleScaleMaxChange=e=>{this.scaleMax=e.detail,this.emitSettings()};handleLockDrawingScaleChange=e=>{this.lockDrawingScale=e.detail,this.emitSettings()};handleThemeChange=e=>{this.theme=e.detail,this.emitSettings()};handleLocaleChange=e=>{this.locale=e.detail,this.emitSettings()};handleViewportBoundaryLeftChange=e=>{this.viewportBoundaryLeft=e.detail??u,this.emitSettings()};handleViewportBoundaryRightChange=e=>{this.viewportBoundaryRight=e.detail??b,this.emitSettings()};handleViewportBoundaryTopChange=e=>{this.viewportBoundaryTop=e.detail??m,this.emitSettings()};handleViewportBoundaryBottomChange=e=>{this.viewportBoundaryBottom=e.detail??f,this.emitSettings()};handleDebugInfoChange=e=>t=>{this.debugInfo={...this.debugInfo,[e]:t.detail},this.emitSettings()};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}t(e,t){return this.terms[e]??t}get categories(){const e={general:"settings",viewport:"viewport",shortcuts:"command",developer:"braces",about:"info"},t={general:{key:"settings.categories.general",fallback:"General"},viewport:{key:"settings.categories.viewport",fallback:"Viewport"},shortcuts:{key:"settings.categories.shortcuts",fallback:"Keyboard Shortcuts"},developer:{key:"settings.categories.developer",fallback:"Developer Options"},about:{key:"settings.categories.about",fallback:"About"}};return w.map((s=>({id:s,label:this.t(t[s].key,t[s].fallback),icon:e[s]})))}renderCategoryContent(){switch(this.selectedCategoryId){case"general":return i("div",{class:"settings-content"},i("h3",null,this.t("settings.general.title","General Settings")),i("div",{class:"settings-group"},i("div",{class:"settings-item"},i("label",{class:"settings-label"},this.t("settings.general.theme.label","Theme")),i("p",{class:"settings-description"},this.t("settings.general.theme.description","Select a registered color theme for the editor interface.")),i("kritzel-dropdown",{options:this.availableThemes.map((e=>({value:e,label:e}))),value:this.theme,onValueChanged:this.handleThemeChange})),this.availableLocales.length>0&&i("div",{class:"settings-item"},i("label",{class:"settings-label"},this.t("settings.general.language.label","Language")),i("p",{class:"settings-description"},this.t("settings.general.language.description","Select the display language for the editor interface.")),i("kritzel-dropdown",{options:this.availableLocales.map((e=>({value:e.code,label:e.label}))),value:this.locale,onValueChanged:this.handleLocaleChange})),i("div",{class:"settings-item"},i("label",{class:"settings-label"},this.t("settings.general.lockDrawingScale.label","Lock Drawing Scale")),i("p",{class:"settings-description"},this.t("settings.general.lockDrawingScale.description","When enabled, drawn objects maintain a fixed visual size regardless of the current zoom level.")),i("kritzel-slide-toggle",{checked:this.lockDrawingScale,label:this.t("settings.general.lockDrawingScale.label","Lock Drawing Scale"),onCheckedChange:this.handleLockDrawingScaleChange}))));case"viewport":return i("div",{class:"settings-content"},i("h3",null,this.t("settings.viewport.title","Viewport Settings")),i("div",{class:"settings-group"},i("div",{class:"settings-item"},i("label",{class:"settings-label"},this.t("settings.viewport.minZoom.label","Minimum Zoom Level")),i("p",{class:"settings-description"},this.t("settings.viewport.minZoom.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"},this.t("settings.viewport.maxZoom.label","Maximum Zoom Level")),i("p",{class:"settings-description"},this.t("settings.viewport.maxZoom.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"},this.t("settings.viewport.boundaryLeft.label","Viewport Boundary Left")),i("p",{class:"settings-description"},this.t("settings.viewport.boundaryLeft.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:this.t("settings.viewport.boundaryPlaceholder","Infinite"),onValueChange:this.handleViewportBoundaryLeftChange})),i("div",{class:"settings-item"},i("label",{class:"settings-label"},this.t("settings.viewport.boundaryRight.label","Viewport Boundary Right")),i("p",{class:"settings-description"},this.t("settings.viewport.boundaryRight.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:this.t("settings.viewport.boundaryPlaceholder","Infinite"),onValueChange:this.handleViewportBoundaryRightChange})),i("div",{class:"settings-item"},i("label",{class:"settings-label"},this.t("settings.viewport.boundaryTop.label","Viewport Boundary Top")),i("p",{class:"settings-description"},this.t("settings.viewport.boundaryTop.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:this.t("settings.viewport.boundaryPlaceholder","Infinite"),onValueChange:this.handleViewportBoundaryTopChange})),i("div",{class:"settings-item"},i("label",{class:"settings-label"},this.t("settings.viewport.boundaryBottom.label","Viewport Boundary Bottom")),i("p",{class:"settings-description"},this.t("settings.viewport.boundaryBottom.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:this.t("settings.viewport.boundaryPlaceholder","Infinite"),onValueChange:this.handleViewportBoundaryBottomChange}))));case"shortcuts":return i("div",{class:"settings-content"},i("h3",null,this.t("settings.shortcuts.title","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,this.t("settings.developer.title","Developer Options")),i("div",{class:"settings-group"},i("div",{class:"settings-item"},i("label",{class:"settings-label"},this.t("settings.developer.showViewportInfo.label","Show Viewport Info")),i("p",{class:"settings-description"},this.t("settings.developer.showViewportInfo.description","Display viewport debug information such as position, zoom level, and boundaries.")),i("kritzel-slide-toggle",{checked:this.debugInfo.showViewportInfo,label:this.t("settings.developer.showViewportInfo.label","Show Viewport Info"),onCheckedChange:this.handleDebugInfoChange("showViewportInfo")})),i("div",{class:"settings-item"},i("label",{class:"settings-label"},this.t("settings.developer.showObjectInfo.label","Show Object Info")),i("p",{class:"settings-description"},this.t("settings.developer.showObjectInfo.description","Display debug information about objects on the canvas.")),i("kritzel-slide-toggle",{checked:this.debugInfo.showObjectInfo,label:this.t("settings.developer.showObjectInfo.label","Show Object Info"),onCheckedChange:this.handleDebugInfoChange("showObjectInfo")})),i("div",{class:"settings-item"},i("label",{class:"settings-label"},this.t("settings.developer.showSyncProviderInfo.label","Show Sync Provider Info")),i("p",{class:"settings-description"},this.t("settings.developer.showSyncProviderInfo.description","Display debug information about the sync provider connection status.")),i("kritzel-slide-toggle",{checked:this.debugInfo.showSyncProviderInfo,label:this.t("settings.developer.showSyncProviderInfo.label","Show Sync Provider Info"),onCheckedChange:this.handleDebugInfoChange("showSyncProviderInfo")})),i("div",{class:"settings-item"},i("label",{class:"settings-label"},this.t("settings.developer.showMigrationInfo.label","Show Migration Info")),i("p",{class:"settings-description"},this.t("settings.developer.showMigrationInfo.description","Display debug information about data migrations.")),i("kritzel-slide-toggle",{checked:this.debugInfo.showMigrationInfo,label:this.t("settings.developer.showMigrationInfo.label","Show Migration Info"),onCheckedChange:this.handleDebugInfoChange("showMigrationInfo")}))));case"about":return i("div",{class:"settings-content"},i("h3",null,this.t("settings.about.title","About")),i("p",null,this.t("settings.about.description","Kritzel - A drawing application")),i("p",{class:"version-info"},"Version ","0.3.24"),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:"8b96261465efeabb2eb0cf724d29699de5e230a8"},i("kritzel-dialog",{key:"273a9df290bb97d59000a97f91821e7bad3f3896",isOpen:this.isDialogOpen,dialogTitle:this.t("settings.dialogTitle","Settings"),size:"large",contained:!0,onDialogClose:this.closeDialog},i("kritzel-master-detail",{key:"64d17dfaa2a0baf2d4a5d00fe5fc65ad40c96ec6",items:this.categories,selectedItemId:this.selectedCategoryId,onItemSelect:this.handleCategorySelect},this.renderCategoryContent())))}static get watchers(){return{settings:[{onSettingsPropChange:0}]}}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",{availableThemes:[16],availableLocales:[16],shortcuts:[16],terms:[16],settings:[16],isDialogOpen:[32],selectedCategoryId:[32],scaleMin:[32],scaleMax:[32],lockDrawingScale:[32],theme:[32],locale:[32],viewportBoundaryLeft:[32],viewportBoundaryRight:[32],viewportBoundaryTop:[32],viewportBoundaryBottom:[32],debugInfo:[32],open:[64]},void 0,{settings:[{onSettingsPropChange:0}]}]);function k(){"undefined"!=typeof customElements&&["kritzel-settings","kritzel-dialog","kritzel-dropdown","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-dropdown":customElements.get(n(e))||c();break;case"kritzel-icon":customElements.get(n(e))||h();break;case"kritzel-master-detail":customElements.get(n(e))||g();break;case"kritzel-numeric-input":customElements.get(n(e))||d();break;case"kritzel-slide-toggle":customElements.get(n(e))||p()}}))}export{y as K,k as d}
|
|
1
|
+
import{p as e,H as t,c as s,h as i,d as o,t as n}from"./p-B43upypT.js";import{a,C as l}from"./p-CW-VyJgK.js";import{d as r}from"./p-DX2nriaq.js";import{d as c}from"./p-Df3BwVGy.js";import{d as h}from"./p-CdR76C4L.js";import{d as g}from"./p-D0v9WP5w.js";import{d}from"./p-BrAeYciD.js";import{d as p}from"./p-D0RYktBV.js";const u=-1/0,b=1/0,m=-1/0,f=1/0,v={showViewportInfo:!1,showObjectInfo:!1,showSyncProviderInfo:!0,showMigrationInfo:!0,showAssetResolverInfo:!1},w=["general","viewport","shortcuts","developer","about"],y=e(class extends t{constructor(e){super(),!1!==e&&this.__registerHost(),this.__attachShadow(),this.settingsChange=s(this,"settingsChange")}get host(){return this}availableThemes=["light","dark"];availableLocales=[];shortcuts=[];terms={};settings;onSettingsPropChange(e){e&&this.applySettings(e)}isDialogOpen=!1;selectedCategoryId=w[0];scaleMin=1e-4;scaleMax=1e3;lockDrawingScale=!0;theme="light";locale="en";viewportBoundaryLeft=u;viewportBoundaryRight=b;viewportBoundaryTop=m;viewportBoundaryBottom=f;debugInfo={...v};settingsChange;componentWillLoad(){this.settings&&this.applySettings(this.settings)}applySettings(e){"number"==typeof e.scaleMin&&(this.scaleMin=e.scaleMin),"number"==typeof e.scaleMax&&(this.scaleMax=e.scaleMax),"boolean"==typeof e.lockDrawingScale&&(this.lockDrawingScale=e.lockDrawingScale),"string"==typeof e.theme&&(this.theme=e.theme),"string"==typeof e.locale&&(this.locale=e.locale),"number"==typeof e.viewportBoundaryLeft&&(this.viewportBoundaryLeft=e.viewportBoundaryLeft),"number"==typeof e.viewportBoundaryRight&&(this.viewportBoundaryRight=e.viewportBoundaryRight),"number"==typeof e.viewportBoundaryTop&&(this.viewportBoundaryTop=e.viewportBoundaryTop),"number"==typeof e.viewportBoundaryBottom&&(this.viewportBoundaryBottom=e.viewportBoundaryBottom),e.debugInfo&&(this.debugInfo={...v,...e.debugInfo})}emitSettings(){this.settingsChange.emit({scaleMin:this.scaleMin,scaleMax:this.scaleMax,lockDrawingScale:this.lockDrawingScale,theme:this.theme,locale:this.locale,viewportBoundaryLeft:this.viewportBoundaryLeft,viewportBoundaryRight:this.viewportBoundaryRight,viewportBoundaryTop:this.viewportBoundaryTop,viewportBoundaryBottom:this.viewportBoundaryBottom,debugInfo:this.debugInfo})}handleScaleMinChange=e=>{this.scaleMin=e.detail,this.emitSettings()};handleScaleMaxChange=e=>{this.scaleMax=e.detail,this.emitSettings()};handleLockDrawingScaleChange=e=>{this.lockDrawingScale=e.detail,this.emitSettings()};handleThemeChange=e=>{this.theme=e.detail,this.emitSettings()};handleLocaleChange=e=>{this.locale=e.detail,this.emitSettings()};handleViewportBoundaryLeftChange=e=>{this.viewportBoundaryLeft=e.detail??u,this.emitSettings()};handleViewportBoundaryRightChange=e=>{this.viewportBoundaryRight=e.detail??b,this.emitSettings()};handleViewportBoundaryTopChange=e=>{this.viewportBoundaryTop=e.detail??m,this.emitSettings()};handleViewportBoundaryBottomChange=e=>{this.viewportBoundaryBottom=e.detail??f,this.emitSettings()};handleDebugInfoChange=e=>t=>{this.debugInfo={...this.debugInfo,[e]:t.detail},this.emitSettings()};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}t(e,t){return this.terms[e]??t}get categories(){const e={general:"settings",viewport:"viewport",shortcuts:"command",developer:"braces",about:"info"},t={general:{key:"settings.categories.general",fallback:"General"},viewport:{key:"settings.categories.viewport",fallback:"Viewport"},shortcuts:{key:"settings.categories.shortcuts",fallback:"Keyboard Shortcuts"},developer:{key:"settings.categories.developer",fallback:"Developer Options"},about:{key:"settings.categories.about",fallback:"About"}};return w.map((s=>({id:s,label:this.t(t[s].key,t[s].fallback),icon:e[s]})))}renderCategoryContent(){switch(this.selectedCategoryId){case"general":return i("div",{class:"settings-content"},i("h3",null,this.t("settings.general.title","General Settings")),i("div",{class:"settings-group"},i("div",{class:"settings-item"},i("label",{class:"settings-label"},this.t("settings.general.theme.label","Theme")),i("p",{class:"settings-description"},this.t("settings.general.theme.description","Select a registered color theme for the editor interface.")),i("kritzel-dropdown",{options:this.availableThemes.map((e=>({value:e,label:e}))),value:this.theme,onValueChanged:this.handleThemeChange})),this.availableLocales.length>0&&i("div",{class:"settings-item"},i("label",{class:"settings-label"},this.t("settings.general.language.label","Language")),i("p",{class:"settings-description"},this.t("settings.general.language.description","Select the display language for the editor interface.")),i("kritzel-dropdown",{options:this.availableLocales.map((e=>({value:e.code,label:e.label}))),value:this.locale,onValueChanged:this.handleLocaleChange})),i("div",{class:"settings-item"},i("label",{class:"settings-label"},this.t("settings.general.lockDrawingScale.label","Lock Drawing Scale")),i("p",{class:"settings-description"},this.t("settings.general.lockDrawingScale.description","When enabled, drawn objects maintain a fixed visual size regardless of the current zoom level.")),i("kritzel-slide-toggle",{checked:this.lockDrawingScale,label:this.t("settings.general.lockDrawingScale.label","Lock Drawing Scale"),onCheckedChange:this.handleLockDrawingScaleChange}))));case"viewport":return i("div",{class:"settings-content"},i("h3",null,this.t("settings.viewport.title","Viewport Settings")),i("div",{class:"settings-group"},i("div",{class:"settings-item"},i("label",{class:"settings-label"},this.t("settings.viewport.minZoom.label","Minimum Zoom Level")),i("p",{class:"settings-description"},this.t("settings.viewport.minZoom.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"},this.t("settings.viewport.maxZoom.label","Maximum Zoom Level")),i("p",{class:"settings-description"},this.t("settings.viewport.maxZoom.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"},this.t("settings.viewport.boundaryLeft.label","Viewport Boundary Left")),i("p",{class:"settings-description"},this.t("settings.viewport.boundaryLeft.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:this.t("settings.viewport.boundaryPlaceholder","Infinite"),onValueChange:this.handleViewportBoundaryLeftChange})),i("div",{class:"settings-item"},i("label",{class:"settings-label"},this.t("settings.viewport.boundaryRight.label","Viewport Boundary Right")),i("p",{class:"settings-description"},this.t("settings.viewport.boundaryRight.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:this.t("settings.viewport.boundaryPlaceholder","Infinite"),onValueChange:this.handleViewportBoundaryRightChange})),i("div",{class:"settings-item"},i("label",{class:"settings-label"},this.t("settings.viewport.boundaryTop.label","Viewport Boundary Top")),i("p",{class:"settings-description"},this.t("settings.viewport.boundaryTop.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:this.t("settings.viewport.boundaryPlaceholder","Infinite"),onValueChange:this.handleViewportBoundaryTopChange})),i("div",{class:"settings-item"},i("label",{class:"settings-label"},this.t("settings.viewport.boundaryBottom.label","Viewport Boundary Bottom")),i("p",{class:"settings-description"},this.t("settings.viewport.boundaryBottom.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:this.t("settings.viewport.boundaryPlaceholder","Infinite"),onValueChange:this.handleViewportBoundaryBottomChange}))));case"shortcuts":return i("div",{class:"settings-content"},i("h3",null,this.t("settings.shortcuts.title","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,this.t("settings.developer.title","Developer Options")),i("div",{class:"settings-group"},i("div",{class:"settings-item"},i("label",{class:"settings-label"},this.t("settings.developer.showViewportInfo.label","Show Viewport Info")),i("p",{class:"settings-description"},this.t("settings.developer.showViewportInfo.description","Display viewport debug information such as position, zoom level, and boundaries.")),i("kritzel-slide-toggle",{checked:this.debugInfo.showViewportInfo,label:this.t("settings.developer.showViewportInfo.label","Show Viewport Info"),onCheckedChange:this.handleDebugInfoChange("showViewportInfo")})),i("div",{class:"settings-item"},i("label",{class:"settings-label"},this.t("settings.developer.showObjectInfo.label","Show Object Info")),i("p",{class:"settings-description"},this.t("settings.developer.showObjectInfo.description","Display debug information about objects on the canvas.")),i("kritzel-slide-toggle",{checked:this.debugInfo.showObjectInfo,label:this.t("settings.developer.showObjectInfo.label","Show Object Info"),onCheckedChange:this.handleDebugInfoChange("showObjectInfo")})),i("div",{class:"settings-item"},i("label",{class:"settings-label"},this.t("settings.developer.showSyncProviderInfo.label","Show Sync Provider Info")),i("p",{class:"settings-description"},this.t("settings.developer.showSyncProviderInfo.description","Display debug information about the sync provider connection status.")),i("kritzel-slide-toggle",{checked:this.debugInfo.showSyncProviderInfo,label:this.t("settings.developer.showSyncProviderInfo.label","Show Sync Provider Info"),onCheckedChange:this.handleDebugInfoChange("showSyncProviderInfo")})),i("div",{class:"settings-item"},i("label",{class:"settings-label"},this.t("settings.developer.showMigrationInfo.label","Show Migration Info")),i("p",{class:"settings-description"},this.t("settings.developer.showMigrationInfo.description","Display debug information about data migrations.")),i("kritzel-slide-toggle",{checked:this.debugInfo.showMigrationInfo,label:this.t("settings.developer.showMigrationInfo.label","Show Migration Info"),onCheckedChange:this.handleDebugInfoChange("showMigrationInfo")}))));case"about":return i("div",{class:"settings-content"},i("h3",null,this.t("settings.about.title","About")),i("p",null,this.t("settings.about.description","Kritzel - A drawing application")),i("p",{class:"version-info"},"Version ","0.3.25"),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:"8b96261465efeabb2eb0cf724d29699de5e230a8"},i("kritzel-dialog",{key:"273a9df290bb97d59000a97f91821e7bad3f3896",isOpen:this.isDialogOpen,dialogTitle:this.t("settings.dialogTitle","Settings"),size:"large",contained:!0,onDialogClose:this.closeDialog},i("kritzel-master-detail",{key:"64d17dfaa2a0baf2d4a5d00fe5fc65ad40c96ec6",items:this.categories,selectedItemId:this.selectedCategoryId,onItemSelect:this.handleCategorySelect},this.renderCategoryContent())))}static get watchers(){return{settings:[{onSettingsPropChange:0}]}}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",{availableThemes:[16],availableLocales:[16],shortcuts:[16],terms:[16],settings:[16],isDialogOpen:[32],selectedCategoryId:[32],scaleMin:[32],scaleMax:[32],lockDrawingScale:[32],theme:[32],locale:[32],viewportBoundaryLeft:[32],viewportBoundaryRight:[32],viewportBoundaryTop:[32],viewportBoundaryBottom:[32],debugInfo:[32],open:[64]},void 0,{settings:[{onSettingsPropChange:0}]}]);function k(){"undefined"!=typeof customElements&&["kritzel-settings","kritzel-dialog","kritzel-dropdown","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-dropdown":customElements.get(n(e))||c();break;case"kritzel-icon":customElements.get(n(e))||h();break;case"kritzel-master-detail":customElements.get(n(e))||g();break;case"kritzel-numeric-input":customElements.get(n(e))||d();break;case"kritzel-slide-toggle":customElements.get(n(e))||p()}}))}export{y as K,k as d}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { H as HocuspocusProvider, a as HocuspocusProviderWebsocket } from './schema.constants-
|
|
2
|
-
export { N as APP_STATE_MIGRATIONS, A as AssetNotFoundError, P as CURRENT_APP_STATE_SCHEMA_VERSION, Q as CURRENT_WORKSPACE_SCHEMA_VERSION, B as DEFAULT_ASSET_STORAGE_CONFIG, D as DEFAULT_BRUSH_CONFIG, z as DEFAULT_LINE_TOOL_CONFIG, y as DEFAULT_TEXT_CONFIG, G as DE_LOCALE, F as EN_LOCALE, J as FR_LOCALE, I as IndexedDBAssetProvider, L as KritzelAlignment, t as KritzelAnchorManager, r as KritzelAssetResolver, K as KritzelBaseObject, i as KritzelBaseTool, j as KritzelBrushTool, p as KritzelCursorHelper, h as KritzelCustomElement, x as KritzelCustomElementRendererRegistry, l as KritzelEraserTool, f as KritzelGroup, d as KritzelImage, m as KritzelImageTool, w as KritzelLicenseManager, e as KritzelLine, k as KritzelLineTool, v as KritzelLocalizationManager, c as KritzelPath, q as KritzelSelectionTool, g as KritzelShape, o as KritzelShapeTool, b as KritzelText, n as KritzelTextTool, u as KritzelThemeManager, s as KritzelWorkspace, S as ShapeType, W as WORKSPACE_EXPORT_VERSION, O as WORKSPACE_MIGRATIONS, E as darkTheme, C as lightTheme, M as runMigrations } from './schema.constants-
|
|
1
|
+
import { H as HocuspocusProvider, a as HocuspocusProviderWebsocket } from './schema.constants-1SDhlkfS.js';
|
|
2
|
+
export { N as APP_STATE_MIGRATIONS, A as AssetNotFoundError, P as CURRENT_APP_STATE_SCHEMA_VERSION, Q as CURRENT_WORKSPACE_SCHEMA_VERSION, B as DEFAULT_ASSET_STORAGE_CONFIG, D as DEFAULT_BRUSH_CONFIG, z as DEFAULT_LINE_TOOL_CONFIG, y as DEFAULT_TEXT_CONFIG, G as DE_LOCALE, F as EN_LOCALE, J as FR_LOCALE, I as IndexedDBAssetProvider, L as KritzelAlignment, t as KritzelAnchorManager, r as KritzelAssetResolver, K as KritzelBaseObject, i as KritzelBaseTool, j as KritzelBrushTool, p as KritzelCursorHelper, h as KritzelCustomElement, x as KritzelCustomElementRendererRegistry, l as KritzelEraserTool, f as KritzelGroup, d as KritzelImage, m as KritzelImageTool, w as KritzelLicenseManager, e as KritzelLine, k as KritzelLineTool, v as KritzelLocalizationManager, c as KritzelPath, q as KritzelSelectionTool, g as KritzelShape, o as KritzelShapeTool, b as KritzelText, n as KritzelTextTool, u as KritzelThemeManager, s as KritzelWorkspace, S as ShapeType, W as WORKSPACE_EXPORT_VERSION, O as WORKSPACE_MIGRATIONS, E as darkTheme, C as lightTheme, M as runMigrations } from './schema.constants-1SDhlkfS.js';
|
|
3
3
|
import * as Y from 'yjs';
|
|
4
4
|
import { IndexeddbPersistence } from 'y-indexeddb';
|
|
5
5
|
import { WebsocketProvider } from 'y-websocket';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { r as registerInstance, h, H as Host, c as createEvent, g as getElement } from './index-Dhio9uis.js';
|
|
2
|
-
import { c as KritzelPath, e as KritzelLine, R as KritzelColorHelper, T as KritzelDevicesHelper, q as KritzelSelectionTool, n as KritzelTextTool, U as KritzelMouseButton, V as KritzelHTMLHelper, X as DEFAULT_STROKE_SIZES, Y as DEFAULT_COLOR_PALETTE, S as ShapeType, D as DEFAULT_BRUSH_CONFIG, j as KritzelBrushTool, l as KritzelEraserTool, z as DEFAULT_LINE_TOOL_CONFIG, k as KritzelLineTool, o as KritzelShapeTool, y as DEFAULT_TEXT_CONFIG, m as KritzelImageTool, L as KritzelAlignment, B as DEFAULT_ASSET_STORAGE_CONFIG, Z as ObjectHelper, _ as ThemeHelper, E as darkTheme, C as lightTheme, $ as KritzelSelectionGroup, a0 as KritzelSelectionBox, a1 as KritzelIconRegistry, a2 as KritzelKeyboardHelper, a3 as KritzelBaseHandler, s as KritzelWorkspace, f as KritzelGroup, h as KritzelCustomElement, d as KritzelImage, g as KritzelShape, b as KritzelText, M as runMigrations, Q as CURRENT_WORKSPACE_SCHEMA_VERSION, O as WORKSPACE_MIGRATIONS, a4 as KritzelClassHelper, P as CURRENT_APP_STATE_SCHEMA_VERSION, N as APP_STATE_MIGRATIONS, p as KritzelCursorHelper, a5 as imageCompression, t as KritzelAnchorManager, u as KritzelThemeManager, v as KritzelLocalizationManager, w as KritzelLicenseManager, r as KritzelAssetResolver, a6 as KritzelEventHelper, W as WORKSPACE_EXPORT_VERSION } from './schema.constants-
|
|
2
|
+
import { c as KritzelPath, e as KritzelLine, R as KritzelColorHelper, T as KritzelDevicesHelper, q as KritzelSelectionTool, n as KritzelTextTool, U as KritzelMouseButton, V as KritzelHTMLHelper, X as DEFAULT_STROKE_SIZES, Y as DEFAULT_COLOR_PALETTE, S as ShapeType, D as DEFAULT_BRUSH_CONFIG, j as KritzelBrushTool, l as KritzelEraserTool, z as DEFAULT_LINE_TOOL_CONFIG, k as KritzelLineTool, o as KritzelShapeTool, y as DEFAULT_TEXT_CONFIG, m as KritzelImageTool, L as KritzelAlignment, B as DEFAULT_ASSET_STORAGE_CONFIG, Z as ObjectHelper, _ as ThemeHelper, E as darkTheme, C as lightTheme, $ as KritzelSelectionGroup, a0 as KritzelSelectionBox, a1 as KritzelIconRegistry, a2 as KritzelKeyboardHelper, a3 as KritzelBaseHandler, s as KritzelWorkspace, f as KritzelGroup, h as KritzelCustomElement, d as KritzelImage, g as KritzelShape, b as KritzelText, M as runMigrations, Q as CURRENT_WORKSPACE_SCHEMA_VERSION, O as WORKSPACE_MIGRATIONS, a4 as KritzelClassHelper, P as CURRENT_APP_STATE_SCHEMA_VERSION, N as APP_STATE_MIGRATIONS, p as KritzelCursorHelper, a5 as imageCompression, t as KritzelAnchorManager, u as KritzelThemeManager, v as KritzelLocalizationManager, w as KritzelLicenseManager, r as KritzelAssetResolver, a6 as KritzelEventHelper, W as WORKSPACE_EXPORT_VERSION } from './schema.constants-1SDhlkfS.js';
|
|
3
3
|
import * as Y from 'yjs';
|
|
4
4
|
import 'y-indexeddb';
|
|
5
5
|
import 'y-websocket';
|
|
@@ -24135,6 +24135,7 @@ class KritzelClipboardManager {
|
|
|
24135
24135
|
*/
|
|
24136
24136
|
regenerateIdsAndRemapAnchors(topLevel) {
|
|
24137
24137
|
const all = [];
|
|
24138
|
+
const hasOnlyTopLevelLines = topLevel.length > 0 && topLevel.every(object => KritzelClassHelper.isInstanceOf(object, 'KritzelLine'));
|
|
24138
24139
|
const collect = (objects) => {
|
|
24139
24140
|
for (const object of objects) {
|
|
24140
24141
|
all.push(object);
|
|
@@ -24159,9 +24160,15 @@ class KritzelClipboardManager {
|
|
|
24159
24160
|
if (object.startAnchor && idMap.has(object.startAnchor.objectId)) {
|
|
24160
24161
|
object.startAnchor = { objectId: idMap.get(object.startAnchor.objectId) };
|
|
24161
24162
|
}
|
|
24163
|
+
else if (hasOnlyTopLevelLines) {
|
|
24164
|
+
object.startAnchor = undefined;
|
|
24165
|
+
}
|
|
24162
24166
|
if (object.endAnchor && idMap.has(object.endAnchor.objectId)) {
|
|
24163
24167
|
object.endAnchor = { objectId: idMap.get(object.endAnchor.objectId) };
|
|
24164
24168
|
}
|
|
24169
|
+
else if (hasOnlyTopLevelLines) {
|
|
24170
|
+
object.endAnchor = undefined;
|
|
24171
|
+
}
|
|
24165
24172
|
}
|
|
24166
24173
|
}
|
|
24167
24174
|
}
|
|
@@ -29390,7 +29397,11 @@ const KritzelEngine = class {
|
|
|
29390
29397
|
transform: object?.transformationMatrix,
|
|
29391
29398
|
transformOrigin: 'top left',
|
|
29392
29399
|
position: 'absolute',
|
|
29393
|
-
|
|
29400
|
+
// The object wrapper establishes its own stacking context (transform + z-index),
|
|
29401
|
+
// so the selection-line handles inside it cannot escape above the snap/anchor
|
|
29402
|
+
// layers (z-index 9999/9998) rendered later at the origin level. Lift the
|
|
29403
|
+
// selected line's wrapper above those layers so its handles always paint on top.
|
|
29404
|
+
zIndex: this.core.displaySelectionLineUI(object) ? '10001' : object.zIndex.toString(),
|
|
29394
29405
|
pointerEvents: getObjectWrapperPointerEvents(object),
|
|
29395
29406
|
} }, KritzelClassHelper.isInstanceOf(object, 'KritzelPath') && (h("svg", { ref: el => el && object.mount(el), xmlns: "http://www.w3.org/2000/svg", style: {
|
|
29396
29407
|
height: object?.totalHeight + 'px',
|
|
@@ -29594,10 +29605,19 @@ const KritzelEngine = class {
|
|
|
29594
29605
|
}
|
|
29595
29606
|
const selectionBorderColor = remoteUserColor ?? (KritzelColorHelper.resolveThemeColor(object.borderColor, currentTheme) || 'var(--kritzel-selection-border-color, #007AFF)');
|
|
29596
29607
|
const selectionHandleStrokeColor = remoteUserColor ?? 'var(--kritzel-selection-handle-stroke-color, #007AFF)';
|
|
29608
|
+
const lineObject = object;
|
|
29609
|
+
const activeSnapCandidate = this.core.store.state.snapCandidate;
|
|
29610
|
+
const isStartHandleSnapped = lineObject.startAnchor != null;
|
|
29611
|
+
const isEndHandleSnapped = lineObject.endAnchor != null;
|
|
29612
|
+
const isStartHandleSnapPreview = activeSnapCandidate?.endpoint === 'start';
|
|
29613
|
+
const isEndHandleSnapPreview = activeSnapCandidate?.endpoint === 'end';
|
|
29614
|
+
const isStartHandleHighlighted = isStartHandleSnapped || isStartHandleSnapPreview;
|
|
29615
|
+
const isEndHandleHighlighted = isEndHandleSnapped || isEndHandleSnapPreview;
|
|
29616
|
+
const selectionOverlayZIndex = this.core.displaySelectionLineUI(object) ? '10000' : (object.zIndex + 1).toString();
|
|
29597
29617
|
const handleScale = object.scale ?? 1;
|
|
29598
29618
|
const { canRenderResizeHandles, canRenderRotationHandle } = this.getSelectionHandleCapabilities(object);
|
|
29599
29619
|
return (h("svg", { xmlns: "http://www.w3.org/2000/svg", style: {
|
|
29600
|
-
zIndex:
|
|
29620
|
+
zIndex: selectionOverlayZIndex,
|
|
29601
29621
|
height: object?.totalHeight.toString(),
|
|
29602
29622
|
width: object?.totalWidth.toString(),
|
|
29603
29623
|
left: '0',
|
|
@@ -29688,7 +29708,7 @@ const KritzelEngine = class {
|
|
|
29688
29708
|
strokeLinecap: 'round',
|
|
29689
29709
|
fill: 'none',
|
|
29690
29710
|
} })), !this.isSelecting && !isRemoteSelection && (h("g", { class: "selection-line-handles", style: { pointerEvents: 'auto' } }, h("circle", { class: "selection-line-handle start", cx: object.startX - object.x, cy: object.startY - object.y, r: `${((baseHandleSize - 1) * object.scale) / this.core.store.state?.scale}`, style: {
|
|
29691
|
-
fill: 'var(--kritzel-selection-handle-color, #000000)',
|
|
29711
|
+
fill: isStartHandleHighlighted ? selectionHandleStrokeColor : 'var(--kritzel-selection-handle-color, #000000)',
|
|
29692
29712
|
stroke: selectionHandleStrokeColor,
|
|
29693
29713
|
strokeWidth: `calc(2px * ${object.scale} / ${this.core.store.state?.scale})`,
|
|
29694
29714
|
paintOrder: 'fill',
|
|
@@ -29712,7 +29732,7 @@ const KritzelEngine = class {
|
|
|
29712
29732
|
fill: 'transparent',
|
|
29713
29733
|
paintOrder: 'fill',
|
|
29714
29734
|
} }), h("circle", { class: "selection-line-handle end", cx: object.endX - object.x, cy: object.endY - object.y, r: `${((baseHandleSize - 1) * object.scale) / this.core.store.state?.scale}`, style: {
|
|
29715
|
-
fill: 'var(--kritzel-selection-handle-color, #000000)',
|
|
29735
|
+
fill: isEndHandleHighlighted ? selectionHandleStrokeColor : 'var(--kritzel-selection-handle-color, #000000)',
|
|
29716
29736
|
stroke: selectionHandleStrokeColor,
|
|
29717
29737
|
strokeWidth: `calc(2px * ${object.scale} / ${this.core.store.state?.scale})`,
|
|
29718
29738
|
paintOrder: 'fill',
|
|
@@ -29722,6 +29742,34 @@ const KritzelEngine = class {
|
|
|
29722
29742
|
} })))))));
|
|
29723
29743
|
})()));
|
|
29724
29744
|
}), (() => {
|
|
29745
|
+
const data = this.core.anchorManager.getSnapIndicatorRenderData();
|
|
29746
|
+
if (!data)
|
|
29747
|
+
return null;
|
|
29748
|
+
return (h("svg", { xmlns: "http://www.w3.org/2000/svg", class: "snap-indicator", style: {
|
|
29749
|
+
position: 'absolute',
|
|
29750
|
+
left: '0',
|
|
29751
|
+
top: '0',
|
|
29752
|
+
width: '1px',
|
|
29753
|
+
height: '1px',
|
|
29754
|
+
pointerEvents: 'none',
|
|
29755
|
+
zIndex: '9999',
|
|
29756
|
+
overflow: 'visible',
|
|
29757
|
+
} }, h("g", null, data.snapLinePath ? (h("path", { d: data.snapLinePath, fill: "none", style: {
|
|
29758
|
+
stroke: 'var(--kritzel-snap-line-stroke, rgba(0, 0, 0, 0.2))',
|
|
29759
|
+
strokeWidth: data.lineStrokeWidth,
|
|
29760
|
+
strokeDasharray: data.dashArray,
|
|
29761
|
+
strokeLinecap: 'round',
|
|
29762
|
+
} })) : (data.edgeX !== undefined &&
|
|
29763
|
+
data.edgeY !== undefined && (h("line", { x1: data.edgeX, y1: data.edgeY, x2: data.centerX, y2: data.centerY, style: {
|
|
29764
|
+
stroke: 'var(--kritzel-snap-line-stroke, rgba(0, 0, 0, 0.2))',
|
|
29765
|
+
strokeWidth: data.lineStrokeWidth,
|
|
29766
|
+
strokeDasharray: data.dashArray,
|
|
29767
|
+
strokeLinecap: 'round',
|
|
29768
|
+
} }))), h("circle", { cx: data.centerX, cy: data.centerY, r: data.indicatorRadius, style: {
|
|
29769
|
+
fill: 'var(--kritzel-snap-indicator-fill, rgba(59, 130, 246, 0.3))',
|
|
29770
|
+
strokeWidth: data.indicatorStrokeWidth,
|
|
29771
|
+
} }))));
|
|
29772
|
+
})(), (() => {
|
|
29725
29773
|
const data = this.core.anchorManager.getAnchorLinesRenderData();
|
|
29726
29774
|
if (!data)
|
|
29727
29775
|
return null;
|
|
@@ -29746,7 +29794,7 @@ const KritzelEngine = class {
|
|
|
29746
29794
|
strokeDasharray: data.dashArray,
|
|
29747
29795
|
strokeLinecap: 'round',
|
|
29748
29796
|
} })), h("circle", { cx: data.startAnchorViz.centerX, cy: data.startAnchorViz.centerY, r: data.indicatorRadius, style: {
|
|
29749
|
-
fill: 'var(--kritzel-snap-indicator-fill, rgba(
|
|
29797
|
+
fill: 'var(--kritzel-snap-indicator-fill, rgba(59, 130, 246, 0.3))',
|
|
29750
29798
|
stroke: 'var(--kritzel-snap-indicator-stroke, #007bff)',
|
|
29751
29799
|
strokeWidth: data.indicatorStrokeWidth,
|
|
29752
29800
|
} }))), data.endAnchorViz && (h("g", { class: "anchor-line-end" }, data.endAnchorViz.pathD ? (h("path", { d: data.endAnchorViz.pathD, style: {
|
|
@@ -29765,35 +29813,6 @@ const KritzelEngine = class {
|
|
|
29765
29813
|
stroke: 'var(--kritzel-snap-indicator-stroke, #007bff)',
|
|
29766
29814
|
strokeWidth: data.indicatorStrokeWidth,
|
|
29767
29815
|
} })))));
|
|
29768
|
-
})(), (() => {
|
|
29769
|
-
const data = this.core.anchorManager.getSnapIndicatorRenderData();
|
|
29770
|
-
if (!data)
|
|
29771
|
-
return null;
|
|
29772
|
-
return (h("svg", { xmlns: "http://www.w3.org/2000/svg", class: "snap-indicator", style: {
|
|
29773
|
-
position: 'absolute',
|
|
29774
|
-
left: '0',
|
|
29775
|
-
top: '0',
|
|
29776
|
-
width: '1px',
|
|
29777
|
-
height: '1px',
|
|
29778
|
-
pointerEvents: 'none',
|
|
29779
|
-
zIndex: '9999',
|
|
29780
|
-
overflow: 'visible',
|
|
29781
|
-
} }, h("g", null, data.snapLinePath ? (h("path", { d: data.snapLinePath, fill: "none", style: {
|
|
29782
|
-
stroke: 'var(--kritzel-snap-line-stroke, rgba(0, 0, 0, 0.2))',
|
|
29783
|
-
strokeWidth: data.lineStrokeWidth,
|
|
29784
|
-
strokeDasharray: data.dashArray,
|
|
29785
|
-
strokeLinecap: 'round',
|
|
29786
|
-
} })) : (data.edgeX !== undefined &&
|
|
29787
|
-
data.edgeY !== undefined && (h("line", { x1: data.edgeX, y1: data.edgeY, x2: data.centerX, y2: data.centerY, style: {
|
|
29788
|
-
stroke: 'var(--kritzel-snap-line-stroke, rgba(0, 0, 0, 0.2))',
|
|
29789
|
-
strokeWidth: data.lineStrokeWidth,
|
|
29790
|
-
strokeDasharray: data.dashArray,
|
|
29791
|
-
strokeLinecap: 'round',
|
|
29792
|
-
} }))), h("circle", { cx: data.centerX, cy: data.centerY, r: data.indicatorRadius, style: {
|
|
29793
|
-
fill: 'var(--kritzel-snap-indicator-fill, rgba(59, 130, 246, 0.3))',
|
|
29794
|
-
stroke: 'var(--kritzel-snap-indicator-stroke, #007bff)',
|
|
29795
|
-
strokeWidth: data.indicatorStrokeWidth,
|
|
29796
|
-
} }))));
|
|
29797
29816
|
})()), this.core.store.state.isContextMenuVisible && (h("kritzel-context-menu", { class: "context-menu", ref: el => (this.contextMenuElement = el ?? null), items: this.core.store.state.contextMenuItems, objects: this.core.store.selectionGroup?.objects || [], style: {
|
|
29798
29817
|
position: 'absolute',
|
|
29799
29818
|
left: `${this.core.store.state.contextMenuX}px`,
|
|
@@ -31205,7 +31224,7 @@ const KritzelPortal = class {
|
|
|
31205
31224
|
* This file is auto-generated by the version bump scripts.
|
|
31206
31225
|
* Do not modify manually.
|
|
31207
31226
|
*/
|
|
31208
|
-
const KRITZEL_VERSION = '0.3.
|
|
31227
|
+
const KRITZEL_VERSION = '0.3.25';
|
|
31209
31228
|
|
|
31210
31229
|
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)}`;
|
|
31211
31230
|
|
|
@@ -27946,7 +27946,10 @@ class KritzelAnchorManager {
|
|
|
27946
27946
|
// Snap Detection
|
|
27947
27947
|
// ============================================
|
|
27948
27948
|
/**
|
|
27949
|
-
* Finds
|
|
27949
|
+
* Finds an object that can be snapped to when the cursor is sufficiently close to its center.
|
|
27950
|
+
* Snap is only triggered when the cursor is inside the object's bounds AND within 1/5 of the
|
|
27951
|
+
* shorter side from the center, so snapping activates only as the user approaches the center
|
|
27952
|
+
* and releases quickly as they move away.
|
|
27950
27953
|
* Returns null if no suitable snap target is found.
|
|
27951
27954
|
*
|
|
27952
27955
|
* @param worldX - X coordinate in world space
|
|
@@ -27975,7 +27978,15 @@ class KritzelAnchorManager {
|
|
|
27975
27978
|
const polygon = object.rotatedPolygon;
|
|
27976
27979
|
const points = [polygon.topLeft, polygon.topRight, polygon.bottomRight, polygon.bottomLeft];
|
|
27977
27980
|
if (KritzelGeometryHelper.isPointInPolygon({ x: worldX, y: worldY }, points)) {
|
|
27978
|
-
//
|
|
27981
|
+
// Only snap when the cursor is near the object's center (within 1/5 of the shorter side)
|
|
27982
|
+
const snapRadius = Math.min(object.width, object.height) / 5;
|
|
27983
|
+
const dx = worldX - object.centerX;
|
|
27984
|
+
const dy = worldY - object.centerY;
|
|
27985
|
+
const distanceToCenter = Math.sqrt(dx * dx + dy * dy);
|
|
27986
|
+
if (distanceToCenter > snapRadius) {
|
|
27987
|
+
continue;
|
|
27988
|
+
}
|
|
27989
|
+
// If inside and close enough to center, check if this object is "above" the current best target
|
|
27979
27990
|
if (object.zIndex > highestZIndex) {
|
|
27980
27991
|
highestZIndex = object.zIndex;
|
|
27981
27992
|
bestTarget = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{H as a,a as T}from"./p-B3IqnD8l.js";export{N as APP_STATE_MIGRATIONS,A as AssetNotFoundError,P as CURRENT_APP_STATE_SCHEMA_VERSION,Q as CURRENT_WORKSPACE_SCHEMA_VERSION,B as DEFAULT_ASSET_STORAGE_CONFIG,D as DEFAULT_BRUSH_CONFIG,z as DEFAULT_LINE_TOOL_CONFIG,y as DEFAULT_TEXT_CONFIG,G as DE_LOCALE,F as EN_LOCALE,J as FR_LOCALE,I as IndexedDBAssetProvider,L as KritzelAlignment,t as KritzelAnchorManager,r as KritzelAssetResolver,K as KritzelBaseObject,i as KritzelBaseTool,j as KritzelBrushTool,p as KritzelCursorHelper,h as KritzelCustomElement,x as KritzelCustomElementRendererRegistry,l as KritzelEraserTool,f as KritzelGroup,d as KritzelImage,m as KritzelImageTool,w as KritzelLicenseManager,e as KritzelLine,k as KritzelLineTool,v as KritzelLocalizationManager,c as KritzelPath,q as KritzelSelectionTool,g as KritzelShape,o as KritzelShapeTool,b as KritzelText,n as KritzelTextTool,u as KritzelThemeManager,s as KritzelWorkspace,S as ShapeType,W as WORKSPACE_EXPORT_VERSION,O as WORKSPACE_MIGRATIONS,E as darkTheme,C as lightTheme,M as runMigrations}from"./p-B3IqnD8l.js";import*as $ from"yjs";import{IndexeddbPersistence as _}from"y-indexeddb";import{WebsocketProvider as R}from"y-websocket";const U=Math.floor,H=127,V=Number.MAX_SAFE_INTEGER;class X{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}const Y=()=>new X,Z=t=>{const e=new Uint8Array((t=>{let e=t.cpos;for(let s=0;s<t.bufs.length;s++)e+=t.bufs[s].length;return e})(t));let s=0;for(let i=0;i<t.bufs.length;i++){const n=t.bufs[i];e.set(n,s),s+=n.length}return e.set(new Uint8Array(t.cbuf.buffer,0,t.cpos),s),e},tt=(t,e)=>{const s=t.cbuf.length;t.cpos===s&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(2*s),t.cpos=0),t.cbuf[t.cpos++]=e},et=(t,e)=>{for(;e>H;)tt(t,128|H&e),e=U(e/128);tt(t,H&e)},st=(t,e)=>{et(t,e.byteLength),((t,e)=>{const s=t.cbuf.length,i=t.cpos,n=((t,e)=>t<e?t:e)(s-i,e.length),o=e.length-n;t.cbuf.set(e.subarray(0,n),i),t.cpos+=n,o>0&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(((t,e)=>t>e?t:e)(2*s,o)),t.cbuf.set(e.subarray(n)),t.cpos=o)})(t,e)},it=t=>new Error(t),nt=it("Unexpected end of array"),ot=it("Integer out of Range");class rt{constructor(t){this.arr=t,this.pos=0}}const ct=t=>((t,e)=>{const s=new Uint8Array(t.arr.buffer,t.pos+t.arr.byteOffset,e);return t.pos+=e,s})(t,at(t)),at=t=>{let e=0,s=1;const i=t.arr.length;for(;t.pos<i;){const i=t.arr[t.pos++];if(e+=(i&H)*s,s*=128,i<128)return e;if(e>V)throw ot}throw nt};class ht{type="local";doc;channel;_synced=!1;constructor(t,e,s){this.doc=e,this.channel=new BroadcastChannel(t),this.channel.onmessage=t=>{this.handleMessage(t.data)},this.doc.on("update",this.handleDocUpdate),this.broadcastSync(),setTimeout((()=>{this._synced=!0}),100),s?.quiet||console.info(`BroadcastChannel Provider initialized: ${t}`)}handleDocUpdate=(t,e)=>{if(e!==this){const e=Y();et(e,0),st(e,t),this.channel.postMessage(Z(e))}};handleMessage(t){const e=(s=new Uint8Array(t),new rt(s));var s;switch(at(e)){case 0:const t=ct(e);$.applyUpdate(this.doc,t,this);break;case 1:this.broadcastSync();break;case 2:const s=ct(e),i=$.encodeStateAsUpdate(this.doc,s);if(i.length>0){const t=Y();et(t,0),st(t,i),this.channel.postMessage(Z(t))}}}broadcastSync(){const t=Y();et(t,2),st(t,$.encodeStateVector(this.doc)),this.channel.postMessage(Z(t))}async connect(){if(!this._synced)return new Promise((t=>{const e=()=>{this._synced?t():setTimeout(e,50)};e()}))}disconnect(){}async reconnect(){return this.disconnect(),this.connect()}destroy(){this.doc.off("update",this.handleDocUpdate),this.channel.close()}}const lt=new Map;class dt{type="local";doc;cacheKey;isConnected=!1;constructor(t,e,s){this.doc=e,this.cacheKey=s?.name??t}handleUpdate=(t,e)=>{e!==this&<.set(this.cacheKey,$.encodeStateAsUpdate(this.doc))};async connect(){if(this.isConnected)return;const t=lt.get(this.cacheKey);t&&$.applyUpdate(this.doc,t,this),this.doc.on("update",this.handleUpdate),this.isConnected=!0}disconnect(){this.isConnected=!1}async reconnect(){return this.disconnect(),this.connect()}destroy(){this.doc.off("update",this.handleUpdate),this.isConnected=!1}static clear(t){void 0!==t?lt.delete(t):lt.clear()}}class ut{type="local";provider;isConnected=!1;constructor(t,e,s){this.provider=new _(s?.name||t,e)}async connect(){if(!this.isConnected)return new Promise((t=>{this.provider.on("synced",(()=>{this.isConnected=!0,t()}))}))}disconnect(){this.isConnected=!1}async reconnect(){return this.disconnect(),this.connect()}destroy(){this.provider&&this.provider.destroy(),this.isConnected=!1}}class yt{type="network";provider;isConnected=!1;_quiet=!1;get awareness(){return this.provider.awareness}constructor(t,e,s){const i=s?.url||"ws://localhost:1234",n=s?.roomName||t;this.provider=new R(i,n,e,{params:s?.params,protocols:s?.protocols,WebSocketPolyfill:s?.WebSocketPolyfill,awareness:s?.awareness,maxBackoffTime:s?.maxBackoffTime,disableBc:!0}),this._quiet=s?.quiet??!1,this.setupEventListeners(),this._quiet||console.info(`WebSocket Provider initialized: ${i}/${n}`)}static with(t){return{create:(e,s,i)=>{const n=i?{...t,...i}:t;return new yt(e,s,n)}}}setupEventListeners(){this.provider.on("status",(({status:t})=>{"connected"===t?(this.isConnected=!0,this._quiet||console.info("WebSocket connected")):"disconnected"===t&&(this.isConnected=!1,this._quiet||console.info("WebSocket disconnected"))})),this.provider.on("sync",(t=>{t&&!this._quiet&&console.info("WebSocket synced")}))}async connect(){if(!this.isConnected)return new Promise(((t,e)=>{const s=setTimeout((()=>{e(new Error("WebSocket connection timeout"))}),1e4),i=({status:e})=>{"connected"===e&&(clearTimeout(s),this.provider.off("status",i),this.isConnected=!0,t())};this.provider.on("status",i),this.provider.wsconnected&&(clearTimeout(s),this.provider.off("status",i),this.isConnected=!0,t())}))}disconnect(){this.provider&&this.provider.disconnect(),this.isConnected=!1}async reconnect(){return this.disconnect(),this.connect()}destroy(){this.provider&&this.provider.destroy(),this.isConnected=!1}}class wt{type="network";provider;isConnected=!1;isSynced=!1;usesSharedSocket=!1;isDestroyed=!1;connectTimeout=null;pendingConnectReject=null;connectionTimeoutMs;_connectionStatus="disconnected";visibilityHandler=null;onlineHandler=null;get awareness(){return this.provider.awareness}get connectionStatus(){return this._connectionStatus}static sharedWebSocketProvider=null;constructor(t,e,s){const i=s?.name||t,n=s?.url||"ws://localhost:1234";this.connectionTimeoutMs=s?.connectionTimeout??1e4;const o=s?.websocketProvider||wt.sharedWebSocketProvider,r={};void 0!==s?.delay&&(r.delay=s.delay),void 0!==s?.factor&&(r.factor=s.factor),void 0!==s?.maxAttempts&&(r.maxAttempts=s.maxAttempts),void 0!==s?.minDelay&&(r.minDelay=s.minDelay),void 0!==s?.maxDelay&&(r.maxDelay=s.maxDelay);const c=()=>{this.isDestroyed||(this.isConnected=!0,this._connectionStatus="connected",s?.quiet||console.info(`Hocuspocus connected: ${i}`),s?.onConnect&&s.onConnect())},h=()=>{this.isDestroyed||(this.isConnected=!1,this.isSynced=!1,this._connectionStatus="disconnected",s?.quiet||console.info(`Hocuspocus disconnected: ${i}`),s?.onDisconnect&&s.onDisconnect())},l=()=>{this.isDestroyed||(this.isSynced=!0,this._connectionStatus="synced",s?.quiet||console.info(`Hocuspocus synced: ${i}`),s?.onSynced&&s.onSynced())},d=t=>{this.isDestroyed||("connecting"===t.status&&(this._connectionStatus="connecting"),s?.onStatus&&s.onStatus(t))};if(o){this.usesSharedSocket=!0;const t={websocketProvider:o,name:i,document:e,token:s?.token||null,onStatus:d,onConnect:c,onDisconnect:h,onSynced:l,...r};void 0!==s?.forceSyncInterval&&(t.forceSyncInterval=s.forceSyncInterval),s?.onAuthenticationFailed&&(t.onAuthenticationFailed=s.onAuthenticationFailed),this.provider=new a(t),this.provider.attach(),s?.quiet||console.info(`Hocuspocus Provider initialized (multiplexed): ${i}`)}else{this.usesSharedSocket=!1;const t={url:n,name:i,document:e,token:s?.token||null,autoConnect:!1,onStatus:d,onConnect:c,onDisconnect:h,onSynced:l,...r};void 0!==s?.forceSyncInterval&&(t.forceSyncInterval=s.forceSyncInterval),s?.onAuthenticationFailed&&(t.onAuthenticationFailed=s.onAuthenticationFailed),s?.WebSocketPolyfill&&(t.WebSocketPolyfill=s.WebSocketPolyfill),this.provider=new a(t),s?.quiet||console.info(`Hocuspocus Provider initialized: ${n}/${i}`)}this.setupBrowserEventListeners()}setupBrowserEventListeners(){"undefined"!=typeof document&&(this.visibilityHandler=()=>{"visible"!==document.visibilityState||this.isConnected||this.isDestroyed||this.provider.connect()},document.addEventListener("visibilitychange",this.visibilityHandler)),"undefined"!=typeof window&&(this.onlineHandler=()=>{this.isConnected||this.isDestroyed||this.provider.connect()},window.addEventListener("online",this.onlineHandler))}removeBrowserEventListeners(){this.visibilityHandler&&"undefined"!=typeof document&&(document.removeEventListener("visibilitychange",this.visibilityHandler),this.visibilityHandler=null),this.onlineHandler&&"undefined"!=typeof window&&(window.removeEventListener("online",this.onlineHandler),this.onlineHandler=null)}static createSharedWebSocket(t){if(wt.sharedWebSocketProvider)return console.warn("Shared WebSocket already exists. Returning existing instance."),wt.sharedWebSocketProvider;const e={url:t.url};return t.WebSocketPolyfill&&(e.WebSocketPolyfill=t.WebSocketPolyfill),t.onConnect&&(e.onConnect=t.onConnect),t.onDisconnect&&(e.onDisconnect=t.onDisconnect),t.onStatus&&(e.onStatus=t.onStatus),wt.sharedWebSocketProvider=new T(e),console.info(`Shared Hocuspocus WebSocket created: ${t.url}`),wt.sharedWebSocketProvider}static destroySharedWebSocket(){wt.sharedWebSocketProvider&&(wt.sharedWebSocketProvider.destroy(),wt.sharedWebSocketProvider=null,console.info("Shared Hocuspocus WebSocket destroyed"))}static getSharedWebSocket(){return wt.sharedWebSocketProvider}static with(t){return{create:(e,s,i)=>{const n=i?{...t,...i}:t;return new wt(e,s,n)}}}async connect(){if(!this.isSynced&&!this.isDestroyed)return this._connectionStatus="connecting",new Promise(((t,e)=>{this.pendingConnectReject=e,this.connectTimeout=setTimeout((()=>{this.pendingConnectReject=null,this.connectTimeout=null,e(new Error("Hocuspocus connection timeout"))}),this.connectionTimeoutMs);const s=()=>{this.connectTimeout&&(clearTimeout(this.connectTimeout),this.connectTimeout=null),this.pendingConnectReject=null,this.provider.off("synced",s),this.isDestroyed||t()};if(this.provider.on("synced",s),this.provider.isSynced)return this.connectTimeout&&(clearTimeout(this.connectTimeout),this.connectTimeout=null),this.pendingConnectReject=null,this.provider.off("synced",s),void t();this.isConnected||this.usesSharedSocket||this.provider.connect()}))}async reconnect(){return this.disconnect(),this.connect()}disconnect(){this.connectTimeout&&(clearTimeout(this.connectTimeout),this.connectTimeout=null),this.pendingConnectReject&&(this.pendingConnectReject=null),this.provider&&(this.usesSharedSocket?this.provider.detach():this.provider.disconnect()),this.isConnected=!1,this.isSynced=!1,this._connectionStatus="disconnected"}destroy(){this.isDestroyed=!0,this.connectTimeout&&(clearTimeout(this.connectTimeout),this.connectTimeout=null),this.pendingConnectReject&&(this.pendingConnectReject=null),this.removeBrowserEventListeners(),this.provider&&this.provider.destroy(),this.isConnected=!1,this.isSynced=!1,this._connectionStatus="disconnected"}}class pt{type="remote";name="HttpAssetProvider";_options;constructor(t){this._options=t}static with(t){return{create:()=>new pt(t)}}async init(){this._options.quiet||console.info("HttpAssetProvider initialized")}destroy(){}canResolve(t){return!0}async put(t,e){const s=e.id??this.generateUuid(),i={...e,id:s},n=await(this._options.headers?.())??{},o=await this._options.uploadUrl(i),r=this._options.upload??this.defaultUpload;return{id:(await r(o,t,i,n)).id??s,kind:e.kind??"file",mimeType:e.mimeType,size:t.size,createdAt:Date.now(),width:e.width,height:e.height,durationMs:e.durationMs,originalFilename:e.originalFilename}}async resolve(t){return this._options.resolveUrl(t)}async fetch(t){const e=await this._options.resolveUrl(t),s=await(this._options.headers?.())??{},i=await fetch(e,{headers:s});if(!i.ok)throw new Error(`[HttpAssetProvider] Failed to fetch asset ${t}: ${i.status} ${i.statusText}`);return i.blob()}async delete(t){if(!this._options.deleteUrl)return;const e=await this._options.deleteUrl(t),s=await(this._options.headers?.())??{},i=await fetch(e,{method:"DELETE",headers:s});if(!i.ok)throw new Error(`[HttpAssetProvider] Failed to delete asset ${t}: ${i.status} ${i.statusText}`);this._options.quiet||console.info(`HttpAssetProvider: deleted asset ${t}`)}defaultUpload=async(t,e,s,i)=>{const n=new FormData;n.append("metadata",JSON.stringify(s)),n.append("file",e,s.originalFilename||`${s.id}.${this.extensionFromMime(s.mimeType)}`);const o=await fetch(t,{method:"POST",headers:i,body:n});if(!o.ok)throw new Error(`[HttpAssetProvider] Upload failed: ${o.status} ${o.statusText}`);return(o.headers.get("content-type")||"").includes("application/json")?await o.json():{}};extensionFromMime(t){const e=t.indexOf("/");return e>=0?t.slice(e+1):"bin"}generateUuid(){if("undefined"!=typeof crypto&&"function"==typeof crypto.randomUUID)return crypto.randomUUID();const t=crypto.getRandomValues(new Uint8Array(16));t[6]=15&t[6]|64,t[8]=63&t[8]|128;const e=Array.from(t,(t=>t.toString(16).padStart(2,"0"))).join("");return`${e.slice(0,8)}-${e.slice(8,12)}-${e.slice(12,16)}-${e.slice(16,20)}-${e.slice(20)}`}}class mt{type="remote";name="PresignedAssetProvider";_options;constructor(t){this._options=t}static with(t){return{create:()=>new mt(t)}}async init(){this._options.quiet||console.info("PresignedAssetProvider initialized")}destroy(){}canResolve(t){return!0}async put(t,e){const s=await this._options.getUploadDescriptor(e),i=s.method??"PUT",n={...s.headers??{}};let o;if(n["Content-Type"]||n["content-type"]||(n["Content-Type"]=e.mimeType),"POST"===i&&s.fields){const e=new FormData;for(const[t,i]of Object.entries(s.fields))e.append(t,i);e.append("file",t),o=e,delete n["Content-Type"],delete n["content-type"]}else o=t;const r=await fetch(s.url,{method:i,headers:n,body:o});if(!r.ok)throw new Error(`[PresignedAssetProvider] Upload failed: ${r.status} ${r.statusText}`);return{id:s.id,kind:e.kind??"file",mimeType:e.mimeType,size:t.size,createdAt:Date.now(),width:e.width,height:e.height,durationMs:e.durationMs,originalFilename:e.originalFilename}}async resolve(t){return this._options.getDownloadUrl(t)}async fetch(t){const e=await this._options.getDownloadUrl(t),s=await fetch(e);if(!s.ok)throw new Error(`[PresignedAssetProvider] Failed to fetch asset ${t}: ${s.status} ${s.statusText}`);return s.blob()}async delete(t){this._options.deleteAsset&&(await this._options.deleteAsset(t),this._options.quiet||console.info(`PresignedAssetProvider: deleted asset ${t}`))}}export{ht as BroadcastSyncProvider,wt as HocuspocusSyncProvider,pt as HttpAssetProvider,dt as InMemorySyncProvider,ut as IndexedDBSyncProvider,mt as PresignedAssetProvider,yt as WebSocketSyncProvider}
|
|
1
|
+
import{H as a,a as T}from"./p-1SDhlkfS.js";export{N as APP_STATE_MIGRATIONS,A as AssetNotFoundError,P as CURRENT_APP_STATE_SCHEMA_VERSION,Q as CURRENT_WORKSPACE_SCHEMA_VERSION,B as DEFAULT_ASSET_STORAGE_CONFIG,D as DEFAULT_BRUSH_CONFIG,z as DEFAULT_LINE_TOOL_CONFIG,y as DEFAULT_TEXT_CONFIG,G as DE_LOCALE,F as EN_LOCALE,J as FR_LOCALE,I as IndexedDBAssetProvider,L as KritzelAlignment,t as KritzelAnchorManager,r as KritzelAssetResolver,K as KritzelBaseObject,i as KritzelBaseTool,j as KritzelBrushTool,p as KritzelCursorHelper,h as KritzelCustomElement,x as KritzelCustomElementRendererRegistry,l as KritzelEraserTool,f as KritzelGroup,d as KritzelImage,m as KritzelImageTool,w as KritzelLicenseManager,e as KritzelLine,k as KritzelLineTool,v as KritzelLocalizationManager,c as KritzelPath,q as KritzelSelectionTool,g as KritzelShape,o as KritzelShapeTool,b as KritzelText,n as KritzelTextTool,u as KritzelThemeManager,s as KritzelWorkspace,S as ShapeType,W as WORKSPACE_EXPORT_VERSION,O as WORKSPACE_MIGRATIONS,E as darkTheme,C as lightTheme,M as runMigrations}from"./p-1SDhlkfS.js";import*as $ from"yjs";import{IndexeddbPersistence as _}from"y-indexeddb";import{WebsocketProvider as R}from"y-websocket";const U=Math.floor,H=127,V=Number.MAX_SAFE_INTEGER;class X{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}const Y=()=>new X,Z=t=>{const e=new Uint8Array((t=>{let e=t.cpos;for(let s=0;s<t.bufs.length;s++)e+=t.bufs[s].length;return e})(t));let s=0;for(let i=0;i<t.bufs.length;i++){const n=t.bufs[i];e.set(n,s),s+=n.length}return e.set(new Uint8Array(t.cbuf.buffer,0,t.cpos),s),e},tt=(t,e)=>{const s=t.cbuf.length;t.cpos===s&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(2*s),t.cpos=0),t.cbuf[t.cpos++]=e},et=(t,e)=>{for(;e>H;)tt(t,128|H&e),e=U(e/128);tt(t,H&e)},st=(t,e)=>{et(t,e.byteLength),((t,e)=>{const s=t.cbuf.length,i=t.cpos,n=((t,e)=>t<e?t:e)(s-i,e.length),o=e.length-n;t.cbuf.set(e.subarray(0,n),i),t.cpos+=n,o>0&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(((t,e)=>t>e?t:e)(2*s,o)),t.cbuf.set(e.subarray(n)),t.cpos=o)})(t,e)},it=t=>new Error(t),nt=it("Unexpected end of array"),ot=it("Integer out of Range");class rt{constructor(t){this.arr=t,this.pos=0}}const ct=t=>((t,e)=>{const s=new Uint8Array(t.arr.buffer,t.pos+t.arr.byteOffset,e);return t.pos+=e,s})(t,at(t)),at=t=>{let e=0,s=1;const i=t.arr.length;for(;t.pos<i;){const i=t.arr[t.pos++];if(e+=(i&H)*s,s*=128,i<128)return e;if(e>V)throw ot}throw nt};class ht{type="local";doc;channel;_synced=!1;constructor(t,e,s){this.doc=e,this.channel=new BroadcastChannel(t),this.channel.onmessage=t=>{this.handleMessage(t.data)},this.doc.on("update",this.handleDocUpdate),this.broadcastSync(),setTimeout((()=>{this._synced=!0}),100),s?.quiet||console.info(`BroadcastChannel Provider initialized: ${t}`)}handleDocUpdate=(t,e)=>{if(e!==this){const e=Y();et(e,0),st(e,t),this.channel.postMessage(Z(e))}};handleMessage(t){const e=(s=new Uint8Array(t),new rt(s));var s;switch(at(e)){case 0:const t=ct(e);$.applyUpdate(this.doc,t,this);break;case 1:this.broadcastSync();break;case 2:const s=ct(e),i=$.encodeStateAsUpdate(this.doc,s);if(i.length>0){const t=Y();et(t,0),st(t,i),this.channel.postMessage(Z(t))}}}broadcastSync(){const t=Y();et(t,2),st(t,$.encodeStateVector(this.doc)),this.channel.postMessage(Z(t))}async connect(){if(!this._synced)return new Promise((t=>{const e=()=>{this._synced?t():setTimeout(e,50)};e()}))}disconnect(){}async reconnect(){return this.disconnect(),this.connect()}destroy(){this.doc.off("update",this.handleDocUpdate),this.channel.close()}}const lt=new Map;class dt{type="local";doc;cacheKey;isConnected=!1;constructor(t,e,s){this.doc=e,this.cacheKey=s?.name??t}handleUpdate=(t,e)=>{e!==this&<.set(this.cacheKey,$.encodeStateAsUpdate(this.doc))};async connect(){if(this.isConnected)return;const t=lt.get(this.cacheKey);t&&$.applyUpdate(this.doc,t,this),this.doc.on("update",this.handleUpdate),this.isConnected=!0}disconnect(){this.isConnected=!1}async reconnect(){return this.disconnect(),this.connect()}destroy(){this.doc.off("update",this.handleUpdate),this.isConnected=!1}static clear(t){void 0!==t?lt.delete(t):lt.clear()}}class ut{type="local";provider;isConnected=!1;constructor(t,e,s){this.provider=new _(s?.name||t,e)}async connect(){if(!this.isConnected)return new Promise((t=>{this.provider.on("synced",(()=>{this.isConnected=!0,t()}))}))}disconnect(){this.isConnected=!1}async reconnect(){return this.disconnect(),this.connect()}destroy(){this.provider&&this.provider.destroy(),this.isConnected=!1}}class yt{type="network";provider;isConnected=!1;_quiet=!1;get awareness(){return this.provider.awareness}constructor(t,e,s){const i=s?.url||"ws://localhost:1234",n=s?.roomName||t;this.provider=new R(i,n,e,{params:s?.params,protocols:s?.protocols,WebSocketPolyfill:s?.WebSocketPolyfill,awareness:s?.awareness,maxBackoffTime:s?.maxBackoffTime,disableBc:!0}),this._quiet=s?.quiet??!1,this.setupEventListeners(),this._quiet||console.info(`WebSocket Provider initialized: ${i}/${n}`)}static with(t){return{create:(e,s,i)=>{const n=i?{...t,...i}:t;return new yt(e,s,n)}}}setupEventListeners(){this.provider.on("status",(({status:t})=>{"connected"===t?(this.isConnected=!0,this._quiet||console.info("WebSocket connected")):"disconnected"===t&&(this.isConnected=!1,this._quiet||console.info("WebSocket disconnected"))})),this.provider.on("sync",(t=>{t&&!this._quiet&&console.info("WebSocket synced")}))}async connect(){if(!this.isConnected)return new Promise(((t,e)=>{const s=setTimeout((()=>{e(new Error("WebSocket connection timeout"))}),1e4),i=({status:e})=>{"connected"===e&&(clearTimeout(s),this.provider.off("status",i),this.isConnected=!0,t())};this.provider.on("status",i),this.provider.wsconnected&&(clearTimeout(s),this.provider.off("status",i),this.isConnected=!0,t())}))}disconnect(){this.provider&&this.provider.disconnect(),this.isConnected=!1}async reconnect(){return this.disconnect(),this.connect()}destroy(){this.provider&&this.provider.destroy(),this.isConnected=!1}}class wt{type="network";provider;isConnected=!1;isSynced=!1;usesSharedSocket=!1;isDestroyed=!1;connectTimeout=null;pendingConnectReject=null;connectionTimeoutMs;_connectionStatus="disconnected";visibilityHandler=null;onlineHandler=null;get awareness(){return this.provider.awareness}get connectionStatus(){return this._connectionStatus}static sharedWebSocketProvider=null;constructor(t,e,s){const i=s?.name||t,n=s?.url||"ws://localhost:1234";this.connectionTimeoutMs=s?.connectionTimeout??1e4;const o=s?.websocketProvider||wt.sharedWebSocketProvider,r={};void 0!==s?.delay&&(r.delay=s.delay),void 0!==s?.factor&&(r.factor=s.factor),void 0!==s?.maxAttempts&&(r.maxAttempts=s.maxAttempts),void 0!==s?.minDelay&&(r.minDelay=s.minDelay),void 0!==s?.maxDelay&&(r.maxDelay=s.maxDelay);const c=()=>{this.isDestroyed||(this.isConnected=!0,this._connectionStatus="connected",s?.quiet||console.info(`Hocuspocus connected: ${i}`),s?.onConnect&&s.onConnect())},h=()=>{this.isDestroyed||(this.isConnected=!1,this.isSynced=!1,this._connectionStatus="disconnected",s?.quiet||console.info(`Hocuspocus disconnected: ${i}`),s?.onDisconnect&&s.onDisconnect())},l=()=>{this.isDestroyed||(this.isSynced=!0,this._connectionStatus="synced",s?.quiet||console.info(`Hocuspocus synced: ${i}`),s?.onSynced&&s.onSynced())},d=t=>{this.isDestroyed||("connecting"===t.status&&(this._connectionStatus="connecting"),s?.onStatus&&s.onStatus(t))};if(o){this.usesSharedSocket=!0;const t={websocketProvider:o,name:i,document:e,token:s?.token||null,onStatus:d,onConnect:c,onDisconnect:h,onSynced:l,...r};void 0!==s?.forceSyncInterval&&(t.forceSyncInterval=s.forceSyncInterval),s?.onAuthenticationFailed&&(t.onAuthenticationFailed=s.onAuthenticationFailed),this.provider=new a(t),this.provider.attach(),s?.quiet||console.info(`Hocuspocus Provider initialized (multiplexed): ${i}`)}else{this.usesSharedSocket=!1;const t={url:n,name:i,document:e,token:s?.token||null,autoConnect:!1,onStatus:d,onConnect:c,onDisconnect:h,onSynced:l,...r};void 0!==s?.forceSyncInterval&&(t.forceSyncInterval=s.forceSyncInterval),s?.onAuthenticationFailed&&(t.onAuthenticationFailed=s.onAuthenticationFailed),s?.WebSocketPolyfill&&(t.WebSocketPolyfill=s.WebSocketPolyfill),this.provider=new a(t),s?.quiet||console.info(`Hocuspocus Provider initialized: ${n}/${i}`)}this.setupBrowserEventListeners()}setupBrowserEventListeners(){"undefined"!=typeof document&&(this.visibilityHandler=()=>{"visible"!==document.visibilityState||this.isConnected||this.isDestroyed||this.provider.connect()},document.addEventListener("visibilitychange",this.visibilityHandler)),"undefined"!=typeof window&&(this.onlineHandler=()=>{this.isConnected||this.isDestroyed||this.provider.connect()},window.addEventListener("online",this.onlineHandler))}removeBrowserEventListeners(){this.visibilityHandler&&"undefined"!=typeof document&&(document.removeEventListener("visibilitychange",this.visibilityHandler),this.visibilityHandler=null),this.onlineHandler&&"undefined"!=typeof window&&(window.removeEventListener("online",this.onlineHandler),this.onlineHandler=null)}static createSharedWebSocket(t){if(wt.sharedWebSocketProvider)return console.warn("Shared WebSocket already exists. Returning existing instance."),wt.sharedWebSocketProvider;const e={url:t.url};return t.WebSocketPolyfill&&(e.WebSocketPolyfill=t.WebSocketPolyfill),t.onConnect&&(e.onConnect=t.onConnect),t.onDisconnect&&(e.onDisconnect=t.onDisconnect),t.onStatus&&(e.onStatus=t.onStatus),wt.sharedWebSocketProvider=new T(e),console.info(`Shared Hocuspocus WebSocket created: ${t.url}`),wt.sharedWebSocketProvider}static destroySharedWebSocket(){wt.sharedWebSocketProvider&&(wt.sharedWebSocketProvider.destroy(),wt.sharedWebSocketProvider=null,console.info("Shared Hocuspocus WebSocket destroyed"))}static getSharedWebSocket(){return wt.sharedWebSocketProvider}static with(t){return{create:(e,s,i)=>{const n=i?{...t,...i}:t;return new wt(e,s,n)}}}async connect(){if(!this.isSynced&&!this.isDestroyed)return this._connectionStatus="connecting",new Promise(((t,e)=>{this.pendingConnectReject=e,this.connectTimeout=setTimeout((()=>{this.pendingConnectReject=null,this.connectTimeout=null,e(new Error("Hocuspocus connection timeout"))}),this.connectionTimeoutMs);const s=()=>{this.connectTimeout&&(clearTimeout(this.connectTimeout),this.connectTimeout=null),this.pendingConnectReject=null,this.provider.off("synced",s),this.isDestroyed||t()};if(this.provider.on("synced",s),this.provider.isSynced)return this.connectTimeout&&(clearTimeout(this.connectTimeout),this.connectTimeout=null),this.pendingConnectReject=null,this.provider.off("synced",s),void t();this.isConnected||this.usesSharedSocket||this.provider.connect()}))}async reconnect(){return this.disconnect(),this.connect()}disconnect(){this.connectTimeout&&(clearTimeout(this.connectTimeout),this.connectTimeout=null),this.pendingConnectReject&&(this.pendingConnectReject=null),this.provider&&(this.usesSharedSocket?this.provider.detach():this.provider.disconnect()),this.isConnected=!1,this.isSynced=!1,this._connectionStatus="disconnected"}destroy(){this.isDestroyed=!0,this.connectTimeout&&(clearTimeout(this.connectTimeout),this.connectTimeout=null),this.pendingConnectReject&&(this.pendingConnectReject=null),this.removeBrowserEventListeners(),this.provider&&this.provider.destroy(),this.isConnected=!1,this.isSynced=!1,this._connectionStatus="disconnected"}}class pt{type="remote";name="HttpAssetProvider";_options;constructor(t){this._options=t}static with(t){return{create:()=>new pt(t)}}async init(){this._options.quiet||console.info("HttpAssetProvider initialized")}destroy(){}canResolve(t){return!0}async put(t,e){const s=e.id??this.generateUuid(),i={...e,id:s},n=await(this._options.headers?.())??{},o=await this._options.uploadUrl(i),r=this._options.upload??this.defaultUpload;return{id:(await r(o,t,i,n)).id??s,kind:e.kind??"file",mimeType:e.mimeType,size:t.size,createdAt:Date.now(),width:e.width,height:e.height,durationMs:e.durationMs,originalFilename:e.originalFilename}}async resolve(t){return this._options.resolveUrl(t)}async fetch(t){const e=await this._options.resolveUrl(t),s=await(this._options.headers?.())??{},i=await fetch(e,{headers:s});if(!i.ok)throw new Error(`[HttpAssetProvider] Failed to fetch asset ${t}: ${i.status} ${i.statusText}`);return i.blob()}async delete(t){if(!this._options.deleteUrl)return;const e=await this._options.deleteUrl(t),s=await(this._options.headers?.())??{},i=await fetch(e,{method:"DELETE",headers:s});if(!i.ok)throw new Error(`[HttpAssetProvider] Failed to delete asset ${t}: ${i.status} ${i.statusText}`);this._options.quiet||console.info(`HttpAssetProvider: deleted asset ${t}`)}defaultUpload=async(t,e,s,i)=>{const n=new FormData;n.append("metadata",JSON.stringify(s)),n.append("file",e,s.originalFilename||`${s.id}.${this.extensionFromMime(s.mimeType)}`);const o=await fetch(t,{method:"POST",headers:i,body:n});if(!o.ok)throw new Error(`[HttpAssetProvider] Upload failed: ${o.status} ${o.statusText}`);return(o.headers.get("content-type")||"").includes("application/json")?await o.json():{}};extensionFromMime(t){const e=t.indexOf("/");return e>=0?t.slice(e+1):"bin"}generateUuid(){if("undefined"!=typeof crypto&&"function"==typeof crypto.randomUUID)return crypto.randomUUID();const t=crypto.getRandomValues(new Uint8Array(16));t[6]=15&t[6]|64,t[8]=63&t[8]|128;const e=Array.from(t,(t=>t.toString(16).padStart(2,"0"))).join("");return`${e.slice(0,8)}-${e.slice(8,12)}-${e.slice(12,16)}-${e.slice(16,20)}-${e.slice(20)}`}}class mt{type="remote";name="PresignedAssetProvider";_options;constructor(t){this._options=t}static with(t){return{create:()=>new mt(t)}}async init(){this._options.quiet||console.info("PresignedAssetProvider initialized")}destroy(){}canResolve(t){return!0}async put(t,e){const s=await this._options.getUploadDescriptor(e),i=s.method??"PUT",n={...s.headers??{}};let o;if(n["Content-Type"]||n["content-type"]||(n["Content-Type"]=e.mimeType),"POST"===i&&s.fields){const e=new FormData;for(const[t,i]of Object.entries(s.fields))e.append(t,i);e.append("file",t),o=e,delete n["Content-Type"],delete n["content-type"]}else o=t;const r=await fetch(s.url,{method:i,headers:n,body:o});if(!r.ok)throw new Error(`[PresignedAssetProvider] Upload failed: ${r.status} ${r.statusText}`);return{id:s.id,kind:e.kind??"file",mimeType:e.mimeType,size:t.size,createdAt:Date.now(),width:e.width,height:e.height,durationMs:e.durationMs,originalFilename:e.originalFilename}}async resolve(t){return this._options.getDownloadUrl(t)}async fetch(t){const e=await this._options.getDownloadUrl(t),s=await fetch(e);if(!s.ok)throw new Error(`[PresignedAssetProvider] Failed to fetch asset ${t}: ${s.status} ${s.statusText}`);return s.blob()}async delete(t){this._options.deleteAsset&&(await this._options.deleteAsset(t),this._options.quiet||console.info(`PresignedAssetProvider: deleted asset ${t}`))}}export{ht as BroadcastSyncProvider,wt as HocuspocusSyncProvider,pt as HttpAssetProvider,dt as InMemorySyncProvider,ut as IndexedDBSyncProvider,mt as PresignedAssetProvider,yt as WebSocketSyncProvider}
|