clone

a browser-first diagram editor with live svg previews, local drafts and encrypted, accountless sharing

fix: normalize Svgbob line art consistently

Dami committed 618dec7
commit
618dec713a785d7f02c919bc1c683bf6750b0cd8
parent
714fe738c6ab2eed7f0678375180eeb645af9760
author
Dami <dami.etoile@gmail.com>
2 files changed, +31 -2
Mapps/editor/test/svg-contract.test.js19+++++++++++++++++++
Mshared/svg/index.js14++++++++++++--
M apps/editor/test/svg-contract.test.js +19 -0
@@ -179,6 +179,25 @@ test('applies D2, PlantUML, Svgbob, and neutral SVG family roles', () => {
179179 }180180 })181181 182+test('themes every Svgbob stroke without treating open curves as object surfaces', () => {183+ const canonical = canonicalizeSvg(184+ '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 40 20" class="svgbob"><path id="curve" d="M 8,2 A 8,8 0,0,0 8,18" class="nofill"></path><path id="closed" d="M20 2L30 2L30 18L20 18Z" class="nofill"></path><line id="plain" x1="2" y1="10" x2="6" y2="10"></line><rect id="box" x="32" y="2" width="6" height="16" class="solid nofill"></rect></svg>',185+ metadata, 'svgbob', 'svgbob@0.7.6/edge-wasm-1',186+ )187+188+ const curve = canonical.match(/<path id="curve"[^>]*>/)?.[0] ?? ''189+ const closed = canonical.match(/<path id="closed"[^>]*>/)?.[0] ?? ''190+ const plain = canonical.match(/<line id="plain"[^>]*>/)?.[0] ?? ''191+ const box = canonical.match(/<rect id="box"[^>]*>/)?.[0] ?? ''192+ assert.match(curve, /data-dz-stroke="line"/)193+ assert.doesNotMatch(curve, /data-dz-fill=/)194+ assert.match(closed, /data-dz-stroke="line"/)195+ assert.match(closed, /data-dz-fill="surface-1"/)196+ assert.match(plain, /data-dz-stroke="line"/)197+ assert.match(box, /data-dz-stroke="line"/)198+ assert.match(box, /data-dz-fill="surface-1"/)199+})200+182201 test('adapts neutral authored paint while preserving non-neutral paint and transparent support', () => {183202 const source = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10"><rect width="10" height="10" fill="white"></rect><path d="M1 1L9 9" stroke="hotpink"></path><text x="2" y="6" fill="black">A</text></svg>'184203 const canonical = canonicalizeSvg(source, metadata, 'tikz', '@planktimerr/tikzjax@1.0.63/client-unit-1')
M shared/svg/index.js +12 -2