svedit 0.6.3 → 0.6.4

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.
@@ -111,6 +111,7 @@
111
111
  class="text svedit-selectable {css_class}"
112
112
  class:empty={is_empty}
113
113
  class:focused={is_focused}
114
+ class:editable={svedit.editable}
114
115
  {placeholder}
115
116
  >
116
117
  {#each fragments as fragment, index (index)}
@@ -157,6 +158,11 @@
157
158
  outline: 1px solid var(--editing-stroke-color);
158
159
  }*/
159
160
 
161
+ /* Disable text-transform when editable and focused so users see original text */
162
+ .text.editable.focused {
163
+ text-transform: none !important;
164
+ }
165
+
160
166
  /* Dim the selection highlight when canvas loses native focus */
161
167
  :global(.svedit-canvas:not(:focus)) .selection-highlight {
162
168
  background: oklch(from var(--editing-fill-color) l 0.02 h / 0.3);
@@ -423,7 +423,8 @@ ${fallback_html}`;
423
423
  * @param {boolean} delete_selection - used by oncut()
424
424
  */
425
425
  function oncopy(event, delete_selection = false) {
426
- // Only handle copy events if focus is within the canvas
426
+ // Only handle copy events if editable and focus is within the canvas
427
+ if (!editable) return;
427
428
  if (!canvas_el?.contains(document.activeElement)) return;
428
429
 
429
430
  event.preventDefault();
@@ -493,6 +494,7 @@ ${fallback_html}`;
493
494
  }
494
495
 
495
496
  function oncut(event) {
497
+ if (!editable) return;
496
498
  oncopy(event, true);
497
499
  }
498
500
 
@@ -563,7 +565,8 @@ ${fallback_html}`;
563
565
  }
564
566
 
565
567
  async function onpaste(event) {
566
- // Only handle paste events if focus is within the canvas
568
+ // Only handle paste events if editable and focus is within the canvas
569
+ if (!editable) return;
567
570
  if (!canvas_el?.contains(document.activeElement)) return;
568
571
  event.preventDefault();
569
572
 
@@ -1 +1 @@
1
- {"version":3,"file":"Svedit.svelte.d.ts","sourceRoot":"","sources":["../src/lib/Svedit.svelte.js"],"names":[],"mappings":";;;;;;;AA+yCA;;eAAqD;iCAxxC1C,cAAc"}
1
+ {"version":3,"file":"Svedit.svelte.d.ts","sourceRoot":"","sources":["../src/lib/Svedit.svelte.js"],"names":[],"mappings":";;;;;;;AAkzCA;;eAAqD;iCA3xC1C,cAAc"}
@@ -727,8 +727,8 @@ export default class Transaction {
727
727
  return annotation;
728
728
  }
729
729
 
730
- // Annotation starts at the insertion point - extend it
731
- if (annotation_start <= range.start_offset && annotation_end >= range.start_offset) {
730
+ // Insertion point is inside the annotation (not at the start) - extend it
731
+ if (annotation_start < range.start_offset && annotation_end >= range.start_offset) {
732
732
  return {
733
733
  start_offset: annotation_start,
734
734
  end_offset: annotation_end + delta,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svedit",
3
- "version": "0.6.3",
3
+ "version": "0.6.4",
4
4
  "license": "MIT",
5
5
  "scripts": {
6
6
  "dev": "vite dev",
@@ -111,6 +111,7 @@
111
111
  class="text svedit-selectable {css_class}"
112
112
  class:empty={is_empty}
113
113
  class:focused={is_focused}
114
+ class:editable={svedit.editable}
114
115
  {placeholder}
115
116
  >
116
117
  {#each fragments as fragment, index (index)}
@@ -157,6 +158,11 @@
157
158
  outline: 1px solid var(--editing-stroke-color);
158
159
  }*/
159
160
 
161
+ /* Disable text-transform when editable and focused so users see original text */
162
+ .text.editable.focused {
163
+ text-transform: none !important;
164
+ }
165
+
160
166
  /* Dim the selection highlight when canvas loses native focus */
161
167
  :global(.svedit-canvas:not(:focus)) .selection-highlight {
162
168
  background: oklch(from var(--editing-fill-color) l 0.02 h / 0.3);
@@ -423,7 +423,8 @@ ${fallback_html}`;
423
423
  * @param {boolean} delete_selection - used by oncut()
424
424
  */
425
425
  function oncopy(event, delete_selection = false) {
426
- // Only handle copy events if focus is within the canvas
426
+ // Only handle copy events if editable and focus is within the canvas
427
+ if (!editable) return;
427
428
  if (!canvas_el?.contains(document.activeElement)) return;
428
429
 
429
430
  event.preventDefault();
@@ -493,6 +494,7 @@ ${fallback_html}`;
493
494
  }
494
495
 
495
496
  function oncut(event) {
497
+ if (!editable) return;
496
498
  oncopy(event, true);
497
499
  }
498
500
 
@@ -563,7 +565,8 @@ ${fallback_html}`;
563
565
  }
564
566
 
565
567
  async function onpaste(event) {
566
- // Only handle paste events if focus is within the canvas
568
+ // Only handle paste events if editable and focus is within the canvas
569
+ if (!editable) return;
567
570
  if (!canvas_el?.contains(document.activeElement)) return;
568
571
  event.preventDefault();
569
572
 
@@ -727,8 +727,8 @@ export default class Transaction {
727
727
  return annotation;
728
728
  }
729
729
 
730
- // Annotation starts at the insertion point - extend it
731
- if (annotation_start <= range.start_offset && annotation_end >= range.start_offset) {
730
+ // Insertion point is inside the annotation (not at the start) - extend it
731
+ if (annotation_start < range.start_offset && annotation_end >= range.start_offset) {
732
732
  return {
733
733
  start_offset: annotation_start,
734
734
  end_offset: annotation_end + delta,