floor-editor-ts 1.0.5 → 1.0.7

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.
@@ -64370,7 +64370,7 @@ var root_20 = /* @__PURE__ */ from_html(`<div class="absolute top-2 left-1/2 -tr
64370
64370
  var root_21 = /* @__PURE__ */ from_html(`<div class="absolute top-2 left-1/2 -translate-x-1/2 bg-emerald-600 text-white px-3 py-1 rounded-full text-xs shadow">Click to place text label · Esc to cancel</div>`);
64371
64371
  var root_22 = /* @__PURE__ */ from_html(`<div class="absolute top-2 left-1/2 -translate-x-1/2 bg-indigo-600 text-white px-3 py-1 rounded-full text-xs shadow"> </div>`);
64372
64372
  var root_1$5 = /* @__PURE__ */ from_html(`<!> <!> <!> <!> <div class="absolute bottom-2 right-2 bg-white/80 rounded px-2 py-1 text-xs text-gray-500 flex gap-3"><!> <!> <!> <span> </span> <button class="hover:text-gray-700" title="Zoom to Fit (F)">⊞ Fit</button> <button class="hover:text-gray-700" title="Toggle Grid (G)"> </button> <button class="hover:text-gray-700" title="Toggle Snap to Grid (S)"> </button> <button class="hover:text-gray-700" title="Toggle Furniture"> </button> <button class="hover:text-gray-700" title="Layer Visibility">🗂 Layers</button> <button class="hover:text-gray-700" title="Toggle Rulers"> </button> <button class="hover:text-gray-700" title="Toggle Mini-map"> </button></div> <!> <!> <!> <!> <!> <!> <!> <div class="absolute bottom-3 left-3 z-20 flex items-center gap-1 bg-white rounded-lg shadow-lg border border-gray-200 px-1 py-0.5"><button class="w-7 h-7 flex items-center justify-center rounded hover:bg-gray-100 text-gray-600 hover:text-gray-800 font-bold text-lg" title="Zoom Out (−)" aria-label="Zoom out">−</button> <button class="min-w-[3.5rem] h-7 flex items-center justify-center rounded hover:bg-gray-100 text-xs font-medium text-gray-600 hover:text-gray-800 tabular-nums" title="Reset to 100%" aria-label="Zoom to 100%"> </button> <button class="w-7 h-7 flex items-center justify-center rounded hover:bg-gray-100 text-gray-600 hover:text-gray-800 font-bold text-lg" title="Zoom In (+)" aria-label="Zoom in">+</button> <div class="w-px h-5 bg-gray-200"></div> <button class="w-7 h-7 flex items-center justify-center rounded hover:bg-gray-100 text-gray-500 hover:text-gray-700 text-sm" title="Zoom to Fit (F)" aria-label="Zoom to fit">⊞</button></div> <!>`, 1);
64373
- var root = /* @__PURE__ */ from_html(`<div class="w-full h-full relative overflow-hidden" role="application"><canvas class="block w-full h-full" tabindex="0" aria-label="Floor plan editor canvas"></canvas> <!></div>`);
64373
+ var root = /* @__PURE__ */ from_html(`<div class="w-full h-full relative overflow-hidden" role="application"><canvas aria-label="Floor plan editor canvas"></canvas> <!></div>`);
64374
64374
  function FloorPlanCanvas($$anchor, $$props) {
64375
64375
  push($$props, true);
64376
64376
  const $panMode = () => store_get(panMode, "$panMode", $$stores);
@@ -64475,6 +64475,9 @@ function FloorPlanCanvas($$anchor, $$props) {
64475
64475
  };
64476
64476
  let showGrid = /* @__PURE__ */ state(true);
64477
64477
  let showRulers = /* @__PURE__ */ state(true);
64478
+ user_effect(() => {
64479
+ if ($$props.viewOnly) set(showRulers, false);
64480
+ });
64478
64481
  let layerVis = /* @__PURE__ */ state(proxy({
64479
64482
  walls: true,
64480
64483
  doors: true,
@@ -64818,6 +64821,9 @@ function FloorPlanCanvas($$anchor, $$props) {
64818
64821
  canvas.height = get(height);
64819
64822
  }
64820
64823
  markDirty();
64824
+ if ($$props.viewOnly) requestAnimationFrame(() => {
64825
+ zoomToFit();
64826
+ });
64821
64827
  }
64822
64828
  function drawGrid() {
64823
64829
  if (!ctx || !get(showGrid)) return;
@@ -65257,7 +65263,7 @@ function FloorPlanCanvas($$anchor, $$props) {
65257
65263
  return `${Math.round(worldCm)}`;
65258
65264
  }
65259
65265
  function drawRulers() {
65260
- if (!ctx || !get(showRulers)) return;
65266
+ if (!ctx || !get(showRulers) || $$props.viewOnly) return;
65261
65267
  const R = RULER_SIZE;
65262
65268
  const fontSize = 9;
65263
65269
  const isImperial = get(dimSettings).units === "imperial";
@@ -65454,10 +65460,12 @@ function FloorPlanCanvas($$anchor, $$props) {
65454
65460
  }
65455
65461
  canvasDirty = false;
65456
65462
  ctx.clearRect(0, 0, get(width), get(height));
65457
- ctx.fillStyle = "#f8f9fa";
65458
- ctx.fillRect(0, 0, get(width), get(height));
65459
- drawGrid();
65460
- if (get(layerVis).guides) drawGuides$1();
65463
+ if (!$$props.viewOnly) {
65464
+ ctx.fillStyle = "#f8f9fa";
65465
+ ctx.fillRect(0, 0, get(width), get(height));
65466
+ drawGrid();
65467
+ }
65468
+ if (!$$props.viewOnly && get(layerVis).guides) drawGuides$1();
65461
65469
  drawBackgroundImage();
65462
65470
  const floor = get(currentFloor);
65463
65471
  if (!floor) {
@@ -65472,7 +65480,7 @@ function FloorPlanCanvas($$anchor, $$props) {
65472
65480
  return id === selId || multiIds.has(id);
65473
65481
  }
65474
65482
  drawRooms$1();
65475
- drawSnapPoints$1();
65483
+ if (!$$props.viewOnly) drawSnapPoints$1();
65476
65484
  if (get(layerVis).walls) {
65477
65485
  for (const w of floor.walls) drawWall$1(w, isSelected(w.id));
65478
65486
  drawWallJoints$1(floor, selId);
@@ -66109,6 +66117,9 @@ function FloorPlanCanvas($$anchor, $$props) {
66109
66117
  const unsub1 = activeFloor.subscribe((f) => {
66110
66118
  set(currentFloor, f, true);
66111
66119
  markDirty();
66120
+ if ($$props.viewOnly && f) requestAnimationFrame(() => {
66121
+ zoomToFit();
66122
+ });
66112
66123
  if (!initialFitDone && f && f.walls.length > 0) {
66113
66124
  initialFitDone = true;
66114
66125
  requestAnimationFrame(() => {
@@ -67916,6 +67927,7 @@ function FloorPlanCanvas($$anchor, $$props) {
67916
67927
  event("keydown", $window, onKeyDown);
67917
67928
  event("keyup", $window, onKeyUp);
67918
67929
  var canvas_1 = child(div);
67930
+ let classes;
67919
67931
  bind_this(canvas_1, ($$value) => canvas = $$value, () => canvas);
67920
67932
  var node = sibling(canvas_1, 2);
67921
67933
  var consequent_20 = ($$anchor) => {
@@ -68426,7 +68438,9 @@ function FloorPlanCanvas($$anchor, $$props) {
68426
68438
  reset(div);
68427
68439
  template_effect(() => {
68428
68440
  var _$$get14;
68429
- return set_style(canvas_1, `cursor: ${(_$$get14 = get(cursorStyle)) !== null && _$$get14 !== void 0 ? _$$get14 : ""}`);
68441
+ classes = set_class(canvas_1, 1, "block w-full h-full", null, classes, { "pointer-events-none": $$props.viewOnly });
68442
+ set_attribute(canvas_1, "tabindex", $$props.viewOnly ? -1 : 0);
68443
+ set_style(canvas_1, `cursor: ${(_$$get14 = get(cursorStyle)) !== null && _$$get14 !== void 0 ? _$$get14 : ""}`);
68430
68444
  });
68431
68445
  delegated("mousedown", canvas_1, onMouseDown);
68432
68446
  delegated("mousemove", canvas_1, onMouseMove);
@@ -69435,655 +69449,7 @@ function App($$anchor, $$props) {
69435
69449
  set(mode, m, true);
69436
69450
  });
69437
69451
  user_effect(() => {
69438
- currentProject.set({
69439
- id: "0retn2ek",
69440
- name: "L-Shaped House",
69441
- floors: [{
69442
- id: "1fg6pga0",
69443
- name: "Ground Floor",
69444
- level: 0,
69445
- walls: [
69446
- {
69447
- id: "lg5h806h",
69448
- start: {
69449
- x: 0,
69450
- y: 0
69451
- },
69452
- end: {
69453
- x: 1400,
69454
- y: 0
69455
- },
69456
- thickness: 15,
69457
- height: 280,
69458
- color: "#444444"
69459
- },
69460
- {
69461
- id: "whcf9cv2",
69462
- start: {
69463
- x: 1400,
69464
- y: 0
69465
- },
69466
- end: {
69467
- x: 1400,
69468
- y: 600
69469
- },
69470
- thickness: 15,
69471
- height: 280,
69472
- color: "#444444"
69473
- },
69474
- {
69475
- id: "phvbebmu",
69476
- start: {
69477
- x: 1400,
69478
- y: 600
69479
- },
69480
- end: {
69481
- x: 600,
69482
- y: 600
69483
- },
69484
- thickness: 15,
69485
- height: 280,
69486
- color: "#444444"
69487
- },
69488
- {
69489
- id: "xaxhdtmi",
69490
- start: {
69491
- x: 600,
69492
- y: 600
69493
- },
69494
- end: {
69495
- x: 600,
69496
- y: 1100
69497
- },
69498
- thickness: 15,
69499
- height: 280,
69500
- color: "#444444"
69501
- },
69502
- {
69503
- id: "cs1poy28",
69504
- start: {
69505
- x: 600,
69506
- y: 1100
69507
- },
69508
- end: {
69509
- x: 0,
69510
- y: 1100
69511
- },
69512
- thickness: 15,
69513
- height: 280,
69514
- color: "#444444"
69515
- },
69516
- {
69517
- id: "irjmbyqg",
69518
- start: {
69519
- x: 0,
69520
- y: 1100
69521
- },
69522
- end: {
69523
- x: 0,
69524
- y: 0
69525
- },
69526
- thickness: 15,
69527
- height: 280,
69528
- color: "#444444"
69529
- },
69530
- {
69531
- id: "n45rb09q",
69532
- start: {
69533
- x: 350,
69534
- y: 600
69535
- },
69536
- end: {
69537
- x: 350,
69538
- y: 1100
69539
- },
69540
- thickness: 15,
69541
- height: 280,
69542
- color: "#444444"
69543
- },
69544
- {
69545
- id: "mrcejzip",
69546
- start: {
69547
- x: 0,
69548
- y: 600
69549
- },
69550
- end: {
69551
- x: 350,
69552
- y: 600
69553
- },
69554
- thickness: 15,
69555
- height: 280,
69556
- color: "#444444"
69557
- },
69558
- {
69559
- id: "s0j86ogg",
69560
- start: {
69561
- x: 400,
69562
- y: 0
69563
- },
69564
- end: {
69565
- x: 400,
69566
- y: 350
69567
- },
69568
- thickness: 15,
69569
- height: 280,
69570
- color: "#444444"
69571
- },
69572
- {
69573
- id: "9779xycw",
69574
- start: {
69575
- x: 0,
69576
- y: 350
69577
- },
69578
- end: {
69579
- x: 400,
69580
- y: 350
69581
- },
69582
- thickness: 15,
69583
- height: 280,
69584
- color: "#444444"
69585
- },
69586
- {
69587
- id: "epl8xjo0",
69588
- start: {
69589
- x: 800,
69590
- y: 0
69591
- },
69592
- end: {
69593
- x: 800,
69594
- y: 350
69595
- },
69596
- thickness: 15,
69597
- height: 280,
69598
- color: "#444444"
69599
- },
69600
- {
69601
- id: "pw24r5jz",
69602
- start: {
69603
- x: 400,
69604
- y: 350
69605
- },
69606
- end: {
69607
- x: 800,
69608
- y: 350
69609
- },
69610
- thickness: 15,
69611
- height: 280,
69612
- color: "#444444"
69613
- },
69614
- {
69615
- id: "xvghl92m",
69616
- start: {
69617
- x: 800,
69618
- y: 350
69619
- },
69620
- end: {
69621
- x: 1400,
69622
- y: 350
69623
- },
69624
- thickness: 15,
69625
- height: 280,
69626
- color: "#444444"
69627
- },
69628
- {
69629
- id: "j5kb9mas",
69630
- start: {
69631
- x: 200,
69632
- y: 350
69633
- },
69634
- end: {
69635
- x: 200,
69636
- y: 600
69637
- },
69638
- thickness: 15,
69639
- height: 280,
69640
- color: "#444444"
69641
- },
69642
- {
69643
- id: "lryeizdx",
69644
- start: {
69645
- x: 0,
69646
- y: 600
69647
- },
69648
- end: {
69649
- x: 200,
69650
- y: 600
69651
- },
69652
- thickness: 15,
69653
- height: 280,
69654
- color: "#444444"
69655
- },
69656
- {
69657
- id: "zp1xe5hf",
69658
- start: {
69659
- x: 1e3,
69660
- y: 350
69661
- },
69662
- end: {
69663
- x: 1e3,
69664
- y: 600
69665
- },
69666
- thickness: 15,
69667
- height: 280,
69668
- color: "#444444"
69669
- },
69670
- {
69671
- id: "2cvf9bma",
69672
- start: {
69673
- x: 200,
69674
- y: 350
69675
- },
69676
- end: {
69677
- x: 200,
69678
- y: 600
69679
- },
69680
- thickness: 15,
69681
- height: 280,
69682
- color: "#444444"
69683
- }
69684
- ],
69685
- rooms: [{
69686
- id: "room-1-1776067835920",
69687
- name: "Room 1",
69688
- walls: [
69689
- "lg5h806h",
69690
- "whcf9cv2",
69691
- "phvbebmu",
69692
- "xaxhdtmi",
69693
- "cs1poy28",
69694
- "irjmbyqg"
69695
- ],
69696
- floorTexture: "hardwood",
69697
- area: 114
69698
- }, {
69699
- id: "room-6-1776067835920",
69700
- name: "Room 6",
69701
- walls: [
69702
- "phvbebmu",
69703
- "zp1xe5hf",
69704
- "xvghl92m",
69705
- "pw24r5jz",
69706
- "9779xycw",
69707
- "j5kb9mas",
69708
- "mrcejzip",
69709
- "n45rb09q",
69710
- "cs1poy28",
69711
- "xaxhdtmi"
69712
- ],
69713
- floorTexture: "light-oak",
69714
- area: 32.5
69715
- }],
69716
- doors: [
69717
- {
69718
- id: "ri02cnm3",
69719
- wallId: "phvbebmu",
69720
- position: .8,
69721
- width: 90,
69722
- height: 210,
69723
- type: "single",
69724
- swingDirection: "left",
69725
- flipSide: false
69726
- },
69727
- {
69728
- id: "5vzer8y2",
69729
- wallId: "mrcejzip",
69730
- position: .5,
69731
- width: 300,
69732
- height: 210,
69733
- type: "double",
69734
- swingDirection: "left",
69735
- flipSide: false
69736
- },
69737
- {
69738
- id: "djdsr69e",
69739
- wallId: "9779xycw",
69740
- position: .6,
69741
- width: 90,
69742
- height: 210,
69743
- type: "single",
69744
- swingDirection: "left",
69745
- flipSide: false
69746
- },
69747
- {
69748
- id: "q7q6yxj5",
69749
- wallId: "pw24r5jz",
69750
- position: .5,
69751
- width: 90,
69752
- height: 210,
69753
- type: "single",
69754
- swingDirection: "left",
69755
- flipSide: false
69756
- },
69757
- {
69758
- id: "trlthzki",
69759
- wallId: "xvghl92m",
69760
- position: .3,
69761
- width: 90,
69762
- height: 210,
69763
- type: "single",
69764
- swingDirection: "left",
69765
- flipSide: false
69766
- },
69767
- {
69768
- id: "cftusuau",
69769
- wallId: "j5kb9mas",
69770
- position: .5,
69771
- width: 90,
69772
- height: 210,
69773
- type: "single",
69774
- swingDirection: "left",
69775
- flipSide: false
69776
- },
69777
- {
69778
- id: "ffwybstc",
69779
- wallId: "zp1xe5hf",
69780
- position: .5,
69781
- width: 90,
69782
- height: 210,
69783
- type: "single",
69784
- swingDirection: "left",
69785
- flipSide: false
69786
- },
69787
- {
69788
- id: "zbqvbt3e",
69789
- wallId: "n45rb09q",
69790
- position: .3,
69791
- width: 90,
69792
- height: 210,
69793
- type: "single",
69794
- swingDirection: "left",
69795
- flipSide: false
69796
- }
69797
- ],
69798
- windows: [
69799
- {
69800
- id: "str62d0g",
69801
- wallId: "lg5h806h",
69802
- position: .15,
69803
- width: 140,
69804
- height: 120,
69805
- sillHeight: 90,
69806
- type: "standard"
69807
- },
69808
- {
69809
- id: "rhl9pa6k",
69810
- wallId: "lg5h806h",
69811
- position: .45,
69812
- width: 140,
69813
- height: 120,
69814
- sillHeight: 90,
69815
- type: "standard"
69816
- },
69817
- {
69818
- id: "lg4nh0s5",
69819
- wallId: "lg5h806h",
69820
- position: .8,
69821
- width: 140,
69822
- height: 120,
69823
- sillHeight: 90,
69824
- type: "standard"
69825
- },
69826
- {
69827
- id: "8bpiebl6",
69828
- wallId: "whcf9cv2",
69829
- position: .3,
69830
- width: 120,
69831
- height: 120,
69832
- sillHeight: 90,
69833
- type: "standard"
69834
- },
69835
- {
69836
- id: "nqvio771",
69837
- wallId: "whcf9cv2",
69838
- position: .7,
69839
- width: 180,
69840
- height: 120,
69841
- sillHeight: 90,
69842
- type: "standard"
69843
- },
69844
- {
69845
- id: "4wfq1m5b",
69846
- wallId: "cs1poy28",
69847
- position: .7,
69848
- width: 150,
69849
- height: 120,
69850
- sillHeight: 90,
69851
- type: "standard"
69852
- },
69853
- {
69854
- id: "uy5t0vr6",
69855
- wallId: "irjmbyqg",
69856
- position: .1,
69857
- width: 120,
69858
- height: 120,
69859
- sillHeight: 90,
69860
- type: "standard"
69861
- }
69862
- ],
69863
- furniture: [
69864
- {
69865
- id: "3s34714b",
69866
- catalogId: "bed_queen",
69867
- position: {
69868
- x: 150,
69869
- y: 120
69870
- },
69871
- rotation: 0,
69872
- scale: {
69873
- x: 1,
69874
- y: 1,
69875
- z: 1
69876
- }
69877
- },
69878
- {
69879
- id: "vy1dh1df",
69880
- catalogId: "bed_queen",
69881
- position: {
69882
- x: 550,
69883
- y: 120
69884
- },
69885
- rotation: 0,
69886
- scale: {
69887
- x: 1,
69888
- y: 1,
69889
- z: 1
69890
- }
69891
- },
69892
- {
69893
- id: "lbkdt1gr",
69894
- catalogId: "bed_twin",
69895
- position: {
69896
- x: 1050,
69897
- y: 120
69898
- },
69899
- rotation: 0,
69900
- scale: {
69901
- x: 1,
69902
- y: 1,
69903
- z: 1
69904
- }
69905
- },
69906
- {
69907
- id: "929s823r",
69908
- catalogId: "sofa",
69909
- position: {
69910
- x: 500,
69911
- y: 450
69912
- },
69913
- rotation: 0,
69914
- scale: {
69915
- x: 1,
69916
- y: 1,
69917
- z: 1
69918
- }
69919
- },
69920
- {
69921
- id: "vemdx0ly",
69922
- catalogId: "dining_table",
69923
- position: {
69924
- x: 1100,
69925
- y: 470
69926
- },
69927
- rotation: 0,
69928
- scale: {
69929
- x: 1,
69930
- y: 1,
69931
- z: 1
69932
- }
69933
- },
69934
- {
69935
- id: "4ut780gy",
69936
- catalogId: "toilet",
69937
- position: {
69938
- x: 80,
69939
- y: 450
69940
- },
69941
- rotation: 0,
69942
- scale: {
69943
- x: 1,
69944
- y: 1,
69945
- z: 1
69946
- }
69947
- },
69948
- {
69949
- id: "b86ttpr9",
69950
- catalogId: "sink_b",
69951
- position: {
69952
- x: 80,
69953
- y: 530
69954
- },
69955
- rotation: 0,
69956
- scale: {
69957
- x: 1,
69958
- y: 1,
69959
- z: 1
69960
- }
69961
- },
69962
- {
69963
- id: "o5vi7zwx",
69964
- catalogId: "toilet",
69965
- position: {
69966
- x: 880,
69967
- y: 450
69968
- },
69969
- rotation: 0,
69970
- scale: {
69971
- x: 1,
69972
- y: 1,
69973
- z: 1
69974
- }
69975
- },
69976
- {
69977
- id: "5n8aegie",
69978
- catalogId: "sink_b",
69979
- position: {
69980
- x: 880,
69981
- y: 530
69982
- },
69983
- rotation: 0,
69984
- scale: {
69985
- x: 1,
69986
- y: 1,
69987
- z: 1
69988
- }
69989
- },
69990
- {
69991
- id: "3srr4a1o",
69992
- catalogId: "camera",
69993
- position: {
69994
- x: 350,
69995
- y: 125
69996
- },
69997
- rotation: 240,
69998
- scale: {
69999
- x: 1,
70000
- y: 1,
70001
- z: 1
70002
- }
70003
- },
70004
- {
70005
- id: "c5t2gb8x",
70006
- catalogId: "camera",
70007
- position: {
70008
- x: 1250,
70009
- y: 175
70010
- },
70011
- rotation: 0,
70012
- scale: {
70013
- x: 1,
70014
- y: 1,
70015
- z: 1
70016
- }
70017
- },
70018
- {
70019
- id: "2i2ebqoi",
70020
- catalogId: "camera",
70021
- position: {
70022
- x: 200,
70023
- y: 775
70024
- },
70025
- rotation: 0,
70026
- scale: {
70027
- x: 1,
70028
- y: 1,
70029
- z: 1
70030
- }
70031
- },
70032
- {
70033
- id: "uem6oqib",
70034
- catalogId: "camera",
70035
- position: {
70036
- x: 350,
70037
- y: 525
70038
- },
70039
- rotation: 225,
70040
- scale: {
70041
- x: 1,
70042
- y: 1,
70043
- z: 1
70044
- }
70045
- },
70046
- {
70047
- id: "h5sbi17v",
70048
- catalogId: "camera",
70049
- position: {
70050
- x: 775,
70051
- y: 450
70052
- },
70053
- rotation: 90,
70054
- scale: {
70055
- x: 1,
70056
- y: 1,
70057
- z: 1
70058
- }
70059
- },
70060
- {
70061
- id: "6uqjgzjq",
70062
- catalogId: "camera",
70063
- position: {
70064
- x: 1275,
70065
- y: 500
70066
- },
70067
- rotation: 345,
70068
- scale: {
70069
- x: 1,
70070
- y: 1,
70071
- z: 1
70072
- }
70073
- }
70074
- ],
70075
- stairs: [],
70076
- columns: [],
70077
- guides: [],
70078
- measurements: [],
70079
- annotations: [],
70080
- textAnnotations: [],
70081
- groups: []
70082
- }],
70083
- activeFloorId: "1fg6pga0",
70084
- createdAt: "2026-04-13T08:10:35.869Z",
70085
- updatedAt: "2026-04-13T08:58:30.617Z"
70086
- });
69452
+ currentProject.set(get(floorData) || createDefaultProject());
70087
69453
  });
70088
69454
  onMount(() => {
70089
69455
  set(ready, true);