Commit Graph

51 Commits

Author SHA1 Message Date
shanyue
f6fbc8d9ff feat(svgcanvas): Trigger 'changed' event on text attribute modifications (#1085)
Some checks failed
CodeQL / Analyze (javascript) (push) Has been cancelled
check each push / build (push) Has been cancelled
* feat(svgcanvas): Trigger 'changed' event on text attribute modifications

This update adds a call to the 'changed' event for various text attribute methods, ensuring that changes to text elements are properly tracked and reflected in the SVG canvas. The methods updated include setBold, setItalic, setTextAnchor, setLetterSpacing, setWordSpacing, setTextLength, setLengthAdjust, setFontFamily, setFontColor, and setFontSize.

* refactor(svgcanvas): Simplify text attribute methods and optimize 'changed' event emission

This update introduces helper functions to streamline the handling of selected text elements and their attribute changes. The methods setBold, setItalic, setTextAnchor, setLetterSpacing, setWordSpacing, and setTextLength now utilize these helpers to filter and notify only modified text elements, improving performance and clarity in event emissions.
2026-03-20 00:23:35 +01:00
shanyue
7c6085e7b9 fix(svgcanvas): Handle 'none' stroke color in SVG elements (#1084)
This update modifies the stroke color handling in both the SvgCanvas and ext-connector modules. When the stroke color is set to 'none', it now correctly assigns an empty string or 'none' instead of a hex value, ensuring proper rendering of SVG elements without strokes.
2026-03-16 16:08:34 +01:00
Geoff Youngs
173dd2607a Fix/rotation recalc compound transforms (#1083)
* Fix rotation recalculation corrupting compound transforms

Two bugs in the rotation center recalculation triggered by attribute
changes on rotated elements:

1. The recalculation fires for ALL attribute changes (stroke-width,
   fill, opacity, etc.) even though only geometric attributes (x, y,
   width, height, d, points, etc.) can change the bbox center. This
   causes unnecessary and incorrect rotation center updates.

2. In undo.js, the center is computed through ALL remaining transforms
   via transformListToTransform(tlist).matrix, but for compound
   transform lists like [translate(tx,ty), rotate(angle)], the
   pre-rotation translate leaks into the center calculation, producing
   rotate(angle, bcx+tx, bcy+ty) instead of the correct
   rotate(angle, bcx, bcy).

3. In history.js (undo/redo), the code replaces the ENTIRE transform
   attribute with just rotate(...), completely destroying any other
   transforms (translate, scale, etc.) in the list.

Fixes:
- Guard recalculation with a BBOX_AFFECTING_ATTRS set so non-geometric
  attribute changes skip the rotation block entirely.
- In undo.js, use transformListToTransform(tlist, n, max) to compute
  the center through only post-rotation transforms.
- In history.js, replace string-based transform replacement with
  transform list API that finds and updates only the rotation entry,
  preserving all other transforms. Extract shared logic into
  relocateRotationCenter() helper.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Add tests for rotation recalculation with compound transforms

Tests demonstrate and verify fixes for three bugs:

1. Non-geometric attributes (stroke-width, fill, opacity) no longer
   trigger rotation center recalculation — the transform list is
   left untouched.

2. Geometric attribute changes on elements with compound transforms
   (e.g. translate + rotate) compute the rotation center using only
   post-rotation transforms, preventing the translate from leaking
   into the center calculation.

3. ChangeElementCommand.apply/unapply preserve compound transform
   structure instead of replacing the entire transform attribute
   with just rotate(...).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Add visual demo and screenshot for rotation recalculation bug

Includes an HTML demo showing both bugs side-by-side:
- Bug 1: Non-geometric attribute changes (stroke-width) on compound
  transforms corrupt character positions (e.g., word art on curves)
- Bug 2: Rotation center computed through ALL transforms instead of
  only post-rotation transforms, causing translate to leak into center

Each panel shows Original / Buggy / Fixed comparisons with the actual
SVG transform math applied. A Playwright script generates screenshots.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Add sample SVG demonstrating compound transform corruption bug

A pinwheel of 6 colored rectangles using translate(200,200) rotate(N).
Loading this into SVG-Edit and changing stroke-width on the group
triggers the rotation recalculation bug on unfixed builds.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Fix standard linting: object properties on separate lines

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Centralize BBOX_AFFECTING_ATTRS and fix bbox-before-remove safety

Address two code review comments:

1. Export BBOX_AFFECTING_ATTRS from history.js and import it in undo.js
   so the attribute list is defined in one place.

2. Compute getBBox() before calling tlist.removeItem() so that a falsy
   bbox causes an early return/break without having already destroyed
   the rotation transform.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-15 22:28:53 +01:00
Namhoon Lee
0be0c3916c fix(text-actions): Calculate accumulated transform matrix for text inside groups (#1082)
Some checks failed
CodeQL / Analyze (javascript) (push) Has been cancelled
check each push / build (push) Has been cancelled
When editing text inside a group element, the text cursor was appearing
in the wrong position because only the text element's own transform was
being considered, ignoring transforms from parent groups.

This change:
- Adds a new #getAccumulatedMatrix() method that traverses up the DOM tree
  from the text element to the SVG content element, collecting and multiplying
  all transform matrices along the way
- Updates the init() method to use this accumulated matrix instead of just
  the text element's transform
- Updates test mock to include getSvgContent() method

Fixes the issue where editing text inside a transformed group would show
the cursor at the wrong position.

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 14:57:35 +01:00
shanyue
b9149f73cb Update svgWhiteList in sanitize.js to include 'font-stretch' for rele… (#1081)
* Update svgWhiteList in sanitize.js to include 'font-stretch' for relevant SVG elements
* Refactor svgWhiteList in sanitize.js to utilize FONT_ATTRIBUTES for better maintainability and consistency across SVG elements
2026-01-30 15:28:57 +01:00
JFH
97386d20b5 Jan2026 fixes (#1077)
* fix release script
* fix svgcanvas edge cases
* Update path-actions.js
* add modern js
* update deps
* Update CHANGES.md
2026-01-11 00:57:06 +01:00
JFH
7ca39b6471 add flip buttons
also update svgedit.css
2025-12-07 18:56:10 +01:00
JFH
370ba56ff0 Simplify publish process 2025-12-07 18:20:29 +01:00
JFH
fa380402e1 increase test coverage
extend test coverage
2025-12-07 10:56:29 +01:00
JFH
a37fbac749 migration to vite/playwright 2025-11-30 19:10:16 +01:00
JFH
babd3490c9 Nov25 fixes (#1072)
* update deps
* fixes #963 and #1061
* fix the issue #974
* update test
2025-11-27 18:10:49 +01:00
JFH
3f9d674854 svgcanvas 7.2.7 2025-06-09 17:01:41 +02:00
JFH
865d1bea33 Prefer href to xlink href (#1059) 2025-06-09 16:59:29 +08:00
JFH
887ad2e39f Fix group rotation (#1058)
* Update history.js
- Change `BatchCommand.unapply` to use `[...this.commands].reverse()` so the original array is never mutated.
- This preserves the order of commands and ensures history integrity.
2025-06-09 00:33:39 +08:00
Michael S. Scherotter
c127c3734b Fixed a bug where a rotated text or image did not translate correctly. (#1055) 2025-05-21 08:27:57 +02:00
JFH
ede259ae87 7.3.7 2025-05-12 10:36:09 +02:00
Michael S. Scherotter
f962f9d884 Fixed issue where foreignObject contents styles were getting removed on object moving (#1053) 2025-05-05 08:55:18 +02:00
Michael S. Scherotter
4b822fe190 Fixed issue where svgToString was converting HTML elements to uppercase in svgCanvas.svgToString() (#1051) 2025-05-01 23:02:34 +02:00
JFH
c22cc05006 fixes #1042 (#1043) 2025-04-01 12:08:06 +02:00
JFH
1859978590 release 2025-03-28 20:09:29 +01:00
Michael S. Scherotter
dc0ce52e71 Html elements in foreign object (#1041) 2025-03-28 18:00:19 +01:00
JFH
88be19fa59 release 7.3.5
* update react-test to react 19

* release 7.3.5
2025-03-09 22:46:01 +01:00
JFH
42840d51de Update to allow commas (#1023)
* update dependencies
* allow commas for separators
2025-02-23 14:21:25 +01:00
JFH
403237c182 Fix text scale #1008 (#1010)
* update dependencies

* fix #1008 by adjusting font-size

(allowing to keep the text keep his proportions to the font)

* refactor math.js
2024-12-27 21:37:05 +01:00
JFH
f0549e4629 Tspan fix (#1006)
* avoid creating x,y in a moving tspan if they didn't exist

* upgrade deps
2024-11-10 14:29:45 +01:00
JFH
3607cc8d69 Fix layer initialisation for orphans (#1005)
* beautify with standard

* update dependencies

* name is created below so no need here

* initialize name before using it.
2024-10-27 12:33:15 +01:00
JFH
989f637e6c Update whitelist with dominant-baseline (#1004) 2024-10-26 19:47:15 +02:00
JFH
346378ead6 convert to base64 before export as CORS restrictions would break the export of linked images (#1003) 2024-10-26 19:26:11 +02:00
JFH
23c6bc2e23 September updates (#992)
* fix deprecated apple-mobile -web-app-capable
* fix issue #974
* update dependencies
* fix a trailing space for points
* fix issue with tspan recalculation
2024-09-16 13:13:05 +02:00
JFH
0c44b49450 Update dep (#988)
* update and adapt code to latest dependencies

-> need testIsolation to False with the latest Cypress

* need this for CI (bug https://github.com/npm/cli/issues/4828)

* run instrument before test

* fix test

* v7.3.4
2024-08-18 23:51:28 +02:00
Delmo Heredia
2c3f20635b Add convertUnit utility function to SvgCanvas instance (#965) 2024-04-23 16:22:06 +02:00
Delmo Heredia
04ab3dd873 Fix initial stroke width (#959)
* Fix initial stroke width

* refresh packages

* update snapshots

* Update issue-752.cy.js

---------

Co-authored-by: JFH <20402845+jfhenon@users.noreply.github.com>
2024-04-18 13:58:59 +02:00
cg-scorpio
b166aa02c7 detect a g layer with the className "Layer" instead of a non empty title (#955)
* detect a g layer with the className "Layer" instead of a non empty title

* fix TU
2024-03-12 06:19:47 +01:00
olekhshch
9f77e9c63a fix #832, floating btns closing, Esc to close confirmation dialog, 0x0 rects disabled (#947) 2024-01-20 22:53:20 +00:00
olekhshch
19403a2755 Panning, modeChange Event, minor changes (#939)
* mode event, panning cursor

* Panning shortcuts(space,wheel), undo shortcut

* Undo/redo shortcuts, svgcanvas changes added to the main file

* minor refactoring
2023-12-28 11:20:26 +01:00
JFH
2b9fa0be0c release 7.2.2 2023-12-10 11:22:50 +01:00
JFH
f0e4407f44 Fix export (#936)
* fix export

* improve dialog and fix quality
2023-12-10 10:52:20 +01:00
JFH
ec3e0522df Fixes issue with xy panel (#935)
* update deps

* fixes #930

* update workflow

* Update TopPanel.js

* fix side effects

* Update utilities-performance.cy.js
2023-12-09 17:17:10 +01:00
Mo'ath Zaghdad
0895235c17 fix: Enhance text properties for multiple selected elements (SVG-Edit/svgedit#918) (#919)
* fix: Enhance text properties for multiple selected elements (SVG-Edit/svgedit#918)

This commit addresses issue SVG-Edit/svgedit#918 by improving
text property handling when multiple elements are selected.
You can now set Bold, Italic, Text-Decoration, Text-Anchor,
Letter-Spacing, Word-Spacing, Text Length, and Length Adjust.

* Update Editor.js

---------

Co-authored-by: JFH <20402845+jfhenon@users.noreply.github.com>
2023-09-18 12:38:41 +02:00
JFH
24b8f74c4d Connector extension (#916)
* npm update
* move connector extension back
2023-08-25 23:47:16 +02:00
JFH
420861f408 update npm packages, refresh ar language. (#901)
* update npm packages

* Update lang.ar.js

* fix linter issues

* update version to publish

---------

Co-authored-by: Abdelmjid Saber <87904671+abdelmjid-saber@users.noreply.github.com>
2023-05-28 09:36:05 +02:00
JFH
13cdaedc63 Fix #879 (#883)
* create and use getTransformList
* update dependencies
2023-03-31 01:57:06 +02:00
JFH
00a7d61122 Update packages and remove the instrument step (#854)
* several updates
* avoid the instrumented step in tests
2022-11-27 23:01:27 +01:00
pmkrawczyk
c0d0db4d7e Prevent accidental selection move (#848) 2022-11-27 10:28:55 +01:00
pmkrawczyk
e08648c8f5 Maintain aspect ratio by default for images (#847) 2022-11-05 19:32:12 +01:00
cg-scorpio
ae243ce906 Code securisation (#843)
* Fix: securize convertToGroup method when manipulate element with no transform attribute
* Fix: securise getIntersectionListMethod method when manipulate element with no bbox (for example : defs element)
* Fix: securise resize method when there is no bbox (for example : defs element)
* Fix: securise recalculateDimensions to avoid to pass null to addSubCommand
2022-10-26 15:38:54 +02:00
cg-scorpio
8350b97875 Enhancement: add a parameter to the importSvgString function in order… (#842)
* Enhancement: add a parameter to the importSvgString function in order to permit to decide if the importation should apply a transformation on the imported element or not

* allow user to import SVG preserving the dimension

Co-authored-by: JFH <20402845+jfhenon@users.noreply.github.com>
2022-10-16 23:30:44 +02:00
cg-scorpio
cb2fe733dd Fix fit to content (#841)
* Fix: avoid to select defs or title as parentElement

* Fix: fix problem when nothing is drawing
2022-10-16 15:43:58 +02:00
cg-scorpio
aabd593123 Fix: avoid to select defs or title as parentElement (#840)
* Fix: avoid to select defs or title as parentElement
2022-10-15 17:21:14 +02:00
cg-scorpio
e2ad8211a5 Fix: applies the transformation of the parent element in addition to … (#839)
* Fix: applies the transformation of the parent element in addition to that of the selected element

* Fix:  delete debug logs and use a ternary operator
2022-10-14 20:17:49 +02:00