Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make SvgCanvas class accessible from bundle #964

Closed

Conversation

delmohf
Copy link
Contributor

@delmohf delmohf commented Apr 22, 2024

I'm using the bundle version of svgedit (as a package npm i svgedit), and I wanna use convertUnit utility which was defined in the module packages/svgcanvas/core/units.js and attached to SvgCanvas class so I thought it should be used as below:

import SvgCanvas from '@svgedit/svgcanvas';
SvgCanvas.convertUnit(38, 'cm');

but the following error arised:

image

getRoundDigits (or even getBaseUnit if I just call SvgCanvas.convertUnit(38)) is a method of SvgCanvas instance created by EditorStartup during initialization and consequently injected to the module units.js.

The problem is that the instance of SvgCanvas is actually in the bundle, not in @svgedit/svgcanvas.

I fixed this issue in a simple way, just re-exporting SvgCanvas from Editor.js as show in this pull request but there could be other ways.

@delmohf delmohf changed the title Make svgcanvas class accessible from bundle Make SvgCanvas class accessible from bundle Apr 22, 2024
@delmohf
Copy link
Contributor Author

delmohf commented Apr 23, 2024

I found that utility function convertUnit was not added to svgCanvas instance which looks like the proper behaviour because the opposite operation convertToNum was indeed added so check my PR #965 which seems a more suitable solution.

@delmohf delmohf closed this Apr 23, 2024
@delmohf delmohf deleted the make-svgcanvas-class-accessible branch April 23, 2024 16:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant