### Start Development Server Source: https://github.com/svg-edit/svgedit/blob/master/docs/Development.md Starts the development server. This is a prerequisite for some testing commands. ```bash npm start ``` -------------------------------- ### Build and Serve Documentation Source: https://github.com/svg-edit/svgedit/blob/master/docs/Development.md Commands to build the project's documentation. Use `open-docs` to start a server and view the built documentation, or `build-and-open-docs` to perform both actions. ```bash npm run build-docs ``` ```bash npm run open-docs ``` ```bash npm run open-docs-no-start ``` ```bash npm run build-and-open-docs ``` ```bash npm run build-and-open-docs-no-start ``` -------------------------------- ### Open ESM Editor with All Extensions Source: https://github.com/svg-edit/svgedit/blob/master/docs/Development.md Launches the ESM editor with all extensions. Use `npm run open-all-ext-no-start` if a start process is already running. ```bash npm run open-all-ext ``` ```bash npm run open-all-ext-no-start ``` -------------------------------- ### Hello World Extension Example Source: https://github.com/svg-edit/svgedit/blob/master/docs/tutorials/ExtensionDocs.md A basic 'Hello World' extension demonstrating how to add a button, define event handlers like 'mouseDown' and 'mouseUp', and specify SVG icons and internationalization data. ```javascript export default { name: 'helloworld', init () { return { svgicons: 'extensions/helloworld-icon.xml', buttons: [ { /* ... */ } ], mouseDown () { // ... }, mouseUp (_opts) { // ... } } } } ``` -------------------------------- ### Run End-to-End Playwright Tests Source: https://github.com/svg-edit/svgedit/blob/master/docs/Development.md Builds the app, starts `vite preview`, and executes Playwright end-to-end tests against the editor. ```bash npm run test:e2e ``` -------------------------------- ### Open Compiled Editor for Production Source: https://github.com/svg-edit/svgedit/blob/master/docs/Development.md Launches a pre-compiled editor suitable for production environments. Requires running the `prep` script beforehand. Use `npm run open-compiled-no-start` if a start process is already running. ```bash npm run open-compiled ``` ```bash npm run open-compiled-no-start ``` -------------------------------- ### Open ESM Editor with Default Extensions Source: https://github.com/svg-edit/svgedit/blob/master/docs/Development.md Launches the ESM editor with default extensions. Use `npm run open-no-start` if a start process is already running. ```bash npm run open ``` ```bash npm run open-no-start ``` -------------------------------- ### Open Embedded ESM Editor Source: https://github.com/svg-edit/svgedit/blob/master/docs/Development.md Launches an embedded ESM editor, also starting a separate server for cross-origin testing. Use `npm run open-embedded-no-start` if a start process is already running. ```bash npm run open-embedded ``` ```bash npm run open-embedded-no-start ``` -------------------------------- ### Open HTML Test Coverage Report Source: https://github.com/svg-edit/svgedit/blob/master/docs/Development.md Opens the HTML-based test coverage report in the browser, showing coverage status for all lines. Use `npm run open-cov-no-start` if a start process is already running. ```bash npm run open-cov ``` ```bash npm run open-cov-no-start ``` -------------------------------- ### Configure SVG-Edit with User Extensions Source: https://github.com/svg-edit/svgedit/blob/master/README.md Configure SVG-Edit to load custom user extensions. This example shows how to specify the path to a React-based extension bundle. ```javascript svgEditor.setConfig({ allowInitialUserOverride: true, extensions: [], noDefaultExtensions: false, userExtensions: ['./react-extensions/react-test/dist/react-test.js'] }) ``` -------------------------------- ### Install SVG-Edit Canvas Source: https://github.com/svg-edit/svgedit/blob/master/README.md Install the SVG-Edit canvas package using npm. This package provides the core functionality for SVG manipulation. ```bash npm i -s "@svgedit/svgcanvas" ``` -------------------------------- ### Build Project Source: https://github.com/svg-edit/svgedit/blob/master/docs/ReleaseInstructions.md Build all workspaces and the main editor from the root directory. This must pass before a version bump. ```bash npm run build ``` -------------------------------- ### Import SVG-Edit Canvas Source: https://github.com/svg-edit/svgedit/blob/master/README.md Import the SVG-Edit canvas into your application after installation. This makes the canvas available for use in your framework. ```javascript import svgCanvas from '@svgedit/svgcanvas' ``` -------------------------------- ### Initialize SvgCanvas and Basic Configuration Source: https://github.com/svg-edit/svgedit/blob/master/packages/svgcanvas/demos/canvas.html Initializes the SvgCanvas with a container element and configuration options. Use this to set up the drawing environment. ```javascript /* globals canvas */ import SvgCanvas from '@svgedit/svgcanvas' const container = document.querySelector('#editorContainer') const { width, height } = { width: 500, height: 300 } window.width = width window.height = height const hiddenTextTagId = 'text' const config = { initFill: { color: 'FFFFFF', opacity: 1 }, initStroke: { color: '000000', opacity: 1, width: 1 }, text: { stroke_width: 0, font_size: 24, font_family: 'serif' }, initOpacity: 1, imgPath: '/src/editor/images', dimensions: [ width, height ], baseUnit: 'px' } window.canvas = new SvgCanvas(container, config) canvas.updateCanvas(width, height) ``` -------------------------------- ### Run Tests Source: https://github.com/svg-edit/svgedit/blob/master/docs/ReleaseInstructions.md Execute all tests, including accessibility tests, before proceeding with a version bump. Address or accept known failures. ```bash npm test ``` -------------------------------- ### Initialize and Configure SVG Editor Source: https://github.com/svg-edit/svgedit/blob/master/src/editor/index.html Import the Editor class and instantiate it with a container element. Configure editor options such as allowing user overrides, managing extensions, and specifying user extensions. Finally, initialize the editor. ```javascript import Editor from './Editor.js' /* for available options see the file `docs/tutorials/ConfigOptions.md` */ const svgEditor = new Editor(document.getElementById('container')) svgEditor.setConfig({ allowInitialUserOverride: true, extensions: [], noDefaultExtensions: false, userExtensions: [/* { pathName: '/packages/react-test/dist/react-test.js' } */] }) svgEditor.init() ``` -------------------------------- ### Run Full Release Checks Source: https://github.com/svg-edit/svgedit/blob/master/docs/ReleaseInstructions.md Execute comprehensive release checks including tests, documentation generation, and building the project. The script exits on failure. ```bash npm run test-build ``` -------------------------------- ### Integrate SVGEdit into a Web Application Source: https://github.com/svg-edit/svgedit/blob/master/README.md Include the SVGEdit CSS and initialize the editor within a specified HTML div. Ensure the div has numeric width and height. Configuration options are available in `docs/tutorials/ConfigOptions.md`. ```html