2018-05-18 03:25:45 +00:00
/* eslint-disable indent */
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
/* globals jQuery, jsPDF */
2011-10-01 04:41:14 +00:00
/ *
2009-11-25 13:51:42 +00:00
* svgcanvas . js
*
2012-09-16 18:53:27 +00:00
* Licensed under the MIT License
2009-11-25 13:51:42 +00:00
*
2010-01-06 04:35:41 +00:00
* Copyright ( c ) 2010 Alexis Deveria
* Copyright ( c ) 2010 Pavol Rusnak
* Copyright ( c ) 2010 Jeff Schiller
2009-11-25 13:51:42 +00:00
*
* /
2010-01-08 20:36:39 +00:00
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
/ * D e p e n d e n c i e s :
1. Also expects jQuery UI for ` svgCanvasToString ` and
` convertToGroup ` use of ` :data() ` selector
* /
2010-10-28 06:08:45 +00:00
2018-05-18 03:25:45 +00:00
import './pathseg.js' ;
import canvg from './canvg/canvg.js' ;
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
import jqPluginSVG from './jquery-svg.js' ; // Needed for SVG attribute setting and array form with `attr`
2018-05-18 03:25:45 +00:00
import * as draw from './draw.js' ;
import * as pathModule from './path.js' ;
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
import { sanitizeSvg } from './sanitize.js' ;
2018-05-18 03:25:45 +00:00
import { getReverseNS , NS } from './svgedit.js' ;
import {
text2xml , assignAttributes , cleanupElement , getElem , getUrlFromAttr ,
findDefs , getHref , setHref , getRefElem , getRotationAngle , getPathBBox ,
preventClickDefault , snapToGrid , walkTree , walkTreePost ,
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
getBBoxOfElementAsPath , convertToPath , toXml , encode64 , decode64 ,
2018-05-18 03:25:45 +00:00
buildJSPDFCallback , dataURLToObjectURL , createObjectURL ,
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
buildCanvgCallback , getVisibleElements , executeAfterLoads ,
init as utilsInit , getBBox as utilsGetBBox , getStrokedBBoxDefaultVisible
2018-05-18 03:25:45 +00:00
} from './svgutils.js' ;
import * as history from './history.js' ;
import {
transformPoint , matrixMultiply , hasMatrixTransform , transformListToTransform ,
getMatrix , snapToAngle , isIdentity , rectsIntersect , transformBox
} from './math.js' ;
import {
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
convertToNum , convertAttrs , convertUnit , shortFloat , getTypeMap ,
init as unitsInit
} from './units.js' ;
2018-05-18 03:25:45 +00:00
import {
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
isGecko , isChrome , isIE , isWebkit , supportsNonScalingStroke , supportsGoodTextCharPos
2018-05-18 03:25:45 +00:00
} from './browser.js' ; // , supportsEditableText
import {
getTransformList , resetListMap ,
SVGTransformList as SVGEditTransformList
} from './svgtransformlist.js' ;
import {
remapElement ,
init as coordsInit
} from './coords.js' ;
import {
recalculateDimensions ,
init as recalculateInit
} from './recalculate.js' ;
import {
getSelectorManager ,
init as selectInit
} from './select.js' ;
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
const $ = jqPluginSVG ( jQuery ) ;
2018-05-18 03:25:45 +00:00
const {
MoveElementCommand , InsertElementCommand , RemoveElementCommand ,
ChangeElementCommand , BatchCommand , UndoManager , HistoryEventTypes
} = history ;
2013-02-15 15:51:58 +00:00
if ( ! window . console ) {
2018-05-18 04:02:30 +00:00
window . console = { } ;
window . console . log = function ( str ) { } ;
window . console . dir = function ( str ) { } ;
2009-06-23 05:17:53 +00:00
}
2013-02-15 15:51:58 +00:00
if ( window . opera ) {
2018-05-18 04:02:30 +00:00
window . console . log = function ( str ) { opera . postError ( str ) ; } ;
window . console . dir = function ( str ) { } ;
2009-12-31 15:25:57 +00:00
}
2014-01-31 10:40:52 +00:00
2010-06-18 20:35:47 +00:00
// Class: SvgCanvas
// The main SvgCanvas class that manages all SVG-related functions
//
// Parameters:
// container - The container HTML element that should hold the SVG root element
// config - An object that contains configuration data
2018-05-17 05:15:20 +00:00
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
export default class {
constructor ( container , config ) {
2013-02-16 15:02:26 +00:00
// Alias Namespace constants
2010-11-07 05:20:03 +00:00
2010-11-06 00:45:21 +00:00
// Default configuration options
2018-05-18 03:25:45 +00:00
const curConfig = {
2018-05-18 04:02:30 +00:00
show _outside _canvas : true ,
selectNew : true ,
dimensions : [ 640 , 480 ]
2010-11-06 00:45:21 +00:00
} ;
// Update config with new one if given
2013-02-15 15:51:58 +00:00
if ( config ) {
2018-05-18 04:02:30 +00:00
$ . extend ( curConfig , config ) ;
2010-11-06 00:45:21 +00:00
}
2010-11-05 17:00:32 +00:00
2010-11-15 09:25:49 +00:00
// Array with width/height of canvas
2018-05-18 03:25:45 +00:00
const { dimensions } = curConfig ;
2010-11-15 09:25:49 +00:00
2018-05-18 03:25:45 +00:00
const canvas = this ;
2010-11-12 19:08:29 +00:00
2010-11-07 05:20:03 +00:00
// "document" element associated with the container (same as window.document using default svg-editor.js)
2018-05-18 03:25:45 +00:00
// NOTE: This is not actually a SVG document, but an HTML document.
const svgdoc = container . ownerDocument ;
2010-11-07 05:20:03 +00:00
2010-11-15 09:25:49 +00:00
// This is a container for the document being edited, not the document itself.
2018-05-18 03:25:45 +00:00
const svgroot = svgdoc . importNode (
text2xml (
2018-05-18 04:02:30 +00:00
'<svg id="svgroot" xmlns="' + NS . SVG + '" xlinkns="' + NS . XLINK + '" ' +
'width="' + dimensions [ 0 ] + '" height="' + dimensions [ 1 ] + '" x="' + dimensions [ 0 ] + '" y="' + dimensions [ 1 ] + '" overflow="visible">' +
'<defs>' +
'<filter id="canvashadow" filterUnits="objectBoundingBox">' +
'<feGaussianBlur in="SourceAlpha" stdDeviation="4" result="blur"/>' +
'<feOffset in="blur" dx="5" dy="5" result="offsetBlur"/>' +
'<feMerge>' +
'<feMergeNode in="offsetBlur"/>' +
'<feMergeNode in="SourceGraphic"/>' +
'</feMerge>' +
'</filter>' +
'</defs>' +
'</svg>'
) . documentElement ,
true
2018-05-16 08:32:44 +00:00
) ;
2010-11-15 09:25:49 +00:00
container . appendChild ( svgroot ) ;
2010-11-07 05:20:03 +00:00
// The actual element that represents the final output SVG element
2018-05-18 03:25:45 +00:00
let svgcontent = svgdoc . createElementNS ( NS . SVG , 'svg' ) ;
2010-11-07 05:20:03 +00:00
2011-02-01 07:22:18 +00:00
// This function resets the svgcontent element while keeping it in the DOM.
2018-05-18 03:25:45 +00:00
const clearSvgContentElement = canvas . clearSvgContentElement = function ( ) {
2018-05-18 04:02:30 +00:00
$ ( svgcontent ) . empty ( ) ;
// TODO: Clear out all other attributes first?
$ ( svgcontent ) . attr ( {
id : 'svgcontent' ,
width : dimensions [ 0 ] ,
height : dimensions [ 1 ] ,
x : dimensions [ 0 ] ,
y : dimensions [ 1 ] ,
overflow : curConfig . show _outside _canvas ? 'visible' : 'hidden' ,
xmlns : NS . SVG ,
'xmlns:se' : NS . SE ,
'xmlns:xlink' : NS . XLINK
} ) . appendTo ( svgroot ) ;
// TODO: make this string optional and set by the client
2018-05-18 03:25:45 +00:00
const comment = svgdoc . createComment ( ' Created with SVG-edit - https://github.com/SVG-Edit/svgedit' ) ;
2018-05-18 04:02:30 +00:00
svgcontent . appendChild ( comment ) ;
2011-02-01 07:22:18 +00:00
} ;
clearSvgContentElement ( ) ;
2010-11-15 09:25:49 +00:00
2011-01-14 18:18:29 +00:00
// Prefix string for element IDs
2018-05-18 03:25:45 +00:00
let idprefix = 'svg_' ;
2011-01-14 18:18:29 +00:00
// Function: setIdPrefix
// Changes the ID prefix to the given value
//
2018-05-16 00:53:27 +00:00
// Parameters:
// p - String with the new prefix
2018-05-16 08:32:44 +00:00
canvas . setIdPrefix = function ( p ) {
2018-05-18 04:02:30 +00:00
idprefix = p ;
2011-01-14 18:18:29 +00:00
} ;
2011-01-16 23:07:35 +00:00
// Current svgedit.draw.Drawing object
// @type {svgedit.draw.Drawing}
2018-05-18 03:25:45 +00:00
canvas . current _drawing _ = new draw . Drawing ( svgcontent , idprefix ) ;
2011-01-14 18:18:29 +00:00
2011-01-16 23:07:35 +00:00
// Function: getCurrentDrawing
// Returns the current Drawing.
// @return {svgedit.draw.Drawing}
2018-05-18 03:25:45 +00:00
const getCurrentDrawing = canvas . getCurrentDrawing = function ( ) {
2018-05-18 04:02:30 +00:00
return canvas . current _drawing _ ;
2011-01-14 18:18:29 +00:00
} ;
2010-11-07 05:20:03 +00:00
// Float displaying the current zoom level (1 = 100%, .5 = 50%, etc)
2018-05-18 03:25:45 +00:00
let currentZoom = 1 ;
2010-11-07 05:20:03 +00:00
2010-11-15 09:25:49 +00:00
// pointer to current group (for in-group editing)
2018-05-18 03:25:45 +00:00
let currentGroup = null ;
2010-11-15 09:25:49 +00:00
// Object containing data for the currently selected styles
2018-05-18 03:25:45 +00:00
const allProperties = {
2018-05-18 04:02:30 +00:00
shape : {
fill : ( curConfig . initFill . color === 'none' ? '' : '#' ) + curConfig . initFill . color ,
fill _paint : null ,
fill _opacity : curConfig . initFill . opacity ,
stroke : '#' + curConfig . initStroke . color ,
stroke _paint : null ,
stroke _opacity : curConfig . initStroke . opacity ,
stroke _width : curConfig . initStroke . width ,
stroke _dasharray : 'none' ,
stroke _linejoin : 'miter' ,
stroke _linecap : 'butt' ,
opacity : curConfig . initOpacity
}
2010-11-15 09:25:49 +00:00
} ;
2018-05-16 08:32:44 +00:00
allProperties . text = $ . extend ( true , { } , allProperties . shape ) ;
$ . extend ( allProperties . text , {
2018-05-18 04:02:30 +00:00
fill : '#000000' ,
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
stroke _width : curConfig . text && curConfig . text . stroke _width ,
font _size : curConfig . text && curConfig . text . font _size ,
font _family : curConfig . text && curConfig . text . font _family
2010-11-15 09:25:49 +00:00
} ) ;
// Current shape style properties
2018-05-18 03:25:45 +00:00
const curShape = allProperties . shape ;
2010-11-15 09:25:49 +00:00
2010-12-02 17:14:24 +00:00
// Array with all the currently selected elements
// default size of 1 until it needs to grow bigger
2018-05-18 03:25:45 +00:00
let selectedElements = [ ] ;
2010-12-02 17:14:24 +00:00
2018-05-18 03:25:45 +00:00
const getJsonFromSvgElement = this . getJsonFromSvgElement = function ( data ) {
2018-05-18 04:02:30 +00:00
// Text node
if ( data . nodeType === 3 ) return data . nodeValue ;
2018-05-17 05:15:20 +00:00
2018-05-18 03:25:45 +00:00
const retval = {
2018-05-18 04:02:30 +00:00
element : data . tagName ,
// namespace: nsMap[data.namespaceURI],
attr : { } ,
children : [ ]
} ;
2018-05-17 05:15:20 +00:00
2018-05-18 04:02:30 +00:00
// Iterate attributes
2018-05-18 03:25:45 +00:00
for ( let i = 0 , attr ; ( attr = data . attributes [ i ] ) ; i ++ ) {
2018-05-18 04:02:30 +00:00
retval . attr [ attr . name ] = attr . value ;
}
2018-05-17 05:15:20 +00:00
2018-05-18 04:02:30 +00:00
// Iterate children
2018-05-18 03:25:45 +00:00
for ( let i = 0 , node ; ( node = data . childNodes [ i ] ) ; i ++ ) {
2018-05-18 04:02:30 +00:00
retval . children [ i ] = getJsonFromSvgElement ( node ) ;
}
2018-05-17 05:15:20 +00:00
2018-05-18 04:02:30 +00:00
return retval ;
2018-05-16 08:32:44 +00:00
} ;
2018-01-18 12:37:49 +00:00
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
/ * *
* Create a new SVG element based on the given object keys / values and add it to the current layer
* The element will be ran through cleanupElement before being returned
*
* @ param data - Object with the following keys / values :
2018-05-28 13:17:27 +00:00
* @ param { String } data . element - tag name of the SVG element to create
* @ param { Object } data . attr - Has key - value attributes to assign to the new element
* @ param { Boolean } [ data . curStyles ] - Indicates whether current style attributes should be applied first
* @ param { Array } [ data . children ] - Data objects to be added recursively as children
* @ param { String } [ data . namespace = "http://www.w3.org/2000/svg" ] - Indicate a ( non - SVG ) namespace
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
*
* @ returns The new element
* /
2018-05-18 03:25:45 +00:00
const addSvgElementFromJson = this . addSvgElementFromJson = function ( data ) {
2018-05-18 04:02:30 +00:00
if ( typeof data === 'string' ) return svgdoc . createTextNode ( data ) ;
2018-05-18 03:25:45 +00:00
let shape = getElem ( data . attr . id ) ;
2018-05-18 04:02:30 +00:00
// if shape is a path but we need to create a rect/ellipse, then remove the path
2018-05-18 03:25:45 +00:00
const currentLayer = getCurrentDrawing ( ) . getCurrentLayer ( ) ;
2018-05-18 04:02:30 +00:00
if ( shape && data . element !== shape . tagName ) {
currentLayer . removeChild ( shape ) ;
shape = null ;
}
if ( ! shape ) {
2018-05-28 13:17:27 +00:00
const ns = data . namespace || NS . SVG ;
shape = svgdoc . createElementNS ( ns , data . element ) ;
2018-05-18 04:02:30 +00:00
if ( currentLayer ) {
( currentGroup || currentLayer ) . appendChild ( shape ) ;
}
}
if ( data . curStyles ) {
2018-05-18 03:25:45 +00:00
assignAttributes ( shape , {
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
fill : curShape . fill ,
stroke : curShape . stroke ,
2018-05-18 04:02:30 +00:00
'stroke-width' : curShape . stroke _width ,
'stroke-dasharray' : curShape . stroke _dasharray ,
'stroke-linejoin' : curShape . stroke _linejoin ,
'stroke-linecap' : curShape . stroke _linecap ,
'stroke-opacity' : curShape . stroke _opacity ,
'fill-opacity' : curShape . fill _opacity ,
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
opacity : curShape . opacity / 2 ,
style : 'pointer-events:inherit'
2018-05-18 04:02:30 +00:00
} , 100 ) ;
}
2018-05-18 03:25:45 +00:00
assignAttributes ( shape , data . attr , 100 ) ;
cleanupElement ( shape ) ;
2018-05-18 04:02:30 +00:00
// Children
if ( data . children ) {
data . children . forEach ( function ( child ) {
shape . appendChild ( addSvgElementFromJson ( child ) ) ;
} ) ;
}
return shape ;
2010-11-15 09:25:49 +00:00
} ;
2018-05-18 03:25:45 +00:00
canvas . getTransformList = getTransformList ;
2010-11-05 17:00:32 +00:00
2018-05-18 03:25:45 +00:00
canvas . matrixMultiply = matrixMultiply ;
canvas . hasMatrixTransform = hasMatrixTransform ;
canvas . transformListToTransform = transformListToTransform ;
2010-11-05 17:00:32 +00:00
2010-11-07 16:46:57 +00:00
// initialize from units.js
2010-11-07 05:20:03 +00:00
// send in an object implementing the ElementContainer interface (see units.js)
2018-05-18 03:25:45 +00:00
unitsInit ( {
getBaseUnit ( ) { return curConfig . baseUnit ; } ,
getElement : getElem ,
getHeight ( ) { return svgcontent . getAttribute ( 'height' ) / currentZoom ; } ,
getWidth ( ) { return svgcontent . getAttribute ( 'width' ) / currentZoom ; } ,
getRoundDigits ( ) { return saveOptions . round _digits ; }
2010-11-07 05:20:03 +00:00
} ) ;
2018-05-18 03:25:45 +00:00
canvas . convertToNum = convertToNum ;
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
const getSVGContent = ( ) => { return svgcontent ; } ;
// Returns the array with selected DOM elements
const getSelectedElements = this . getSelectedElems = function ( ) {
return selectedElements ;
} ;
const pathActions = pathModule . pathActions ;
2018-05-18 03:25:45 +00:00
utilsInit ( {
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
pathActions , // Ok since not modifying
getSVGContent ,
addSvgElementFromJson ,
getSelectedElements ,
2018-05-18 03:25:45 +00:00
getDOMDocument ( ) { return svgdoc ; } ,
getDOMContainer ( ) { return container ; } ,
getSVGRoot ( ) { return svgroot ; } ,
2018-05-18 04:02:30 +00:00
// TODO: replace this mostly with a way to get the current drawing.
2018-05-18 03:25:45 +00:00
getBaseUnit ( ) { return curConfig . baseUnit ; } ,
getSnappingStep ( ) { return curConfig . snappingStep ; }
2010-12-02 17:14:24 +00:00
} ) ;
2018-05-18 03:25:45 +00:00
canvas . findDefs = findDefs ;
canvas . getUrlFromAttr = getUrlFromAttr ;
canvas . getHref = getHref ;
canvas . setHref = setHref ;
/* const getBBox = */ canvas . getBBox = utilsGetBBox ;
canvas . getRotationAngle = getRotationAngle ;
canvas . getElem = getElem ;
canvas . getRefElem = getRefElem ;
canvas . assignAttributes = assignAttributes ;
this . cleanupElement = cleanupElement ;
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
const getGridSnapping = ( ) => { return curConfig . gridSnapping ; } ;
2018-05-18 03:25:45 +00:00
coordsInit ( {
getDrawing ( ) { return getCurrentDrawing ( ) ; } ,
getSVGRoot ( ) { return svgroot ; } ,
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
getGridSnapping
2013-02-17 04:58:04 +00:00
} ) ;
2018-05-18 03:25:45 +00:00
this . remapElement = remapElement ;
2013-02-17 04:58:04 +00:00
2018-05-18 03:25:45 +00:00
recalculateInit ( {
getSVGRoot ( ) { return svgroot ; } ,
getStartTransform ( ) { return startTransform ; } ,
setStartTransform ( transform ) { startTransform = transform ; }
2013-02-20 06:29:25 +00:00
} ) ;
2018-05-18 03:25:45 +00:00
this . recalculateDimensions = recalculateDimensions ;
2013-02-20 06:29:25 +00:00
2010-11-07 20:14:05 +00:00
// import from sanitize.js
2018-05-18 03:25:45 +00:00
const nsMap = getReverseNS ( ) ;
canvas . sanitizeSvg = sanitizeSvg ;
2010-11-12 19:08:29 +00:00
// Implement the svgedit.history.HistoryEventHandler interface.
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
const undoMgr = canvas . undoMgr = new UndoManager ( {
2018-05-18 03:25:45 +00:00
handleHistoryEvent ( eventType , cmd ) {
const EventTypes = HistoryEventTypes ;
2018-05-18 04:02:30 +00:00
// TODO: handle setBlurOffsets.
if ( eventType === EventTypes . BEFORE _UNAPPLY || eventType === EventTypes . BEFORE _APPLY ) {
canvas . clearSelection ( ) ;
} else if ( eventType === EventTypes . AFTER _APPLY || eventType === EventTypes . AFTER _UNAPPLY ) {
2018-05-18 03:25:45 +00:00
const elems = cmd . elements ( ) ;
2018-05-18 04:02:30 +00:00
canvas . pathActions . clear ( ) ;
call ( 'changed' , elems ) ;
2018-05-18 03:25:45 +00:00
const cmdType = cmd . type ( ) ;
const isApply = ( eventType === EventTypes . AFTER _APPLY ) ;
2018-05-18 04:02:30 +00:00
if ( cmdType === MoveElementCommand . type ( ) ) {
2018-05-18 03:25:45 +00:00
const parent = isApply ? cmd . newParent : cmd . oldParent ;
2018-05-18 04:02:30 +00:00
if ( parent === svgcontent ) {
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
draw . identifyLayers ( ) ;
2018-05-18 04:02:30 +00:00
}
} else if ( cmdType === InsertElementCommand . type ( ) ||
cmdType === RemoveElementCommand . type ( ) ) {
if ( cmd . parent === svgcontent ) {
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
draw . identifyLayers ( ) ;
2018-05-18 04:02:30 +00:00
}
if ( cmdType === InsertElementCommand . type ( ) ) {
if ( isApply ) { restoreRefElems ( cmd . elem ) ; }
} else {
if ( ! isApply ) { restoreRefElems ( cmd . elem ) ; }
}
if ( cmd . elem . tagName === 'use' ) {
setUseData ( cmd . elem ) ;
}
} else if ( cmdType === ChangeElementCommand . type ( ) ) {
// if we are changing layer names, re-identify all layers
if ( cmd . elem . tagName === 'title' &&
cmd . elem . parentNode . parentNode === svgcontent
) {
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
draw . identifyLayers ( ) ;
2018-05-18 04:02:30 +00:00
}
2018-05-18 03:25:45 +00:00
const values = isApply ? cmd . newValues : cmd . oldValues ;
2018-05-18 04:02:30 +00:00
// If stdDeviation was changed, update the blur.
if ( values . stdDeviation ) {
canvas . setBlurOffsets ( cmd . elem . parentNode , values . stdDeviation ) ;
}
// This is resolved in later versions of webkit, perhaps we should
// have a featured detection for correct 'use' behavior?
// ——————————
// Remove & Re-add hack for Webkit (issue 775)
2018-05-18 03:25:45 +00:00
// if (cmd.elem.tagName === 'use' && isWebkit()) {
// const {elem} = cmd;
2018-05-18 06:41:43 +00:00
// if (!elem.getAttribute('x') && !elem.getAttribute('y')) {
2018-05-18 03:25:45 +00:00
// const parent = elem.parentNode;
// const sib = elem.nextSibling;
2018-05-18 06:41:43 +00:00
// parent.removeChild(elem);
// parent.insertBefore(elem, sib);
// }
2018-05-18 04:02:30 +00:00
// }
}
}
}
2010-11-12 19:08:29 +00:00
} ) ;
2018-05-18 03:25:45 +00:00
const addCommandToHistory = function ( cmd ) {
2018-05-18 04:02:30 +00:00
canvas . undoMgr . addCommandToHistory ( cmd ) ;
2010-11-12 19:08:29 +00:00
} ;
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
// Returns the current zoom level
const getCurrentZoom = this . getZoom = function ( ) { return currentZoom ; } ;
// This method rounds the incoming value to the nearest value based on the currentZoom
const round = this . round = function ( val ) {
return parseInt ( val * currentZoom , 10 ) / currentZoom ;
} ;
2016-05-04 13:38:29 +00:00
2010-11-15 09:25:49 +00:00
// import from select.js
2018-05-18 03:25:45 +00:00
selectInit ( curConfig , {
createSVGElement ( jsonMap ) { return canvas . addSvgElementFromJson ( jsonMap ) ; } ,
svgRoot ( ) { return svgroot ; } ,
svgContent ( ) { return svgcontent ; } ,
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
getCurrentZoom
2010-11-15 09:25:49 +00:00
} ) ;
// this object manages selectors for us
2018-05-18 03:25:45 +00:00
const selectorManager = this . selectorManager = getSelectorManager ( ) ;
2010-11-07 20:14:05 +00:00
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
const getNextId = canvas . getNextId = function ( ) { return getCurrentDrawing ( ) . getNextId ( ) ; } ;
const getId = canvas . getId = function ( ) { return getCurrentDrawing ( ) . getId ( ) ; } ;
// Run the callback function associated with the given event
//
// Parameters:
// event - String with the event name
// arg - Argument to pass through to the callback function
const call = function ( event , arg ) {
if ( events [ event ] ) {
return events [ event ] ( window , arg ) ;
}
} ;
/ * *
* Clears the selection . The 'selected' handler is then called .
* @ param { Boolean } [ noCall ] - When true does not call the "selected" handler
* /
const clearSelection = function ( noCall ) {
selectedElements . map ( function ( elem ) {
if ( elem == null ) return ;
selectorManager . releaseSelector ( elem ) ;
} ) ;
selectedElements = [ ] ;
if ( ! noCall ) { call ( 'selected' , selectedElements ) ; }
} ;
// Adds a list of elements to the selection. The 'selected' handler is then called.
//
// Parameters:
// elemsToAdd - an array of DOM elements to add to the selection
// showGrips - a boolean flag indicating whether the resize grips should be shown
const addToSelection = function ( elemsToAdd , showGrips ) {
if ( ! elemsToAdd . length ) { return ; }
// find the first null in our selectedElements array
let j = 0 ;
while ( j < selectedElements . length ) {
if ( selectedElements [ j ] == null ) {
break ;
}
++ j ;
}
// now add each element consecutively
let i = elemsToAdd . length ;
while ( i -- ) {
let elem = elemsToAdd [ i ] ;
if ( ! elem ) { continue ; }
const bbox = utilsGetBBox ( elem ) ;
if ( ! bbox ) { continue ; }
if ( elem . tagName === 'a' && elem . childNodes . length === 1 ) {
// Make "a" element's child be the selected element
elem = elem . firstChild ;
}
// if it's not already there, add it
if ( ! selectedElements . includes ( elem ) ) {
selectedElements [ j ] = elem ;
// only the first selectedBBoxes element is ever used in the codebase these days
// if (j === 0) selectedBBoxes[0] = utilsGetBBox(elem);
j ++ ;
const sel = selectorManager . requestSelector ( elem , bbox ) ;
if ( selectedElements . length > 1 ) {
sel . showGrips ( false ) ;
}
}
}
call ( 'selected' , selectedElements ) ;
if ( showGrips || selectedElements . length === 1 ) {
selectorManager . requestSelector ( selectedElements [ 0 ] ) . showGrips ( true ) ;
} else {
selectorManager . requestSelector ( selectedElements [ 0 ] ) . showGrips ( false ) ;
}
// make sure the elements are in the correct order
// See: https://www.w3.org/TR/DOM-Level-3-Core/core.html#Node3-compareDocumentPosition
selectedElements . sort ( function ( a , b ) {
if ( a && b && a . compareDocumentPosition ) {
return 3 - ( b . compareDocumentPosition ( a ) & 6 ) ;
}
if ( a == null ) {
return 1 ;
}
} ) ;
// Make sure first elements are not null
while ( selectedElements [ 0 ] == null ) {
selectedElements . shift ( 0 ) ;
}
} ;
const getOpacity = function ( ) {
return curShape . opacity ;
} ;
// Gets the desired element from a mouse event
//
// Parameters:
// evt - Event object from the mouse event
//
// Returns:
// DOM element we want
const getMouseTarget = this . getMouseTarget = function ( evt ) {
if ( evt == null ) {
return null ;
}
let mouseTarget = evt . target ;
// if it was a <use>, Opera and WebKit return the SVGElementInstance
if ( mouseTarget . correspondingUseElement ) { mouseTarget = mouseTarget . correspondingUseElement ; }
// for foreign content, go up until we find the foreignObject
// WebKit browsers set the mouse target to the svgcanvas div
if ( [ NS . MATH , NS . HTML ] . includes ( mouseTarget . namespaceURI ) &&
mouseTarget . id !== 'svgcanvas'
) {
while ( mouseTarget . nodeName !== 'foreignObject' ) {
mouseTarget = mouseTarget . parentNode ;
if ( ! mouseTarget ) { return svgroot ; }
}
}
// Get the desired mouseTarget with jQuery selector-fu
// If it's root-like, select the root
const currentLayer = getCurrentDrawing ( ) . getCurrentLayer ( ) ;
if ( [ svgroot , container , svgcontent , currentLayer ] . includes ( mouseTarget ) ) {
return svgroot ;
}
const $target = $ ( mouseTarget ) ;
// If it's a selection grip, return the grip parent
if ( $target . closest ( '#selectorParentGroup' ) . length ) {
// While we could instead have just returned mouseTarget,
// this makes it easier to indentify as being a selector grip
return selectorManager . selectorParentGroup ;
}
while ( mouseTarget . parentNode !== ( currentGroup || currentLayer ) ) {
mouseTarget = mouseTarget . parentNode ;
}
//
// // go up until we hit a child of a layer
// while (mouseTarget.parentNode.parentNode.tagName == 'g') {
// mouseTarget = mouseTarget.parentNode;
// }
// Webkit bubbles the mouse event all the way up to the div, so we
// set the mouseTarget to the svgroot like the other browsers
// if (mouseTarget.nodeName.toLowerCase() == 'div') {
// mouseTarget = svgroot;
// }
return mouseTarget ;
} ;
canvas . pathActions = pathActions ;
2018-05-18 03:25:45 +00:00
function resetD ( p ) {
p . setAttribute ( 'd' , pathActions . convertPath ( p ) ) ;
}
pathModule . init ( {
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
selectorManager , // Ok since not changing
canvas , // Ok since not changing
call ,
2018-05-18 03:25:45 +00:00
resetD ,
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
round ,
clearSelection ,
addToSelection ,
addCommandToHistory ,
remapElement ,
addSvgElementFromJson ,
getGridSnapping ,
getOpacity ,
getSelectedElements ,
getContainer ( ) {
return container ;
} ,
setStarted ( s ) {
started = s ;
} ,
getRubberBox ( ) {
return rubberBox ;
} ,
setRubberBox ( rb ) {
rubberBox = rb ;
return rubberBox ;
} ,
2018-05-18 03:25:45 +00:00
addPtsToSelection ( { closedSubpath , grips } ) {
// TODO: Correct this:
pathActions . canDeleteNodes = true ;
pathActions . closed _subpath = closedSubpath ;
call ( 'selected' , grips ) ;
} ,
endChanges ( { cmd , elem } ) {
addCommandToHistory ( cmd ) ;
call ( 'changed' , [ elem ] ) ;
} ,
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
getCurrentZoom ,
getId ,
getNextId ,
getMouseTarget ,
getCurrentMode ( ) {
return currentMode ;
} ,
setCurrentmode ( cm ) {
currentMode = cm ;
return currentMode ;
} ,
getDrawnPath ( ) {
return drawnPath ;
} ,
setDrawnPath ( dp ) {
drawnPath = dp ;
return drawnPath ;
} ,
2018-05-18 03:25:45 +00:00
getSVGRoot ( ) { return svgroot ; }
2011-02-04 08:02:46 +00:00
} ) ;
2010-11-15 09:24:02 +00:00
// Interface strings, usually for title elements
2018-05-18 03:25:45 +00:00
const uiStrings = { } ;
2010-11-15 09:24:02 +00:00
2018-05-18 03:25:45 +00:00
const visElems = 'a,circle,ellipse,foreignObject,g,image,line,path,polygon,polyline,rect,svg,text,tspan,use' ;
const refAttrs = [ 'clip-path' , 'fill' , 'filter' , 'marker-end' , 'marker-mid' , 'marker-start' , 'mask' , 'stroke' ] ;
2010-06-30 18:27:36 +00:00
2018-05-18 03:25:45 +00:00
const elData = $ . data ;
2010-11-12 19:08:29 +00:00
2010-06-21 15:05:41 +00:00
// Animation element to change the opacity of any newly created element
2018-05-18 03:25:45 +00:00
const opacAni = document . createElementNS ( NS . SVG , 'animate' ) ;
2018-05-16 08:32:44 +00:00
$ ( opacAni ) . attr ( {
2018-05-18 04:02:30 +00:00
attributeName : 'opacity' ,
begin : 'indefinite' ,
dur : 1 ,
fill : 'freeze'
2010-06-21 15:05:41 +00:00
} ) . appendTo ( svgroot ) ;
2018-05-18 03:25:45 +00:00
const restoreRefElems = function ( elem ) {
2018-05-18 04:02:30 +00:00
// Look for missing reference elements, restore any found
2018-05-18 03:25:45 +00:00
const attrs = $ ( elem ) . attr ( refAttrs ) ;
for ( const o in attrs ) {
const val = attrs [ o ] ;
if ( val && val . startsWith ( 'url(' ) ) {
const id = getUrlFromAttr ( val ) . substr ( 1 ) ;
const ref = getElem ( id ) ;
2018-05-18 04:02:30 +00:00
if ( ! ref ) {
2018-05-18 03:25:45 +00:00
findDefs ( ) . appendChild ( removedElements [ id ] ) ;
2018-05-18 04:02:30 +00:00
delete removedElements [ id ] ;
}
}
}
2018-05-18 03:25:45 +00:00
const childs = elem . getElementsByTagName ( '*' ) ;
2018-05-18 04:02:30 +00:00
if ( childs . length ) {
2018-05-18 03:25:45 +00:00
for ( let i = 0 , l = childs . length ; i < l ; i ++ ) {
2018-05-18 04:02:30 +00:00
restoreRefElems ( childs [ i ] ) ;
}
}
2010-11-12 19:08:29 +00:00
} ;
2010-06-21 18:06:21 +00:00
2018-05-17 05:15:20 +00:00
// (function () {
// TODO For Issue 208: this is a start on a thumbnail
2018-05-18 03:25:45 +00:00
// const svgthumb = svgdoc.createElementNS(NS.SVG, 'use');
2018-05-18 06:41:43 +00:00
// svgthumb.setAttribute('width', '100');
// svgthumb.setAttribute('height', '100');
2018-05-18 03:25:45 +00:00
// setHref(svgthumb, '#svgcontent');
2018-05-18 06:41:43 +00:00
// svgroot.appendChild(svgthumb);
2018-05-17 05:15:20 +00:00
// }());
2010-06-22 14:52:51 +00:00
2011-01-16 16:28:26 +00:00
// Object to contain image data for raster images that were found encodable
2018-05-18 03:25:45 +00:00
const encodableImages = { } ,
2018-05-16 00:53:27 +00:00
2018-05-18 03:25:45 +00:00
// Object with save options
saveOptions = { round _digits : 5 } ,
// Object with IDs for imported files, to see if one was already added
importIds = { } ,
// Current text style properties
curText = allProperties . text ,
// Object to contain all included extensions
extensions = { } ,
// Map of deleted reference elements
removedElements = { } ;
let
2018-05-18 04:02:30 +00:00
// String with image URL of last loadable image
lastGoodImgUrl = curConfig . imgPath + 'logo.png' ,
2018-05-16 00:53:27 +00:00
2018-05-18 04:02:30 +00:00
// Boolean indicating whether or not a draw action has been started
started = false ,
2018-05-16 00:53:27 +00:00
2018-05-18 04:02:30 +00:00
// String with an element's initial transform attribute value
startTransform = null ,
2018-05-16 00:53:27 +00:00
2018-05-18 04:02:30 +00:00
// String indicating the current editor mode
currentMode = 'select' ,
2018-05-16 00:53:27 +00:00
2018-05-18 04:02:30 +00:00
// String with the current direction in which an element is being resized
currentResizeMode = 'none' ,
2018-05-16 00:53:27 +00:00
2018-05-18 04:02:30 +00:00
// Current general properties
curProperties = curShape ,
2018-05-16 00:53:27 +00:00
2018-05-18 04:02:30 +00:00
// Array with selected elements' Bounding box object
// selectedBBoxes = new Array(1),
2018-05-16 00:53:27 +00:00
2018-05-18 04:02:30 +00:00
// The DOM element that was just selected
justSelected = null ,
2018-05-16 00:53:27 +00:00
2018-05-18 04:02:30 +00:00
// DOM element for selection rectangle drawn by the user
rubberBox = null ,
2018-05-16 00:53:27 +00:00
2018-05-18 04:02:30 +00:00
// Array of current BBoxes, used in getIntersectionList().
curBBoxes = [ ] ,
2018-05-16 00:53:27 +00:00
2018-05-18 04:02:30 +00:00
// Canvas point for the most recent right click
2018-05-18 03:25:45 +00:00
lastClickPoint = null ;
2010-08-17 18:09:50 +00:00
2010-06-22 14:52:51 +00:00
// Should this return an array by default, so extension results aren't overwritten?
2018-05-18 03:25:45 +00:00
const runExtensions = this . runExtensions = function ( action , vars , returnArray ) {
let result = returnArray ? [ ] : false ;
2018-05-18 04:02:30 +00:00
$ . each ( extensions , function ( name , opts ) {
if ( opts && action in opts ) {
if ( returnArray ) {
result . push ( opts [ action ] ( vars ) ) ;
} else {
result = opts [ action ] ( vars ) ;
}
}
} ) ;
return result ;
2013-02-15 15:51:58 +00:00
} ;
2010-06-30 18:27:36 +00:00
// Function: addExtension
// Add an extension to the editor
2018-05-16 00:53:27 +00:00
//
2010-06-30 18:27:36 +00:00
// Parameters:
// name - String with the ID of the extension
2018-05-16 08:32:44 +00:00
// extFunc - Function supplied by the extension with its data
this . addExtension = function ( name , extFunc ) {
2018-05-18 03:25:45 +00:00
let ext ;
2018-05-18 04:02:30 +00:00
if ( ! ( name in extensions ) ) {
// Provide private vars/funcs here. Is there a better way to do this?
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
const argObj = $ . extend ( canvas . getPrivateMethods ( ) , {
svgroot ,
svgcontent ,
nonce : getCurrentDrawing ( ) . getNonce ( ) ,
selectorManager
} ) ;
2018-05-18 03:25:45 +00:00
if ( typeof extFunc === 'function' ) {
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
ext = extFunc ( argObj ) ;
2018-05-18 04:02:30 +00:00
} else {
ext = extFunc ;
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
if ( ext . callback ) {
ext . callback = ext . callback . bind ( ext , argObj ) ;
}
2018-05-18 04:02:30 +00:00
}
extensions [ name ] = ext ;
call ( 'extension_added' , ext ) ;
} else {
console . log ( 'Cannot add extension "' + name + '", an extension by that name already exists.' ) ;
}
2010-06-30 18:27:36 +00:00
} ;
2018-05-16 00:53:27 +00:00
2010-06-22 14:52:51 +00:00
// This method sends back an array or a NodeList full of elements that
2018-05-16 08:32:44 +00:00
// intersect the multi-select rubber-band-box on the currentLayer only.
2018-05-16 00:53:27 +00:00
//
2015-12-01 03:08:13 +00:00
// We brute-force getIntersectionList for browsers that do not support it (Firefox).
2018-05-16 00:53:27 +00:00
//
2010-06-22 14:52:51 +00:00
// Reference:
// Firefox does not implement getIntersectionList(), see https://bugzilla.mozilla.org/show_bug.cgi?id=501421
2018-05-18 03:25:45 +00:00
const getIntersectionList = this . getIntersectionList = function ( rect ) {
2018-05-18 04:02:30 +00:00
if ( rubberBox == null ) { return null ; }
2018-05-18 03:25:45 +00:00
const parent = currentGroup || getCurrentDrawing ( ) . getCurrentLayer ( ) ;
2018-05-18 04:02:30 +00:00
2018-05-18 03:25:45 +00:00
let rubberBBox ;
2018-05-18 04:02:30 +00:00
if ( ! rect ) {
rubberBBox = rubberBox . getBBox ( ) ;
2018-05-18 03:25:45 +00:00
const bb = svgcontent . createSVGRect ( ) ;
2018-05-18 04:02:30 +00:00
2018-05-18 03:25:45 +00:00
for ( const o in rubberBBox ) {
2018-05-18 04:02:30 +00:00
bb [ o ] = rubberBBox [ o ] / currentZoom ;
}
rubberBBox = bb ;
} else {
rubberBBox = svgcontent . createSVGRect ( ) ;
rubberBBox . x = rect . x ;
rubberBBox . y = rect . y ;
rubberBBox . width = rect . width ;
rubberBBox . height = rect . height ;
}
2018-05-18 03:25:45 +00:00
let resultList = null ;
if ( ! isIE ) {
2018-05-18 04:02:30 +00:00
if ( typeof svgroot . getIntersectionList === 'function' ) {
// Offset the bbox of the rubber box by the offset of the svgcontent element.
rubberBBox . x += parseInt ( svgcontent . getAttribute ( 'x' ) , 10 ) ;
rubberBBox . y += parseInt ( svgcontent . getAttribute ( 'y' ) , 10 ) ;
resultList = svgroot . getIntersectionList ( rubberBBox , parent ) ;
}
}
if ( resultList == null || typeof resultList . item !== 'function' ) {
resultList = [ ] ;
if ( ! curBBoxes . length ) {
// Cache all bboxes
curBBoxes = getVisibleElementsAndBBoxes ( parent ) ;
}
2018-05-18 03:25:45 +00:00
let i = curBBoxes . length ;
2018-05-18 04:02:30 +00:00
while ( i -- ) {
if ( ! rubberBBox . width ) { continue ; }
2018-05-18 03:25:45 +00:00
if ( rectsIntersect ( rubberBBox , curBBoxes [ i ] . bbox ) ) {
2018-05-18 04:02:30 +00:00
resultList . push ( curBBoxes [ i ] . elem ) ;
}
}
}
// addToSelection expects an array, but it's ok to pass a NodeList
// because using square-bracket notation is allowed:
2018-05-18 04:40:50 +00:00
// https://www.w3.org/TR/DOM-Level-2-Core/ecma-script-binding.html
2018-05-18 04:02:30 +00:00
return resultList ;
2010-06-22 14:52:51 +00:00
} ;
2009-08-26 19:59:52 +00:00
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
this . getStrokedBBox = getStrokedBBoxDefaultVisible ;
2018-05-16 00:53:27 +00:00
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
this . getVisibleElements = getVisibleElements ;
2010-11-14 19:01:00 +00:00
// Function: getVisibleElementsAndBBoxes
// Get all elements that have a BBox (excludes <defs>, <title>, etc).
// Note that 0-opacity, off-screen etc elements are still considered "visible"
// for this function
//
// Parameters:
// parent - The parent DOM element to search within
//
// Returns:
// An array with objects that include:
2010-06-30 18:27:36 +00:00
// * elem - The element
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
// * bbox - The element's BBox as retrieved from getStrokedBBoxDefaultVisible
2018-05-18 03:25:45 +00:00
const getVisibleElementsAndBBoxes = this . getVisibleElementsAndBBoxes = function ( parent ) {
2018-05-18 04:02:30 +00:00
if ( ! parent ) {
parent = $ ( svgcontent ) . children ( ) ; // Prevent layers from being included
}
2018-05-18 03:25:45 +00:00
const contentElems = [ ] ;
2018-05-18 04:02:30 +00:00
$ ( parent ) . children ( ) . each ( function ( i , elem ) {
if ( elem . getBBox ) {
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
contentElems . push ( { elem , bbox : getStrokedBBoxDefaultVisible ( [ elem ] ) } ) ;
2018-05-18 04:02:30 +00:00
}
} ) ;
return contentElems . reverse ( ) ;
2010-11-14 19:01:00 +00:00
} ;
2010-06-30 18:27:36 +00:00
2010-07-16 15:46:54 +00:00
// Function: groupSvgElem
// Wrap an SVG element into a group element, mark the group as 'gsvg'
//
// Parameters:
// elem - SVG element to wrap
2018-05-18 03:25:45 +00:00
const groupSvgElem = this . groupSvgElem = function ( elem ) {
const g = document . createElementNS ( NS . SVG , 'g' ) ;
2018-05-18 04:02:30 +00:00
elem . parentNode . replaceChild ( g , elem ) ;
$ ( g ) . append ( elem ) . data ( 'gsvg' , elem ) [ 0 ] . id = getNextId ( ) ;
2013-02-15 15:51:58 +00:00
} ;
2010-07-16 15:46:54 +00:00
2010-06-30 18:27:36 +00:00
// Set scope for these functions
2018-05-17 05:15:20 +00:00
// Object to contain editor event names and callback functions
2018-05-18 03:25:45 +00:00
const events = { } ;
2010-06-30 18:27:36 +00:00
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
canvas . call = call ;
2013-02-15 23:05:23 +00:00
2018-05-17 05:15:20 +00:00
// Function: bind
// Attaches a callback function to an event
//
// Parameters:
// event - String indicating the name of the event
// f - The callback function to bind to the event
//
// Return:
// The previous event
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
canvas . bind = function ( event , f ) {
2018-05-18 03:25:45 +00:00
const old = events [ event ] ;
2018-05-18 04:02:30 +00:00
events [ event ] = f ;
return old ;
2018-05-17 05:15:20 +00:00
} ;
2010-06-30 18:27:36 +00:00
2010-11-07 20:14:05 +00:00
// Function: canvas.prepareSvg
// Runs the SVG Document through the sanitizer and then updates its paths.
2010-06-22 14:52:51 +00:00
//
// Parameters:
2010-11-07 20:14:05 +00:00
// newDoc - The SVG DOM document
2018-05-16 08:32:44 +00:00
this . prepareSvg = function ( newDoc ) {
2018-05-18 04:02:30 +00:00
this . sanitizeSvg ( newDoc . documentElement ) ;
2010-04-28 16:53:36 +00:00
2018-05-18 04:02:30 +00:00
// convert paths into absolute commands
2018-05-18 03:25:45 +00:00
const paths = newDoc . getElementsByTagNameNS ( NS . SVG , 'path' ) ;
for ( let i = 0 , len = paths . length ; i < len ; ++ i ) {
const path = paths [ i ] ;
2018-05-18 04:02:30 +00:00
path . setAttribute ( 'd' , pathActions . convertPath ( path ) ) ;
pathActions . fixEnd ( path ) ;
}
2010-06-22 14:52:51 +00:00
} ;
2010-04-07 18:18:28 +00:00
2010-06-29 20:43:44 +00:00
// Function: ffClone
2018-05-16 00:53:27 +00:00
// Hack for Firefox bugs where text element features aren't updated or get
2011-01-31 20:02:24 +00:00
// messed up. See issue 136 and issue 137.
2018-05-16 00:53:27 +00:00
// This function clones the element and re-selects it
// TODO: Test for this bug on load and add it to "support" object instead of
2010-06-29 20:43:44 +00:00
// browser sniffing
//
2018-05-16 00:53:27 +00:00
// Parameters:
2010-06-29 20:43:44 +00:00
// elem - The (text) DOM element to clone
2018-05-18 03:25:45 +00:00
const ffClone = function ( elem ) {
if ( ! isGecko ( ) ) { return elem ; }
const clone = elem . cloneNode ( true ) ;
2018-05-18 04:02:30 +00:00
elem . parentNode . insertBefore ( clone , elem ) ;
elem . parentNode . removeChild ( elem ) ;
selectorManager . releaseSelector ( elem ) ;
selectedElements [ 0 ] = clone ;
selectorManager . requestSelector ( clone ) . showGrips ( true ) ;
return clone ;
2013-02-15 15:51:58 +00:00
} ;
2010-06-29 20:43:44 +00:00
// this.each is deprecated, if any extension used this it can be recreated by doing this:
// $(canvas.getRootElem()).children().each(...)
2018-05-16 08:32:44 +00:00
// this.each = function (cb) {
2018-05-18 06:41:43 +00:00
// $(svgroot).children().each(cb);
2010-06-29 20:43:44 +00:00
// };
// Function: setRotationAngle
// Removes any old rotations if present, prepends a new rotation at the
// transformed center
//
// Parameters:
// val - The new rotation angle in degrees
// preventUndo - Boolean indicating whether the action should be undoable or not
2018-05-16 08:32:44 +00:00
this . setRotationAngle = function ( val , preventUndo ) {
2018-05-18 04:02:30 +00:00
// ensure val is the proper type
val = parseFloat ( val ) ;
2018-05-18 03:25:45 +00:00
const elem = selectedElements [ 0 ] ;
const oldTransform = elem . getAttribute ( 'transform' ) ;
const bbox = utilsGetBBox ( elem ) ;
const cx = bbox . x + bbox . width / 2 , cy = bbox . y + bbox . height / 2 ;
const tlist = getTransformList ( elem ) ;
2018-05-18 04:02:30 +00:00
// only remove the real rotational transform if present (i.e. at index=0)
if ( tlist . numberOfItems > 0 ) {
2018-05-18 03:25:45 +00:00
const xform = tlist . getItem ( 0 ) ;
2018-05-18 04:02:30 +00:00
if ( xform . type === 4 ) {
tlist . removeItem ( 0 ) ;
}
}
// find Rnc and insert it
if ( val !== 0 ) {
2018-05-18 03:25:45 +00:00
const center = transformPoint ( cx , cy , transformListToTransform ( tlist ) . matrix ) ;
const Rnc = svgroot . createSVGTransform ( ) ;
2018-05-18 04:02:30 +00:00
Rnc . setRotate ( val , center . x , center . y ) ;
if ( tlist . numberOfItems ) {
tlist . insertItemBefore ( Rnc , 0 ) ;
} else {
tlist . appendItem ( Rnc ) ;
}
} else if ( tlist . numberOfItems === 0 ) {
elem . removeAttribute ( 'transform' ) ;
}
if ( ! preventUndo ) {
// we need to undo it, then redo it so it can be undo-able! :)
// TODO: figure out how to make changes to transform list undo-able cross-browser?
2018-05-18 03:25:45 +00:00
const newTransform = elem . getAttribute ( 'transform' ) ;
2018-05-18 04:02:30 +00:00
elem . setAttribute ( 'transform' , oldTransform ) ;
changeSelectedAttribute ( 'transform' , newTransform , selectedElements ) ;
call ( 'changed' , selectedElements ) ;
}
2018-05-18 03:25:45 +00:00
// const pointGripContainer = getElem('pathpointgrip_container');
2018-05-18 04:02:30 +00:00
// if (elem.nodeName === 'path' && pointGripContainer) {
2018-05-18 06:41:43 +00:00
// pathActions.setPointContainerTransform(elem.getAttribute('transform'));
2018-05-18 04:02:30 +00:00
// }
2018-05-18 03:25:45 +00:00
const selector = selectorManager . requestSelector ( selectedElements [ 0 ] ) ;
2018-05-18 04:02:30 +00:00
selector . resize ( ) ;
selector . updateGripCursors ( val ) ;
2010-06-29 20:43:44 +00:00
} ;
2010-06-22 18:17:42 +00:00
// Function: recalculateAllSelectedDimensions
2018-05-16 00:53:27 +00:00
// Runs recalculateDimensions on the selected elements,
2010-06-22 18:17:42 +00:00
// adding the changes to a single batch command
2018-05-18 03:25:45 +00:00
const recalculateAllSelectedDimensions = this . recalculateAllSelectedDimensions = function ( ) {
const text = ( currentResizeMode === 'none' ? 'position' : 'size' ) ;
const batchCmd = new BatchCommand ( text ) ;
2010-06-22 14:52:51 +00:00
2018-05-18 03:25:45 +00:00
let i = selectedElements . length ;
2018-05-18 04:02:30 +00:00
while ( i -- ) {
2018-05-18 03:25:45 +00:00
const elem = selectedElements [ i ] ;
// if (getRotationAngle(elem) && !hasMatrixTransform(getTransformList(elem))) { continue; }
const cmd = recalculateDimensions ( elem ) ;
2018-05-18 04:02:30 +00:00
if ( cmd ) {
batchCmd . addSubCommand ( cmd ) ;
}
}
2010-06-22 14:52:51 +00:00
2018-05-18 04:02:30 +00:00
if ( ! batchCmd . isEmpty ( ) ) {
addCommandToHistory ( batchCmd ) ;
call ( 'changed' , selectedElements ) ;
}
2010-06-22 14:52:51 +00:00
} ;
2010-06-22 18:17:42 +00:00
// Debug tool to easily see the current matrix in the browser's console
2018-05-18 03:25:45 +00:00
const logMatrix = function ( m ) {
2018-05-18 04:02:30 +00:00
console . log ( [ m . a , m . b , m . c , m . d , m . e , m . f ] ) ;
2010-06-22 14:52:51 +00:00
} ;
2010-06-22 18:17:42 +00:00
// Root Current Transformation Matrix in user units
2018-05-18 03:25:45 +00:00
let rootSctm = null ;
2010-06-22 18:17:42 +00:00
2010-06-22 14:52:51 +00:00
// Group: Selection
2009-10-13 02:48:27 +00:00
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
this . clearSelection = clearSelection ;
2018-01-18 12:37:49 +00:00
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
// TODO: do we need to worry about selectedBBoxes here?
2018-01-18 12:37:49 +00:00
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
this . addToSelection = addToSelection ;
// Function: selectOnly()
// Selects only the given elements, shortcut for clearSelection(); addToSelection()
//
// Parameters:
// elems - an array of DOM elements to be selected
const selectOnly = this . selectOnly = function ( elems , showGrips ) {
clearSelection ( true ) ;
addToSelection ( elems , showGrips ) ;
2010-06-22 14:52:51 +00:00
} ;
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
// TODO: could use slice here to make this faster?
// TODO: should the 'selected' handler
2010-06-22 14:52:51 +00:00
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
// Function: removeFromSelection
// Removes elements from the selection.
2010-06-22 14:52:51 +00:00
//
// Parameters:
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
// elemsToRemove - an array of elements to remove from selection
/* const removeFromSelection = */ this . removeFromSelection = function ( elemsToRemove ) {
if ( selectedElements [ 0 ] == null ) { return ; }
if ( ! elemsToRemove . length ) { return ; }
2018-05-18 04:02:30 +00:00
// find every element and remove it from our array copy
2018-05-18 03:25:45 +00:00
let j = 0 ;
const newSelectedItems = [ ] ,
2018-05-18 04:02:30 +00:00
len = selectedElements . length ;
newSelectedItems . length = len ;
2018-05-18 03:25:45 +00:00
for ( let i = 0 ; i < len ; ++ i ) {
const elem = selectedElements [ i ] ;
2018-05-18 04:02:30 +00:00
if ( elem ) {
// keep the item
2018-05-18 03:25:45 +00:00
if ( ! elemsToRemove . includes ( elem ) ) {
2018-05-18 04:02:30 +00:00
newSelectedItems [ j ] = elem ;
j ++ ;
} else { // remove the item and its selector
selectorManager . releaseSelector ( elem ) ;
}
}
}
// the copy becomes the master now
selectedElements = newSelectedItems ;
2010-06-22 14:52:51 +00:00
} ;
2010-06-28 13:10:22 +00:00
// Function: selectAllInCurrentLayer
// Clears the selection, then adds all elements in the current layer to the selection.
2018-05-16 08:32:44 +00:00
this . selectAllInCurrentLayer = function ( ) {
2018-05-18 03:25:45 +00:00
const currentLayer = getCurrentDrawing ( ) . getCurrentLayer ( ) ;
2018-05-18 04:02:30 +00:00
if ( currentLayer ) {
currentMode = 'select' ;
selectOnly ( $ ( currentGroup || currentLayer ) . children ( ) ) ;
}
2010-06-28 13:10:22 +00:00
} ;
2018-05-18 03:25:45 +00:00
let drawnPath = null ;
2018-05-16 08:32:44 +00:00
2010-06-22 14:52:51 +00:00
// Mouse events
2018-05-16 08:32:44 +00:00
( function ( ) {
2018-05-18 03:25:45 +00:00
const freehand = {
minx : null ,
miny : null ,
maxx : null ,
maxy : null
} ;
const THRESHOLD _DIST = 0.8 ,
STEP _COUNT = 10 ;
let dAttr = null ,
2018-05-18 04:02:30 +00:00
startX = null ,
startY = null ,
rStartX = null ,
rStartY = null ,
initBbox = { } ,
sumDistance = 0 ,
controllPoint2 = { x : 0 , y : 0 } ,
controllPoint1 = { x : 0 , y : 0 } ,
start = { x : 0 , y : 0 } ,
end = { x : 0 , y : 0 } ,
bSpline = { x : 0 , y : 0 } ,
nextPos = { x : 0 , y : 0 } ,
2018-05-18 03:25:45 +00:00
parameter ,
nextParameter ;
2018-05-17 05:15:20 +00:00
2018-05-18 03:25:45 +00:00
const getBsplinePoint = function ( t ) {
const spline = { x : 0 , y : 0 } ,
2018-05-18 04:02:30 +00:00
p0 = controllPoint2 ,
p1 = controllPoint1 ,
p2 = start ,
p3 = end ,
S = 1.0 / 6.0 ,
t2 = t * t ,
t3 = t2 * t ;
2018-05-18 03:25:45 +00:00
const m = [
2018-05-18 04:02:30 +00:00
[ - 1 , 3 , - 3 , 1 ] ,
[ 3 , - 6 , 3 , 0 ] ,
[ - 3 , 0 , 3 , 0 ] ,
[ 1 , 4 , 1 , 0 ]
] ;
spline . x = S * (
( p0 . x * m [ 0 ] [ 0 ] + p1 . x * m [ 0 ] [ 1 ] + p2 . x * m [ 0 ] [ 2 ] + p3 . x * m [ 0 ] [ 3 ] ) * t3 +
( p0 . x * m [ 1 ] [ 0 ] + p1 . x * m [ 1 ] [ 1 ] + p2 . x * m [ 1 ] [ 2 ] + p3 . x * m [ 1 ] [ 3 ] ) * t2 +
( p0 . x * m [ 2 ] [ 0 ] + p1 . x * m [ 2 ] [ 1 ] + p2 . x * m [ 2 ] [ 2 ] + p3 . x * m [ 2 ] [ 3 ] ) * t +
( p0 . x * m [ 3 ] [ 0 ] + p1 . x * m [ 3 ] [ 1 ] + p2 . x * m [ 3 ] [ 2 ] + p3 . x * m [ 3 ] [ 3 ] )
) ;
spline . y = S * (
( p0 . y * m [ 0 ] [ 0 ] + p1 . y * m [ 0 ] [ 1 ] + p2 . y * m [ 0 ] [ 2 ] + p3 . y * m [ 0 ] [ 3 ] ) * t3 +
( p0 . y * m [ 1 ] [ 0 ] + p1 . y * m [ 1 ] [ 1 ] + p2 . y * m [ 1 ] [ 2 ] + p3 . y * m [ 1 ] [ 3 ] ) * t2 +
( p0 . y * m [ 2 ] [ 0 ] + p1 . y * m [ 2 ] [ 1 ] + p2 . y * m [ 2 ] [ 2 ] + p3 . y * m [ 2 ] [ 3 ] ) * t +
( p0 . y * m [ 3 ] [ 0 ] + p1 . y * m [ 3 ] [ 1 ] + p2 . y * m [ 3 ] [ 2 ] + p3 . y * m [ 3 ] [ 3 ] )
) ;
return {
x : spline . x ,
y : spline . y
} ;
2018-05-17 05:15:20 +00:00
} ;
// - when we are in a create mode, the element is added to the canvas
// but the action is not recorded until mousing up
// - when we are in select mode, select the element, remember the position
// and do nothing else
2018-05-18 03:25:45 +00:00
const mouseDown = function ( evt ) {
2018-05-18 04:02:30 +00:00
if ( canvas . spaceKey || evt . button === 1 ) { return ; }
2018-05-18 03:25:45 +00:00
const rightClick = evt . button === 2 ;
2018-05-18 04:02:30 +00:00
if ( evt . altKey ) { // duplicate when dragging
2018-05-18 03:25:45 +00:00
canvas . cloneSelectedElements ( 0 , 0 ) ;
2018-05-18 04:02:30 +00:00
}
rootSctm = $ ( '#svgcontent g' ) [ 0 ] . getScreenCTM ( ) . inverse ( ) ;
2018-05-18 03:25:45 +00:00
const pt = transformPoint ( evt . pageX , evt . pageY , rootSctm ) ,
2018-05-18 04:02:30 +00:00
mouseX = pt . x * currentZoom ,
mouseY = pt . y * currentZoom ;
evt . preventDefault ( ) ;
if ( rightClick ) {
currentMode = 'select' ;
lastClickPoint = pt ;
}
// This would seem to be unnecessary...
2018-05-18 03:25:45 +00:00
// if (!['select', 'resize'].includes(currentMode)) {
2018-05-18 06:41:43 +00:00
// setGradient();
2018-05-18 04:02:30 +00:00
// }
2018-05-18 03:25:45 +00:00
let x = mouseX / currentZoom ,
y = mouseY / currentZoom ;
let mouseTarget = getMouseTarget ( evt ) ;
2018-05-18 04:02:30 +00:00
if ( mouseTarget . tagName === 'a' && mouseTarget . childNodes . length === 1 ) {
mouseTarget = mouseTarget . firstChild ;
}
// realX/y ignores grid-snap value
2018-05-18 03:25:45 +00:00
const realX = x ;
2018-05-18 04:02:30 +00:00
rStartX = startX = x ;
2018-05-18 03:25:45 +00:00
const realY = y ;
2018-05-18 04:02:30 +00:00
rStartY = startY = y ;
if ( curConfig . gridSnapping ) {
2018-05-18 03:25:45 +00:00
x = snapToGrid ( x ) ;
y = snapToGrid ( y ) ;
startX = snapToGrid ( startX ) ;
startY = snapToGrid ( startY ) ;
2018-05-18 04:02:30 +00:00
}
// if it is a selector grip, then it must be a single element selected,
// set the mouseTarget to that and update the mode to rotate/resize
if ( mouseTarget === selectorManager . selectorParentGroup && selectedElements [ 0 ] != null ) {
2018-05-18 03:25:45 +00:00
const grip = evt . target ;
const griptype = elData ( grip , 'type' ) ;
2018-05-18 04:02:30 +00:00
// rotating
if ( griptype === 'rotate' ) {
currentMode = 'rotate' ;
// resizing
} else if ( griptype === 'resize' ) {
currentMode = 'resize' ;
currentResizeMode = elData ( grip , 'dir' ) ;
}
mouseTarget = selectedElements [ 0 ] ;
}
startTransform = mouseTarget . getAttribute ( 'transform' ) ;
2018-05-18 03:25:45 +00:00
let i , strokeW ;
const tlist = getTransformList ( mouseTarget ) ;
2018-05-18 04:02:30 +00:00
switch ( currentMode ) {
case 'select' :
started = true ;
currentResizeMode = 'none' ;
if ( rightClick ) { started = false ; }
if ( mouseTarget !== svgroot ) {
// if this element is not yet selected, clear selection and select it
2018-05-18 03:25:45 +00:00
if ( ! selectedElements . includes ( mouseTarget ) ) {
2018-05-18 04:02:30 +00:00
// only clear selection if shift is not pressed (otherwise, add
// element to selection)
if ( ! evt . shiftKey ) {
// No need to do the call here as it will be done on addToSelection
clearSelection ( true ) ;
}
addToSelection ( [ mouseTarget ] ) ;
justSelected = mouseTarget ;
pathActions . clear ( ) ;
}
// else if it's a path, go into pathedit mode in mouseup
if ( ! rightClick ) {
// insert a dummy transform so if the element(s) are moved it will have
// a transform to use for its translate
for ( i = 0 ; i < selectedElements . length ; ++ i ) {
if ( selectedElements [ i ] == null ) { continue ; }
2018-05-18 03:25:45 +00:00
const slist = getTransformList ( selectedElements [ i ] ) ;
2018-05-18 04:02:30 +00:00
if ( slist . numberOfItems ) {
slist . insertItemBefore ( svgroot . createSVGTransform ( ) , 0 ) ;
} else {
slist . appendItem ( svgroot . createSVGTransform ( ) ) ;
}
}
}
} else if ( ! rightClick ) {
clearSelection ( ) ;
currentMode = 'multiselect' ;
if ( rubberBox == null ) {
rubberBox = selectorManager . getRubberBandBox ( ) ;
}
rStartX *= currentZoom ;
rStartY *= currentZoom ;
// console.log('p',[evt.pageX, evt.pageY]);
// console.log('c',[evt.clientX, evt.clientY]);
// console.log('o',[evt.offsetX, evt.offsetY]);
// console.log('s',[startX, startY]);
2018-05-18 03:25:45 +00:00
assignAttributes ( rubberBox , {
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
x : rStartX ,
y : rStartY ,
width : 0 ,
height : 0 ,
display : 'inline'
2018-05-18 04:02:30 +00:00
} , 100 ) ;
}
break ;
case 'zoom' :
started = true ;
if ( rubberBox == null ) {
rubberBox = selectorManager . getRubberBandBox ( ) ;
}
2018-05-18 03:25:45 +00:00
assignAttributes ( rubberBox , {
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
x : realX * currentZoom ,
y : realX * currentZoom ,
width : 0 ,
height : 0 ,
display : 'inline'
2018-05-18 04:02:30 +00:00
} , 100 ) ;
break ;
case 'resize' :
started = true ;
startX = x ;
startY = y ;
// Getting the BBox from the selection box, since we know we
// want to orient around it
2018-05-18 03:25:45 +00:00
initBbox = utilsGetBBox ( $ ( '#selectedBox0' ) [ 0 ] ) ;
const bb = { } ;
2018-05-18 04:02:30 +00:00
$ . each ( initBbox , function ( key , val ) {
bb [ key ] = val / currentZoom ;
} ) ;
initBbox = bb ;
// append three dummy transforms to the tlist so that
// we can translate,scale,translate in mousemove
2018-05-18 03:25:45 +00:00
const pos = getRotationAngle ( mouseTarget ) ? 1 : 0 ;
2018-05-18 04:02:30 +00:00
2018-05-18 03:25:45 +00:00
if ( hasMatrixTransform ( tlist ) ) {
2018-05-18 04:02:30 +00:00
tlist . insertItemBefore ( svgroot . createSVGTransform ( ) , pos ) ;
tlist . insertItemBefore ( svgroot . createSVGTransform ( ) , pos ) ;
tlist . insertItemBefore ( svgroot . createSVGTransform ( ) , pos ) ;
} else {
tlist . appendItem ( svgroot . createSVGTransform ( ) ) ;
tlist . appendItem ( svgroot . createSVGTransform ( ) ) ;
tlist . appendItem ( svgroot . createSVGTransform ( ) ) ;
2018-05-18 03:25:45 +00:00
if ( supportsNonScalingStroke ( ) ) {
2018-05-18 04:02:30 +00:00
// Handle crash for newer Chrome and Safari 6 (Mobile and Desktop):
// https://code.google.com/p/svg-edit/issues/detail?id=904
// Chromium issue: https://code.google.com/p/chromium/issues/detail?id=114625
// TODO: Remove this workaround once vendor fixes the issue
2018-05-18 03:25:45 +00:00
const iswebkit = isWebkit ( ) ;
2018-05-18 04:02:30 +00:00
2018-05-18 03:25:45 +00:00
let delayedStroke ;
if ( iswebkit ) {
delayedStroke = function ( ele ) {
const _stroke = ele . getAttributeNS ( null , 'stroke' ) ;
2018-05-18 04:02:30 +00:00
ele . removeAttributeNS ( null , 'stroke' ) ;
// Re-apply stroke after delay. Anything higher than 1 seems to cause flicker
if ( _stroke !== null ) setTimeout ( function ( ) { ele . setAttributeNS ( null , 'stroke' , _stroke ) ; } , 0 ) ;
} ;
}
mouseTarget . style . vectorEffect = 'non-scaling-stroke' ;
2018-05-18 03:25:45 +00:00
if ( iswebkit ) { delayedStroke ( mouseTarget ) ; }
2018-05-18 04:02:30 +00:00
2018-05-18 03:25:45 +00:00
const all = mouseTarget . getElementsByTagName ( '*' ) ,
2018-05-18 04:02:30 +00:00
len = all . length ;
for ( i = 0 ; i < len ; i ++ ) {
all [ i ] . style . vectorEffect = 'non-scaling-stroke' ;
2018-05-18 03:25:45 +00:00
if ( iswebkit ) { delayedStroke ( all [ i ] ) ; }
2018-05-18 04:02:30 +00:00
}
}
}
break ;
case 'fhellipse' :
case 'fhrect' :
case 'fhpath' :
start . x = realX ;
start . y = realY ;
started = true ;
dAttr = realX + ',' + realY + ' ' ;
strokeW = parseFloat ( curShape . stroke _width ) === 0 ? 1 : curShape . stroke _width ;
addSvgElementFromJson ( {
element : 'polyline' ,
curStyles : true ,
attr : {
points : dAttr ,
id : getNextId ( ) ,
fill : 'none' ,
opacity : curShape . opacity / 2 ,
'stroke-linecap' : 'round' ,
style : 'pointer-events:none'
}
} ) ;
freehand . minx = realX ;
freehand . maxx = realX ;
freehand . miny = realY ;
freehand . maxy = realY ;
break ;
case 'image' :
started = true ;
2018-05-18 03:25:45 +00:00
const newImage = addSvgElementFromJson ( {
2018-05-18 04:02:30 +00:00
element : 'image' ,
attr : {
2018-05-18 03:25:45 +00:00
x ,
y ,
2018-05-18 04:02:30 +00:00
width : 0 ,
height : 0 ,
id : getNextId ( ) ,
opacity : curShape . opacity / 2 ,
style : 'pointer-events:inherit'
}
} ) ;
setHref ( newImage , lastGoodImgUrl ) ;
2018-05-18 03:25:45 +00:00
preventClickDefault ( newImage ) ;
2018-05-18 04:02:30 +00:00
break ;
case 'square' :
// FIXME: once we create the rect, we lose information that this was a square
// (for resizing purposes this could be important)
// Fallthrough
case 'rect' :
started = true ;
startX = x ;
startY = y ;
addSvgElementFromJson ( {
element : 'rect' ,
curStyles : true ,
attr : {
2018-05-18 03:25:45 +00:00
x ,
y ,
2018-05-18 04:02:30 +00:00
width : 0 ,
height : 0 ,
id : getNextId ( ) ,
opacity : curShape . opacity / 2
}
} ) ;
break ;
case 'line' :
started = true ;
strokeW = Number ( curShape . stroke _width ) === 0 ? 1 : curShape . stroke _width ;
addSvgElementFromJson ( {
element : 'line' ,
curStyles : true ,
attr : {
x1 : x ,
y1 : y ,
x2 : x ,
y2 : y ,
id : getNextId ( ) ,
stroke : curShape . stroke ,
'stroke-width' : strokeW ,
'stroke-dasharray' : curShape . stroke _dasharray ,
'stroke-linejoin' : curShape . stroke _linejoin ,
'stroke-linecap' : curShape . stroke _linecap ,
'stroke-opacity' : curShape . stroke _opacity ,
fill : 'none' ,
opacity : curShape . opacity / 2 ,
style : 'pointer-events:none'
}
} ) ;
break ;
case 'circle' :
started = true ;
addSvgElementFromJson ( {
element : 'circle' ,
curStyles : true ,
attr : {
cx : x ,
cy : y ,
r : 0 ,
id : getNextId ( ) ,
opacity : curShape . opacity / 2
}
} ) ;
break ;
case 'ellipse' :
started = true ;
addSvgElementFromJson ( {
element : 'ellipse' ,
curStyles : true ,
attr : {
cx : x ,
cy : y ,
rx : 0 ,
ry : 0 ,
id : getNextId ( ) ,
opacity : curShape . opacity / 2
}
} ) ;
break ;
case 'text' :
started = true ;
2018-05-18 03:25:45 +00:00
/* const newText = */ addSvgElementFromJson ( {
2018-05-18 04:02:30 +00:00
element : 'text' ,
curStyles : true ,
attr : {
2018-05-18 03:25:45 +00:00
x ,
y ,
2018-05-18 04:02:30 +00:00
id : getNextId ( ) ,
fill : curText . fill ,
'stroke-width' : curText . stroke _width ,
'font-size' : curText . font _size ,
'font-family' : curText . font _family ,
'text-anchor' : 'middle' ,
'xml:space' : 'preserve' ,
opacity : curShape . opacity
}
} ) ;
// newText.textContent = 'text';
break ;
case 'path' :
// Fall through
case 'pathedit' :
startX *= currentZoom ;
startY *= currentZoom ;
pathActions . mouseDown ( evt , mouseTarget , startX , startY ) ;
started = true ;
break ;
case 'textedit' :
startX *= currentZoom ;
startY *= currentZoom ;
textActions . mouseDown ( evt , mouseTarget , startX , startY ) ;
started = true ;
break ;
case 'rotate' :
started = true ;
// we are starting an undoable change (a drag-rotation)
canvas . undoMgr . beginUndoableChange ( 'transform' , selectedElements ) ;
break ;
default :
// This could occur in an extension
break ;
}
2018-05-18 03:25:45 +00:00
const extResult = runExtensions ( 'mouseDown' , {
2018-05-18 04:02:30 +00:00
event : evt ,
start _x : startX ,
start _y : startY ,
2018-05-18 03:25:45 +00:00
selectedElements
2018-05-18 04:02:30 +00:00
} , true ) ;
$ . each ( extResult , function ( i , r ) {
if ( r && r . started ) {
started = true ;
}
} ) ;
2018-05-17 05:15:20 +00:00
} ;
2010-09-09 12:46:34 +00:00
2018-05-17 05:15:20 +00:00
// in this function we do not record any state changes yet (but we do update
// any elements that are still being created, moved or resized on the canvas)
2018-05-18 03:25:45 +00:00
const mouseMove = function ( evt ) {
2018-05-18 04:02:30 +00:00
if ( ! started ) { return ; }
if ( evt . button === 1 || canvas . spaceKey ) { return ; }
2018-05-18 03:25:45 +00:00
let i , xya , c , cx , cy , dx , dy , len , angle , box ,
selected = selectedElements [ 0 ] ;
const
pt = transformPoint ( evt . pageX , evt . pageY , rootSctm ) ,
2018-05-18 04:02:30 +00:00
mouseX = pt . x * currentZoom ,
mouseY = pt . y * currentZoom ,
2018-05-18 03:25:45 +00:00
shape = getElem ( getId ( ) ) ;
2018-05-18 04:02:30 +00:00
2018-05-18 03:25:45 +00:00
let realX = mouseX / currentZoom ;
let x = realX ;
let realY = mouseY / currentZoom ;
let y = realY ;
2018-05-18 04:02:30 +00:00
if ( curConfig . gridSnapping ) {
2018-05-18 03:25:45 +00:00
x = snapToGrid ( x ) ;
y = snapToGrid ( y ) ;
2018-05-18 04:02:30 +00:00
}
evt . preventDefault ( ) ;
2018-05-18 03:25:45 +00:00
let tlist ;
2018-05-18 04:02:30 +00:00
switch ( currentMode ) {
2018-05-18 03:25:45 +00:00
case 'select' : {
2018-05-18 04:02:30 +00:00
// we temporarily use a translate on the element(s) being dragged
// this transform is removed upon mousing up and the element is
// relocated to the new location
if ( selectedElements [ 0 ] !== null ) {
dx = x - startX ;
dy = y - startY ;
if ( curConfig . gridSnapping ) {
2018-05-18 03:25:45 +00:00
dx = snapToGrid ( dx ) ;
dy = snapToGrid ( dy ) ;
2018-05-18 04:02:30 +00:00
}
if ( evt . shiftKey ) {
2018-05-18 03:25:45 +00:00
xya = snapToAngle ( startX , startY , x , y ) ;
( { x , y } = xya ) ;
2018-05-18 04:02:30 +00:00
}
if ( dx !== 0 || dy !== 0 ) {
len = selectedElements . length ;
for ( i = 0 ; i < len ; ++ i ) {
selected = selectedElements [ i ] ;
if ( selected == null ) { break ; }
// if (i === 0) {
2018-05-18 03:25:45 +00:00
// const box = utilsGetBBox(selected);
2018-05-18 06:41:43 +00:00
// selectedBBoxes[i].x = box.x + dx;
// selectedBBoxes[i].y = box.y + dy;
2018-05-18 04:02:30 +00:00
// }
// update the dummy transform in our transform list
// to be a translate
2018-05-18 03:25:45 +00:00
const xform = svgroot . createSVGTransform ( ) ;
tlist = getTransformList ( selected ) ;
2018-05-18 04:02:30 +00:00
// Note that if Webkit and there's no ID for this
// element, the dummy transform may have gotten lost.
// This results in unexpected behaviour
xform . setTranslate ( dx , dy ) ;
if ( tlist . numberOfItems ) {
tlist . replaceItem ( xform , 0 ) ;
} else {
tlist . appendItem ( xform ) ;
}
// update our internal bbox that we're tracking while dragging
selectorManager . requestSelector ( selected ) . resize ( ) ;
}
call ( 'transition' , selectedElements ) ;
}
}
break ;
2018-05-18 03:25:45 +00:00
} case 'multiselect' : {
2018-05-18 04:02:30 +00:00
realX *= currentZoom ;
realY *= currentZoom ;
2018-05-18 03:25:45 +00:00
assignAttributes ( rubberBox , {
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
x : Math . min ( rStartX , realX ) ,
y : Math . min ( rStartY , realY ) ,
width : Math . abs ( realX - rStartX ) ,
height : Math . abs ( realY - rStartY )
2018-05-18 04:02:30 +00:00
} , 100 ) ;
// for each selected:
// - if newList contains selected, do nothing
// - if newList doesn't contain selected, remove it from selected
// - for any newList that was not in selectedElements, add it to selected
2018-05-18 03:25:45 +00:00
const elemsToRemove = selectedElements . slice ( ) , elemsToAdd = [ ] ,
2018-05-18 04:02:30 +00:00
newList = getIntersectionList ( ) ;
// For every element in the intersection, add if not present in selectedElements.
len = newList . length ;
for ( i = 0 ; i < len ; ++ i ) {
2018-05-18 03:25:45 +00:00
const intElem = newList [ i ] ;
2018-05-18 04:02:30 +00:00
// Found an element that was not selected before, so we should add it.
2018-05-18 03:25:45 +00:00
if ( ! selectedElements . includes ( intElem ) ) {
2018-05-18 04:02:30 +00:00
elemsToAdd . push ( intElem ) ;
}
// Found an element that was already selected, so we shouldn't remove it.
2018-05-18 03:25:45 +00:00
const foundInd = elemsToRemove . indexOf ( intElem ) ;
2018-05-18 04:02:30 +00:00
if ( foundInd !== - 1 ) {
elemsToRemove . splice ( foundInd , 1 ) ;
}
}
if ( elemsToRemove . length > 0 ) {
canvas . removeFromSelection ( elemsToRemove ) ;
}
if ( elemsToAdd . length > 0 ) {
canvas . addToSelection ( elemsToAdd ) ;
}
break ;
2018-05-18 03:25:45 +00:00
} case 'resize' : {
2018-05-18 04:02:30 +00:00
// we track the resize bounding box and translate/scale the selected element
// while the mouse is down, when mouse goes up, we use this to recalculate
// the shape's coordinates
2018-05-18 03:25:45 +00:00
tlist = getTransformList ( selected ) ;
const hasMatrix = hasMatrixTransform ( tlist ) ;
box = hasMatrix ? initBbox : utilsGetBBox ( selected ) ;
let left = box . x ,
top = box . y ,
{ width , height } = box ;
2018-05-18 04:02:30 +00:00
dx = ( x - startX ) ;
dy = ( y - startY ) ;
if ( curConfig . gridSnapping ) {
2018-05-18 03:25:45 +00:00
dx = snapToGrid ( dx ) ;
dy = snapToGrid ( dy ) ;
height = snapToGrid ( height ) ;
width = snapToGrid ( width ) ;
2018-05-18 04:02:30 +00:00
}
// if rotated, adjust the dx,dy values
2018-05-18 03:25:45 +00:00
angle = getRotationAngle ( selected ) ;
2018-05-18 04:02:30 +00:00
if ( angle ) {
2018-05-18 03:25:45 +00:00
const r = Math . sqrt ( dx * dx + dy * dy ) ,
2018-05-18 04:02:30 +00:00
theta = Math . atan2 ( dy , dx ) - angle * Math . PI / 180.0 ;
dx = r * Math . cos ( theta ) ;
dy = r * Math . sin ( theta ) ;
}
// if not stretching in y direction, set dy to 0
// if not stretching in x direction, set dx to 0
2018-05-18 03:25:45 +00:00
if ( ! currentResizeMode . includes ( 'n' ) && ! currentResizeMode . includes ( 's' ) ) {
2018-05-18 04:02:30 +00:00
dy = 0 ;
}
2018-05-18 03:25:45 +00:00
if ( ! currentResizeMode . includes ( 'e' ) && ! currentResizeMode . includes ( 'w' ) ) {
2018-05-18 04:02:30 +00:00
dx = 0 ;
}
2018-05-18 03:25:45 +00:00
let // ts = null,
2018-05-18 04:02:30 +00:00
tx = 0 , ty = 0 ,
sy = height ? ( height + dy ) / height : 1 ,
sx = width ? ( width + dx ) / width : 1 ;
// if we are dragging on the north side, then adjust the scale factor and ty
2018-05-18 03:25:45 +00:00
if ( currentResizeMode . includes ( 'n' ) ) {
2018-05-18 04:02:30 +00:00
sy = height ? ( height - dy ) / height : 1 ;
ty = height ;
}
// if we dragging on the east side, then adjust the scale factor and tx
2018-05-18 03:25:45 +00:00
if ( currentResizeMode . includes ( 'w' ) ) {
2018-05-18 04:02:30 +00:00
sx = width ? ( width - dx ) / width : 1 ;
tx = width ;
}
// update the transform list with translate,scale,translate
2018-05-18 03:25:45 +00:00
const translateOrigin = svgroot . createSVGTransform ( ) ,
2018-05-18 04:02:30 +00:00
scale = svgroot . createSVGTransform ( ) ,
translateBack = svgroot . createSVGTransform ( ) ;
if ( curConfig . gridSnapping ) {
2018-05-18 03:25:45 +00:00
left = snapToGrid ( left ) ;
tx = snapToGrid ( tx ) ;
top = snapToGrid ( top ) ;
ty = snapToGrid ( ty ) ;
2018-05-18 04:02:30 +00:00
}
translateOrigin . setTranslate ( - ( left + tx ) , - ( top + ty ) ) ;
if ( evt . shiftKey ) {
if ( sx === 1 ) {
sx = sy ;
} else { sy = sx ; }
}
scale . setScale ( sx , sy ) ;
translateBack . setTranslate ( left + tx , top + ty ) ;
if ( hasMatrix ) {
2018-05-18 03:25:45 +00:00
const diff = angle ? 1 : 0 ;
2018-05-18 04:02:30 +00:00
tlist . replaceItem ( translateOrigin , 2 + diff ) ;
tlist . replaceItem ( scale , 1 + diff ) ;
tlist . replaceItem ( translateBack , Number ( diff ) ) ;
} else {
2018-05-18 03:25:45 +00:00
const N = tlist . numberOfItems ;
2018-05-18 04:02:30 +00:00
tlist . replaceItem ( translateBack , N - 3 ) ;
tlist . replaceItem ( scale , N - 2 ) ;
tlist . replaceItem ( translateOrigin , N - 1 ) ;
}
selectorManager . requestSelector ( selected ) . resize ( ) ;
call ( 'transition' , selectedElements ) ;
break ;
2018-05-18 03:25:45 +00:00
} case 'zoom' : {
2018-05-18 04:02:30 +00:00
realX *= currentZoom ;
realY *= currentZoom ;
2018-05-18 03:25:45 +00:00
assignAttributes ( rubberBox , {
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
x : Math . min ( rStartX * currentZoom , realX ) ,
y : Math . min ( rStartY * currentZoom , realY ) ,
width : Math . abs ( realX - rStartX * currentZoom ) ,
height : Math . abs ( realY - rStartY * currentZoom )
2018-05-18 04:02:30 +00:00
} , 100 ) ;
break ;
2018-05-18 03:25:45 +00:00
} case 'text' : {
assignAttributes ( shape , {
x ,
y
2018-05-18 04:02:30 +00:00
} , 1000 ) ;
break ;
2018-05-18 03:25:45 +00:00
} case 'line' : {
2018-05-18 04:02:30 +00:00
if ( curConfig . gridSnapping ) {
2018-05-18 03:25:45 +00:00
x = snapToGrid ( x ) ;
y = snapToGrid ( y ) ;
2018-05-18 04:02:30 +00:00
}
2018-05-18 03:25:45 +00:00
let x2 = x ;
let y2 = y ;
2018-05-18 04:02:30 +00:00
if ( evt . shiftKey ) {
2018-05-18 03:25:45 +00:00
xya = snapToAngle ( startX , startY , x2 , y2 ) ;
2018-05-18 04:02:30 +00:00
x2 = xya . x ;
y2 = xya . y ;
}
shape . setAttributeNS ( null , 'x2' , x2 ) ;
shape . setAttributeNS ( null , 'y2' , y2 ) ;
break ;
2018-05-18 03:25:45 +00:00
} case 'foreignObject' :
2018-05-18 04:02:30 +00:00
// fall through
case 'square' :
// fall through
case 'rect' :
// fall through
2018-05-18 03:25:45 +00:00
case 'image' : {
const square = ( currentMode === 'square' ) || evt . shiftKey ;
let
2018-05-18 04:02:30 +00:00
w = Math . abs ( x - startX ) ,
2018-05-18 03:25:45 +00:00
h = Math . abs ( y - startY ) ;
let newX , newY ;
2018-05-18 04:02:30 +00:00
if ( square ) {
w = h = Math . max ( w , h ) ;
newX = startX < x ? startX : startX - w ;
newY = startY < y ? startY : startY - h ;
} else {
newX = Math . min ( startX , x ) ;
newY = Math . min ( startY , y ) ;
}
if ( curConfig . gridSnapping ) {
2018-05-18 03:25:45 +00:00
w = snapToGrid ( w ) ;
h = snapToGrid ( h ) ;
newX = snapToGrid ( newX ) ;
newY = snapToGrid ( newY ) ;
2018-05-18 04:02:30 +00:00
}
2018-05-18 03:25:45 +00:00
assignAttributes ( shape , {
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
width : w ,
height : h ,
x : newX ,
y : newY
2018-05-18 04:02:30 +00:00
} , 1000 ) ;
break ;
2018-05-18 03:25:45 +00:00
} case 'circle' : {
2018-05-18 04:02:30 +00:00
c = $ ( shape ) . attr ( [ 'cx' , 'cy' ] ) ;
2018-05-18 03:25:45 +00:00
( { cx , cy } = c ) ;
let rad = Math . sqrt ( ( x - cx ) * ( x - cx ) + ( y - cy ) * ( y - cy ) ) ;
2018-05-18 04:02:30 +00:00
if ( curConfig . gridSnapping ) {
2018-05-18 03:25:45 +00:00
rad = snapToGrid ( rad ) ;
2018-05-18 04:02:30 +00:00
}
shape . setAttributeNS ( null , 'r' , rad ) ;
break ;
2018-05-18 03:25:45 +00:00
} case 'ellipse' : {
2018-05-18 04:02:30 +00:00
c = $ ( shape ) . attr ( [ 'cx' , 'cy' ] ) ;
2018-05-18 03:25:45 +00:00
( { cx , cy } = c ) ;
2018-05-18 04:02:30 +00:00
if ( curConfig . gridSnapping ) {
2018-05-18 03:25:45 +00:00
x = snapToGrid ( x ) ;
cx = snapToGrid ( cx ) ;
y = snapToGrid ( y ) ;
cy = snapToGrid ( cy ) ;
2018-05-18 04:02:30 +00:00
}
shape . setAttributeNS ( null , 'rx' , Math . abs ( x - cx ) ) ;
2018-05-18 03:25:45 +00:00
const ry = Math . abs ( evt . shiftKey ? ( x - cx ) : ( y - cy ) ) ;
2018-05-18 04:02:30 +00:00
shape . setAttributeNS ( null , 'ry' , ry ) ;
break ;
2018-05-18 03:25:45 +00:00
}
2018-05-18 04:02:30 +00:00
case 'fhellipse' :
2018-05-18 03:25:45 +00:00
case 'fhrect' : {
2018-05-18 04:02:30 +00:00
freehand . minx = Math . min ( realX , freehand . minx ) ;
freehand . maxx = Math . max ( realX , freehand . maxx ) ;
freehand . miny = Math . min ( realY , freehand . miny ) ;
freehand . maxy = Math . max ( realY , freehand . maxy ) ;
2018-05-18 03:25:45 +00:00
}
// Fallthrough
case 'fhpath' : {
2018-05-18 04:02:30 +00:00
// dAttr += + realX + ',' + realY + ' ';
// shape.setAttributeNS(null, 'points', dAttr);
end . x = realX ; end . y = realY ;
if ( controllPoint2 . x && controllPoint2 . y ) {
for ( i = 0 ; i < STEP _COUNT - 1 ; i ++ ) {
parameter = i / STEP _COUNT ;
nextParameter = ( i + 1 ) / STEP _COUNT ;
bSpline = getBsplinePoint ( nextParameter ) ;
nextPos = bSpline ;
bSpline = getBsplinePoint ( parameter ) ;
sumDistance += Math . sqrt ( ( nextPos . x - bSpline . x ) * ( nextPos . x - bSpline . x ) + ( nextPos . y - bSpline . y ) * ( nextPos . y - bSpline . y ) ) ;
if ( sumDistance > THRESHOLD _DIST ) {
dAttr += + bSpline . x + ',' + bSpline . y + ' ' ;
shape . setAttributeNS ( null , 'points' , dAttr ) ;
sumDistance -= THRESHOLD _DIST ;
}
}
}
controllPoint2 = { x : controllPoint1 . x , y : controllPoint1 . y } ;
controllPoint1 = { x : start . x , y : start . y } ;
start = { x : end . x , y : end . y } ;
break ;
// update path stretch line coordinates
2018-05-18 03:25:45 +00:00
} case 'path' : {
}
// fall through
case 'pathedit' : {
2018-05-18 04:02:30 +00:00
x *= currentZoom ;
y *= currentZoom ;
if ( curConfig . gridSnapping ) {
2018-05-18 03:25:45 +00:00
x = snapToGrid ( x ) ;
y = snapToGrid ( y ) ;
startX = snapToGrid ( startX ) ;
startY = snapToGrid ( startY ) ;
2018-05-18 04:02:30 +00:00
}
if ( evt . shiftKey ) {
2018-05-18 03:25:45 +00:00
const { path } = pathModule ;
let x1 , y1 ;
2018-05-18 04:02:30 +00:00
if ( path ) {
x1 = path . dragging ? path . dragging [ 0 ] : startX ;
y1 = path . dragging ? path . dragging [ 1 ] : startY ;
} else {
x1 = startX ;
y1 = startY ;
}
2018-05-18 03:25:45 +00:00
xya = snapToAngle ( x1 , y1 , x , y ) ;
( { x , y } = xya ) ;
2018-05-18 04:02:30 +00:00
}
if ( rubberBox && rubberBox . getAttribute ( 'display' ) !== 'none' ) {
realX *= currentZoom ;
realY *= currentZoom ;
2018-05-18 03:25:45 +00:00
assignAttributes ( rubberBox , {
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
x : Math . min ( rStartX * currentZoom , realX ) ,
y : Math . min ( rStartY * currentZoom , realY ) ,
width : Math . abs ( realX - rStartX * currentZoom ) ,
height : Math . abs ( realY - rStartY * currentZoom )
2018-05-18 04:02:30 +00:00
} , 100 ) ;
}
pathActions . mouseMove ( x , y ) ;
break ;
2018-05-18 03:25:45 +00:00
} case 'textedit' : {
2018-05-18 04:02:30 +00:00
x *= currentZoom ;
y *= currentZoom ;
// if (rubberBox && rubberBox.getAttribute('display') !== 'none') {
2018-05-18 03:25:45 +00:00
// assignAttributes(rubberBox, {
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
// x: Math.min(startX, x),
// y: Math.min(startY, y),
// width: Math.abs(x - startX),
// height: Math.abs(y - startY)
2018-05-18 06:41:43 +00:00
// }, 100);
2018-05-18 04:02:30 +00:00
// }
textActions . mouseMove ( mouseX , mouseY ) ;
break ;
2018-05-18 03:25:45 +00:00
} case 'rotate' : {
box = utilsGetBBox ( selected ) ;
2018-05-18 04:02:30 +00:00
cx = box . x + box . width / 2 ;
cy = box . y + box . height / 2 ;
2018-05-18 03:25:45 +00:00
const m = getMatrix ( selected ) ,
center = transformPoint ( cx , cy , m ) ;
2018-05-18 04:02:30 +00:00
cx = center . x ;
cy = center . y ;
angle = ( ( Math . atan2 ( cy - y , cx - x ) * ( 180 / Math . PI ) ) - 90 ) % 360 ;
if ( curConfig . gridSnapping ) {
2018-05-18 03:25:45 +00:00
angle = snapToGrid ( angle ) ;
2018-05-18 04:02:30 +00:00
}
if ( evt . shiftKey ) { // restrict rotations to nice angles (WRS)
2018-05-18 03:25:45 +00:00
const snap = 45 ;
2018-05-18 04:02:30 +00:00
angle = Math . round ( angle / snap ) * snap ;
}
canvas . setRotationAngle ( angle < - 180 ? ( 360 + angle ) : angle , true ) ;
call ( 'transition' , selectedElements ) ;
break ;
2018-05-18 03:25:45 +00:00
} default :
2018-05-18 04:02:30 +00:00
break ;
}
runExtensions ( 'mouseMove' , {
event : evt ,
mouse _x : mouseX ,
mouse _y : mouseY ,
2018-05-18 03:25:45 +00:00
selected
2018-05-18 04:02:30 +00:00
} ) ;
2018-05-17 05:15:20 +00:00
} ; // mouseMove()
// - in create mode, the element's opacity is set properly, we create an InsertElementCommand
// and store it on the Undo stack
// - in move/resize mode, the element's attributes which were affected by the move/resize are
// identified, a ChangeElementCommand is created and stored on the stack for those attrs
// this is done in when we recalculate the selected dimensions()
2018-05-18 03:25:45 +00:00
const mouseUp = function ( evt ) {
2018-05-18 04:02:30 +00:00
if ( evt . button === 2 ) { return ; }
2018-05-18 03:25:45 +00:00
const tempJustSelected = justSelected ;
2018-05-18 04:02:30 +00:00
justSelected = null ;
if ( ! started ) { return ; }
2018-05-18 03:25:45 +00:00
const pt = transformPoint ( evt . pageX , evt . pageY , rootSctm ) ,
2018-05-18 04:02:30 +00:00
mouseX = pt . x * currentZoom ,
mouseY = pt . y * currentZoom ,
x = mouseX / currentZoom ,
2018-05-18 03:25:45 +00:00
y = mouseY / currentZoom ;
2018-05-18 04:02:30 +00:00
2018-05-18 03:25:45 +00:00
let element = getElem ( getId ( ) ) ;
let keep = false ;
const realX = x ;
const realY = y ;
2018-05-18 04:02:30 +00:00
// TODO: Make true when in multi-unit mode
2018-05-18 03:25:45 +00:00
const useUnit = false ; // (curConfig.baseUnit !== 'px');
2018-05-18 04:02:30 +00:00
started = false ;
2018-05-18 03:25:45 +00:00
let attrs , t ;
2018-05-18 04:02:30 +00:00
switch ( currentMode ) {
// intentionally fall-through to select here
case 'resize' :
case 'multiselect' :
if ( rubberBox != null ) {
rubberBox . setAttribute ( 'display' , 'none' ) ;
curBBoxes = [ ] ;
}
currentMode = 'select' ;
// Fallthrough
case 'select' :
if ( selectedElements [ 0 ] != null ) {
// if we only have one selected element
if ( selectedElements [ 1 ] == null ) {
// set our current stroke/fill properties to the element's
2018-05-18 03:25:45 +00:00
const selected = selectedElements [ 0 ] ;
2018-05-18 04:02:30 +00:00
switch ( selected . tagName ) {
case 'g' :
case 'use' :
case 'image' :
case 'foreignObject' :
break ;
default :
curProperties . fill = selected . getAttribute ( 'fill' ) ;
curProperties . fill _opacity = selected . getAttribute ( 'fill-opacity' ) ;
curProperties . stroke = selected . getAttribute ( 'stroke' ) ;
curProperties . stroke _opacity = selected . getAttribute ( 'stroke-opacity' ) ;
curProperties . stroke _width = selected . getAttribute ( 'stroke-width' ) ;
curProperties . stroke _dasharray = selected . getAttribute ( 'stroke-dasharray' ) ;
curProperties . stroke _linejoin = selected . getAttribute ( 'stroke-linejoin' ) ;
curProperties . stroke _linecap = selected . getAttribute ( 'stroke-linecap' ) ;
}
if ( selected . tagName === 'text' ) {
curText . font _size = selected . getAttribute ( 'font-size' ) ;
curText . font _family = selected . getAttribute ( 'font-family' ) ;
}
selectorManager . requestSelector ( selected ) . showGrips ( true ) ;
// This shouldn't be necessary as it was done on mouseDown...
// call('selected', [selected]);
}
// always recalculate dimensions to strip off stray identity transforms
recalculateAllSelectedDimensions ( ) ;
// if it was being dragged/resized
if ( realX !== rStartX || realY !== rStartY ) {
2018-05-18 03:25:45 +00:00
const len = selectedElements . length ;
for ( let i = 0 ; i < len ; ++ i ) {
2018-05-18 04:02:30 +00:00
if ( selectedElements [ i ] == null ) { break ; }
if ( ! selectedElements [ i ] . firstChild ) {
// Not needed for groups (incorrectly resizes elems), possibly not needed at all?
selectorManager . requestSelector ( selectedElements [ i ] ) . resize ( ) ;
}
}
// no change in position/size, so maybe we should move to pathedit
} else {
t = evt . target ;
if ( selectedElements [ 0 ] . nodeName === 'path' && selectedElements [ 1 ] == null ) {
pathActions . select ( selectedElements [ 0 ] ) ;
// if it was a path
// else, if it was selected and this is a shift-click, remove it from selection
} else if ( evt . shiftKey ) {
if ( tempJustSelected !== t ) {
canvas . removeFromSelection ( [ t ] ) ;
}
}
} // no change in mouse position
// Remove non-scaling stroke
2018-05-18 03:25:45 +00:00
if ( supportsNonScalingStroke ( ) ) {
const elem = selectedElements [ 0 ] ;
2018-05-18 04:02:30 +00:00
if ( elem ) {
elem . removeAttribute ( 'style' ) ;
2018-05-18 03:25:45 +00:00
walkTree ( elem , function ( elem ) {
2018-05-18 04:02:30 +00:00
elem . removeAttribute ( 'style' ) ;
} ) ;
}
}
}
return ;
case 'zoom' :
if ( rubberBox != null ) {
rubberBox . setAttribute ( 'display' , 'none' ) ;
}
2018-05-18 03:25:45 +00:00
const factor = evt . shiftKey ? 0.5 : 2 ;
2018-05-18 04:02:30 +00:00
call ( 'zoomed' , {
2018-05-18 03:25:45 +00:00
x : Math . min ( rStartX , realX ) ,
y : Math . min ( rStartY , realY ) ,
width : Math . abs ( realX - rStartX ) ,
height : Math . abs ( realY - rStartY ) ,
factor
2018-05-18 04:02:30 +00:00
} ) ;
return ;
case 'fhpath' :
// Check that the path contains at least 2 points; a degenerate one-point path
// causes problems.
// Webkit ignores how we set the points attribute with commas and uses space
// to separate all coordinates, see https://bugs.webkit.org/show_bug.cgi?id=29870
sumDistance = 0 ;
controllPoint2 = { x : 0 , y : 0 } ;
controllPoint1 = { x : 0 , y : 0 } ;
start = { x : 0 , y : 0 } ;
end = { x : 0 , y : 0 } ;
2018-05-18 03:25:45 +00:00
const coords = element . getAttribute ( 'points' ) ;
const commaIndex = coords . indexOf ( ',' ) ;
2018-05-18 04:02:30 +00:00
if ( commaIndex >= 0 ) {
keep = coords . indexOf ( ',' , commaIndex + 1 ) >= 0 ;
} else {
keep = coords . indexOf ( ' ' , coords . indexOf ( ' ' ) + 1 ) >= 0 ;
}
if ( keep ) {
element = pathActions . smoothPolylineIntoPath ( element ) ;
}
break ;
case 'line' :
attrs = $ ( element ) . attr ( [ 'x1' , 'x2' , 'y1' , 'y2' ] ) ;
keep = ( attrs . x1 !== attrs . x2 || attrs . y1 !== attrs . y2 ) ;
break ;
case 'foreignObject' :
case 'square' :
case 'rect' :
case 'image' :
attrs = $ ( element ) . attr ( [ 'width' , 'height' ] ) ;
// Image should be kept regardless of size (use inherit dimensions later)
keep = ( attrs . width !== '0' || attrs . height !== '0' ) || currentMode === 'image' ;
break ;
case 'circle' :
keep = ( element . getAttribute ( 'r' ) !== '0' ) ;
break ;
case 'ellipse' :
attrs = $ ( element ) . attr ( [ 'rx' , 'ry' ] ) ;
keep = ( attrs . rx != null || attrs . ry != null ) ;
break ;
case 'fhellipse' :
if ( ( freehand . maxx - freehand . minx ) > 0 &&
( freehand . maxy - freehand . miny ) > 0 ) {
element = addSvgElementFromJson ( {
element : 'ellipse' ,
curStyles : true ,
attr : {
cx : ( freehand . minx + freehand . maxx ) / 2 ,
cy : ( freehand . miny + freehand . maxy ) / 2 ,
rx : ( freehand . maxx - freehand . minx ) / 2 ,
ry : ( freehand . maxy - freehand . miny ) / 2 ,
id : getId ( )
}
} ) ;
call ( 'changed' , [ element ] ) ;
keep = true ;
}
break ;
case 'fhrect' :
if ( ( freehand . maxx - freehand . minx ) > 0 &&
( freehand . maxy - freehand . miny ) > 0 ) {
element = addSvgElementFromJson ( {
element : 'rect' ,
curStyles : true ,
attr : {
x : freehand . minx ,
y : freehand . miny ,
width : ( freehand . maxx - freehand . minx ) ,
height : ( freehand . maxy - freehand . miny ) ,
id : getId ( )
}
} ) ;
call ( 'changed' , [ element ] ) ;
keep = true ;
}
break ;
case 'text' :
keep = true ;
selectOnly ( [ element ] ) ;
textActions . start ( element ) ;
break ;
case 'path' :
// set element to null here so that it is not removed nor finalized
element = null ;
// continue to be set to true so that mouseMove happens
started = true ;
2018-05-18 03:25:45 +00:00
const res = pathActions . mouseUp ( evt , element , mouseX , mouseY ) ;
( { element } = res ) ;
( { keep } = res ) ;
2018-05-18 04:02:30 +00:00
break ;
case 'pathedit' :
keep = true ;
element = null ;
pathActions . mouseUp ( evt ) ;
break ;
case 'textedit' :
keep = false ;
element = null ;
textActions . mouseUp ( evt , mouseX , mouseY ) ;
break ;
case 'rotate' :
keep = true ;
element = null ;
currentMode = 'select' ;
2018-05-18 03:25:45 +00:00
const batchCmd = canvas . undoMgr . finishUndoableChange ( ) ;
2018-05-18 04:02:30 +00:00
if ( ! batchCmd . isEmpty ( ) ) {
addCommandToHistory ( batchCmd ) ;
}
// perform recalculation to weed out any stray identity transforms that might get stuck
recalculateAllSelectedDimensions ( ) ;
call ( 'changed' , selectedElements ) ;
break ;
default :
// This could occur in an extension
break ;
}
2018-05-18 03:25:45 +00:00
const extResult = runExtensions ( 'mouseUp' , {
2018-05-18 04:02:30 +00:00
event : evt ,
mouse _x : mouseX ,
mouse _y : mouseY
} , true ) ;
$ . each ( extResult , function ( i , r ) {
if ( r ) {
keep = r . keep || keep ;
2018-05-18 03:25:45 +00:00
( { element } = r ) ;
2018-05-18 04:02:30 +00:00
started = r . started || started ;
}
} ) ;
if ( ! keep && element != null ) {
getCurrentDrawing ( ) . releaseId ( getId ( ) ) ;
element . parentNode . removeChild ( element ) ;
element = null ;
t = evt . target ;
// if this element is in a group, go up until we reach the top-level group
// just below the layer groups
// TODO: once we implement links, we also would have to check for <a> elements
while ( t && t . parentNode && t . parentNode . parentNode && t . parentNode . parentNode . tagName === 'g' ) {
t = t . parentNode ;
}
// if we are not in the middle of creating a path, and we've clicked on some shape,
// then go to Select mode.
// WebKit returns <div> when the canvas is clicked, Firefox/Opera return <svg>
if ( ( currentMode !== 'path' || ! drawnPath ) &&
t && t . parentNode &&
t . parentNode . id !== 'selectorParentGroup' &&
t . id !== 'svgcanvas' && t . id !== 'svgroot'
) {
// switch into "select" mode if we've clicked on an element
canvas . setMode ( 'select' ) ;
selectOnly ( [ t ] , true ) ;
}
} else if ( element != null ) {
canvas . addedNew = true ;
2018-05-18 03:25:45 +00:00
if ( useUnit ) { convertAttrs ( element ) ; }
2018-05-18 04:02:30 +00:00
2018-05-18 03:25:45 +00:00
let aniDur = 0.2 ;
let cAni ;
2018-05-18 04:02:30 +00:00
if ( opacAni . beginElement && parseFloat ( element . getAttribute ( 'opacity' ) ) !== curShape . opacity ) {
cAni = $ ( opacAni ) . clone ( ) . attr ( {
to : curShape . opacity ,
dur : aniDur
} ) . appendTo ( element ) ;
try {
// Fails in FF4 on foreignObject
cAni [ 0 ] . beginElement ( ) ;
} catch ( e ) { }
} else {
aniDur = 0 ;
}
// Ideally this would be done on the endEvent of the animation,
// but that doesn't seem to be supported in Webkit
setTimeout ( function ( ) {
if ( cAni ) { cAni . remove ( ) ; }
element . setAttribute ( 'opacity' , curShape . opacity ) ;
element . setAttribute ( 'style' , 'pointer-events:inherit' ) ;
cleanupElement ( element ) ;
if ( currentMode === 'path' ) {
pathActions . toEditMode ( element ) ;
} else if ( curConfig . selectNew ) {
selectOnly ( [ element ] , true ) ;
}
// we create the insert command that is stored on the stack
// undo means to call cmd.unapply(), redo means to call cmd.apply()
2018-05-18 03:25:45 +00:00
addCommandToHistory ( new InsertElementCommand ( element ) ) ;
2018-05-18 04:02:30 +00:00
call ( 'changed' , [ element ] ) ;
} , aniDur * 1000 ) ;
}
startTransform = null ;
2018-05-17 05:15:20 +00:00
} ;
2018-05-16 00:53:27 +00:00
2018-05-18 03:25:45 +00:00
const dblClick = function ( evt ) {
const evtTarget = evt . target ;
const parent = evtTarget . parentNode ;
2018-05-18 04:02:30 +00:00
// Do nothing if already in current group
if ( parent === currentGroup ) { return ; }
2018-05-18 03:25:45 +00:00
let mouseTarget = getMouseTarget ( evt ) ;
const { tagName } = mouseTarget ;
2018-05-18 04:02:30 +00:00
if ( tagName === 'text' && currentMode !== 'textedit' ) {
2018-05-18 03:25:45 +00:00
const pt = transformPoint ( evt . pageX , evt . pageY , rootSctm ) ;
2018-05-18 04:02:30 +00:00
textActions . select ( mouseTarget , pt . x , pt . y ) ;
}
if ( ( tagName === 'g' || tagName === 'a' ) &&
2018-05-18 03:25:45 +00:00
getRotationAngle ( mouseTarget )
2018-05-18 04:02:30 +00:00
) {
// TODO: Allow method of in-group editing without having to do
// this (similar to editing rotated paths)
// Ungroup and regroup
pushGroupProperties ( mouseTarget ) ;
mouseTarget = selectedElements [ 0 ] ;
clearSelection ( true ) ;
}
// Reset context
if ( currentGroup ) {
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
draw . leaveContext ( ) ;
2018-05-18 04:02:30 +00:00
}
if ( ( parent . tagName !== 'g' && parent . tagName !== 'a' ) ||
parent === getCurrentDrawing ( ) . getCurrentLayer ( ) ||
mouseTarget === selectorManager . selectorParentGroup
) {
// Escape from in-group edit
return ;
}
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
draw . setContext ( mouseTarget ) ;
2018-05-17 05:15:20 +00:00
} ;
2010-06-22 14:52:51 +00:00
2018-05-17 05:15:20 +00:00
// prevent links from being followed in the canvas
2018-05-18 03:25:45 +00:00
const handleLinkInCanvas = function ( e ) {
2018-05-18 04:02:30 +00:00
e . preventDefault ( ) ;
return false ;
2018-05-17 05:15:20 +00:00
} ;
2013-01-16 11:42:18 +00:00
2018-05-17 05:15:20 +00:00
// Added mouseup to the container here.
// TODO(codedread): Figure out why after the Closure compiler, the window mouseup is ignored.
$ ( container ) . mousedown ( mouseDown ) . mousemove ( mouseMove ) . click ( handleLinkInCanvas ) . dblclick ( dblClick ) . mouseup ( mouseUp ) ;
// $(window).mouseup(mouseUp);
// TODO(rafaelcastrocouto): User preference for shift key and zoom factor
$ ( container ) . bind ( 'mousewheel DOMMouseScroll' , function ( e ) {
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
if ( ! e . shiftKey ) { return ; }
2018-05-18 04:02:30 +00:00
e . preventDefault ( ) ;
2018-05-18 03:25:45 +00:00
const evt = e . originalEvent ;
2018-05-17 05:15:20 +00:00
2018-05-18 04:02:30 +00:00
rootSctm = $ ( '#svgcontent g' ) [ 0 ] . getScreenCTM ( ) . inverse ( ) ;
2018-05-17 05:15:20 +00:00
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
const workarea = $ ( '#workarea' ) ;
const scrbar = 15 ;
const rulerwidth = curConfig . showRulers ? 16 : 0 ;
// mouse relative to content area in content pixels
const pt = transformPoint ( evt . pageX , evt . pageY , rootSctm ) ;
// full work area width in screen pixels
const editorFullW = workarea . width ( ) ;
const editorFullH = workarea . height ( ) ;
// work area width minus scroll and ruler in screen pixels
const editorW = editorFullW - scrbar - rulerwidth ;
const editorH = editorFullH - scrbar - rulerwidth ;
// work area width in content pixels
const workareaViewW = editorW * rootSctm . a ;
const workareaViewH = editorH * rootSctm . d ;
// content offset from canvas in screen pixels
const wOffset = workarea . offset ( ) ;
const wOffsetLeft = wOffset [ 'left' ] + rulerwidth ;
const wOffsetTop = wOffset [ 'top' ] + rulerwidth ;
2010-06-22 14:52:51 +00:00
2018-05-18 03:25:45 +00:00
const delta = ( evt . wheelDelta ) ? evt . wheelDelta : ( evt . detail ) ? - evt . detail : 0 ;
2018-05-18 04:02:30 +00:00
if ( ! delta ) { return ; }
2013-01-16 11:42:18 +00:00
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
let factor = Math . max ( 3 / 4 , Math . min ( 4 / 3 , ( delta ) ) ) ;
let wZoom , hZoom ;
if ( factor > 1 ) {
wZoom = Math . ceil ( editorW / workareaViewW * factor * 100 ) / 100 ;
hZoom = Math . ceil ( editorH / workareaViewH * factor * 100 ) / 100 ;
} else {
wZoom = Math . floor ( editorW / workareaViewW * factor * 100 ) / 100 ;
hZoom = Math . floor ( editorH / workareaViewH * factor * 100 ) / 100 ;
}
let zoomlevel = Math . min ( wZoom , hZoom ) ;
zoomlevel = Math . min ( 10 , Math . max ( 0.01 , zoomlevel ) ) ;
if ( zoomlevel === currentZoom ) {
return ;
}
factor = zoomlevel / currentZoom ;
// top left of workarea in content pixels before zoom
const topLeftOld = transformPoint ( wOffsetLeft , wOffsetTop , rootSctm ) ;
// top left of workarea in content pixels after zoom
const topLeftNew = {
x : pt . x - ( pt . x - topLeftOld . x ) / factor ,
y : pt . y - ( pt . y - topLeftOld . y ) / factor
} ;
// top left of workarea in canvas pixels relative to content after zoom
const topLeftNewCanvas = {
x : topLeftNew . x * zoomlevel ,
y : topLeftNew . y * zoomlevel
} ;
// new center in canvas pixels
const newCtr = {
x : topLeftNewCanvas . x - rulerwidth + editorFullW / 2 ,
y : topLeftNewCanvas . y - rulerwidth + editorFullH / 2
} ;
canvas . setZoom ( zoomlevel ) ;
$ ( '#zoom' ) . val ( ( zoomlevel * 100 ) . toFixed ( 1 ) ) ;
call ( 'updateCanvas' , { center : false , newCtr } ) ;
call ( 'zoomDone' ) ;
2018-05-17 05:15:20 +00:00
} ) ;
2010-06-22 14:52:51 +00:00
} ( ) ) ;
2010-04-30 15:06:47 +00:00
2010-06-29 20:43:44 +00:00
// Group: Text edit functions
2010-06-22 18:17:42 +00:00
// Functions relating to editing text elements
2018-05-18 03:25:45 +00:00
const textActions = canvas . textActions = ( function ( ) {
let curtext ;
let textinput ;
let cursor ;
let selblock ;
let blinker ;
let chardata = [ ] ;
let textbb ; // , transbb;
let matrix ;
let lastX , lastY ;
let allowDbl ;
2018-05-17 05:15:20 +00:00
function setCursor ( index ) {
2018-05-18 03:25:45 +00:00
const empty = ( textinput . value === '' ) ;
2018-05-18 04:02:30 +00:00
$ ( textinput ) . focus ( ) ;
if ( ! arguments . length ) {
if ( empty ) {
index = 0 ;
} else {
if ( textinput . selectionEnd !== textinput . selectionStart ) { return ; }
index = textinput . selectionEnd ;
}
}
2018-05-18 03:25:45 +00:00
const charbb = chardata [ index ] ;
2018-05-18 04:02:30 +00:00
if ( ! empty ) {
textinput . setSelectionRange ( index , index ) ;
}
2018-05-18 03:25:45 +00:00
cursor = getElem ( 'text_cursor' ) ;
2018-05-18 04:02:30 +00:00
if ( ! cursor ) {
cursor = document . createElementNS ( NS . SVG , 'line' ) ;
2018-05-18 03:25:45 +00:00
assignAttributes ( cursor , {
2018-05-18 04:02:30 +00:00
id : 'text_cursor' ,
stroke : '#333' ,
'stroke-width' : 1
} ) ;
2018-05-18 03:25:45 +00:00
cursor = getElem ( 'selectorParentGroup' ) . appendChild ( cursor ) ;
2018-05-18 04:02:30 +00:00
}
if ( ! blinker ) {
blinker = setInterval ( function ( ) {
2018-05-18 03:25:45 +00:00
const show = ( cursor . getAttribute ( 'display' ) === 'none' ) ;
2018-05-18 04:02:30 +00:00
cursor . setAttribute ( 'display' , show ? 'inline' : 'none' ) ;
} , 600 ) ;
}
2018-05-18 03:25:45 +00:00
const startPt = ptToScreen ( charbb . x , textbb . y ) ;
const endPt = ptToScreen ( charbb . x , ( textbb . y + textbb . height ) ) ;
2018-05-18 04:02:30 +00:00
2018-05-18 03:25:45 +00:00
assignAttributes ( cursor , {
2018-05-18 04:02:30 +00:00
x1 : startPt . x ,
y1 : startPt . y ,
x2 : endPt . x ,
y2 : endPt . y ,
visibility : 'visible' ,
display : 'inline'
} ) ;
if ( selblock ) { selblock . setAttribute ( 'd' , '' ) ; }
2018-05-17 05:15:20 +00:00
}
2018-05-16 00:53:27 +00:00
2018-05-17 05:15:20 +00:00
function setSelection ( start , end , skipInput ) {
2018-05-18 04:02:30 +00:00
if ( start === end ) {
setCursor ( end ) ;
return ;
}
if ( ! skipInput ) {
textinput . setSelectionRange ( start , end ) ;
}
2018-05-18 03:25:45 +00:00
selblock = getElem ( 'text_selectblock' ) ;
2018-05-18 04:02:30 +00:00
if ( ! selblock ) {
selblock = document . createElementNS ( NS . SVG , 'path' ) ;
2018-05-18 03:25:45 +00:00
assignAttributes ( selblock , {
2018-05-18 04:02:30 +00:00
id : 'text_selectblock' ,
fill : 'green' ,
opacity : 0.5 ,
style : 'pointer-events:none'
} ) ;
2018-05-18 03:25:45 +00:00
getElem ( 'selectorParentGroup' ) . appendChild ( selblock ) ;
2018-05-18 04:02:30 +00:00
}
2018-05-18 03:25:45 +00:00
const startbb = chardata [ start ] ;
const endbb = chardata [ end ] ;
2018-05-18 04:02:30 +00:00
cursor . setAttribute ( 'visibility' , 'hidden' ) ;
2018-05-18 03:25:45 +00:00
const tl = ptToScreen ( startbb . x , textbb . y ) ,
2018-05-18 04:02:30 +00:00
tr = ptToScreen ( startbb . x + ( endbb . x - startbb . x ) , textbb . y ) ,
bl = ptToScreen ( startbb . x , textbb . y + textbb . height ) ,
br = ptToScreen ( startbb . x + ( endbb . x - startbb . x ) , textbb . y + textbb . height ) ;
2018-05-18 03:25:45 +00:00
const dstr = 'M' + tl . x + ',' + tl . y +
2018-05-18 04:02:30 +00:00
' L' + tr . x + ',' + tr . y +
' ' + br . x + ',' + br . y +
' ' + bl . x + ',' + bl . y + 'z' ;
2018-05-18 03:25:45 +00:00
assignAttributes ( selblock , {
2018-05-18 04:02:30 +00:00
d : dstr ,
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
display : 'inline'
2018-05-18 04:02:30 +00:00
} ) ;
2018-05-17 05:15:20 +00:00
}
2010-04-30 15:06:47 +00:00
2018-05-17 05:15:20 +00:00
function getIndexFromPoint ( mouseX , mouseY ) {
2018-05-18 04:02:30 +00:00
// Position cursor here
2018-05-18 03:25:45 +00:00
const pt = svgroot . createSVGPoint ( ) ;
2018-05-18 04:02:30 +00:00
pt . x = mouseX ;
pt . y = mouseY ;
// No content, so return 0
if ( chardata . length === 1 ) { return 0 ; }
// Determine if cursor should be on left or right of character
2018-05-18 03:25:45 +00:00
let charpos = curtext . getCharNumAtPosition ( pt ) ;
2018-05-18 04:02:30 +00:00
if ( charpos < 0 ) {
// Out of text range, look at mouse coords
charpos = chardata . length - 2 ;
if ( mouseX <= chardata [ 0 ] . x ) {
charpos = 0 ;
}
} else if ( charpos >= chardata . length - 2 ) {
charpos = chardata . length - 2 ;
}
2018-05-18 03:25:45 +00:00
const charbb = chardata [ charpos ] ;
const mid = charbb . x + ( charbb . width / 2 ) ;
2018-05-18 04:02:30 +00:00
if ( mouseX > mid ) {
charpos ++ ;
}
return charpos ;
2018-05-17 05:15:20 +00:00
}
2018-05-16 00:53:27 +00:00
2018-05-17 05:15:20 +00:00
function setCursorFromPoint ( mouseX , mouseY ) {
2018-05-18 04:02:30 +00:00
setCursor ( getIndexFromPoint ( mouseX , mouseY ) ) ;
2018-05-17 05:15:20 +00:00
}
2018-05-16 00:53:27 +00:00
2018-05-17 05:15:20 +00:00
function setEndSelectionFromPoint ( x , y , apply ) {
2018-05-18 03:25:45 +00:00
const i1 = textinput . selectionStart ;
const i2 = getIndexFromPoint ( x , y ) ;
2018-05-16 00:53:27 +00:00
2018-05-18 03:25:45 +00:00
const start = Math . min ( i1 , i2 ) ;
const end = Math . max ( i1 , i2 ) ;
2018-05-18 04:02:30 +00:00
setSelection ( start , end , ! apply ) ;
2018-05-17 05:15:20 +00:00
}
2018-05-16 00:53:27 +00:00
2018-05-17 05:15:20 +00:00
function screenToPt ( xIn , yIn ) {
2018-05-18 03:25:45 +00:00
const out = {
2018-05-18 04:02:30 +00:00
x : xIn ,
y : yIn
} ;
2018-05-16 00:53:27 +00:00
2018-05-18 04:02:30 +00:00
out . x /= currentZoom ;
out . y /= currentZoom ;
2018-05-16 00:53:27 +00:00
2018-05-18 04:02:30 +00:00
if ( matrix ) {
2018-05-18 03:25:45 +00:00
const pt = transformPoint ( out . x , out . y , matrix . inverse ( ) ) ;
2018-05-18 04:02:30 +00:00
out . x = pt . x ;
out . y = pt . y ;
}
2010-04-13 15:28:52 +00:00
2018-05-18 04:02:30 +00:00
return out ;
2018-05-17 05:15:20 +00:00
}
2018-05-16 00:53:27 +00:00
2018-05-17 05:15:20 +00:00
function ptToScreen ( xIn , yIn ) {
2018-05-18 03:25:45 +00:00
const out = {
2018-05-18 04:02:30 +00:00
x : xIn ,
y : yIn
} ;
2018-05-16 00:53:27 +00:00
2018-05-18 04:02:30 +00:00
if ( matrix ) {
2018-05-18 03:25:45 +00:00
const pt = transformPoint ( out . x , out . y , matrix ) ;
2018-05-18 04:02:30 +00:00
out . x = pt . x ;
out . y = pt . y ;
}
2010-06-22 14:52:51 +00:00
2018-05-18 04:02:30 +00:00
out . x *= currentZoom ;
out . y *= currentZoom ;
2011-02-23 15:56:14 +00:00
2018-05-18 04:02:30 +00:00
return out ;
2018-05-17 05:15:20 +00:00
}
2018-05-16 00:53:27 +00:00
2018-05-17 05:15:20 +00:00
/ *
// Not currently in use
function hideCursor ( ) {
2018-05-18 04:02:30 +00:00
if ( cursor ) {
cursor . setAttribute ( 'visibility' , 'hidden' ) ;
}
2018-05-17 05:15:20 +00:00
}
* /
2010-09-28 16:57:26 +00:00
2018-05-17 05:15:20 +00:00
function selectAll ( evt ) {
2018-05-18 04:02:30 +00:00
setSelection ( 0 , curtext . textContent . length ) ;
$ ( this ) . unbind ( evt ) ;
2018-05-17 05:15:20 +00:00
}
2018-05-16 00:53:27 +00:00
2018-05-17 05:15:20 +00:00
function selectWord ( evt ) {
2018-05-18 04:02:30 +00:00
if ( ! allowDbl || ! curtext ) { return ; }
2018-05-18 03:25:45 +00:00
const ept = transformPoint ( evt . pageX , evt . pageY , rootSctm ) ,
2018-05-18 04:02:30 +00:00
mouseX = ept . x * currentZoom ,
mouseY = ept . y * currentZoom ;
2018-05-18 03:25:45 +00:00
const pt = screenToPt ( mouseX , mouseY ) ;
2018-05-18 04:02:30 +00:00
2018-05-18 03:25:45 +00:00
const index = getIndexFromPoint ( pt . x , pt . y ) ;
const str = curtext . textContent ;
const first = str . substr ( 0 , index ) . replace ( /[a-z0-9]+$/i , '' ) . length ;
const m = str . substr ( index ) . match ( /^[a-z0-9]+/i ) ;
const last = ( m ? m [ 0 ] . length : 0 ) + index ;
2018-05-18 04:02:30 +00:00
setSelection ( first , last ) ;
// Set tripleclick
$ ( evt . target ) . click ( selectAll ) ;
setTimeout ( function ( ) {
$ ( evt . target ) . unbind ( 'click' , selectAll ) ;
} , 300 ) ;
2018-05-17 05:15:20 +00:00
}
2018-05-16 00:53:27 +00:00
2018-05-17 05:15:20 +00:00
return {
2018-05-18 03:25:45 +00:00
select ( target , x , y ) {
2018-05-18 04:02:30 +00:00
curtext = target ;
textActions . toEditMode ( x , y ) ;
} ,
2018-05-18 03:25:45 +00:00
start ( elem ) {
2018-05-18 04:02:30 +00:00
curtext = elem ;
textActions . toEditMode ( ) ;
} ,
2018-05-18 03:25:45 +00:00
mouseDown ( evt , mouseTarget , startX , startY ) {
const pt = screenToPt ( startX , startY ) ;
2018-05-18 04:02:30 +00:00
textinput . focus ( ) ;
setCursorFromPoint ( pt . x , pt . y ) ;
lastX = startX ;
lastY = startY ;
// TODO: Find way to block native selection
} ,
2018-05-18 03:25:45 +00:00
mouseMove ( mouseX , mouseY ) {
const pt = screenToPt ( mouseX , mouseY ) ;
2018-05-18 04:02:30 +00:00
setEndSelectionFromPoint ( pt . x , pt . y ) ;
} ,
2018-05-18 03:25:45 +00:00
mouseUp ( evt , mouseX , mouseY ) {
const pt = screenToPt ( mouseX , mouseY ) ;
2018-05-18 04:02:30 +00:00
setEndSelectionFromPoint ( pt . x , pt . y , true ) ;
// TODO: Find a way to make this work: Use transformed BBox instead of evt.target
// if (lastX === mouseX && lastY === mouseY
2018-05-18 03:25:45 +00:00
// && !rectsIntersect(transbb, {x: pt.x, y: pt.y, width: 0, height: 0})) {
2018-05-18 06:41:43 +00:00
// textActions.toSelectMode(true);
2018-05-18 04:02:30 +00:00
// }
if (
evt . target !== curtext &&
mouseX < lastX + 2 &&
mouseX > lastX - 2 &&
mouseY < lastY + 2 &&
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
mouseY > lastY - 2
) {
textActions . toSelectMode ( true ) ;
2018-05-18 04:02:30 +00:00
}
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
} ,
setCursor ,
toEditMode ( x , y ) {
allowDbl = false ;
currentMode = 'textedit' ;
selectorManager . requestSelector ( curtext ) . showGrips ( false ) ;
// Make selector group accept clicks
/* const selector = */ selectorManager . requestSelector ( curtext ) ; // Do we need this? Has side effect of setting lock, so keeping for now, but next line wasn't being used
// const sel = selector.selectorRect;
2018-05-18 04:02:30 +00:00
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
textActions . init ( ) ;
2018-05-18 04:02:30 +00:00
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
$ ( curtext ) . css ( 'cursor' , 'text' ) ;
2018-05-18 04:02:30 +00:00
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
// if (supportsEditableText()) {
// curtext.setAttribute('editable', 'simple');
// return;
// }
2018-05-18 04:02:30 +00:00
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
if ( ! arguments . length ) {
setCursor ( ) ;
} else {
const pt = screenToPt ( x , y ) ;
setCursorFromPoint ( pt . x , pt . y ) ;
2018-05-18 04:02:30 +00:00
}
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
setTimeout ( function ( ) {
allowDbl = true ;
} , 300 ) ;
} ,
toSelectMode ( selectElem ) {
currentMode = 'select' ;
clearInterval ( blinker ) ;
blinker = null ;
if ( selblock ) { $ ( selblock ) . attr ( 'display' , 'none' ) ; }
if ( cursor ) { $ ( cursor ) . attr ( 'visibility' , 'hidden' ) ; }
$ ( curtext ) . css ( 'cursor' , 'move' ) ;
2018-05-18 04:02:30 +00:00
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
if ( selectElem ) {
clearSelection ( ) ;
$ ( curtext ) . css ( 'cursor' , 'move' ) ;
2018-05-18 04:02:30 +00:00
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
call ( 'selected' , [ curtext ] ) ;
addToSelection ( [ curtext ] , true ) ;
2018-05-18 04:02:30 +00:00
}
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
if ( curtext && ! curtext . textContent . length ) {
// No content, so delete
canvas . deleteSelectedElements ( ) ;
2018-05-18 04:02:30 +00:00
}
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
$ ( textinput ) . blur ( ) ;
2018-05-18 04:02:30 +00:00
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
curtext = false ;
2018-05-18 04:02:30 +00:00
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
// if (supportsEditableText()) {
// curtext.removeAttribute('editable');
// }
2018-05-18 04:02:30 +00:00
} ,
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
setInputElem ( elem ) {
textinput = elem ;
// $(textinput).blur(hideCursor);
} ,
clear ( ) {
if ( currentMode === 'textedit' ) {
textActions . toSelectMode ( ) ;
2018-05-18 04:02:30 +00:00
}
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
} ,
init ( inputElem ) {
if ( ! curtext ) { return ; }
let i , end ;
// if (supportsEditableText()) {
// curtext.select();
// return;
// }
2018-05-18 04:02:30 +00:00
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
if ( ! curtext . parentNode ) {
// Result of the ffClone, need to get correct element
curtext = selectedElements [ 0 ] ;
selectorManager . requestSelector ( curtext ) . showGrips ( false ) ;
}
2018-05-18 04:02:30 +00:00
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
const str = curtext . textContent ;
const len = str . length ;
2018-05-18 04:02:30 +00:00
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
const xform = curtext . getAttribute ( 'transform' ) ;
2018-05-18 04:02:30 +00:00
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
textbb = utilsGetBBox ( curtext ) ;
2018-05-18 04:02:30 +00:00
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
matrix = xform ? getMatrix ( curtext ) : null ;
2018-05-18 04:02:30 +00:00
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
chardata = [ ] ;
chardata . length = len ;
textinput . focus ( ) ;
2018-05-18 04:02:30 +00:00
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
$ ( curtext ) . unbind ( 'dblclick' , selectWord ) . dblclick ( selectWord ) ;
2018-05-18 04:02:30 +00:00
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
if ( ! len ) {
end = { x : textbb . x + ( textbb . width / 2 ) , width : 0 } ;
2018-05-18 04:02:30 +00:00
}
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
for ( i = 0 ; i < len ; i ++ ) {
const start = curtext . getStartPositionOfChar ( i ) ;
end = curtext . getEndPositionOfChar ( i ) ;
2018-05-18 04:02:30 +00:00
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
if ( ! supportsGoodTextCharPos ( ) ) {
const offset = canvas . contentW * currentZoom ;
start . x -= offset ;
end . x -= offset ;
2018-05-18 04:02:30 +00:00
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
start . x /= currentZoom ;
end . x /= currentZoom ;
2018-05-18 04:02:30 +00:00
}
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
// Get a "bbox" equivalent for each character. Uses the
// bbox data of the actual text for y, height purposes
// TODO: Decide if y, width and height are actually necessary
chardata [ i ] = {
x : start . x ,
y : textbb . y , // start.y?
width : end . x - start . x ,
height : textbb . height
} ;
2018-05-18 04:02:30 +00:00
}
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
// Add a last bbox for cursor at end of text
chardata . push ( {
x : end . x ,
width : 0
} ) ;
setSelection ( textinput . selectionStart , textinput . selectionEnd , true ) ;
}
2018-05-17 05:15:20 +00:00
} ;
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
} ( ) ) ;
2010-06-22 14:52:51 +00:00
// Group: Serialization
// Function: removeUnusedDefElems
// Looks at DOM elements inside the <defs> to see if they are referred to,
// removes them from the DOM if they are not.
2018-05-16 00:53:27 +00:00
//
2010-06-22 14:52:51 +00:00
// Returns:
// The amount of elements that were removed
2018-05-18 03:25:45 +00:00
const removeUnusedDefElems = this . removeUnusedDefElems = function ( ) {
const defs = svgcontent . getElementsByTagNameNS ( NS . SVG , 'defs' ) ;
2018-05-18 04:02:30 +00:00
if ( ! defs || ! defs . length ) { return 0 ; }
// if (!defs.firstChild) { return; }
2018-05-18 03:25:45 +00:00
const defelemUses = [ ] ;
let numRemoved = 0 ;
const attrs = [ 'fill' , 'stroke' , 'filter' , 'marker-start' , 'marker-mid' , 'marker-end' ] ;
const alen = attrs . length ;
2018-05-18 04:02:30 +00:00
2018-05-18 03:25:45 +00:00
const allEls = svgcontent . getElementsByTagNameNS ( NS . SVG , '*' ) ;
const allLen = allEls . length ;
2018-05-18 04:02:30 +00:00
2018-05-18 03:25:45 +00:00
let i , j ;
2018-05-18 04:02:30 +00:00
for ( i = 0 ; i < allLen ; i ++ ) {
2018-05-18 03:25:45 +00:00
const el = allEls [ i ] ;
2018-05-18 04:02:30 +00:00
for ( j = 0 ; j < alen ; j ++ ) {
2018-05-18 03:25:45 +00:00
const ref = getUrlFromAttr ( el . getAttribute ( attrs [ j ] ) ) ;
2018-05-18 04:02:30 +00:00
if ( ref ) {
defelemUses . push ( ref . substr ( 1 ) ) ;
}
}
// gradients can refer to other gradients
2018-05-18 03:25:45 +00:00
const href = getHref ( el ) ;
if ( href && href . startsWith ( '#' ) ) {
2018-05-18 04:02:30 +00:00
defelemUses . push ( href . substr ( 1 ) ) ;
}
}
2018-05-18 03:25:45 +00:00
const defelems = $ ( defs ) . find ( 'linearGradient, radialGradient, filter, marker, svg, symbol' ) ;
2018-05-18 04:02:30 +00:00
i = defelems . length ;
while ( i -- ) {
2018-05-18 03:25:45 +00:00
const defelem = defelems [ i ] ;
const { id } = defelem ;
if ( ! defelemUses . includes ( id ) ) {
2018-05-18 04:02:30 +00:00
// Not found, so remove (but remember)
removedElements [ id ] = defelem ;
defelem . parentNode . removeChild ( defelem ) ;
numRemoved ++ ;
}
}
return numRemoved ;
2013-02-15 15:51:58 +00:00
} ;
2010-06-22 14:52:51 +00:00
// Function: svgCanvasToString
2018-05-16 00:53:27 +00:00
// Main function to set up the SVG content for output
2010-06-22 14:52:51 +00:00
//
2018-05-16 00:53:27 +00:00
// Returns:
2010-06-22 14:52:51 +00:00
// String containing the SVG image for output
2018-05-16 08:32:44 +00:00
this . svgCanvasToString = function ( ) {
2018-05-18 04:02:30 +00:00
// keep calling it until there are none to remove
while ( removeUnusedDefElems ( ) > 0 ) { }
pathActions . clear ( true ) ;
// Keep SVG-Edit comment on top
$ . each ( svgcontent . childNodes , function ( i , node ) {
2018-05-18 03:25:45 +00:00
if ( i && node . nodeType === 8 && node . data . includes ( 'Created with' ) ) {
2018-05-18 04:02:30 +00:00
svgcontent . insertBefore ( node , svgcontent . firstChild ) ;
}
} ) ;
// Move out of in-group editing mode
if ( currentGroup ) {
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
draw . leaveContext ( ) ;
2018-05-18 04:02:30 +00:00
selectOnly ( [ currentGroup ] ) ;
}
2018-05-18 03:25:45 +00:00
const nakedSvgs = [ ] ;
2018-05-18 04:02:30 +00:00
// Unwrap gsvg if it has no special attributes (only id and style)
$ ( svgcontent ) . find ( 'g:data(gsvg)' ) . each ( function ( ) {
2018-05-18 03:25:45 +00:00
const attrs = this . attributes ;
let len = attrs . length ;
for ( let i = 0 ; i < len ; i ++ ) {
2018-05-18 04:02:30 +00:00
if ( attrs [ i ] . nodeName === 'id' || attrs [ i ] . nodeName === 'style' ) {
len -- ;
}
}
// No significant attributes, so ungroup
if ( len <= 0 ) {
2018-05-18 03:25:45 +00:00
const svg = this . firstChild ;
2018-05-18 04:02:30 +00:00
nakedSvgs . push ( svg ) ;
$ ( this ) . replaceWith ( svg ) ;
}
} ) ;
2018-05-18 03:25:45 +00:00
const output = this . svgToString ( svgcontent , 0 ) ;
2018-05-18 04:02:30 +00:00
// Rewrap gsvg
if ( nakedSvgs . length ) {
$ ( nakedSvgs ) . each ( function ( ) {
groupSvgElem ( this ) ;
} ) ;
}
return output ;
2010-11-07 05:20:03 +00:00
} ;
2010-06-22 14:52:51 +00:00
// Function: svgToString
// Sub function ran on each SVG element to convert it to a string as desired
2018-05-16 00:53:27 +00:00
//
// Parameters:
2010-06-22 14:52:51 +00:00
// elem - The SVG element to convert
// indent - Integer with the amount of spaces to indent this tag
//
2018-05-16 00:53:27 +00:00
// Returns:
2010-06-22 14:52:51 +00:00
// String with the given element as an SVG tag
2018-05-16 08:32:44 +00:00
this . svgToString = function ( elem , indent ) {
2018-05-18 03:25:45 +00:00
const out = [ ] ;
const unit = curConfig . baseUnit ;
const unitRe = new RegExp ( '^-?[\\d\\.]+' + unit + '$' ) ;
2018-05-18 04:02:30 +00:00
if ( elem ) {
cleanupElement ( elem ) ;
2018-05-18 03:25:45 +00:00
const attrs = elem . attributes ;
let attr , i ;
const childs = elem . childNodes ;
2018-05-18 04:02:30 +00:00
for ( i = 0 ; i < indent ; i ++ ) { out . push ( ' ' ) ; }
out . push ( '<' ) ; out . push ( elem . nodeName ) ;
if ( elem . id === 'svgcontent' ) {
// Process root element separately
2018-05-18 03:25:45 +00:00
const res = getResolution ( ) ;
2018-05-18 04:02:30 +00:00
2018-05-18 03:25:45 +00:00
const vb = '' ;
2018-05-18 04:02:30 +00:00
// TODO: Allow this by dividing all values by current baseVal
// Note that this also means we should properly deal with this on import
// if (curConfig.baseUnit !== 'px') {
2018-05-18 03:25:45 +00:00
// const unit = curConfig.baseUnit;
// const unitM = getTypeMap()[unit];
// res.w = shortFloat(res.w / unitM);
// res.h = shortFloat(res.h / unitM);
2018-05-18 06:41:43 +00:00
// vb = ' viewBox="' + [0, 0, res.w, res.h].join(' ') + '"';
// res.w += unit;
// res.h += unit;
2018-05-18 04:02:30 +00:00
// }
if ( unit !== 'px' ) {
2018-05-18 03:25:45 +00:00
res . w = convertUnit ( res . w , unit ) + unit ;
res . h = convertUnit ( res . h , unit ) + unit ;
2018-05-18 04:02:30 +00:00
}
out . push ( ' width="' + res . w + '" height="' + res . h + '"' + vb + ' xmlns="' + NS . SVG + '"' ) ;
2018-05-18 03:25:45 +00:00
const nsuris = { } ;
2018-05-18 04:02:30 +00:00
// Check elements for namespaces, add if found
$ ( elem ) . find ( '*' ) . andSelf ( ) . each ( function ( ) {
2018-05-18 03:25:45 +00:00
// const el = this;
2018-05-18 04:02:30 +00:00
// for some elements have no attribute
2018-05-18 03:25:45 +00:00
const uri = this . namespaceURI ;
2018-05-18 04:02:30 +00:00
if ( uri && ! nsuris [ uri ] && nsMap [ uri ] && nsMap [ uri ] !== 'xmlns' && nsMap [ uri ] !== 'xml' ) {
nsuris [ uri ] = true ;
out . push ( ' xmlns:' + nsMap [ uri ] + '="' + uri + '"' ) ;
}
$ . each ( this . attributes , function ( i , attr ) {
2018-05-18 03:25:45 +00:00
const uri = attr . namespaceURI ;
2018-05-18 04:02:30 +00:00
if ( uri && ! nsuris [ uri ] && nsMap [ uri ] !== 'xmlns' && nsMap [ uri ] !== 'xml' ) {
nsuris [ uri ] = true ;
out . push ( ' xmlns:' + nsMap [ uri ] + '="' + uri + '"' ) ;
}
} ) ;
} ) ;
i = attrs . length ;
2018-05-18 03:25:45 +00:00
const attrNames = [ 'width' , 'height' , 'xmlns' , 'x' , 'y' , 'viewBox' , 'id' , 'overflow' ] ;
2018-05-18 04:02:30 +00:00
while ( i -- ) {
attr = attrs . item ( i ) ;
2018-05-18 03:25:45 +00:00
const attrVal = toXml ( attr . value ) ;
2018-05-18 04:02:30 +00:00
// Namespaces have already been dealt with, so skip
2018-05-18 03:25:45 +00:00
if ( attr . nodeName . startsWith ( 'xmlns:' ) ) { continue ; }
2018-05-18 04:02:30 +00:00
// only serialize attributes we don't use internally
2018-05-18 03:25:45 +00:00
if ( attrVal !== '' && ! attrNames . includes ( attr . localName ) ) {
2018-05-18 04:02:30 +00:00
if ( ! attr . namespaceURI || nsMap [ attr . namespaceURI ] ) {
out . push ( ' ' ) ;
out . push ( attr . nodeName ) ; out . push ( '="' ) ;
out . push ( attrVal ) ; out . push ( '"' ) ;
}
}
}
} else {
// Skip empty defs
if ( elem . nodeName === 'defs' && ! elem . firstChild ) { return ; }
2018-05-18 03:25:45 +00:00
const mozAttrs = [ '-moz-math-font-style' , '_moz-math-font-style' ] ;
2018-05-18 04:02:30 +00:00
for ( i = attrs . length - 1 ; i >= 0 ; i -- ) {
attr = attrs . item ( i ) ;
2018-05-18 03:25:45 +00:00
let attrVal = toXml ( attr . value ) ;
2018-05-18 04:02:30 +00:00
// remove bogus attributes added by Gecko
2018-05-18 03:25:45 +00:00
if ( mozAttrs . includes ( attr . localName ) ) { continue ; }
2018-05-18 04:02:30 +00:00
if ( attrVal !== '' ) {
2018-05-18 03:25:45 +00:00
if ( attrVal . startsWith ( 'pointer-events' ) ) { continue ; }
if ( attr . localName === 'class' && attrVal . startsWith ( 'se_' ) ) { continue ; }
2018-05-18 04:02:30 +00:00
out . push ( ' ' ) ;
if ( attr . localName === 'd' ) { attrVal = pathActions . convertPath ( elem , true ) ; }
if ( ! isNaN ( attrVal ) ) {
2018-05-18 03:25:45 +00:00
attrVal = shortFloat ( attrVal ) ;
2018-05-18 04:02:30 +00:00
} else if ( unitRe . test ( attrVal ) ) {
2018-05-18 03:25:45 +00:00
attrVal = shortFloat ( attrVal ) + unit ;
2018-05-18 04:02:30 +00:00
}
// Embed images when saving
if ( saveOptions . apply &&
elem . nodeName === 'image' &&
attr . localName === 'href' &&
saveOptions . images &&
saveOptions . images === 'embed'
) {
2018-05-18 03:25:45 +00:00
const img = encodableImages [ attrVal ] ;
2018-05-18 04:02:30 +00:00
if ( img ) { attrVal = img ; }
}
// map various namespaces to our fixed namespace prefixes
// (the default xmlns attribute itself does not get a prefix)
if ( ! attr . namespaceURI || attr . namespaceURI === NS . SVG || nsMap [ attr . namespaceURI ] ) {
out . push ( attr . nodeName ) ; out . push ( '="' ) ;
out . push ( attrVal ) ; out . push ( '"' ) ;
}
}
}
}
if ( elem . hasChildNodes ( ) ) {
out . push ( '>' ) ;
indent ++ ;
2018-05-18 03:25:45 +00:00
let bOneLine = false ;
2018-05-18 04:02:30 +00:00
for ( i = 0 ; i < childs . length ; i ++ ) {
2018-05-18 03:25:45 +00:00
const child = childs . item ( i ) ;
2018-05-18 04:02:30 +00:00
switch ( child . nodeType ) {
case 1 : // element node
out . push ( '\n' ) ;
out . push ( this . svgToString ( childs . item ( i ) , indent ) ) ;
break ;
case 3 : // text node
2018-05-18 03:25:45 +00:00
const str = child . nodeValue . replace ( /^\s+|\s+$/g , '' ) ;
2018-05-18 04:02:30 +00:00
if ( str !== '' ) {
bOneLine = true ;
out . push ( String ( toXml ( str ) ) ) ;
}
break ;
case 4 : // cdata node
out . push ( '\n' ) ;
out . push ( new Array ( indent + 1 ) . join ( ' ' ) ) ;
out . push ( '<![CDATA[' ) ;
out . push ( child . nodeValue ) ;
out . push ( ']]>' ) ;
break ;
case 8 : // comment
out . push ( '\n' ) ;
out . push ( new Array ( indent + 1 ) . join ( ' ' ) ) ;
out . push ( '<!--' ) ;
out . push ( child . data ) ;
out . push ( '-->' ) ;
break ;
} // switch on node type
}
indent -- ;
if ( ! bOneLine ) {
out . push ( '\n' ) ;
for ( i = 0 ; i < indent ; i ++ ) { out . push ( ' ' ) ; }
}
out . push ( '</' ) ; out . push ( elem . nodeName ) ; out . push ( '>' ) ;
} else {
out . push ( '/>' ) ;
}
}
return out . join ( '' ) ;
2010-06-22 14:52:51 +00:00
} ; // end svgToString()
2009-12-30 18:06:29 +00:00
2010-06-22 14:52:51 +00:00
// Function: embedImage
// Converts a given image file to a data URL when possible, then runs a given callback
//
2018-05-16 00:53:27 +00:00
// Parameters:
2010-06-22 14:52:51 +00:00
// val - String with the path/URL of the image
// callback - Optional function to run when image data is found, supplies the
// result (data URL or false) as first parameter.
2018-05-16 08:32:44 +00:00
this . embedImage = function ( val , callback ) {
2018-05-18 04:02:30 +00:00
// load in the image and once it's loaded, get the dimensions
$ ( new Image ( ) ) . load ( function ( ) {
// create a canvas the same size as the raster image
2018-05-18 03:25:45 +00:00
const canvas = document . createElement ( 'canvas' ) ;
2018-05-18 04:02:30 +00:00
canvas . width = this . width ;
canvas . height = this . height ;
// load the raster image into the canvas
canvas . getContext ( '2d' ) . drawImage ( this , 0 , 0 ) ;
// retrieve the data: URL
try {
2018-05-18 03:25:45 +00:00
let urldata = ';svgedit_url=' + encodeURIComponent ( val ) ;
2018-05-18 04:02:30 +00:00
urldata = canvas . toDataURL ( ) . replace ( ';base64' , urldata + ';base64' ) ;
encodableImages [ val ] = urldata ;
} catch ( e ) {
encodableImages [ val ] = false ;
}
lastGoodImgUrl = val ;
if ( callback ) { callback ( encodableImages [ val ] ) ; }
} ) . attr ( 'src' , val ) ;
2013-02-15 15:51:58 +00:00
} ;
2009-06-01 21:24:30 +00:00
2010-07-05 15:38:06 +00:00
// Function: setGoodImage
// Sets a given URL to be a "last good image" URL
2018-05-16 08:32:44 +00:00
this . setGoodImage = function ( val ) {
2018-05-18 04:02:30 +00:00
lastGoodImgUrl = val ;
2013-02-15 15:51:58 +00:00
} ;
2009-06-01 21:24:30 +00:00
2018-05-16 08:32:44 +00:00
this . open = function ( ) {
2018-05-18 04:02:30 +00:00
// Nothing by default, handled by optional widget/extension
2010-06-22 14:52:51 +00:00
} ;
2009-10-13 02:48:27 +00:00
2010-06-22 14:52:51 +00:00
// Function: save
// Serializes the current drawing into SVG XML text and returns it to the 'saved' handler.
2014-01-31 10:40:52 +00:00
// This function also includes the XML prolog. Clients of the SvgCanvas bind their save
2010-06-22 14:52:51 +00:00
// function to the 'saved' event.
//
2018-05-16 00:53:27 +00:00
// Returns:
2010-06-22 14:52:51 +00:00
// Nothing
2018-05-16 08:32:44 +00:00
this . save = function ( opts ) {
2018-05-18 04:02:30 +00:00
// remove the selected outline before serializing
clearSelection ( ) ;
// Update save options if provided
if ( opts ) { $ . extend ( saveOptions , opts ) ; }
saveOptions . apply = true ;
2018-05-16 00:53:27 +00:00
2018-05-18 04:40:50 +00:00
// no need for doctype, see https://jwatt.org/svg/authoring/#doctype-declaration
2018-05-18 03:25:45 +00:00
const str = this . svgCanvasToString ( ) ;
2018-05-18 04:02:30 +00:00
call ( 'saved' , str ) ;
2010-06-22 14:52:51 +00:00
} ;
2009-08-19 03:42:27 +00:00
2018-05-18 03:25:45 +00:00
/ * *
* Codes only is useful for locale - independent detection
* /
function getIssues ( { codesOnly = false } = { } ) {
2018-05-18 04:02:30 +00:00
// remove the selected outline before serializing
clearSelection ( ) ;
// Check for known CanVG issues
2018-05-18 03:25:45 +00:00
const issues = [ ] ;
2018-05-18 04:02:30 +00:00
// Selector and notice
2018-05-18 03:25:45 +00:00
const issueList = {
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
feGaussianBlur : uiStrings . exportNoBlur ,
foreignObject : uiStrings . exportNoforeignObject ,
2018-05-18 04:02:30 +00:00
'[stroke-dasharray]' : uiStrings . exportNoDashArray
} ;
2018-05-18 03:25:45 +00:00
const content = $ ( svgcontent ) ;
2018-05-18 04:02:30 +00:00
// Add font/text check if Canvas Text API is not implemented
if ( ! ( 'font' in $ ( '<canvas>' ) [ 0 ] . getContext ( '2d' ) ) ) {
issueList . text = uiStrings . exportNoText ;
}
$ . each ( issueList , function ( sel , descr ) {
if ( content . find ( sel ) . length ) {
2018-05-18 03:25:45 +00:00
issues . push ( codesOnly ? sel : descr ) ;
2018-05-18 04:02:30 +00:00
}
} ) ;
return issues ;
2014-05-22 10:21:29 +00:00
}
2010-04-14 17:30:25 +00:00
2014-05-22 10:21:29 +00:00
// Function: rasterExport
2018-05-16 00:53:27 +00:00
// Generates a Data URL based on the current image, then calls "exported"
2014-05-22 10:21:29 +00:00
// with an object including the string, image information, and any issues found
2018-05-16 08:32:44 +00:00
this . rasterExport = function ( imgType , quality , exportWindowName ) {
2018-05-18 03:25:45 +00:00
const mimeType = 'image/' + imgType . toLowerCase ( ) ;
const issues = getIssues ( ) ;
const issueCodes = getIssues ( { codesOnly : true } ) ;
const str = this . svgCanvasToString ( ) ;
2018-05-18 04:02:30 +00:00
2018-05-18 03:25:45 +00:00
buildCanvgCallback ( function ( ) {
const type = imgType || 'PNG' ;
2018-05-18 04:02:30 +00:00
if ( ! $ ( '#export_canvas' ) . length ) {
$ ( '<canvas>' , { id : 'export_canvas' } ) . hide ( ) . appendTo ( 'body' ) ;
}
2018-05-18 03:25:45 +00:00
const c = $ ( '#export_canvas' ) [ 0 ] ;
c . width = canvas . contentW ;
c . height = canvas . contentH ;
2018-05-18 04:02:30 +00:00
2018-05-18 03:25:45 +00:00
canvg ( c , str , { renderCallback ( ) {
const dataURLType = ( type === 'ICO' ? 'BMP' : type ) . toLowerCase ( ) ;
const datauri = quality ? c . toDataURL ( 'image/' + dataURLType , quality ) : c . toDataURL ( 'image/' + dataURLType ) ;
2018-05-18 04:02:30 +00:00
if ( c . toBlob ) {
c . toBlob ( function ( blob ) {
2018-05-18 03:25:45 +00:00
const bloburl = createObjectURL ( blob ) ;
call ( 'exported' , { datauri , bloburl , svg : str , issues , issueCodes , type : imgType , mimeType , quality , exportWindowName } ) ;
2018-05-18 04:02:30 +00:00
} , mimeType , quality ) ;
return ;
}
2018-05-18 03:25:45 +00:00
const bloburl = dataURLToObjectURL ( datauri ) ;
call ( 'exported' , { datauri , bloburl , svg : str , issues , issueCodes , type : imgType , mimeType , quality , exportWindowName } ) ;
2018-05-18 04:02:30 +00:00
} } ) ;
} ) ( ) ;
2010-06-22 14:52:51 +00:00
} ;
2014-05-22 10:21:29 +00:00
this . exportPDF = function ( exportWindowName , outputType ) {
2018-05-18 03:25:45 +00:00
const that = this ;
buildJSPDFCallback ( function ( ) {
const res = getResolution ( ) ;
const orientation = res . w > res . h ? 'landscape' : 'portrait' ;
const unit = 'pt' ; // curConfig.baseUnit; // We could use baseUnit, but that is presumably not intended for export purposes
const doc = jsPDF ( {
orientation ,
unit ,
2018-05-18 04:02:30 +00:00
format : [ res . w , res . h ]
// , compressPdf: true
} ) ; // Todo: Give options to use predefined jsPDF formats like "a4", etc. from pull-down (with option to keep customizable)
2018-05-18 03:25:45 +00:00
const docTitle = getDocumentTitle ( ) ;
2018-05-18 04:02:30 +00:00
doc . setProperties ( {
title : docTitle / * ,
subject : '' ,
author : '' ,
keywords : '' ,
creator : '' * /
} ) ;
2018-05-18 03:25:45 +00:00
const issues = getIssues ( ) ;
const issueCodes = getIssues ( { codesOnly : true } ) ;
const str = that . svgCanvasToString ( ) ;
2018-05-18 04:02:30 +00:00
doc . addSVG ( str , 0 , 0 ) ;
// doc.output('save'); // Works to open in a new
// window; todo: configure this and other export
// options to optionally work in this manner as
// opposed to opening a new tab
2018-05-18 03:25:45 +00:00
const obj = { svg : str , issues , issueCodes , exportWindowName } ;
const method = outputType || 'dataurlstring' ;
2018-05-18 04:02:30 +00:00
obj [ method ] = doc . output ( method ) ;
call ( 'exportedPDF' , obj ) ;
} ) ( ) ;
2014-05-22 10:21:29 +00:00
} ;
2010-06-22 14:52:51 +00:00
// Function: getSvgString
// Returns the current drawing as raw SVG XML text.
//
// Returns:
// The current drawing as raw SVG XML text.
2018-05-16 08:32:44 +00:00
this . getSvgString = function ( ) {
2018-05-18 04:02:30 +00:00
saveOptions . apply = false ;
return this . svgCanvasToString ( ) ;
2010-06-22 14:52:51 +00:00
} ;
2011-02-01 07:22:18 +00:00
// Function: randomizeIds
// This function determines whether to use a nonce in the prefix, when
// generating IDs for future documents in SVG-Edit.
2018-05-16 00:53:27 +00:00
//
2014-01-31 10:40:52 +00:00
// Parameters:
// an optional boolean, which, if true, adds a nonce to the prefix. Thus
// svgCanvas.randomizeIds() <==> svgCanvas.randomizeIds(true)
2010-06-22 14:52:51 +00:00
//
// if you're controlling SVG-Edit externally, and want randomized IDs, call
// this BEFORE calling svgCanvas.setSvgString
//
2018-05-16 08:32:44 +00:00
this . randomizeIds = function ( enableRandomization ) {
2018-05-18 04:02:30 +00:00
if ( arguments . length > 0 && enableRandomization === false ) {
2018-05-18 03:25:45 +00:00
draw . randomizeIds ( false , getCurrentDrawing ( ) ) ;
2018-05-18 04:02:30 +00:00
} else {
2018-05-18 03:25:45 +00:00
draw . randomizeIds ( true , getCurrentDrawing ( ) ) ;
2018-05-18 04:02:30 +00:00
}
2011-02-01 07:22:18 +00:00
} ;
2010-06-22 14:52:51 +00:00
2010-07-16 15:46:54 +00:00
// Function: uniquifyElems
// Ensure each element has a unique ID
//
// Parameters:
// g - The parent element of the tree to give unique IDs
2018-05-18 03:25:45 +00:00
const uniquifyElems = this . uniquifyElems = function ( g ) {
const ids = { } ;
2018-05-18 04:02:30 +00:00
// TODO: Handle markers and connectors. These are not yet re-identified properly
// as their referring elements do not get remapped.
//
// <marker id='se_marker_end_svg_7'/>
// <polyline id='svg_7' se:connector='svg_1 svg_6' marker-end='url(#se_marker_end_svg_7)'/>
//
// Problem #1: if svg_1 gets renamed, we do not update the polyline's se:connector attribute
// Problem #2: if the polyline svg_7 gets renamed, we do not update the marker id nor the polyline's marker-end attribute
2018-05-18 03:25:45 +00:00
const refElems = [ 'filter' , 'linearGradient' , 'pattern' , 'radialGradient' , 'symbol' , 'textPath' , 'use' ] ;
2018-05-18 04:02:30 +00:00
2018-05-18 03:25:45 +00:00
walkTree ( g , function ( n ) {
2018-05-18 04:02:30 +00:00
// if it's an element node
if ( n . nodeType === 1 ) {
// and the element has an ID
if ( n . id ) {
// and we haven't tracked this ID yet
if ( ! ( n . id in ids ) ) {
// add this id to our map
ids [ n . id ] = { elem : null , attrs : [ ] , hrefs : [ ] } ;
}
ids [ n . id ] . elem = n ;
}
// now search for all attributes on this element that might refer
// to other elements
$ . each ( refAttrs , function ( i , attr ) {
2018-05-18 03:25:45 +00:00
const attrnode = n . getAttributeNode ( attr ) ;
2018-05-18 04:02:30 +00:00
if ( attrnode ) {
// the incoming file has been sanitized, so we should be able to safely just strip off the leading #
2018-05-18 03:25:45 +00:00
const url = getUrlFromAttr ( attrnode . value ) ,
2018-05-18 04:02:30 +00:00
refid = url ? url . substr ( 1 ) : null ;
if ( refid ) {
if ( ! ( refid in ids ) ) {
// add this id to our map
ids [ refid ] = { elem : null , attrs : [ ] , hrefs : [ ] } ;
}
ids [ refid ] . attrs . push ( attrnode ) ;
}
}
} ) ;
// check xlink:href now
2018-05-18 03:25:45 +00:00
const href = getHref ( n ) ;
2018-05-18 04:02:30 +00:00
// TODO: what if an <image> or <a> element refers to an element internally?
2018-05-18 03:25:45 +00:00
if ( href && refElems . includes ( n . nodeName ) ) {
const refid = href . substr ( 1 ) ;
2018-05-18 04:02:30 +00:00
if ( refid ) {
if ( ! ( refid in ids ) ) {
// add this id to our map
ids [ refid ] = { elem : null , attrs : [ ] , hrefs : [ ] } ;
}
ids [ refid ] . hrefs . push ( n ) ;
}
}
}
} ) ;
// in ids, we now have a map of ids, elements and attributes, let's re-identify
2018-05-18 03:25:45 +00:00
for ( const oldid in ids ) {
2018-05-18 04:02:30 +00:00
if ( ! oldid ) { continue ; }
2018-05-18 03:25:45 +00:00
const { elem } = ids [ oldid ] ;
2018-05-18 04:02:30 +00:00
if ( elem ) {
2018-05-18 03:25:45 +00:00
const newid = getNextId ( ) ;
2018-05-18 04:02:30 +00:00
// assign element its new id
elem . id = newid ;
// remap all url() attributes
2018-05-18 03:25:45 +00:00
const { attrs } = ids [ oldid ] ;
let j = attrs . length ;
2018-05-18 04:02:30 +00:00
while ( j -- ) {
2018-05-18 03:25:45 +00:00
const attr = attrs [ j ] ;
2018-05-18 04:02:30 +00:00
attr . ownerElement . setAttribute ( attr . name , 'url(#' + newid + ')' ) ;
}
// remap all href attributes
2018-05-18 03:25:45 +00:00
const hreffers = ids [ oldid ] . hrefs ;
let k = hreffers . length ;
2018-05-18 04:02:30 +00:00
while ( k -- ) {
2018-05-18 03:25:45 +00:00
const hreffer = hreffers [ k ] ;
setHref ( hreffer , '#' + newid ) ;
2018-05-18 04:02:30 +00:00
}
}
}
2013-02-15 15:51:58 +00:00
} ;
2010-07-16 15:46:54 +00:00
2011-01-31 18:22:04 +00:00
// Function setUseData
// Assigns reference data for each use element
2018-05-18 03:25:45 +00:00
const setUseData = this . setUseData = function ( parent ) {
let elems = $ ( parent ) ;
2018-05-16 00:53:27 +00:00
2018-05-18 04:02:30 +00:00
if ( parent . tagName !== 'use' ) {
elems = elems . find ( 'use' ) ;
}
2018-05-16 00:53:27 +00:00
2018-05-18 04:02:30 +00:00
elems . each ( function ( ) {
2018-05-18 03:25:45 +00:00
const id = getHref ( this ) . substr ( 1 ) ;
const refElem = getElem ( id ) ;
2018-05-18 04:02:30 +00:00
if ( ! refElem ) { return ; }
$ ( this ) . data ( 'ref' , refElem ) ;
if ( refElem . tagName === 'symbol' || refElem . tagName === 'svg' ) {
$ ( this ) . data ( 'symbol' , refElem ) . data ( 'ref' , refElem ) ;
}
} ) ;
2013-02-15 15:51:58 +00:00
} ;
2011-01-31 18:22:04 +00:00
2010-09-28 18:59:31 +00:00
// Function convertGradients
// Converts gradients from userSpaceOnUse to objectBoundingBox
2018-05-18 03:25:45 +00:00
const convertGradients = this . convertGradients = function ( elem ) {
let elems = $ ( elem ) . find ( 'linearGradient, radialGradient' ) ;
if ( ! elems . length && isWebkit ( ) ) {
2018-05-18 04:02:30 +00:00
// Bug in webkit prevents regular *Gradient selector search
elems = $ ( elem ) . find ( '*' ) . filter ( function ( ) {
2018-05-18 03:25:45 +00:00
return ( this . tagName . includes ( 'Gradient' ) ) ;
2018-05-18 04:02:30 +00:00
} ) ;
}
elems . each ( function ( ) {
2018-05-18 03:25:45 +00:00
const grad = this ;
2018-05-18 04:02:30 +00:00
if ( $ ( grad ) . attr ( 'gradientUnits' ) === 'userSpaceOnUse' ) {
// TODO: Support more than one element with this ref by duplicating parent grad
2018-05-18 03:25:45 +00:00
const elems = $ ( svgcontent ) . find ( '[fill="url(#' + grad . id + ')"],[stroke="url(#' + grad . id + ')"]' ) ;
2018-05-18 04:02:30 +00:00
if ( ! elems . length ) { return ; }
// get object's bounding box
2018-05-18 03:25:45 +00:00
const bb = utilsGetBBox ( elems [ 0 ] ) ;
2018-05-18 04:02:30 +00:00
// This will occur if the element is inside a <defs> or a <symbol>,
// in which we shouldn't need to convert anyway.
if ( ! bb ) { return ; }
if ( grad . tagName === 'linearGradient' ) {
2018-05-18 03:25:45 +00:00
const gCoords = $ ( grad ) . attr ( [ 'x1' , 'y1' , 'x2' , 'y2' ] ) ;
2018-05-18 04:02:30 +00:00
// If has transform, convert
2018-05-18 03:25:45 +00:00
const tlist = grad . gradientTransform . baseVal ;
2018-05-18 04:02:30 +00:00
if ( tlist && tlist . numberOfItems > 0 ) {
2018-05-18 03:25:45 +00:00
const m = transformListToTransform ( tlist ) . matrix ;
const pt1 = transformPoint ( gCoords . x1 , gCoords . y1 , m ) ;
const pt2 = transformPoint ( gCoords . x2 , gCoords . y2 , m ) ;
2018-05-18 04:02:30 +00:00
gCoords . x1 = pt1 . x ;
gCoords . y1 = pt1 . y ;
gCoords . x2 = pt2 . x ;
gCoords . y2 = pt2 . y ;
grad . removeAttribute ( 'gradientTransform' ) ;
}
$ ( grad ) . attr ( {
x1 : ( gCoords . x1 - bb . x ) / bb . width ,
y1 : ( gCoords . y1 - bb . y ) / bb . height ,
x2 : ( gCoords . x2 - bb . x ) / bb . width ,
y2 : ( gCoords . y2 - bb . y ) / bb . height
} ) ;
grad . removeAttribute ( 'gradientUnits' ) ;
}
// else {
2018-05-18 06:41:43 +00:00
// Note: radialGradient elements cannot be easily converted
// because userSpaceOnUse will keep circular gradients, while
// objectBoundingBox will x/y scale the gradient according to
// its bbox.
2018-05-18 04:02:30 +00:00
//
2018-05-18 06:41:43 +00:00
// For now we'll do nothing, though we should probably have
// the gradient be updated as the element is moved, as
// inkscape/illustrator do.
2018-05-18 04:02:30 +00:00
//
2018-05-18 03:25:45 +00:00
// const gCoords = $(grad).attr(['cx', 'cy', 'r']);
2018-05-18 04:02:30 +00:00
//
2018-05-18 06:41:43 +00:00
// $(grad).attr({
// cx: (gCoords.cx - bb.x) / bb.width,
// cy: (gCoords.cy - bb.y) / bb.height,
// r: gCoords.r
// });
2018-05-18 04:02:30 +00:00
//
2018-05-18 06:41:43 +00:00
// grad.removeAttribute('gradientUnits');
2018-05-18 04:02:30 +00:00
// }
}
} ) ;
2013-02-15 15:51:58 +00:00
} ;
2010-09-28 18:59:31 +00:00
2010-07-29 15:09:49 +00:00
// Function: convertToGroup
// Converts selected/given <use> or child SVG element to a group
2018-05-18 03:25:45 +00:00
const convertToGroup = this . convertToGroup = function ( elem ) {
2018-05-18 04:02:30 +00:00
if ( ! elem ) {
elem = selectedElements [ 0 ] ;
}
2018-05-18 03:25:45 +00:00
const $elem = $ ( elem ) ;
const batchCmd = new BatchCommand ( ) ;
let ts ;
2018-05-18 04:02:30 +00:00
if ( $elem . data ( 'gsvg' ) ) {
// Use the gsvg as the new group
2018-05-18 03:25:45 +00:00
const svg = elem . firstChild ;
const pt = $ ( svg ) . attr ( [ 'x' , 'y' ] ) ;
2018-05-18 04:02:30 +00:00
$ ( elem . firstChild . firstChild ) . unwrap ( ) ;
$ ( elem ) . removeData ( 'gsvg' ) ;
2018-05-18 03:25:45 +00:00
const tlist = getTransformList ( elem ) ;
const xform = svgroot . createSVGTransform ( ) ;
2018-05-18 04:02:30 +00:00
xform . setTranslate ( pt . x , pt . y ) ;
tlist . appendItem ( xform ) ;
2018-05-18 03:25:45 +00:00
recalculateDimensions ( elem ) ;
2018-05-18 04:02:30 +00:00
call ( 'selected' , [ elem ] ) ;
} else if ( $elem . data ( 'symbol' ) ) {
elem = $elem . data ( 'symbol' ) ;
ts = $elem . attr ( 'transform' ) ;
2018-05-18 03:25:45 +00:00
const pos = $elem . attr ( [ 'x' , 'y' ] ) ;
2018-05-18 04:02:30 +00:00
2018-05-18 03:25:45 +00:00
const vb = elem . getAttribute ( 'viewBox' ) ;
2018-05-18 04:02:30 +00:00
if ( vb ) {
2018-05-18 03:25:45 +00:00
const nums = vb . split ( ' ' ) ;
2018-05-18 04:02:30 +00:00
pos . x -= + nums [ 0 ] ;
pos . y -= + nums [ 1 ] ;
}
// Not ideal, but works
ts += ' translate(' + ( pos . x || 0 ) + ',' + ( pos . y || 0 ) + ')' ;
2018-05-18 03:25:45 +00:00
const prev = $elem . prev ( ) ;
2018-05-18 04:02:30 +00:00
// Remove <use> element
2018-05-18 03:25:45 +00:00
batchCmd . addSubCommand ( new RemoveElementCommand ( $elem [ 0 ] , $elem [ 0 ] . nextSibling , $elem [ 0 ] . parentNode ) ) ;
2018-05-18 04:02:30 +00:00
$elem . remove ( ) ;
// See if other elements reference this symbol
2018-05-18 03:25:45 +00:00
const hasMore = $ ( svgcontent ) . find ( 'use:data(symbol)' ) . length ;
2018-05-18 04:02:30 +00:00
2018-05-18 03:25:45 +00:00
const g = svgdoc . createElementNS ( NS . SVG , 'g' ) ;
const childs = elem . childNodes ;
2018-05-18 04:02:30 +00:00
2018-05-18 03:25:45 +00:00
let i ;
2018-05-18 04:02:30 +00:00
for ( i = 0 ; i < childs . length ; i ++ ) {
g . appendChild ( childs [ i ] . cloneNode ( true ) ) ;
}
// Duplicate the gradients for Gecko, since they weren't included in the <symbol>
2018-05-18 03:25:45 +00:00
if ( isGecko ( ) ) {
const dupeGrads = $ ( findDefs ( ) ) . children ( 'linearGradient,radialGradient,pattern' ) . clone ( ) ;
2018-05-18 04:02:30 +00:00
$ ( g ) . append ( dupeGrads ) ;
}
if ( ts ) {
g . setAttribute ( 'transform' , ts ) ;
}
2018-05-18 03:25:45 +00:00
const parent = elem . parentNode ;
2018-05-18 04:02:30 +00:00
uniquifyElems ( g ) ;
// Put the dupe gradients back into <defs> (after uniquifying them)
2018-05-18 03:25:45 +00:00
if ( isGecko ( ) ) {
2018-05-18 04:02:30 +00:00
$ ( findDefs ( ) ) . append ( $ ( g ) . find ( 'linearGradient,radialGradient,pattern' ) ) ;
}
// now give the g itself a new id
g . id = getNextId ( ) ;
prev . after ( g ) ;
if ( parent ) {
if ( ! hasMore ) {
// remove symbol/svg element
2018-05-18 03:25:45 +00:00
const { nextSibling } = elem ;
2018-05-18 04:02:30 +00:00
parent . removeChild ( elem ) ;
2018-05-18 03:25:45 +00:00
batchCmd . addSubCommand ( new RemoveElementCommand ( elem , nextSibling , parent ) ) ;
2018-05-18 04:02:30 +00:00
}
2018-05-18 03:25:45 +00:00
batchCmd . addSubCommand ( new InsertElementCommand ( g ) ) ;
2018-05-18 04:02:30 +00:00
}
setUseData ( g ) ;
2018-05-18 03:25:45 +00:00
if ( isGecko ( ) ) {
convertGradients ( findDefs ( ) ) ;
2018-05-18 04:02:30 +00:00
} else {
convertGradients ( g ) ;
}
// recalculate dimensions on the top-level children so that unnecessary transforms
// are removed
2018-05-18 03:25:45 +00:00
walkTreePost ( g , function ( n ) {
2018-05-18 04:02:30 +00:00
try {
2018-05-18 03:25:45 +00:00
recalculateDimensions ( n ) ;
2018-05-18 04:02:30 +00:00
} catch ( e ) {
console . log ( e ) ;
}
} ) ;
2018-05-16 00:53:27 +00:00
2018-05-18 04:02:30 +00:00
// Give ID for any visible element missing one
$ ( g ) . find ( visElems ) . each ( function ( ) {
if ( ! this . id ) { this . id = getNextId ( ) ; }
} ) ;
2018-05-16 00:53:27 +00:00
2018-05-18 04:02:30 +00:00
selectOnly ( [ g ] ) ;
2018-05-18 03:25:45 +00:00
const cm = pushGroupProperties ( g , true ) ;
2018-05-18 04:02:30 +00:00
if ( cm ) {
batchCmd . addSubCommand ( cm ) ;
}
2011-02-02 18:24:44 +00:00
2018-05-18 04:02:30 +00:00
addCommandToHistory ( batchCmd ) ;
} else {
console . log ( 'Unexpected element to ungroup:' , elem ) ;
}
2013-02-15 15:51:58 +00:00
} ;
2010-07-22 19:10:51 +00:00
2018-05-28 12:42:37 +00:00
/ * *
* This function sets the current drawing as the input SVG XML .
* @ param { String } xmlString - The SVG as XML text .
* @ param { Boolean } [ preventUndo = false ] - Indicates if we want to do the
* changes without adding them to the undo stack - e . g . for initializing a
* drawing on page load .
* @ returns { Boolean } This function returns false if the set was
* unsuccessful , true otherwise .
* /
2018-05-16 08:32:44 +00:00
this . setSvgString = function ( xmlString , preventUndo ) {
2018-05-18 04:02:30 +00:00
try {
// convert string into XML document
2018-05-18 03:25:45 +00:00
const newDoc = text2xml ( xmlString ) ;
2018-05-28 12:42:37 +00:00
if ( newDoc . firstElementChild &&
newDoc . firstElementChild . namespaceURI !== NS . SVG ) {
return false ;
}
2018-05-18 04:02:30 +00:00
this . prepareSvg ( newDoc ) ;
2018-05-18 03:25:45 +00:00
const batchCmd = new BatchCommand ( 'Change Source' ) ;
2018-05-18 04:02:30 +00:00
// remove old svg document
2018-05-18 03:25:45 +00:00
const { nextSibling } = svgcontent ;
const oldzoom = svgroot . removeChild ( svgcontent ) ;
batchCmd . addSubCommand ( new RemoveElementCommand ( oldzoom , nextSibling , svgroot ) ) ;
2018-05-18 04:02:30 +00:00
// set new svg document
// If DOM3 adoptNode() available, use it. Otherwise fall back to DOM2 importNode()
if ( svgdoc . adoptNode ) {
svgcontent = svgdoc . adoptNode ( newDoc . documentElement ) ;
} else {
svgcontent = svgdoc . importNode ( newDoc . documentElement , true ) ;
}
svgroot . appendChild ( svgcontent ) ;
2018-05-18 03:25:45 +00:00
const content = $ ( svgcontent ) ;
2018-05-18 04:02:30 +00:00
2018-05-18 03:25:45 +00:00
canvas . current _drawing _ = new draw . Drawing ( svgcontent , idprefix ) ;
2018-05-18 04:02:30 +00:00
// retrieve or set the nonce
2018-05-18 03:25:45 +00:00
const nonce = getCurrentDrawing ( ) . getNonce ( ) ;
2018-05-18 04:02:30 +00:00
if ( nonce ) {
call ( 'setnonce' , nonce ) ;
} else {
call ( 'unsetnonce' ) ;
}
// change image href vals if possible
content . find ( 'image' ) . each ( function ( ) {
2018-05-18 03:25:45 +00:00
const image = this ;
preventClickDefault ( image ) ;
const val = getHref ( this ) ;
2018-05-18 04:02:30 +00:00
if ( val ) {
2018-05-18 03:25:45 +00:00
if ( val . startsWith ( 'data:' ) ) {
2018-05-18 04:02:30 +00:00
// Check if an SVG-edit data URI
2018-05-18 03:25:45 +00:00
const m = val . match ( /svgedit_url=(.*?);/ ) ;
2018-05-18 04:02:30 +00:00
if ( m ) {
2018-05-18 03:25:45 +00:00
const url = decodeURIComponent ( m [ 1 ] ) ;
2018-05-18 04:02:30 +00:00
$ ( new Image ( ) ) . load ( function ( ) {
image . setAttributeNS ( NS . XLINK , 'xlink:href' , url ) ;
} ) . attr ( 'src' , url ) ;
}
}
// Add to encodableImages if it loads
canvas . embedImage ( val ) ;
}
} ) ;
// Wrap child SVGs in group elements
content . find ( 'svg' ) . each ( function ( ) {
// Skip if it's in a <defs>
if ( $ ( this ) . closest ( 'defs' ) . length ) { return ; }
uniquifyElems ( this ) ;
// Check if it already has a gsvg group
2018-05-18 03:25:45 +00:00
const pa = this . parentNode ;
2018-05-18 04:02:30 +00:00
if ( pa . childNodes . length === 1 && pa . nodeName === 'g' ) {
$ ( pa ) . data ( 'gsvg' , this ) ;
pa . id = pa . id || getNextId ( ) ;
} else {
groupSvgElem ( this ) ;
}
} ) ;
// For Firefox: Put all paint elems in defs
2018-05-18 03:25:45 +00:00
if ( isGecko ( ) ) {
content . find ( 'linearGradient, radialGradient, pattern' ) . appendTo ( findDefs ( ) ) ;
2018-05-18 04:02:30 +00:00
}
// Set ref element for <use> elements
// TODO: This should also be done if the object is re-added through "redo"
setUseData ( content ) ;
convertGradients ( content [ 0 ] ) ;
2018-05-18 03:25:45 +00:00
const attrs = {
2018-05-18 04:02:30 +00:00
id : 'svgcontent' ,
overflow : curConfig . show _outside _canvas ? 'visible' : 'hidden'
} ;
2018-05-18 03:25:45 +00:00
let percs = false ;
2018-05-18 04:02:30 +00:00
// determine proper size
if ( content . attr ( 'viewBox' ) ) {
2018-05-18 03:25:45 +00:00
const vb = content . attr ( 'viewBox' ) . split ( ' ' ) ;
2018-05-18 04:02:30 +00:00
attrs . width = vb [ 2 ] ;
attrs . height = vb [ 3 ] ;
// handle content that doesn't have a viewBox
} else {
$ . each ( [ 'width' , 'height' ] , function ( i , dim ) {
// Set to 100 if not given
2018-05-18 03:25:45 +00:00
const val = content . attr ( dim ) || '100%' ;
2018-05-18 04:02:30 +00:00
if ( String ( val ) . substr ( - 1 ) === '%' ) {
// Use user units if percentage given
percs = true ;
} else {
2018-05-18 03:25:45 +00:00
attrs [ dim ] = convertToNum ( dim , val ) ;
2018-05-18 04:02:30 +00:00
}
} ) ;
}
// identify layers
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
draw . identifyLayers ( ) ;
2018-05-18 04:02:30 +00:00
// Give ID for any visible layer children missing one
content . children ( ) . find ( visElems ) . each ( function ( ) {
if ( ! this . id ) { this . id = getNextId ( ) ; }
} ) ;
// Percentage width/height, so let's base it on visible elements
if ( percs ) {
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
const bb = getStrokedBBoxDefaultVisible ( ) ;
2018-05-18 04:02:30 +00:00
attrs . width = bb . width + bb . x ;
attrs . height = bb . height + bb . y ;
}
// Just in case negative numbers are given or
// result from the percs calculation
if ( attrs . width <= 0 ) { attrs . width = 100 ; }
if ( attrs . height <= 0 ) { attrs . height = 100 ; }
content . attr ( attrs ) ;
this . contentW = attrs . width ;
this . contentH = attrs . height ;
2018-05-18 03:25:45 +00:00
batchCmd . addSubCommand ( new InsertElementCommand ( svgcontent ) ) ;
2018-05-18 04:02:30 +00:00
// update root to the correct size
2018-05-18 03:25:45 +00:00
const changes = content . attr ( [ 'width' , 'height' ] ) ;
batchCmd . addSubCommand ( new ChangeElementCommand ( svgroot , changes ) ) ;
2018-05-18 04:02:30 +00:00
// reset zoom
currentZoom = 1 ;
// reset transform lists
2018-05-18 03:25:45 +00:00
resetListMap ( ) ;
2018-05-18 04:02:30 +00:00
clearSelection ( ) ;
2018-05-18 03:25:45 +00:00
pathModule . clearData ( ) ;
2018-05-18 04:02:30 +00:00
svgroot . appendChild ( selectorManager . selectorParentGroup ) ;
if ( ! preventUndo ) addCommandToHistory ( batchCmd ) ;
call ( 'changed' , [ svgcontent ] ) ;
} catch ( e ) {
console . log ( e ) ;
return false ;
}
return true ;
2010-06-22 14:52:51 +00:00
} ;
// Function: importSvgString
2010-07-29 15:09:49 +00:00
// This function imports the input SVG XML as a <symbol> in the <defs>, then adds a
// <use> to the current layer.
2010-06-22 14:52:51 +00:00
//
// Parameters:
// xmlString - The SVG as XML text.
//
// Returns:
2015-09-30 10:24:16 +00:00
// This function returns null if the import was unsuccessful, or the element otherwise.
2018-05-16 00:53:27 +00:00
// TODO:
2010-06-28 13:10:22 +00:00
// * properly handle if namespace is introduced by imported content (must add to svgcontent
// and update all prefixes in the imported node)
// * properly handle recalculating dimensions, recalculateDimensions() doesn't handle
2018-05-16 00:53:27 +00:00
// arbitrary transform lists, but makes some assumptions about how the transform list
2010-06-28 13:10:22 +00:00
// was obtained
2018-05-16 00:53:27 +00:00
// * import should happen in top-left of current zoomed viewport
2018-05-16 08:32:44 +00:00
this . importSvgString = function ( xmlString ) {
2018-05-18 03:25:45 +00:00
let j , ts , useEl ;
2018-05-18 04:02:30 +00:00
try {
// Get unique ID
2018-05-18 03:25:45 +00:00
const uid = encode64 ( xmlString . length + xmlString ) . substr ( 0 , 32 ) ;
2018-05-18 04:02:30 +00:00
2018-05-18 03:25:45 +00:00
let useExisting = false ;
2018-05-18 04:02:30 +00:00
// Look for symbol and make sure symbol exists in image
if ( importIds [ uid ] ) {
if ( $ ( importIds [ uid ] . symbol ) . parents ( '#svgroot' ) . length ) {
useExisting = true ;
}
}
2018-05-18 03:25:45 +00:00
const batchCmd = new BatchCommand ( 'Import Image' ) ;
let symbol ;
2018-05-18 04:02:30 +00:00
if ( useExisting ) {
2018-05-18 03:25:45 +00:00
( { symbol } = importIds [ uid ] ) ;
2018-05-18 04:02:30 +00:00
ts = importIds [ uid ] . xform ;
} else {
// convert string into XML document
2018-05-18 03:25:45 +00:00
const newDoc = text2xml ( xmlString ) ;
2018-05-18 04:02:30 +00:00
this . prepareSvg ( newDoc ) ;
// import new svg document into our document
2018-05-18 03:25:45 +00:00
let svg ;
2018-05-18 04:02:30 +00:00
// If DOM3 adoptNode() available, use it. Otherwise fall back to DOM2 importNode()
if ( svgdoc . adoptNode ) {
svg = svgdoc . adoptNode ( newDoc . documentElement ) ;
} else {
svg = svgdoc . importNode ( newDoc . documentElement , true ) ;
}
uniquifyElems ( svg ) ;
2018-05-18 03:25:45 +00:00
const innerw = convertToNum ( 'width' , svg . getAttribute ( 'width' ) ) ,
innerh = convertToNum ( 'height' , svg . getAttribute ( 'height' ) ) ,
2018-05-18 04:02:30 +00:00
innervb = svg . getAttribute ( 'viewBox' ) ,
// if no explicit viewbox, create one out of the width and height
vb = innervb ? innervb . split ( ' ' ) : [ 0 , 0 , innerw , innerh ] ;
for ( j = 0 ; j < 4 ; ++ j ) {
vb [ j ] = + ( vb [ j ] ) ;
}
// TODO: properly handle preserveAspectRatio
2018-05-18 03:25:45 +00:00
const // canvasw = +svgcontent.getAttribute('width'),
2018-05-18 04:02:30 +00:00
canvash = + svgcontent . getAttribute ( 'height' ) ;
// imported content should be 1/3 of the canvas on its largest dimension
if ( innerh > innerw ) {
ts = 'scale(' + ( canvash / 3 ) / vb [ 3 ] + ')' ;
} else {
ts = 'scale(' + ( canvash / 3 ) / vb [ 2 ] + ')' ;
}
// Hack to make recalculateDimensions understand how to scale
ts = 'translate(0) ' + ts + ' translate(0)' ;
symbol = svgdoc . createElementNS ( NS . SVG , 'symbol' ) ;
2018-05-18 03:25:45 +00:00
const defs = findDefs ( ) ;
2018-05-18 04:02:30 +00:00
2018-05-18 03:25:45 +00:00
if ( isGecko ( ) ) {
2018-05-18 04:02:30 +00:00
// Move all gradients into root for Firefox, workaround for this bug:
// https://bugzilla.mozilla.org/show_bug.cgi?id=353575
// TODO: Make this properly undo-able.
$ ( svg ) . find ( 'linearGradient, radialGradient, pattern' ) . appendTo ( defs ) ;
}
while ( svg . firstChild ) {
2018-05-18 03:25:45 +00:00
const first = svg . firstChild ;
2018-05-18 04:02:30 +00:00
symbol . appendChild ( first ) ;
}
2018-05-18 03:25:45 +00:00
const attrs = svg . attributes ;
for ( let i = 0 ; i < attrs . length ; i ++ ) {
const attr = attrs [ i ] ;
2018-05-18 04:02:30 +00:00
symbol . setAttribute ( attr . nodeName , attr . value ) ;
}
symbol . id = getNextId ( ) ;
// Store data
importIds [ uid ] = {
2018-05-18 03:25:45 +00:00
symbol ,
2018-05-18 04:02:30 +00:00
xform : ts
} ;
2018-05-18 03:25:45 +00:00
findDefs ( ) . appendChild ( symbol ) ;
batchCmd . addSubCommand ( new InsertElementCommand ( symbol ) ) ;
2018-05-18 04:02:30 +00:00
}
2018-05-18 03:25:45 +00:00
useEl = svgdoc . createElementNS ( NS . SVG , 'use' ) ;
2018-05-18 04:02:30 +00:00
useEl . id = getNextId ( ) ;
setHref ( useEl , '#' + symbol . id ) ;
( currentGroup || getCurrentDrawing ( ) . getCurrentLayer ( ) ) . appendChild ( useEl ) ;
2018-05-18 03:25:45 +00:00
batchCmd . addSubCommand ( new InsertElementCommand ( useEl ) ) ;
2018-05-18 04:02:30 +00:00
clearSelection ( ) ;
useEl . setAttribute ( 'transform' , ts ) ;
2018-05-18 03:25:45 +00:00
recalculateDimensions ( useEl ) ;
2018-05-18 04:02:30 +00:00
$ ( useEl ) . data ( 'symbol' , symbol ) . data ( 'ref' , symbol ) ;
addToSelection ( [ useEl ] ) ;
// TODO: Find way to add this in a recalculateDimensions-parsable way
2018-05-18 03:25:45 +00:00
// if (vb[0] !== 0 || vb[1] !== 0) {
2018-05-18 06:41:43 +00:00
// ts = 'translate(' + (-vb[0]) + ',' + (-vb[1]) + ') ' + ts;
2018-05-18 04:02:30 +00:00
// }
addCommandToHistory ( batchCmd ) ;
call ( 'changed' , [ svgcontent ] ) ;
} catch ( e ) {
console . log ( e ) ;
return null ;
}
// we want to return the element so we can automatically select it
return useEl ;
2010-06-22 14:52:51 +00:00
} ;
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
// Could deprecate, but besides external uses, their usage makes clear that
// canvas is a dependency for all of these
[
'identifyLayers' , 'createLayer' , 'cloneLayer' , 'deleteCurrentLayer' ,
'setCurrentLayer' , 'renameCurrentLayer' , 'setCurrentLayerPosition' ,
'setLayerVisibility' , 'moveSelectedToLayer' , 'mergeLayer' , 'mergeAllLayers' ,
'leaveContext' , 'setContext'
] . forEach ( ( prop ) => {
canvas [ prop ] = draw [ prop ] ;
} ) ;
draw . init ( {
pathActions ,
getCurrentGroup ( ) {
return currentGroup ;
} ,
setCurrentGroup ( cg ) {
currentGroup = cg ;
} ,
getSelectedElements ,
getSVGContent ,
undoMgr ,
elData ,
getCurrentDrawing ,
clearSelection ,
call ,
addCommandToHistory ,
changeSvgcontent ( ) {
call ( 'changed' , [ svgcontent ] ) ;
2018-05-18 04:02:30 +00:00
}
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
} ) ;
2010-09-23 19:53:43 +00:00
2010-06-28 20:09:34 +00:00
// Group: Document functions
2009-09-21 02:05:58 +00:00
2010-06-22 14:52:51 +00:00
// Function: clear
2014-01-31 10:40:52 +00:00
// Clears the current document. This is not an undoable action.
2018-05-16 08:32:44 +00:00
this . clear = function ( ) {
2018-05-18 04:02:30 +00:00
pathActions . clear ( ) ;
2010-06-22 14:52:51 +00:00
2018-05-18 04:02:30 +00:00
clearSelection ( ) ;
2011-02-01 15:36:45 +00:00
2018-05-18 04:02:30 +00:00
// clear the svgcontent node
canvas . clearSvgContentElement ( ) ;
2011-02-01 07:22:18 +00:00
2018-05-18 04:02:30 +00:00
// create new document
2018-05-18 03:25:45 +00:00
canvas . current _drawing _ = new draw . Drawing ( svgcontent ) ;
2011-02-01 07:22:18 +00:00
2018-05-18 04:02:30 +00:00
// create empty first layer
canvas . createLayer ( 'Layer 1' ) ;
2018-05-16 00:53:27 +00:00
2018-05-18 04:02:30 +00:00
// clear the undo stack
canvas . undoMgr . resetUndoStack ( ) ;
2011-02-01 07:22:18 +00:00
2018-05-18 04:02:30 +00:00
// reset the selector manager
selectorManager . initGroup ( ) ;
2011-02-01 07:22:18 +00:00
2018-05-18 04:02:30 +00:00
// reset the rubber band box
rubberBox = selectorManager . getRubberBandBox ( ) ;
2011-02-01 07:22:18 +00:00
2018-05-18 04:02:30 +00:00
call ( 'cleared' ) ;
2010-06-22 14:52:51 +00:00
} ;
2010-06-28 13:10:22 +00:00
// Function: linkControlPoints
// Alias function
this . linkControlPoints = pathActions . linkControlPoints ;
2009-06-01 21:24:30 +00:00
2010-06-28 13:10:22 +00:00
// Function: getContentElem
// Returns the content DOM element
2018-05-16 08:32:44 +00:00
this . getContentElem = function ( ) { return svgcontent ; } ;
2010-06-28 13:10:22 +00:00
// Function: getRootElem
// Returns the root DOM element
2018-05-16 08:32:44 +00:00
this . getRootElem = function ( ) { return svgroot ; } ;
2010-06-28 13:10:22 +00:00
// Function: getResolution
// Returns the current dimensions and zoom level in an object
2018-05-18 03:25:45 +00:00
const getResolution = this . getResolution = function ( ) {
// const vb = svgcontent.getAttribute('viewBox').split(' ');
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
// return {w:vb[2], h:vb[3], zoom: currentZoom};
2018-05-16 00:53:27 +00:00
2018-05-18 03:25:45 +00:00
const w = svgcontent . getAttribute ( 'width' ) / currentZoom ;
const h = svgcontent . getAttribute ( 'height' ) / currentZoom ;
2018-05-16 00:53:27 +00:00
2018-05-18 04:02:30 +00:00
return {
2018-05-18 03:25:45 +00:00
w ,
h ,
zoom : currentZoom
2018-05-18 04:02:30 +00:00
} ;
2010-06-22 14:52:51 +00:00
} ;
2016-03-11 13:33:43 +00:00
// Function: getSnapToGrid
// Returns the current snap to grid setting
2018-05-16 08:32:44 +00:00
this . getSnapToGrid = function ( ) { return curConfig . gridSnapping ; } ;
2016-03-11 13:33:43 +00:00
2010-06-30 18:27:36 +00:00
// Function: getVersion
// Returns a string which describes the revision number of SvgCanvas.
2018-05-16 08:32:44 +00:00
this . getVersion = function ( ) {
2018-05-18 04:02:30 +00:00
return 'svgcanvas.js ($Rev$)' ;
2010-06-30 18:27:36 +00:00
} ;
2018-05-18 03:25:45 +00:00
/ * *
* Update interface strings with given values
* @ param strs - Object with strings ( see locales file )
* /
2018-05-16 08:32:44 +00:00
this . setUiStrings = function ( strs ) {
2018-05-18 03:25:45 +00:00
Object . assign ( uiStrings , strs . notification ) ;
pathModule . setUiStrings ( strs ) ;
2013-02-15 15:51:58 +00:00
} ;
2010-06-30 18:27:36 +00:00
// Function: setConfig
// Update configuration options with given values
//
// Parameters:
// opts - Object with options (see curConfig for examples)
2018-05-16 08:32:44 +00:00
this . setConfig = function ( opts ) {
2018-05-18 03:25:45 +00:00
Object . assign ( curConfig , opts ) ;
2013-02-15 15:51:58 +00:00
} ;
2010-06-30 18:27:36 +00:00
2011-01-30 17:11:56 +00:00
// Function: getTitle
2010-07-22 19:10:51 +00:00
// Returns the current group/SVG's title contents
2018-05-16 08:32:44 +00:00
this . getTitle = function ( elem ) {
2018-05-18 04:02:30 +00:00
elem = elem || selectedElements [ 0 ] ;
if ( ! elem ) { return ; }
elem = $ ( elem ) . data ( 'gsvg' ) || $ ( elem ) . data ( 'symbol' ) || elem ;
2018-05-18 03:25:45 +00:00
const childs = elem . childNodes ;
for ( let i = 0 ; i < childs . length ; i ++ ) {
2018-05-18 04:02:30 +00:00
if ( childs [ i ] . nodeName === 'title' ) {
return childs [ i ] . textContent ;
}
}
return '' ;
2013-02-15 15:51:58 +00:00
} ;
2010-06-22 14:52:51 +00:00
2010-07-22 19:10:51 +00:00
// Function: setGroupTitle
// Sets the group/SVG's title content
// TODO: Combine this with setDocumentTitle
2018-05-16 08:32:44 +00:00
this . setGroupTitle = function ( val ) {
2018-05-18 03:25:45 +00:00
let elem = selectedElements [ 0 ] ;
2018-05-18 04:02:30 +00:00
elem = $ ( elem ) . data ( 'gsvg' ) || elem ;
2018-05-18 03:25:45 +00:00
const ts = $ ( elem ) . children ( 'title' ) ;
2018-05-18 04:02:30 +00:00
2018-05-18 03:25:45 +00:00
const batchCmd = new BatchCommand ( 'Set Label' ) ;
2018-05-18 04:02:30 +00:00
2018-05-18 03:25:45 +00:00
let title ;
2018-05-18 04:02:30 +00:00
if ( ! val . length ) {
// Remove title element
2018-05-18 03:25:45 +00:00
const tsNextSibling = ts . nextSibling ;
batchCmd . addSubCommand ( new RemoveElementCommand ( ts [ 0 ] , tsNextSibling , elem ) ) ;
2018-05-18 04:02:30 +00:00
ts . remove ( ) ;
} else if ( ts . length ) {
// Change title contents
2018-05-18 03:25:45 +00:00
title = ts [ 0 ] ;
batchCmd . addSubCommand ( new ChangeElementCommand ( title , { '#text' : title . textContent } ) ) ;
2018-05-18 04:02:30 +00:00
title . textContent = val ;
} else {
// Add title element
title = svgdoc . createElementNS ( NS . SVG , 'title' ) ;
title . textContent = val ;
$ ( elem ) . prepend ( title ) ;
2018-05-18 03:25:45 +00:00
batchCmd . addSubCommand ( new InsertElementCommand ( title ) ) ;
2018-05-18 04:02:30 +00:00
}
addCommandToHistory ( batchCmd ) ;
2013-02-15 15:51:58 +00:00
} ;
2010-07-22 19:10:51 +00:00
// Function: getDocumentTitle
// Returns the current document title or an empty string if not found
2018-05-18 03:25:45 +00:00
const getDocumentTitle = this . getDocumentTitle = function ( ) {
2018-05-18 04:02:30 +00:00
return canvas . getTitle ( svgcontent ) ;
2013-02-15 15:51:58 +00:00
} ;
2010-07-22 19:10:51 +00:00
2010-06-28 13:10:22 +00:00
// Function: setDocumentTitle
// Adds/updates a title element for the document with the given name.
// This is an undoable action
//
// Parameters:
// newtitle - String with the new title
2018-05-16 08:32:44 +00:00
this . setDocumentTitle = function ( newtitle ) {
2018-05-18 03:25:45 +00:00
const childs = svgcontent . childNodes ;
let docTitle = false , oldTitle = '' ;
2018-05-18 04:02:30 +00:00
2018-05-18 03:25:45 +00:00
const batchCmd = new BatchCommand ( 'Change Image Title' ) ;
2018-05-18 04:02:30 +00:00
2018-05-18 03:25:45 +00:00
for ( let i = 0 ; i < childs . length ; i ++ ) {
2018-05-18 04:02:30 +00:00
if ( childs [ i ] . nodeName === 'title' ) {
docTitle = childs [ i ] ;
oldTitle = docTitle . textContent ;
break ;
}
}
if ( ! docTitle ) {
docTitle = svgdoc . createElementNS ( NS . SVG , 'title' ) ;
svgcontent . insertBefore ( docTitle , svgcontent . firstChild ) ;
}
if ( newtitle . length ) {
docTitle . textContent = newtitle ;
} else {
// No title given, so element is not necessary
docTitle . parentNode . removeChild ( docTitle ) ;
}
2018-05-18 03:25:45 +00:00
batchCmd . addSubCommand ( new ChangeElementCommand ( docTitle , { '#text' : oldTitle } ) ) ;
2018-05-18 04:02:30 +00:00
addCommandToHistory ( batchCmd ) ;
2013-02-15 15:51:58 +00:00
} ;
2009-07-30 22:45:59 +00:00
2010-06-28 20:09:34 +00:00
// Function: getEditorNS
// Returns the editor's namespace URL, optionally adds it to root element
//
// Parameters:
// add - Boolean to indicate whether or not to add the namespace value
2018-05-16 08:32:44 +00:00
this . getEditorNS = function ( add ) {
2018-05-18 04:02:30 +00:00
if ( add ) {
svgcontent . setAttribute ( 'xmlns:se' , NS . SE ) ;
}
return NS . SE ;
2013-02-15 15:51:58 +00:00
} ;
2009-09-14 00:04:53 +00:00
2010-06-28 20:09:34 +00:00
// Function: setResolution
// Changes the document's dimensions to the given size
//
2018-05-16 00:53:27 +00:00
// Parameters:
// x - Number with the width of the new dimensions in user units.
2010-06-28 20:09:34 +00:00
// Can also be the string "fit" to indicate "fit to content"
2018-05-16 00:53:27 +00:00
// y - Number with the height of the new dimensions in user units.
2010-06-28 20:09:34 +00:00
//
// Returns:
2018-05-16 00:53:27 +00:00
// Boolean to indicate if resolution change was succesful.
2010-06-28 20:09:34 +00:00
// It will fail on "fit to content" option with no content to fit to.
2018-05-16 08:32:44 +00:00
this . setResolution = function ( x , y ) {
2018-05-18 03:25:45 +00:00
const res = getResolution ( ) ;
const { w , h } = res ;
let batchCmd ;
2018-05-18 04:02:30 +00:00
if ( x === 'fit' ) {
// Get bounding box
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
const bbox = getStrokedBBoxDefaultVisible ( ) ;
2018-05-18 04:02:30 +00:00
if ( bbox ) {
2018-05-18 03:25:45 +00:00
batchCmd = new BatchCommand ( 'Fit Canvas to Content' ) ;
const visEls = getVisibleElements ( ) ;
2018-05-18 04:02:30 +00:00
addToSelection ( visEls ) ;
2018-05-18 03:25:45 +00:00
const dx = [ ] , dy = [ ] ;
2018-05-18 04:02:30 +00:00
$ . each ( visEls , function ( i , item ) {
dx . push ( bbox . x * - 1 ) ;
dy . push ( bbox . y * - 1 ) ;
} ) ;
2018-05-18 03:25:45 +00:00
const cmd = canvas . moveSelectedElements ( dx , dy , true ) ;
2018-05-18 04:02:30 +00:00
batchCmd . addSubCommand ( cmd ) ;
clearSelection ( ) ;
x = Math . round ( bbox . width ) ;
y = Math . round ( bbox . height ) ;
} else {
return false ;
}
}
if ( x !== w || y !== h ) {
if ( ! batchCmd ) {
2018-05-18 03:25:45 +00:00
batchCmd = new BatchCommand ( 'Change Image Dimensions' ) ;
2018-05-18 04:02:30 +00:00
}
2018-05-18 03:25:45 +00:00
x = convertToNum ( 'width' , x ) ;
y = convertToNum ( 'height' , y ) ;
2018-05-18 04:02:30 +00:00
svgcontent . setAttribute ( 'width' , x ) ;
svgcontent . setAttribute ( 'height' , y ) ;
this . contentW = x ;
this . contentH = y ;
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
batchCmd . addSubCommand ( new ChangeElementCommand ( svgcontent , { width : w , height : h } ) ) ;
2018-05-18 04:02:30 +00:00
svgcontent . setAttribute ( 'viewBox' , [ 0 , 0 , x / currentZoom , y / currentZoom ] . join ( ' ' ) ) ;
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
batchCmd . addSubCommand ( new ChangeElementCommand ( svgcontent , { viewBox : [ '0 0' , w , h ] . join ( ' ' ) } ) ) ;
2018-05-18 04:02:30 +00:00
addCommandToHistory ( batchCmd ) ;
call ( 'changed' , [ svgcontent ] ) ;
}
return true ;
2010-06-22 14:52:51 +00:00
} ;
2010-06-28 20:09:34 +00:00
// Function: getOffset
// Returns an object with x, y values indicating the svgcontent element's
// position in the editor's canvas.
2018-05-16 08:32:44 +00:00
this . getOffset = function ( ) {
2018-05-18 04:02:30 +00:00
return $ ( svgcontent ) . attr ( [ 'x' , 'y' ] ) ;
2013-02-15 15:51:58 +00:00
} ;
2010-06-22 14:52:51 +00:00
2010-06-28 20:09:34 +00:00
// Function: setBBoxZoom
// Sets the zoom level on the canvas-side based on the given value
2018-05-16 00:53:27 +00:00
//
2010-06-28 20:09:34 +00:00
// Parameters:
2018-05-16 00:53:27 +00:00
// val - Bounding box object to zoom to or string indicating zoom option
2018-05-16 08:32:44 +00:00
// editorW - Integer with the editor's workarea box's width
// editorH - Integer with the editor's workarea box's height
this . setBBoxZoom = function ( val , editorW , editorH ) {
2018-05-18 03:25:45 +00:00
let spacer = 0.85 ;
let bb ;
const calcZoom = function ( bb ) {
2018-05-18 04:02:30 +00:00
if ( ! bb ) { return false ; }
2018-05-18 03:25:45 +00:00
const wZoom = Math . round ( ( editorW / bb . width ) * 100 * spacer ) / 100 ;
const hZoom = Math . round ( ( editorH / bb . height ) * 100 * spacer ) / 100 ;
const zoom = Math . min ( wZoom , hZoom ) ;
canvas . setZoom ( zoom ) ;
return { zoom , bbox : bb } ;
2018-05-18 04:02:30 +00:00
} ;
if ( typeof val === 'object' ) {
bb = val ;
if ( bb . width === 0 || bb . height === 0 ) {
2018-05-18 03:25:45 +00:00
const newzoom = bb . zoom ? bb . zoom : currentZoom * bb . factor ;
2018-05-18 04:02:30 +00:00
canvas . setZoom ( newzoom ) ;
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
return { zoom : currentZoom , bbox : bb } ;
2018-05-18 04:02:30 +00:00
}
return calcZoom ( bb ) ;
}
switch ( val ) {
case 'selection' :
if ( ! selectedElements [ 0 ] ) { return ; }
2018-05-18 03:25:45 +00:00
const selectedElems = $ . map ( selectedElements , function ( n ) { if ( n ) { return n ; } } ) ;
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
bb = getStrokedBBoxDefaultVisible ( selectedElems ) ;
2018-05-18 04:02:30 +00:00
break ;
case 'canvas' :
2018-05-18 03:25:45 +00:00
const res = getResolution ( ) ;
2018-05-18 04:02:30 +00:00
spacer = 0.95 ;
bb = { width : res . w , height : res . h , x : 0 , y : 0 } ;
break ;
case 'content' :
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
bb = getStrokedBBoxDefaultVisible ( ) ;
2018-05-18 04:02:30 +00:00
break ;
case 'layer' :
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
bb = getStrokedBBoxDefaultVisible ( getVisibleElements ( getCurrentDrawing ( ) . getCurrentLayer ( ) ) ) ;
2018-05-18 04:02:30 +00:00
break ;
default :
return ;
}
return calcZoom ( bb ) ;
2013-02-15 15:51:58 +00:00
} ;
2009-09-09 14:18:24 +00:00
2010-06-28 20:09:34 +00:00
// Function: setZoom
// Sets the zoom to the given level
//
// Parameters:
// zoomlevel - Float indicating the zoom level to change to
2018-05-16 08:32:44 +00:00
this . setZoom = function ( zoomlevel ) {
2018-05-18 03:25:45 +00:00
const res = getResolution ( ) ;
2018-05-18 04:02:30 +00:00
svgcontent . setAttribute ( 'viewBox' , '0 0 ' + res . w / zoomlevel + ' ' + res . h / zoomlevel ) ;
currentZoom = zoomlevel ;
$ . each ( selectedElements , function ( i , elem ) {
if ( ! elem ) { return ; }
selectorManager . requestSelector ( elem ) . resize ( ) ;
} ) ;
pathActions . zoomChange ( ) ;
runExtensions ( 'zoomChanged' , zoomlevel ) ;
2013-02-15 15:51:58 +00:00
} ;
2009-06-06 12:25:26 +00:00
2010-06-28 20:09:34 +00:00
// Function: getMode
// Returns the current editor mode string
2018-05-16 08:32:44 +00:00
this . getMode = function ( ) {
2018-05-18 04:02:30 +00:00
return currentMode ;
2010-06-22 14:52:51 +00:00
} ;
2009-06-01 21:24:30 +00:00
2010-06-28 20:09:34 +00:00
// Function: setMode
// Sets the editor's mode to the given string
//
// Parameters:
// name - String with the new mode to change to
2018-05-16 08:32:44 +00:00
this . setMode = function ( name ) {
2018-05-18 04:02:30 +00:00
pathActions . clear ( true ) ;
textActions . clear ( ) ;
curProperties = ( selectedElements [ 0 ] && selectedElements [ 0 ] . nodeName === 'text' ) ? curText : curShape ;
currentMode = name ;
2010-06-22 14:52:51 +00:00
} ;
2009-06-06 12:25:26 +00:00
2010-06-28 20:09:34 +00:00
// Group: Element Styling
// Function: getColor
// Returns the current fill/stroke option
2018-05-16 08:32:44 +00:00
this . getColor = function ( type ) {
2018-05-18 04:02:30 +00:00
return curProperties [ type ] ;
2010-06-22 14:52:51 +00:00
} ;
2010-02-02 05:48:33 +00:00
2010-06-28 20:09:34 +00:00
// Function: setColor
// Change the current stroke/fill color/gradient value
2018-05-16 00:53:27 +00:00
//
2010-06-28 20:09:34 +00:00
// Parameters:
// type - String indicating fill or stroke
// val - The value to set the stroke attribute to
// preventUndo - Boolean indicating whether or not this should be and undoable option
2018-05-16 08:32:44 +00:00
this . setColor = function ( type , val , preventUndo ) {
2018-05-18 04:02:30 +00:00
curShape [ type ] = val ;
curProperties [ type + '_paint' ] = { type : 'solidColor' } ;
2018-05-18 03:25:45 +00:00
const elems = [ ] ;
2018-05-18 04:02:30 +00:00
function addNonG ( e ) {
if ( e . nodeName !== 'g' ) {
elems . push ( e ) ;
}
}
2018-05-18 03:25:45 +00:00
let i = selectedElements . length ;
2018-05-18 04:02:30 +00:00
while ( i -- ) {
2018-05-18 03:25:45 +00:00
const elem = selectedElements [ i ] ;
2018-05-18 04:02:30 +00:00
if ( elem ) {
if ( elem . tagName === 'g' ) {
2018-05-18 03:25:45 +00:00
walkTree ( elem , addNonG ) ;
2018-05-18 04:02:30 +00:00
} else {
if ( type === 'fill' ) {
if ( elem . tagName !== 'polyline' && elem . tagName !== 'line' ) {
elems . push ( elem ) ;
}
} else {
elems . push ( elem ) ;
}
}
}
}
if ( elems . length > 0 ) {
if ( ! preventUndo ) {
changeSelectedAttribute ( type , val , elems ) ;
call ( 'changed' , elems ) ;
} else {
changeSelectedAttributeNoUndo ( type , val , elems ) ;
}
}
2013-02-15 15:51:58 +00:00
} ;
2009-06-01 21:24:30 +00:00
2010-06-28 20:09:34 +00:00
// Function: setGradient
// Apply the current gradient to selected element's fill or stroke
//
// Parameters
// type - String indicating "fill" or "stroke" to apply to an element
2018-05-18 03:25:45 +00:00
const setGradient = this . setGradient = function ( type ) {
2018-05-18 04:02:30 +00:00
if ( ! curProperties [ type + '_paint' ] || curProperties [ type + '_paint' ] . type === 'solidColor' ) { return ; }
2018-05-18 03:25:45 +00:00
let grad = canvas [ type + 'Grad' ] ;
2018-05-18 04:02:30 +00:00
// find out if there is a duplicate gradient already in the defs
2018-05-18 03:25:45 +00:00
const duplicateGrad = findDuplicateGradient ( grad ) ;
const defs = findDefs ( ) ;
2018-05-18 04:02:30 +00:00
// no duplicate found, so import gradient into defs
if ( ! duplicateGrad ) {
2018-05-18 03:25:45 +00:00
// const origGrad = grad;
2018-05-18 04:02:30 +00:00
grad = defs . appendChild ( svgdoc . importNode ( grad , true ) ) ;
// get next id and set it on the grad
grad . id = getNextId ( ) ;
} else { // use existing gradient
grad = duplicateGrad ;
}
canvas . setColor ( type , 'url(#' + grad . id + ')' ) ;
2013-02-15 15:51:58 +00:00
} ;
2009-08-17 06:56:55 +00:00
2010-06-28 20:09:34 +00:00
// Function: findDuplicateGradient
// Check if exact gradient already exists
//
// Parameters:
// grad - The gradient DOM element to compare to others
//
// Returns:
// The existing gradient if found, null if not
2018-05-18 03:25:45 +00:00
const findDuplicateGradient = function ( grad ) {
const defs = findDefs ( ) ;
const existingGrads = $ ( defs ) . find ( 'linearGradient, radialGradient' ) ;
let i = existingGrads . length ;
const radAttrs = [ 'r' , 'cx' , 'cy' , 'fx' , 'fy' ] ;
2018-05-18 04:02:30 +00:00
while ( i -- ) {
2018-05-18 03:25:45 +00:00
const og = existingGrads [ i ] ;
2018-05-18 04:02:30 +00:00
if ( grad . tagName === 'linearGradient' ) {
if ( grad . getAttribute ( 'x1' ) !== og . getAttribute ( 'x1' ) ||
grad . getAttribute ( 'y1' ) !== og . getAttribute ( 'y1' ) ||
grad . getAttribute ( 'x2' ) !== og . getAttribute ( 'x2' ) ||
grad . getAttribute ( 'y2' ) !== og . getAttribute ( 'y2' )
) {
continue ;
}
} else {
2018-05-18 03:25:45 +00:00
const gradAttrs = $ ( grad ) . attr ( radAttrs ) ;
const ogAttrs = $ ( og ) . attr ( radAttrs ) ;
2018-05-18 04:02:30 +00:00
2018-05-18 03:25:45 +00:00
let diff = false ;
2018-05-18 04:02:30 +00:00
$ . each ( radAttrs , function ( i , attr ) {
if ( gradAttrs [ attr ] !== ogAttrs [ attr ] ) { diff = true ; }
} ) ;
if ( diff ) { continue ; }
}
// else could be a duplicate, iterate through stops
2018-05-18 03:25:45 +00:00
const stops = grad . getElementsByTagNameNS ( NS . SVG , 'stop' ) ;
const ostops = og . getElementsByTagNameNS ( NS . SVG , 'stop' ) ;
2018-05-18 04:02:30 +00:00
if ( stops . length !== ostops . length ) {
continue ;
}
2018-05-18 03:25:45 +00:00
let j = stops . length ;
2018-05-18 04:02:30 +00:00
while ( j -- ) {
2018-05-18 03:25:45 +00:00
const stop = stops [ j ] ;
const ostop = ostops [ j ] ;
2018-05-18 04:02:30 +00:00
if ( stop . getAttribute ( 'offset' ) !== ostop . getAttribute ( 'offset' ) ||
stop . getAttribute ( 'stop-opacity' ) !== ostop . getAttribute ( 'stop-opacity' ) ||
stop . getAttribute ( 'stop-color' ) !== ostop . getAttribute ( 'stop-color' ) ) {
break ;
}
}
if ( j === - 1 ) {
return og ;
}
} // for each gradient in defs
return null ;
2010-06-22 14:52:51 +00:00
} ;
2009-09-04 06:30:18 +00:00
2010-06-28 20:09:34 +00:00
// Function: setPaint
// Set a color/gradient to a fill/stroke
//
2013-02-25 13:05:25 +00:00
// Parameters:
2010-06-28 20:09:34 +00:00
// type - String with "fill" or "stroke"
// paint - The jGraduate paint object to apply
2018-05-16 08:32:44 +00:00
this . setPaint = function ( type , paint ) {
2018-05-18 04:02:30 +00:00
// make a copy
2018-05-18 03:25:45 +00:00
const p = new $ . jGraduate . Paint ( paint ) ;
2018-05-18 04:02:30 +00:00
this . setPaintOpacity ( type , p . alpha / 100 , true ) ;
// now set the current paint object
curProperties [ type + '_paint' ] = p ;
switch ( p . type ) {
case 'solidColor' :
this . setColor ( type , p . solidColor !== 'none' ? '#' + p . solidColor : 'none' ) ;
break ;
case 'linearGradient' :
case 'radialGradient' :
canvas [ type + 'Grad' ] = p [ p . type ] ;
setGradient ( type ) ;
break ;
}
2010-06-22 14:52:51 +00:00
} ;
2009-07-30 22:45:59 +00:00
2013-02-25 13:05:25 +00:00
// alias
2018-05-16 08:32:44 +00:00
this . setStrokePaint = function ( paint ) {
2018-05-18 04:02:30 +00:00
this . setPaint ( 'stroke' , paint ) ;
2013-02-25 13:05:25 +00:00
} ;
2009-06-01 21:24:30 +00:00
2018-05-16 08:32:44 +00:00
this . setFillPaint = function ( paint ) {
2018-05-18 04:02:30 +00:00
this . setPaint ( 'fill' , paint ) ;
2013-02-25 13:05:25 +00:00
} ;
2010-06-28 20:09:34 +00:00
// Function: getStrokeWidth
// Returns the current stroke-width value
2018-05-16 08:32:44 +00:00
this . getStrokeWidth = function ( ) {
2018-05-18 04:02:30 +00:00
return curProperties . stroke _width ;
2010-06-22 14:52:51 +00:00
} ;
2010-06-28 20:09:34 +00:00
// Function: setStrokeWidth
// Sets the stroke width for the current selected elements
// When attempting to set a line's width to 0, this changes it to 1 instead
//
// Parameters:
// val - A Float indicating the new stroke width value
2018-05-16 08:32:44 +00:00
this . setStrokeWidth = function ( val ) {
2018-05-18 03:25:45 +00:00
if ( val === 0 && [ 'line' , 'path' ] . includes ( currentMode ) ) {
2018-05-18 04:02:30 +00:00
canvas . setStrokeWidth ( 1 ) ;
return ;
}
curProperties . stroke _width = val ;
2018-05-18 03:25:45 +00:00
const elems = [ ] ;
2018-05-18 04:02:30 +00:00
function addNonG ( e ) {
if ( e . nodeName !== 'g' ) {
elems . push ( e ) ;
}
}
2018-05-18 03:25:45 +00:00
let i = selectedElements . length ;
2018-05-18 04:02:30 +00:00
while ( i -- ) {
2018-05-18 03:25:45 +00:00
const elem = selectedElements [ i ] ;
2018-05-18 04:02:30 +00:00
if ( elem ) {
if ( elem . tagName === 'g' ) {
2018-05-18 03:25:45 +00:00
walkTree ( elem , addNonG ) ;
2018-05-18 04:02:30 +00:00
} else {
elems . push ( elem ) ;
}
}
}
if ( elems . length > 0 ) {
changeSelectedAttribute ( 'stroke-width' , val , elems ) ;
call ( 'changed' , selectedElements ) ;
}
2010-06-22 14:52:51 +00:00
} ;
2009-06-06 12:25:26 +00:00
2010-06-28 20:09:34 +00:00
// Function: setStrokeAttr
// Set the given stroke-related attribute the given value for selected elements
//
// Parameters:
// attr - String with the attribute name
// val - String or number with the attribute value
2018-05-16 08:32:44 +00:00
this . setStrokeAttr = function ( attr , val ) {
2018-05-18 04:02:30 +00:00
curShape [ attr . replace ( '-' , '_' ) ] = val ;
2018-05-18 03:25:45 +00:00
const elems = [ ] ;
2018-05-18 04:02:30 +00:00
2018-05-18 03:25:45 +00:00
let i = selectedElements . length ;
2018-05-18 04:02:30 +00:00
while ( i -- ) {
2018-05-18 03:25:45 +00:00
const elem = selectedElements [ i ] ;
2018-05-18 04:02:30 +00:00
if ( elem ) {
if ( elem . tagName === 'g' ) {
2018-05-18 03:25:45 +00:00
walkTree ( elem , function ( e ) { if ( e . nodeName !== 'g' ) { elems . push ( e ) ; } } ) ;
2018-05-18 04:02:30 +00:00
} else {
elems . push ( elem ) ;
}
}
}
if ( elems . length > 0 ) {
changeSelectedAttribute ( attr , val , elems ) ;
call ( 'changed' , selectedElements ) ;
}
2010-06-22 14:52:51 +00:00
} ;
2010-07-09 19:09:37 +00:00
// Function: getStyle
// Returns current style options
2018-05-16 08:32:44 +00:00
this . getStyle = function ( ) {
2018-05-18 04:02:30 +00:00
return curShape ;
2013-02-15 15:51:58 +00:00
} ;
2010-07-09 19:09:37 +00:00
2010-06-28 20:09:34 +00:00
// Returns the current opacity
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
this . getOpacity = getOpacity ;
2010-06-22 14:52:51 +00:00
2010-06-28 20:09:34 +00:00
// Function: setOpacity
// Sets the given opacity to the current selected elements
2018-05-16 08:32:44 +00:00
this . setOpacity = function ( val ) {
2018-05-18 04:02:30 +00:00
curShape . opacity = val ;
changeSelectedAttribute ( 'opacity' , val ) ;
2010-06-22 14:52:51 +00:00
} ;
2009-06-04 13:43:58 +00:00
2010-06-28 20:09:34 +00:00
// Function: getOpacity
// Returns the current fill opacity
2018-05-16 08:32:44 +00:00
this . getFillOpacity = function ( ) {
2018-05-18 04:02:30 +00:00
return curShape . fill _opacity ;
2010-06-28 20:09:34 +00:00
} ;
// Function: getStrokeOpacity
// Returns the current stroke opacity
2018-05-16 08:32:44 +00:00
this . getStrokeOpacity = function ( ) {
2018-05-18 04:02:30 +00:00
return curShape . stroke _opacity ;
2010-06-28 20:09:34 +00:00
} ;
// Function: setPaintOpacity
// Sets the current fill/stroke opacity
//
// Parameters:
// type - String with "fill" or "stroke"
// val - Float with the new opacity value
// preventUndo - Boolean indicating whether or not this should be an undoable action
2018-05-16 08:32:44 +00:00
this . setPaintOpacity = function ( type , val , preventUndo ) {
2018-05-18 04:02:30 +00:00
curShape [ type + '_opacity' ] = val ;
if ( ! preventUndo ) {
changeSelectedAttribute ( type + '-opacity' , val ) ;
} else {
changeSelectedAttributeNoUndo ( type + '-opacity' , val ) ;
}
2010-06-28 20:09:34 +00:00
} ;
2013-02-19 13:17:27 +00:00
// Function: getPaintOpacity
// Gets the current fill/stroke opacity
//
// Parameters:
// type - String with "fill" or "stroke"
2018-05-16 08:32:44 +00:00
this . getPaintOpacity = function ( type ) {
2018-05-18 04:02:30 +00:00
return type === 'fill' ? this . getFillOpacity ( ) : this . getStrokeOpacity ( ) ;
2013-02-19 13:17:27 +00:00
} ;
2010-06-29 20:43:44 +00:00
// Function: getBlur
// Gets the stdDeviation blur value of the given element
//
// Parameters:
// elem - The element to check the blur value for
2018-05-16 08:32:44 +00:00
this . getBlur = function ( elem ) {
2018-05-18 03:25:45 +00:00
let val = 0 ;
// const elem = selectedElements[0];
2013-02-19 13:17:27 +00:00
2018-05-18 04:02:30 +00:00
if ( elem ) {
2018-05-18 03:25:45 +00:00
const filterUrl = elem . getAttribute ( 'filter' ) ;
2018-05-18 04:02:30 +00:00
if ( filterUrl ) {
2018-05-18 03:25:45 +00:00
const blur = getElem ( elem . id + '_blur' ) ;
2018-05-18 04:02:30 +00:00
if ( blur ) {
val = blur . firstChild . getAttribute ( 'stdDeviation' ) ;
}
}
}
return val ;
2010-06-22 14:52:51 +00:00
} ;
2010-04-06 18:40:10 +00:00
2018-05-16 08:32:44 +00:00
( function ( ) {
2018-05-18 03:25:45 +00:00
let curCommand = null ;
let filter = null ;
let filterHidden = false ;
2018-05-16 00:53:27 +00:00
2018-05-17 05:15:20 +00:00
// Function: setBlurNoUndo
// Sets the stdDeviation blur value on the selected element without being undoable
//
// Parameters:
// val - The new stdDeviation value
canvas . setBlurNoUndo = function ( val ) {
2018-05-18 04:02:30 +00:00
if ( ! filter ) {
canvas . setBlur ( val ) ;
return ;
}
if ( val === 0 ) {
// Don't change the StdDev, as that will hide the element.
// Instead, just remove the value for "filter"
changeSelectedAttributeNoUndo ( 'filter' , '' ) ;
filterHidden = true ;
} else {
2018-05-18 03:25:45 +00:00
const elem = selectedElements [ 0 ] ;
2018-05-18 04:02:30 +00:00
if ( filterHidden ) {
changeSelectedAttributeNoUndo ( 'filter' , 'url(#' + elem . id + '_blur)' ) ;
}
2018-05-18 03:25:45 +00:00
if ( isWebkit ( ) ) {
2018-05-18 04:02:30 +00:00
console . log ( 'e' , elem ) ;
elem . removeAttribute ( 'filter' ) ;
elem . setAttribute ( 'filter' , 'url(#' + elem . id + '_blur)' ) ;
}
changeSelectedAttributeNoUndo ( 'stdDeviation' , val , [ filter . firstChild ] ) ;
canvas . setBlurOffsets ( filter , val ) ;
}
2018-05-17 05:15:20 +00:00
} ;
2010-06-22 14:52:51 +00:00
2018-05-17 05:15:20 +00:00
function finishChange ( ) {
2018-05-18 03:25:45 +00:00
const bCmd = canvas . undoMgr . finishUndoableChange ( ) ;
2018-05-18 04:02:30 +00:00
curCommand . addSubCommand ( bCmd ) ;
addCommandToHistory ( curCommand ) ;
curCommand = null ;
filter = null ;
2018-05-17 05:15:20 +00:00
}
2010-06-22 14:52:51 +00:00
2018-05-17 05:15:20 +00:00
// Function: setBlurOffsets
// Sets the x, y, with, height values of the filter element in order to
// make the blur not be clipped. Removes them if not neeeded
//
// Parameters:
// filter - The filter DOM element to update
// stdDev - The standard deviation value on which to base the offset size
canvas . setBlurOffsets = function ( filter , stdDev ) {
2018-05-18 04:02:30 +00:00
if ( stdDev > 3 ) {
// TODO: Create algorithm here where size is based on expected blur
2018-05-18 03:25:45 +00:00
assignAttributes ( filter , {
2018-05-18 04:02:30 +00:00
x : '-50%' ,
y : '-50%' ,
width : '200%' ,
height : '200%'
} , 100 ) ;
} else {
// Removing these attributes hides text in Chrome (see Issue 579)
2018-05-18 03:25:45 +00:00
if ( ! isWebkit ( ) ) {
2018-05-18 04:02:30 +00:00
filter . removeAttribute ( 'x' ) ;
filter . removeAttribute ( 'y' ) ;
filter . removeAttribute ( 'width' ) ;
filter . removeAttribute ( 'height' ) ;
}
}
2018-05-17 05:15:20 +00:00
} ;
2018-05-16 00:53:27 +00:00
2018-05-17 05:15:20 +00:00
// Function: setBlur
// Adds/updates the blur filter to the selected element
//
// Parameters:
// val - Float with the new stdDeviation blur value
// complete - Boolean indicating whether or not the action should be completed (to add to the undo manager)
canvas . setBlur = function ( val , complete ) {
2018-05-18 04:02:30 +00:00
if ( curCommand ) {
finishChange ( ) ;
return ;
}
// Looks for associated blur, creates one if not found
2018-05-18 03:25:45 +00:00
const elem = selectedElements [ 0 ] ;
const elemId = elem . id ;
filter = getElem ( elemId + '_blur' ) ;
2018-05-18 04:02:30 +00:00
val -= 0 ;
2018-05-18 03:25:45 +00:00
const batchCmd = new BatchCommand ( ) ;
2018-05-18 04:02:30 +00:00
// Blur found!
if ( filter ) {
if ( val === 0 ) {
filter = null ;
}
} else {
// Not found, so create
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
const newblur = addSvgElementFromJson ( { element : 'feGaussianBlur' ,
attr : {
in : 'SourceGraphic' ,
stdDeviation : val
2018-05-18 04:02:30 +00:00
}
} ) ;
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
filter = addSvgElementFromJson ( { element : 'filter' ,
attr : {
id : elemId + '_blur'
2018-05-18 04:02:30 +00:00
}
} ) ;
filter . appendChild ( newblur ) ;
2018-05-18 03:25:45 +00:00
findDefs ( ) . appendChild ( filter ) ;
2018-05-18 04:02:30 +00:00
2018-05-18 03:25:45 +00:00
batchCmd . addSubCommand ( new InsertElementCommand ( filter ) ) ;
2018-05-18 04:02:30 +00:00
}
2018-05-18 03:25:45 +00:00
const changes = { filter : elem . getAttribute ( 'filter' ) } ;
2018-05-18 04:02:30 +00:00
if ( val === 0 ) {
elem . removeAttribute ( 'filter' ) ;
2018-05-18 03:25:45 +00:00
batchCmd . addSubCommand ( new ChangeElementCommand ( elem , changes ) ) ;
2018-05-18 04:02:30 +00:00
return ;
}
changeSelectedAttribute ( 'filter' , 'url(#' + elemId + '_blur)' ) ;
2018-05-18 03:25:45 +00:00
batchCmd . addSubCommand ( new ChangeElementCommand ( elem , changes ) ) ;
2018-05-18 04:02:30 +00:00
canvas . setBlurOffsets ( filter , val ) ;
curCommand = batchCmd ;
canvas . undoMgr . beginUndoableChange ( 'stdDeviation' , [ filter ? filter . firstChild : null ] ) ;
if ( complete ) {
canvas . setBlurNoUndo ( val ) ;
finishChange ( ) ;
}
2018-05-17 05:15:20 +00:00
} ;
2010-06-22 14:52:51 +00:00
} ( ) ) ;
2009-06-06 12:25:26 +00:00
2010-06-29 20:43:44 +00:00
// Function: getBold
// Check whether selected element is bold or not
//
// Returns:
// Boolean indicating whether or not element is bold
2018-05-16 08:32:44 +00:00
this . getBold = function ( ) {
2018-05-18 04:02:30 +00:00
// should only have one element selected
2018-05-18 03:25:45 +00:00
const selected = selectedElements [ 0 ] ;
2018-05-18 04:02:30 +00:00
if ( selected != null && selected . tagName === 'text' &&
selectedElements [ 1 ] == null ) {
return ( selected . getAttribute ( 'font-weight' ) === 'bold' ) ;
}
return false ;
2010-06-22 14:52:51 +00:00
} ;
2009-08-17 06:56:55 +00:00
2010-06-29 20:43:44 +00:00
// Function: setBold
// Make the selected element bold or normal
//
// Parameters:
// b - Boolean indicating bold (true) or normal (false)
2018-05-16 08:32:44 +00:00
this . setBold = function ( b ) {
2018-05-18 03:25:45 +00:00
const selected = selectedElements [ 0 ] ;
2018-05-18 04:02:30 +00:00
if ( selected != null && selected . tagName === 'text' &&
selectedElements [ 1 ] == null ) {
changeSelectedAttribute ( 'font-weight' , b ? 'bold' : 'normal' ) ;
}
if ( ! selectedElements [ 0 ] . textContent ) {
textActions . setCursor ( ) ;
}
2010-06-22 14:52:51 +00:00
} ;
2009-08-17 06:56:55 +00:00
2010-06-29 20:43:44 +00:00
// Function: getItalic
// Check whether selected element is italic or not
//
// Returns:
// Boolean indicating whether or not element is italic
2018-05-16 08:32:44 +00:00
this . getItalic = function ( ) {
2018-05-18 03:25:45 +00:00
const selected = selectedElements [ 0 ] ;
2018-05-18 04:02:30 +00:00
if ( selected != null && selected . tagName === 'text' &&
selectedElements [ 1 ] == null ) {
return ( selected . getAttribute ( 'font-style' ) === 'italic' ) ;
}
return false ;
2010-06-22 14:52:51 +00:00
} ;
2009-08-17 06:56:55 +00:00
2010-06-29 20:43:44 +00:00
// Function: setItalic
// Make the selected element italic or normal
//
// Parameters:
// b - Boolean indicating italic (true) or normal (false)
2018-05-16 08:32:44 +00:00
this . setItalic = function ( i ) {
2018-05-18 03:25:45 +00:00
const selected = selectedElements [ 0 ] ;
2018-05-18 04:02:30 +00:00
if ( selected != null && selected . tagName === 'text' &&
selectedElements [ 1 ] == null ) {
changeSelectedAttribute ( 'font-style' , i ? 'italic' : 'normal' ) ;
}
if ( ! selectedElements [ 0 ] . textContent ) {
textActions . setCursor ( ) ;
}
2010-06-22 14:52:51 +00:00
} ;
2009-08-17 06:56:55 +00:00
2010-06-29 20:43:44 +00:00
// Function: getFontFamily
// Returns the current font family
2018-05-16 08:32:44 +00:00
this . getFontFamily = function ( ) {
2018-05-18 04:02:30 +00:00
return curText . font _family ;
2010-06-22 14:52:51 +00:00
} ;
2009-06-12 06:45:37 +00:00
2010-06-29 20:43:44 +00:00
// Function: setFontFamily
// Set the new font family
//
// Parameters:
// val - String with the new font family
2018-05-16 08:32:44 +00:00
this . setFontFamily = function ( val ) {
2018-05-18 04:02:30 +00:00
curText . font _family = val ;
changeSelectedAttribute ( 'font-family' , val ) ;
if ( selectedElements [ 0 ] && ! selectedElements [ 0 ] . textContent ) {
textActions . setCursor ( ) ;
}
2010-06-22 14:52:51 +00:00
} ;
2009-06-23 07:48:15 +00:00
2011-03-09 18:55:48 +00:00
// Function: setFontColor
// Set the new font color
//
// Parameters:
// val - String with the new font color
2018-05-16 08:32:44 +00:00
this . setFontColor = function ( val ) {
2018-05-18 04:02:30 +00:00
curText . fill = val ;
changeSelectedAttribute ( 'fill' , val ) ;
2011-03-09 18:55:48 +00:00
} ;
// Function: getFontColor
// Returns the current font color
2018-05-16 08:32:44 +00:00
this . getFontColor = function ( ) {
2018-05-18 04:02:30 +00:00
return curText . fill ;
2011-03-09 18:55:48 +00:00
} ;
2010-06-29 20:43:44 +00:00
// Function: getFontSize
// Returns the current font size
2018-05-16 08:32:44 +00:00
this . getFontSize = function ( ) {
2018-05-18 04:02:30 +00:00
return curText . font _size ;
2010-06-22 14:52:51 +00:00
} ;
2009-06-10 03:12:19 +00:00
2010-06-29 20:43:44 +00:00
// Function: setFontSize
// Applies the given font size to the selected element
//
// Parameters:
// val - Float with the new font size
2018-05-16 08:32:44 +00:00
this . setFontSize = function ( val ) {
2018-05-18 04:02:30 +00:00
curText . font _size = val ;
changeSelectedAttribute ( 'font-size' , val ) ;
if ( ! selectedElements [ 0 ] . textContent ) {
textActions . setCursor ( ) ;
}
2010-06-22 14:52:51 +00:00
} ;
2009-06-23 07:48:15 +00:00
2010-06-29 20:43:44 +00:00
// Function: getText
// Returns the current text (textContent) of the selected element
2018-05-16 08:32:44 +00:00
this . getText = function ( ) {
2018-05-18 03:25:45 +00:00
const selected = selectedElements [ 0 ] ;
2018-05-18 04:02:30 +00:00
if ( selected == null ) { return '' ; }
return selected . textContent ;
2010-06-22 14:52:51 +00:00
} ;
2009-06-23 07:48:15 +00:00
2010-06-29 20:43:44 +00:00
// Function: setTextContent
// Updates the text element with the given string
//
// Parameters:
// val - String with the new text
2018-05-16 08:32:44 +00:00
this . setTextContent = function ( val ) {
2018-05-18 04:02:30 +00:00
changeSelectedAttribute ( '#text' , val ) ;
textActions . init ( val ) ;
textActions . setCursor ( ) ;
2010-06-22 14:52:51 +00:00
} ;
2009-06-23 07:48:15 +00:00
2010-06-29 20:43:44 +00:00
// Function: setImageURL
// Sets the new image URL for the selected image element. Updates its size if
// a new URL is given
2018-05-16 00:53:27 +00:00
//
2010-06-29 20:43:44 +00:00
// Parameters:
// val - String with the image URL/path
2018-05-16 08:32:44 +00:00
this . setImageURL = function ( val ) {
2018-05-18 03:25:45 +00:00
const elem = selectedElements [ 0 ] ;
2018-05-18 04:02:30 +00:00
if ( ! elem ) { return ; }
2018-05-16 00:53:27 +00:00
2018-05-18 03:25:45 +00:00
const attrs = $ ( elem ) . attr ( [ 'width' , 'height' ] ) ;
let setsize = ( ! attrs . width || ! attrs . height ) ;
2010-04-09 16:01:09 +00:00
2018-05-18 03:25:45 +00:00
const curHref = getHref ( elem ) ;
2018-05-16 00:53:27 +00:00
2018-05-18 04:02:30 +00:00
// Do nothing if no URL change or size change
if ( curHref !== val ) {
setsize = true ;
} else if ( ! setsize ) { return ; }
2010-06-22 14:52:51 +00:00
2018-05-18 03:25:45 +00:00
const batchCmd = new BatchCommand ( 'Change Image URL' ) ;
2010-06-22 14:52:51 +00:00
2018-05-18 04:02:30 +00:00
setHref ( elem , val ) ;
2018-05-18 03:25:45 +00:00
batchCmd . addSubCommand ( new ChangeElementCommand ( elem , {
2018-05-18 04:02:30 +00:00
'#href' : curHref
} ) ) ;
2010-06-22 14:52:51 +00:00
2018-05-18 04:02:30 +00:00
if ( setsize ) {
$ ( new Image ( ) ) . load ( function ( ) {
2018-05-18 03:25:45 +00:00
const changes = $ ( elem ) . attr ( [ 'width' , 'height' ] ) ;
2018-05-16 00:53:27 +00:00
2018-05-18 04:02:30 +00:00
$ ( elem ) . attr ( {
width : this . width ,
height : this . height
} ) ;
2018-05-16 00:53:27 +00:00
2018-05-18 04:02:30 +00:00
selectorManager . requestSelector ( elem ) . resize ( ) ;
2018-05-16 00:53:27 +00:00
2018-05-18 03:25:45 +00:00
batchCmd . addSubCommand ( new ChangeElementCommand ( elem , changes ) ) ;
2018-05-18 04:02:30 +00:00
addCommandToHistory ( batchCmd ) ;
call ( 'changed' , [ elem ] ) ;
} ) . attr ( 'src' , val ) ;
} else {
addCommandToHistory ( batchCmd ) ;
}
2010-06-22 14:52:51 +00:00
} ;
2009-09-04 22:22:40 +00:00
2010-12-01 17:54:11 +00:00
// Function: setLinkURL
// Sets the new link URL for the selected anchor element.
2018-05-16 00:53:27 +00:00
//
2010-12-01 17:54:11 +00:00
// Parameters:
// val - String with the link URL/path
2018-05-16 08:32:44 +00:00
this . setLinkURL = function ( val ) {
2018-05-18 03:25:45 +00:00
let elem = selectedElements [ 0 ] ;
2018-05-18 04:02:30 +00:00
if ( ! elem ) { return ; }
if ( elem . tagName !== 'a' ) {
// See if parent is an anchor
2018-05-18 03:25:45 +00:00
const parentsA = $ ( elem ) . parents ( 'a' ) ;
2018-05-18 04:02:30 +00:00
if ( parentsA . length ) {
elem = parentsA [ 0 ] ;
} else {
return ;
}
}
2018-05-16 00:53:27 +00:00
2018-05-18 03:25:45 +00:00
const curHref = getHref ( elem ) ;
2018-05-16 00:53:27 +00:00
2018-05-18 04:02:30 +00:00
if ( curHref === val ) { return ; }
2018-05-16 00:53:27 +00:00
2018-05-18 03:25:45 +00:00
const batchCmd = new BatchCommand ( 'Change Link URL' ) ;
2010-12-01 17:54:11 +00:00
2018-05-18 04:02:30 +00:00
setHref ( elem , val ) ;
2018-05-18 03:25:45 +00:00
batchCmd . addSubCommand ( new ChangeElementCommand ( elem , {
2018-05-18 04:02:30 +00:00
'#href' : curHref
} ) ) ;
2010-12-01 17:54:11 +00:00
2018-05-18 04:02:30 +00:00
addCommandToHistory ( batchCmd ) ;
2010-12-01 17:54:11 +00:00
} ;
2010-06-29 20:43:44 +00:00
// Function: setRectRadius
// Sets the rx & ry values to the selected rect element to change its corner radius
2018-05-16 00:53:27 +00:00
//
2010-06-29 20:43:44 +00:00
// Parameters:
// val - The new radius
2018-05-16 08:32:44 +00:00
this . setRectRadius = function ( val ) {
2018-05-18 03:25:45 +00:00
const selected = selectedElements [ 0 ] ;
2018-05-18 04:02:30 +00:00
if ( selected != null && selected . tagName === 'rect' ) {
2018-05-18 03:25:45 +00:00
const r = selected . getAttribute ( 'rx' ) ;
2018-05-18 04:02:30 +00:00
if ( r !== String ( val ) ) {
selected . setAttribute ( 'rx' , val ) ;
selected . setAttribute ( 'ry' , val ) ;
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
addCommandToHistory ( new ChangeElementCommand ( selected , { rx : r , ry : r } , 'Radius' ) ) ;
2018-05-18 04:02:30 +00:00
call ( 'changed' , [ selected ] ) ;
}
}
2010-06-22 14:52:51 +00:00
} ;
2009-06-29 14:38:30 +00:00
2010-12-01 17:54:11 +00:00
// Function: makeHyperlink
// Wraps the selected element(s) in an anchor element or converts group to one
2018-05-16 08:32:44 +00:00
this . makeHyperlink = function ( url ) {
2018-05-18 04:02:30 +00:00
canvas . groupSelectedElements ( 'a' , url ) ;
2018-05-16 00:53:27 +00:00
2018-05-18 04:02:30 +00:00
// TODO: If element is a single "g", convert to "a"
2018-05-18 06:41:43 +00:00
// if (selectedElements.length > 1 && selectedElements[1]) {
2013-02-15 15:51:58 +00:00
} ;
2010-12-01 17:54:11 +00:00
// Function: removeHyperlink
2018-05-16 08:32:44 +00:00
this . removeHyperlink = function ( ) {
2018-05-18 04:02:30 +00:00
canvas . ungroupSelectedElement ( ) ;
2013-02-15 15:51:58 +00:00
} ;
2010-12-01 17:54:11 +00:00
2010-06-30 18:27:36 +00:00
// Group: Element manipulation
2010-06-29 20:43:44 +00:00
// Function: setSegType
2018-05-16 00:53:27 +00:00
// Sets the new segment type to the selected segment(s).
2010-06-29 20:43:44 +00:00
//
// Parameters:
// new_type - Integer with the new segment type
2018-05-18 04:40:50 +00:00
// See https://www.w3.org/TR/SVG/paths.html#InterfaceSVGPathSeg for list
2018-05-16 08:32:44 +00:00
this . setSegType = function ( newType ) {
2018-05-18 04:02:30 +00:00
pathActions . setSegType ( newType ) ;
2014-02-17 06:48:40 +00:00
} ;
2010-06-22 14:52:51 +00:00
2010-11-15 09:25:49 +00:00
// TODO(codedread): Remove the getBBox argument and split this function into two.
2010-06-30 18:27:36 +00:00
// Function: convertToPath
// Convert selected element to a path, or get the BBox of an element-as-path
//
2018-05-16 00:53:27 +00:00
// Parameters:
2010-06-30 18:27:36 +00:00
// elem - The DOM element to be converted
// getBBox - Boolean on whether or not to only return the path's BBox
//
// Returns:
// If the getBBox flag is true, the resulting path's bounding box object.
// Otherwise the resulting path element is returned.
2018-05-16 08:32:44 +00:00
this . convertToPath = function ( elem , getBBox ) {
2018-05-18 04:02:30 +00:00
if ( elem == null ) {
2018-05-18 03:25:45 +00:00
const elems = selectedElements ;
2018-05-18 04:02:30 +00:00
$ . each ( elems , function ( i , elem ) {
if ( elem ) { canvas . convertToPath ( elem ) ; }
} ) ;
return ;
}
if ( getBBox ) {
2018-05-18 03:25:45 +00:00
return getBBoxOfElementAsPath ( elem , addSvgElementFromJson , pathActions ) ;
2018-05-18 04:02:30 +00:00
} else {
// TODO: Why is this applying attributes from curShape, then inside utilities.convertToPath it's pulling addition attributes from elem?
// TODO: If convertToPath is called with one elem, curShape and elem are probably the same; but calling with multiple is a bug or cool feature.
2018-05-18 03:25:45 +00:00
const attrs = {
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
fill : curShape . fill ,
2018-05-18 04:02:30 +00:00
'fill-opacity' : curShape . fill _opacity ,
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
stroke : curShape . stroke ,
2018-05-18 04:02:30 +00:00
'stroke-width' : curShape . stroke _width ,
'stroke-dasharray' : curShape . stroke _dasharray ,
'stroke-linejoin' : curShape . stroke _linejoin ,
'stroke-linecap' : curShape . stroke _linecap ,
'stroke-opacity' : curShape . stroke _opacity ,
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
opacity : curShape . opacity ,
visibility : 'hidden'
2018-05-18 04:02:30 +00:00
} ;
2018-05-18 03:25:45 +00:00
return convertToPath ( elem , attrs , addSvgElementFromJson , pathActions , clearSelection , addToSelection , history , addCommandToHistory ) ;
2018-05-18 04:02:30 +00:00
}
2010-11-08 07:23:26 +00:00
} ;
2010-06-30 18:27:36 +00:00
// Function: changeSelectedAttributeNoUndo
// This function makes the changes to the elements. It does not add the change
2018-05-16 00:53:27 +00:00
// to the history stack.
//
2010-06-30 18:27:36 +00:00
// Parameters:
// attr - String with the attribute name
// newValue - String or number with the new attribute value
// elems - The DOM elements to apply the change to
2018-05-18 03:25:45 +00:00
const changeSelectedAttributeNoUndo = function ( attr , newValue , elems ) {
2018-05-18 04:02:30 +00:00
if ( currentMode === 'pathedit' ) {
// Editing node
pathActions . moveNode ( attr , newValue ) ;
}
elems = elems || selectedElements ;
2018-05-18 03:25:45 +00:00
let i = elems . length ;
const noXYElems = [ 'g' , 'polyline' , 'path' ] ;
const goodGAttrs = [ 'transform' , 'opacity' , 'filter' ] ;
2018-05-18 04:02:30 +00:00
while ( i -- ) {
2018-05-18 03:25:45 +00:00
let elem = elems [ i ] ;
2018-05-18 04:02:30 +00:00
if ( elem == null ) { continue ; }
// Set x,y vals on elements that don't have them
2018-05-18 03:25:45 +00:00
if ( ( attr === 'x' || attr === 'y' ) && noXYElems . includes ( elem . tagName ) ) {
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
const bbox = getStrokedBBoxDefaultVisible ( [ elem ] ) ;
2018-05-18 03:25:45 +00:00
const diffX = attr === 'x' ? newValue - bbox . x : 0 ;
const diffY = attr === 'y' ? newValue - bbox . y : 0 ;
2018-05-18 04:02:30 +00:00
canvas . moveSelectedElements ( diffX * currentZoom , diffY * currentZoom , true ) ;
continue ;
}
// only allow the transform/opacity/filter attribute to change on <g> elements, slightly hacky
// TODO: FIXME: This doesn't seem right. Where's the body of this if statement?
2018-05-18 03:25:45 +00:00
if ( elem . tagName === 'g' && goodGAttrs . includes ( attr ) ) { }
let oldval = attr === '#text' ? elem . textContent : elem . getAttribute ( attr ) ;
2018-05-18 04:02:30 +00:00
if ( oldval == null ) { oldval = '' ; }
if ( oldval !== String ( newValue ) ) {
if ( attr === '#text' ) {
2018-05-18 03:25:45 +00:00
// const oldW = utilsGetBBox(elem).width;
2018-05-18 04:02:30 +00:00
elem . textContent = newValue ;
// FF bug occurs on on rotated elements
if ( ( /rotate/ ) . test ( elem . getAttribute ( 'transform' ) ) ) {
elem = ffClone ( elem ) ;
}
// Hoped to solve the issue of moving text with text-anchor="start",
// but this doesn't actually fix it. Hopefully on the right track, though. -Fyrd
2018-05-18 03:25:45 +00:00
// const box = getBBox(elem), left = box.x, top = box.y, {width, height} = box,
// dx = width - oldW, dy = 0;
// const angle = getRotationAngle(elem, true);
2018-05-18 04:02:30 +00:00
// if (angle) {
2018-05-18 03:25:45 +00:00
// const r = Math.sqrt(dx * dx + dy * dy);
// const theta = Math.atan2(dy, dx) - angle;
2018-05-18 06:41:43 +00:00
// dx = r * Math.cos(theta);
// dy = r * Math.sin(theta);
2018-05-18 04:02:30 +00:00
//
2018-05-18 06:41:43 +00:00
// elem.setAttribute('x', elem.getAttribute('x') - dx);
// elem.setAttribute('y', elem.getAttribute('y') - dy);
2018-05-18 04:02:30 +00:00
// }
} else if ( attr === '#href' ) {
setHref ( elem , newValue ) ;
} else { elem . setAttribute ( attr , newValue ) ; }
// Go into "select" mode for text changes
// NOTE: Important that this happens AFTER elem.setAttribute() or else attributes like
// font-size can get reset to their old value, ultimately by svgEditor.updateContextPanel(),
// after calling textActions.toSelectMode() below
if ( currentMode === 'textedit' && attr !== '#text' && elem . textContent . length ) {
textActions . toSelectMode ( elem ) ;
}
// if (i === 0) {
2018-05-18 03:25:45 +00:00
// selectedBBoxes[0] = utilsGetBBox(elem);
2018-05-18 04:02:30 +00:00
// }
// Use the Firefox ffClone hack for text elements with gradients or
// where other text attributes are changed.
2018-05-18 03:25:45 +00:00
if ( isGecko ( ) && elem . nodeName === 'text' && ( /rotate/ ) . test ( elem . getAttribute ( 'transform' ) ) ) {
if ( String ( newValue ) . startsWith ( 'url' ) || ( [ 'font-size' , 'font-family' , 'x' , 'y' ] . includes ( attr ) && elem . textContent ) ) {
2018-05-18 04:02:30 +00:00
elem = ffClone ( elem ) ;
}
}
// Timeout needed for Opera & Firefox
// codedread: it is now possible for this function to be called with elements
// that are not in the selectedElements array, we need to only request a
// selector if the element is in that array
2018-05-18 03:25:45 +00:00
if ( selectedElements . includes ( elem ) ) {
2018-05-18 04:02:30 +00:00
setTimeout ( function ( ) {
// Due to element replacement, this element may no longer
// be part of the DOM
if ( ! elem . parentNode ) { return ; }
selectorManager . requestSelector ( elem ) . resize ( ) ;
} , 0 ) ;
}
// if this element was rotated, and we changed the position of this element
// we need to update the rotational transform attribute
2018-05-18 03:25:45 +00:00
const angle = getRotationAngle ( elem ) ;
2018-05-18 04:02:30 +00:00
if ( angle !== 0 && attr !== 'transform' ) {
2018-05-18 03:25:45 +00:00
const tlist = getTransformList ( elem ) ;
let n = tlist . numberOfItems ;
2018-05-18 04:02:30 +00:00
while ( n -- ) {
2018-05-18 03:25:45 +00:00
const xform = tlist . getItem ( n ) ;
2018-05-18 04:02:30 +00:00
if ( xform . type === 4 ) {
// remove old rotate
tlist . removeItem ( n ) ;
2018-05-18 03:25:45 +00:00
const box = utilsGetBBox ( elem ) ;
const center = transformPoint ( box . x + box . width / 2 , box . y + box . height / 2 , transformListToTransform ( tlist ) . matrix ) ;
const cx = center . x ,
2018-05-18 04:02:30 +00:00
cy = center . y ;
2018-05-18 03:25:45 +00:00
const newrot = svgroot . createSVGTransform ( ) ;
2018-05-18 04:02:30 +00:00
newrot . setRotate ( angle , cx , cy ) ;
tlist . insertItemBefore ( newrot , n ) ;
break ;
}
}
}
} // if oldValue != newValue
} // for each elem
2010-06-22 14:52:51 +00:00
} ;
2010-06-21 18:06:21 +00:00
2010-06-29 20:43:44 +00:00
// Function: changeSelectedAttribute
// Change the given/selected element and add the original value to the history stack
2010-06-22 14:52:51 +00:00
// If you want to change all selectedElements, ignore the elems argument.
// If you want to change only a subset of selectedElements, then send the
// subset to this function in the elems argument.
2018-05-16 00:53:27 +00:00
//
2010-06-29 20:43:44 +00:00
// Parameters:
// attr - String with the attribute name
// newValue - String or number with the new attribute value
// elems - The DOM elements to apply the change to
2018-05-18 03:25:45 +00:00
const changeSelectedAttribute = this . changeSelectedAttribute = function ( attr , val , elems ) {
2018-05-18 04:02:30 +00:00
elems = elems || selectedElements ;
canvas . undoMgr . beginUndoableChange ( attr , elems ) ;
2018-05-18 03:25:45 +00:00
// const i = elems.length;
2009-09-04 05:10:48 +00:00
2018-05-18 04:02:30 +00:00
changeSelectedAttributeNoUndo ( attr , val , elems ) ;
2010-06-22 14:52:51 +00:00
2018-05-18 03:25:45 +00:00
const batchCmd = canvas . undoMgr . finishUndoableChange ( ) ;
2018-05-18 04:02:30 +00:00
if ( ! batchCmd . isEmpty ( ) ) {
addCommandToHistory ( batchCmd ) ;
}
2010-06-22 14:52:51 +00:00
} ;
2010-06-29 20:43:44 +00:00
// Function: deleteSelectedElements
2018-05-16 00:53:27 +00:00
// Removes all selected elements from the DOM and adds the change to the
2010-06-29 20:43:44 +00:00
// history stack
2018-05-16 08:32:44 +00:00
this . deleteSelectedElements = function ( ) {
2018-05-18 03:25:45 +00:00
const batchCmd = new BatchCommand ( 'Delete Elements' ) ;
const len = selectedElements . length ;
const selectedCopy = [ ] ; // selectedElements is being deleted
2018-01-18 12:37:49 +00:00
2018-05-18 03:25:45 +00:00
for ( let i = 0 ; i < len ; ++ i ) {
const selected = selectedElements [ i ] ;
2018-05-18 04:02:30 +00:00
if ( selected == null ) { break ; }
2010-06-22 14:52:51 +00:00
2018-05-18 03:25:45 +00:00
let parent = selected . parentNode ;
let t = selected ;
2018-05-16 00:53:27 +00:00
2018-05-18 04:02:30 +00:00
// this will unselect the element and remove the selectedOutline
selectorManager . releaseSelector ( t ) ;
2018-05-16 00:53:27 +00:00
2018-05-18 04:02:30 +00:00
// Remove the path if present.
2018-05-18 03:25:45 +00:00
pathModule . removePath _ ( t . id ) ;
2018-05-16 00:53:27 +00:00
2018-05-18 04:02:30 +00:00
// Get the parent if it's a single-child anchor
if ( parent . tagName === 'a' && parent . childNodes . length === 1 ) {
t = parent ;
parent = parent . parentNode ;
}
2018-05-16 00:53:27 +00:00
2018-05-18 03:25:45 +00:00
const { nextSibling } = t ;
const elem = parent . removeChild ( t ) ;
2018-05-18 04:02:30 +00:00
selectedCopy . push ( selected ) ; // for the copy
batchCmd . addSubCommand ( new RemoveElementCommand ( elem , nextSibling , parent ) ) ;
}
selectedElements = [ ] ;
2018-01-18 12:37:49 +00:00
2018-05-18 04:02:30 +00:00
if ( ! batchCmd . isEmpty ( ) ) { addCommandToHistory ( batchCmd ) ; }
call ( 'changed' , selectedCopy ) ;
clearSelection ( ) ;
2010-06-22 14:52:51 +00:00
} ;
2018-05-18 03:25:45 +00:00
/ * *
* Removes all selected elements from the DOM and adds the change to the
* history stack . Remembers removed elements on the clipboard
* /
2018-05-16 08:32:44 +00:00
this . cutSelectedElements = function ( ) {
2018-05-18 03:25:45 +00:00
canvas . copySelectedElements ( ) ;
canvas . deleteSelectedElements ( ) ;
2010-08-17 18:09:50 +00:00
} ;
2018-05-18 03:25:45 +00:00
/ * *
* Remembers the current selected elements on the clipboard
* /
2018-05-16 08:32:44 +00:00
this . copySelectedElements = function ( ) {
2018-05-18 04:02:30 +00:00
localStorage . setItem ( 'svgedit_clipboard' , JSON . stringify (
selectedElements . map ( function ( x ) { return getJsonFromSvgElement ( x ) ; } )
) ) ;
2018-01-18 12:37:49 +00:00
2018-05-18 04:02:30 +00:00
$ ( '#cmenu_canvas' ) . enableContextMenuItems ( '#paste,#paste_in_place' ) ;
2010-08-17 18:09:50 +00:00
} ;
2018-05-16 08:32:44 +00:00
this . pasteElements = function ( type , x , y ) {
2018-05-18 03:25:45 +00:00
let cb = JSON . parse ( localStorage . getItem ( 'svgedit_clipboard' ) ) ;
let len = cb . length ;
2018-05-18 04:02:30 +00:00
if ( ! len ) { return ; }
2018-05-18 03:25:45 +00:00
const pasted = [ ] ;
const batchCmd = new BatchCommand ( 'Paste elements' ) ;
// const drawing = getCurrentDrawing();
const changedIDs = { } ;
2018-05-18 04:02:30 +00:00
// Recursively replace IDs and record the changes
function checkIDs ( elem ) {
if ( elem . attr && elem . attr . id ) {
changedIDs [ elem . attr . id ] = getNextId ( ) ;
elem . attr . id = changedIDs [ elem . attr . id ] ;
}
if ( elem . children ) elem . children . forEach ( checkIDs ) ;
}
cb . forEach ( checkIDs ) ;
// Give extensions like the connector extension a chance to reflect new IDs and remove invalid elements
runExtensions ( 'IDsUpdated' , { elems : cb , changes : changedIDs } , true ) . forEach ( function ( extChanges ) {
if ( ! extChanges || ! ( 'remove' in extChanges ) ) return ;
extChanges . remove . forEach ( function ( removeID ) {
cb = cb . filter ( function ( cbItem ) {
return cbItem . attr . id !== removeID ;
} ) ;
} ) ;
} ) ;
// Move elements to lastClickPoint
while ( len -- ) {
2018-05-18 03:25:45 +00:00
const elem = cb [ len ] ;
2018-05-18 04:02:30 +00:00
if ( ! elem ) { continue ; }
2018-05-18 03:25:45 +00:00
const copy = addSvgElementFromJson ( elem ) ;
2018-05-18 04:02:30 +00:00
pasted . push ( copy ) ;
2018-05-18 03:25:45 +00:00
batchCmd . addSubCommand ( new InsertElementCommand ( copy ) ) ;
2018-05-18 04:02:30 +00:00
restoreRefElems ( copy ) ;
}
selectOnly ( pasted ) ;
if ( type !== 'in_place' ) {
2018-05-18 03:25:45 +00:00
let ctrX , ctrY ;
2018-05-18 04:02:30 +00:00
if ( ! type ) {
ctrX = lastClickPoint . x ;
ctrY = lastClickPoint . y ;
} else if ( type === 'point' ) {
ctrX = x ;
ctrY = y ;
}
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
const bbox = getStrokedBBoxDefaultVisible ( pasted ) ;
2018-05-18 03:25:45 +00:00
const cx = ctrX - ( bbox . x + bbox . width / 2 ) ,
2018-05-18 04:02:30 +00:00
cy = ctrY - ( bbox . y + bbox . height / 2 ) ,
dx = [ ] ,
dy = [ ] ;
$ . each ( pasted , function ( i , item ) {
dx . push ( cx ) ;
dy . push ( cy ) ;
} ) ;
2018-05-18 03:25:45 +00:00
const cmd = canvas . moveSelectedElements ( dx , dy , false ) ;
2018-05-18 04:02:30 +00:00
if ( cmd ) batchCmd . addSubCommand ( cmd ) ;
}
addCommandToHistory ( batchCmd ) ;
call ( 'changed' , pasted ) ;
2013-02-15 15:51:58 +00:00
} ;
2010-08-17 18:09:50 +00:00
2010-06-29 20:43:44 +00:00
// Function: groupSelectedElements
// Wraps all the selected elements in a group (g) element
2010-12-01 17:54:11 +00:00
2018-05-16 00:53:27 +00:00
// Parameters:
2010-12-01 17:54:11 +00:00
// type - type of element to group into, defaults to <g>
2018-05-16 08:32:44 +00:00
this . groupSelectedElements = function ( type , urlArg ) {
2018-05-18 04:02:30 +00:00
if ( ! type ) { type = 'g' ; }
2018-05-18 03:25:45 +00:00
let cmdStr = '' ;
let url ;
2018-05-18 04:02:30 +00:00
switch ( type ) {
2018-05-18 03:25:45 +00:00
case 'a' : {
2018-05-18 04:02:30 +00:00
cmdStr = 'Make hyperlink' ;
2018-05-18 03:25:45 +00:00
url = '' ;
2018-05-18 04:02:30 +00:00
if ( arguments . length > 1 ) {
url = urlArg ;
}
break ;
2018-05-18 03:25:45 +00:00
} default : {
2018-05-18 04:02:30 +00:00
type = 'g' ;
cmdStr = 'Group Elements' ;
break ;
}
2018-05-18 03:25:45 +00:00
}
2018-05-18 04:02:30 +00:00
2018-05-18 03:25:45 +00:00
const batchCmd = new BatchCommand ( cmdStr ) ;
2018-05-18 04:02:30 +00:00
// create and insert the group element
2018-05-18 03:25:45 +00:00
const g = addSvgElementFromJson ( {
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
element : type ,
attr : {
id : getNextId ( )
2018-05-18 04:02:30 +00:00
}
} ) ;
if ( type === 'a' ) {
setHref ( g , url ) ;
}
2018-05-18 03:25:45 +00:00
batchCmd . addSubCommand ( new InsertElementCommand ( g ) ) ;
2018-05-18 04:02:30 +00:00
// now move all children into the group
2018-05-18 03:25:45 +00:00
let i = selectedElements . length ;
2018-05-18 04:02:30 +00:00
while ( i -- ) {
2018-05-18 03:25:45 +00:00
let elem = selectedElements [ i ] ;
2018-05-18 04:02:30 +00:00
if ( elem == null ) { continue ; }
if ( elem . parentNode . tagName === 'a' && elem . parentNode . childNodes . length === 1 ) {
elem = elem . parentNode ;
}
2018-05-18 03:25:45 +00:00
const oldNextSibling = elem . nextSibling ;
const oldParent = elem . parentNode ;
2018-05-18 04:02:30 +00:00
g . appendChild ( elem ) ;
2018-05-18 03:25:45 +00:00
batchCmd . addSubCommand ( new MoveElementCommand ( elem , oldNextSibling , oldParent ) ) ;
2018-05-18 04:02:30 +00:00
}
if ( ! batchCmd . isEmpty ( ) ) { addCommandToHistory ( batchCmd ) ; }
// update selection
selectOnly ( [ g ] , true ) ;
2010-06-22 14:52:51 +00:00
} ;
2010-10-20 18:07:30 +00:00
// Function: pushGroupProperties
// Pushes all appropriate parent group properties down to its children, then
// removes them from the group
2018-05-18 03:25:45 +00:00
const pushGroupProperties = this . pushGroupProperties = function ( g , undoable ) {
const children = g . childNodes ;
const len = children . length ;
const xform = g . getAttribute ( 'transform' ) ;
2018-05-18 04:02:30 +00:00
2018-05-18 03:25:45 +00:00
const glist = getTransformList ( g ) ;
const m = transformListToTransform ( glist ) . matrix ;
2018-05-18 04:02:30 +00:00
2018-05-18 03:25:45 +00:00
const batchCmd = new BatchCommand ( 'Push group properties' ) ;
2018-05-18 04:02:30 +00:00
// TODO: get all fill/stroke properties from the group that we are about to destroy
// "fill", "fill-opacity", "fill-rule", "stroke", "stroke-dasharray", "stroke-dashoffset",
// "stroke-linecap", "stroke-linejoin", "stroke-miterlimit", "stroke-opacity",
// "stroke-width"
// and then for each child, if they do not have the attribute (or the value is 'inherit')
// then set the child's attribute
2018-05-18 03:25:45 +00:00
const gangle = getRotationAngle ( g ) ;
2018-05-18 04:02:30 +00:00
2018-05-18 03:25:45 +00:00
const gattrs = $ ( g ) . attr ( [ 'filter' , 'opacity' ] ) ;
let gfilter , gblur , changes ;
const drawing = getCurrentDrawing ( ) ;
2018-05-18 04:02:30 +00:00
2018-05-18 03:25:45 +00:00
for ( let i = 0 ; i < len ; i ++ ) {
const elem = children [ i ] ;
2018-05-18 04:02:30 +00:00
if ( elem . nodeType !== 1 ) { continue ; }
if ( gattrs . opacity !== null && gattrs . opacity !== 1 ) {
2018-05-18 03:25:45 +00:00
// const c_opac = elem.getAttribute('opacity') || 1;
const newOpac = Math . round ( ( elem . getAttribute ( 'opacity' ) || 1 ) * gattrs . opacity * 100 ) / 100 ;
2018-05-18 04:02:30 +00:00
changeSelectedAttribute ( 'opacity' , newOpac , [ elem ] ) ;
}
if ( gattrs . filter ) {
2018-05-18 03:25:45 +00:00
let cblur = this . getBlur ( elem ) ;
const origCblur = cblur ;
2018-05-18 04:02:30 +00:00
if ( ! gblur ) { gblur = this . getBlur ( g ) ; }
if ( cblur ) {
// Is this formula correct?
cblur = Number ( gblur ) + Number ( cblur ) ;
} else if ( cblur === 0 ) {
cblur = gblur ;
}
// If child has no current filter, get group's filter or clone it.
if ( ! origCblur ) {
// Set group's filter to use first child's ID
if ( ! gfilter ) {
2018-05-18 03:25:45 +00:00
gfilter = getRefElem ( gattrs . filter ) ;
2018-05-18 04:02:30 +00:00
} else {
// Clone the group's filter
gfilter = drawing . copyElem ( gfilter ) ;
2018-05-18 03:25:45 +00:00
findDefs ( ) . appendChild ( gfilter ) ;
2018-05-18 04:02:30 +00:00
}
} else {
2018-05-18 03:25:45 +00:00
gfilter = getRefElem ( elem . getAttribute ( 'filter' ) ) ;
2018-05-18 04:02:30 +00:00
}
// Change this in future for different filters
2018-05-18 03:25:45 +00:00
const suffix = ( gfilter . firstChild . tagName === 'feGaussianBlur' ) ? 'blur' : 'filter' ;
2018-05-18 04:02:30 +00:00
gfilter . id = elem . id + '_' + suffix ;
changeSelectedAttribute ( 'filter' , 'url(#' + gfilter . id + ')' , [ elem ] ) ;
// Update blur value
if ( cblur ) {
changeSelectedAttribute ( 'stdDeviation' , cblur , [ gfilter . firstChild ] ) ;
canvas . setBlurOffsets ( gfilter , cblur ) ;
}
}
2018-05-18 03:25:45 +00:00
let chtlist = getTransformList ( elem ) ;
2018-05-18 04:02:30 +00:00
// Don't process gradient transforms
2018-05-18 03:25:45 +00:00
if ( elem . tagName . includes ( 'Gradient' ) ) { chtlist = null ; }
2018-05-18 04:02:30 +00:00
// Hopefully not a problem to add this. Necessary for elements like <desc/>
if ( ! chtlist ) { continue ; }
// Apparently <defs> can get get a transformlist, but we don't want it to have one!
if ( elem . tagName === 'defs' ) { continue ; }
if ( glist . numberOfItems ) {
// TODO: if the group's transform is just a rotate, we can always transfer the
// rotate() down to the children (collapsing consecutive rotates and factoring
// out any translates)
if ( gangle && glist . numberOfItems === 1 ) {
// [Rg] [Rc] [Mc]
// we want [Tr] [Rc2] [Mc] where:
2018-05-18 06:41:43 +00:00
// - [Rc2] is at the child's current center but has the
2018-05-18 04:02:30 +00:00
// sum of the group and child's rotation angles
2018-05-18 06:41:43 +00:00
// - [Tr] is the equivalent translation that this child
2018-05-18 04:02:30 +00:00
// undergoes if the group wasn't there
// [Tr] = [Rg] [Rc] [Rc2_inv]
// get group's rotation matrix (Rg)
2018-05-18 03:25:45 +00:00
const rgm = glist . getItem ( 0 ) . matrix ;
2018-05-18 04:02:30 +00:00
// get child's rotation matrix (Rc)
2018-05-18 03:25:45 +00:00
let rcm = svgroot . createSVGMatrix ( ) ;
const cangle = getRotationAngle ( elem ) ;
2018-05-18 04:02:30 +00:00
if ( cangle ) {
rcm = chtlist . getItem ( 0 ) . matrix ;
}
// get child's old center of rotation
2018-05-18 03:25:45 +00:00
const cbox = utilsGetBBox ( elem ) ;
const ceqm = transformListToTransform ( chtlist ) . matrix ;
const coldc = transformPoint ( cbox . x + cbox . width / 2 , cbox . y + cbox . height / 2 , ceqm ) ;
2018-05-18 04:02:30 +00:00
// sum group and child's angles
2018-05-18 03:25:45 +00:00
const sangle = gangle + cangle ;
2018-05-18 04:02:30 +00:00
// get child's rotation at the old center (Rc2_inv)
2018-05-18 03:25:45 +00:00
const r2 = svgroot . createSVGTransform ( ) ;
2018-05-18 04:02:30 +00:00
r2 . setRotate ( sangle , coldc . x , coldc . y ) ;
// calculate equivalent translate
2018-05-18 03:25:45 +00:00
const trm = matrixMultiply ( rgm , rcm , r2 . matrix . inverse ( ) ) ;
2018-05-18 04:02:30 +00:00
// set up tlist
if ( cangle ) {
chtlist . removeItem ( 0 ) ;
}
if ( sangle ) {
if ( chtlist . numberOfItems ) {
chtlist . insertItemBefore ( r2 , 0 ) ;
} else {
chtlist . appendItem ( r2 ) ;
}
}
if ( trm . e || trm . f ) {
2018-05-18 03:25:45 +00:00
const tr = svgroot . createSVGTransform ( ) ;
2018-05-18 04:02:30 +00:00
tr . setTranslate ( trm . e , trm . f ) ;
if ( chtlist . numberOfItems ) {
chtlist . insertItemBefore ( tr , 0 ) ;
} else {
chtlist . appendItem ( tr ) ;
}
}
} else { // more complicated than just a rotate
// transfer the group's transform down to each child and then
2018-05-18 03:25:45 +00:00
// call recalculateDimensions()
const oldxform = elem . getAttribute ( 'transform' ) ;
2018-05-18 04:02:30 +00:00
changes = { } ;
changes . transform = oldxform || '' ;
2018-05-18 03:25:45 +00:00
const newxform = svgroot . createSVGTransform ( ) ;
2018-05-18 04:02:30 +00:00
// [ gm ] [ chm ] = [ chm ] [ gm' ]
// [ gm' ] = [ chmInv ] [ gm ] [ chm ]
2018-05-18 03:25:45 +00:00
const chm = transformListToTransform ( chtlist ) . matrix ,
2018-05-18 04:02:30 +00:00
chmInv = chm . inverse ( ) ;
2018-05-18 03:25:45 +00:00
const gm = matrixMultiply ( chmInv , m , chm ) ;
2018-05-18 04:02:30 +00:00
newxform . setMatrix ( gm ) ;
chtlist . appendItem ( newxform ) ;
}
2018-05-18 03:25:45 +00:00
const cmd = recalculateDimensions ( elem ) ;
2018-05-18 04:02:30 +00:00
if ( cmd ) { batchCmd . addSubCommand ( cmd ) ; }
}
}
// remove transform and make it undo-able
if ( xform ) {
changes = { } ;
changes . transform = xform ;
g . setAttribute ( 'transform' , '' ) ;
g . removeAttribute ( 'transform' ) ;
2018-05-18 03:25:45 +00:00
batchCmd . addSubCommand ( new ChangeElementCommand ( g , changes ) ) ;
2018-05-18 04:02:30 +00:00
}
if ( undoable && ! batchCmd . isEmpty ( ) ) {
return batchCmd ;
}
2013-02-15 15:51:58 +00:00
} ;
2010-10-20 18:07:30 +00:00
2010-06-29 20:43:44 +00:00
// Function: ungroupSelectedElement
// Unwraps all the elements in a selected group (g) element. This requires
// significant recalculations to apply group's transforms, etc to its children
2018-05-16 08:32:44 +00:00
this . ungroupSelectedElement = function ( ) {
2018-05-18 03:25:45 +00:00
let g = selectedElements [ 0 ] ;
2018-05-18 04:02:30 +00:00
if ( ! g ) {
return ;
}
if ( $ ( g ) . data ( 'gsvg' ) || $ ( g ) . data ( 'symbol' ) ) {
// Is svg, so actually convert to group
convertToGroup ( g ) ;
return ;
}
if ( g . tagName === 'use' ) {
// Somehow doesn't have data set, so retrieve
2018-05-18 03:25:45 +00:00
const symbol = getElem ( getHref ( g ) . substr ( 1 ) ) ;
2018-05-18 04:02:30 +00:00
$ ( g ) . data ( 'symbol' , symbol ) . data ( 'ref' , symbol ) ;
convertToGroup ( g ) ;
return ;
}
2018-05-18 03:25:45 +00:00
const parentsA = $ ( g ) . parents ( 'a' ) ;
2018-05-18 04:02:30 +00:00
if ( parentsA . length ) {
g = parentsA [ 0 ] ;
}
// Look for parent "a"
if ( g . tagName === 'g' || g . tagName === 'a' ) {
2018-05-18 03:25:45 +00:00
const batchCmd = new BatchCommand ( 'Ungroup Elements' ) ;
const cmd = pushGroupProperties ( g , true ) ;
2018-05-18 04:02:30 +00:00
if ( cmd ) { batchCmd . addSubCommand ( cmd ) ; }
2018-05-18 03:25:45 +00:00
const parent = g . parentNode ;
const anchor = g . nextSibling ;
const children = new Array ( g . childNodes . length ) ;
2018-05-18 04:02:30 +00:00
2018-05-18 03:25:45 +00:00
let i = 0 ;
2018-05-18 04:02:30 +00:00
while ( g . firstChild ) {
2018-05-18 03:25:45 +00:00
let elem = g . firstChild ;
const oldNextSibling = elem . nextSibling ;
const oldParent = elem . parentNode ;
2018-05-18 04:02:30 +00:00
// Remove child title elements
if ( elem . tagName === 'title' ) {
2018-05-18 03:25:45 +00:00
const { nextSibling } = elem ;
batchCmd . addSubCommand ( new RemoveElementCommand ( elem , nextSibling , oldParent ) ) ;
2018-05-18 04:02:30 +00:00
oldParent . removeChild ( elem ) ;
continue ;
}
children [ i ++ ] = elem = parent . insertBefore ( elem , anchor ) ;
2018-05-18 03:25:45 +00:00
batchCmd . addSubCommand ( new MoveElementCommand ( elem , oldNextSibling , oldParent ) ) ;
2018-05-18 04:02:30 +00:00
}
// remove the group from the selection
clearSelection ( ) ;
// delete the group element (but make undo-able)
2018-05-18 03:25:45 +00:00
const gNextSibling = g . nextSibling ;
2018-05-18 04:02:30 +00:00
g = parent . removeChild ( g ) ;
2018-05-18 03:25:45 +00:00
batchCmd . addSubCommand ( new RemoveElementCommand ( g , gNextSibling , parent ) ) ;
2018-05-18 04:02:30 +00:00
if ( ! batchCmd . isEmpty ( ) ) { addCommandToHistory ( batchCmd ) ; }
// update selection
addToSelection ( children ) ;
}
2010-06-30 18:27:36 +00:00
} ;
// Function: moveToTopSelectedElement
// Repositions the selected element to the bottom in the DOM to appear on top of
// other elements
2018-05-16 08:32:44 +00:00
this . moveToTopSelectedElement = function ( ) {
2018-05-18 03:25:45 +00:00
const selected = selectedElements [ 0 ] ;
2018-05-18 04:02:30 +00:00
if ( selected != null ) {
2018-05-18 03:25:45 +00:00
let t = selected ;
const oldParent = t . parentNode ;
const oldNextSibling = t . nextSibling ;
2018-05-18 04:02:30 +00:00
t = t . parentNode . appendChild ( t ) ;
// If the element actually moved position, add the command and fire the changed
// event handler.
if ( oldNextSibling !== t . nextSibling ) {
2018-05-18 03:25:45 +00:00
addCommandToHistory ( new MoveElementCommand ( t , oldNextSibling , oldParent , 'top' ) ) ;
2018-05-18 04:02:30 +00:00
call ( 'changed' , [ t ] ) ;
}
}
2010-06-22 14:52:51 +00:00
} ;
2010-06-30 18:27:36 +00:00
// Function: moveToBottomSelectedElement
2018-05-16 00:53:27 +00:00
// Repositions the selected element to the top in the DOM to appear under
2010-06-30 18:27:36 +00:00
// other elements
2018-05-16 08:32:44 +00:00
this . moveToBottomSelectedElement = function ( ) {
2018-05-18 03:25:45 +00:00
const selected = selectedElements [ 0 ] ;
2018-05-18 04:02:30 +00:00
if ( selected != null ) {
2018-05-18 03:25:45 +00:00
let t = selected ;
const oldParent = t . parentNode ;
const oldNextSibling = t . nextSibling ;
let { firstChild } = t . parentNode ;
2018-05-18 04:02:30 +00:00
if ( firstChild . tagName === 'title' ) {
firstChild = firstChild . nextSibling ;
}
// This can probably be removed, as the defs should not ever apppear
// inside a layer group
if ( firstChild . tagName === 'defs' ) {
firstChild = firstChild . nextSibling ;
}
t = t . parentNode . insertBefore ( t , firstChild ) ;
// If the element actually moved position, add the command and fire the changed
// event handler.
if ( oldNextSibling !== t . nextSibling ) {
2018-05-18 03:25:45 +00:00
addCommandToHistory ( new MoveElementCommand ( t , oldNextSibling , oldParent , 'bottom' ) ) ;
2018-05-18 04:02:30 +00:00
call ( 'changed' , [ t ] ) ;
}
}
2010-06-30 18:27:36 +00:00
} ;
2010-06-22 18:17:42 +00:00
2010-08-20 14:52:55 +00:00
// Function: moveUpDownSelected
// Moves the select element up or down the stack, based on the visibly
// intersecting elements
//
2018-05-16 00:53:27 +00:00
// Parameters:
2010-08-20 14:52:55 +00:00
// dir - String that's either 'Up' or 'Down'
2018-05-16 08:32:44 +00:00
this . moveUpDownSelected = function ( dir ) {
2018-05-18 03:25:45 +00:00
const selected = selectedElements [ 0 ] ;
2018-05-18 04:02:30 +00:00
if ( ! selected ) { return ; }
curBBoxes = [ ] ;
2018-05-18 03:25:45 +00:00
let closest , foundCur ;
2018-05-18 04:02:30 +00:00
// jQuery sorts this list
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
const list = $ ( getIntersectionList ( getStrokedBBoxDefaultVisible ( [ selected ] ) ) ) . toArray ( ) ;
2018-05-18 04:02:30 +00:00
if ( dir === 'Down' ) { list . reverse ( ) ; }
$ . each ( list , function ( ) {
if ( ! foundCur ) {
if ( this === selected ) {
foundCur = true ;
}
return ;
}
closest = this ;
return false ;
} ) ;
if ( ! closest ) { return ; }
2018-05-18 03:25:45 +00:00
const t = selected ;
const oldParent = t . parentNode ;
const oldNextSibling = t . nextSibling ;
2018-05-18 04:02:30 +00:00
$ ( closest ) [ dir === 'Down' ? 'before' : 'after' ] ( t ) ;
// If the element actually moved position, add the command and fire the changed
// event handler.
if ( oldNextSibling !== t . nextSibling ) {
2018-05-18 03:25:45 +00:00
addCommandToHistory ( new MoveElementCommand ( t , oldNextSibling , oldParent , 'Move ' + dir ) ) ;
2018-05-18 04:02:30 +00:00
call ( 'changed' , [ t ] ) ;
}
2011-01-30 16:45:29 +00:00
} ;
2010-08-20 14:52:55 +00:00
2010-06-30 18:27:36 +00:00
// Function: moveSelectedElements
2018-05-16 00:53:27 +00:00
// Moves selected elements on the X/Y axis
2010-06-22 18:17:42 +00:00
//
2010-06-30 18:27:36 +00:00
// Parameters:
// dx - Float with the distance to move on the x-axis
// dy - Float with the distance to move on the y-axis
// undoable - Boolean indicating whether or not the action should be undoable
2010-06-22 18:17:42 +00:00
//
// Returns:
2010-06-30 18:27:36 +00:00
// Batch command for the move
2018-05-16 08:32:44 +00:00
this . moveSelectedElements = function ( dx , dy , undoable ) {
2018-05-18 04:02:30 +00:00
// if undoable is not sent, default to true
// if single values, scale them to the zoom
if ( dx . constructor !== Array ) {
dx /= currentZoom ;
dy /= currentZoom ;
}
undoable = undoable || true ;
2018-05-18 03:25:45 +00:00
const batchCmd = new BatchCommand ( 'position' ) ;
let i = selectedElements . length ;
2018-05-18 04:02:30 +00:00
while ( i -- ) {
2018-05-18 03:25:45 +00:00
const selected = selectedElements [ i ] ;
2018-05-18 04:02:30 +00:00
if ( selected != null ) {
// if (i === 0) {
2018-05-18 03:25:45 +00:00
// selectedBBoxes[0] = utilsGetBBox(selected);
2018-05-18 04:02:30 +00:00
// }
2018-05-18 03:25:45 +00:00
// const b = {};
// for (const j in selectedBBoxes[i]) b[j] = selectedBBoxes[i][j];
2018-05-18 04:02:30 +00:00
// selectedBBoxes[i] = b;
2018-05-18 03:25:45 +00:00
const xform = svgroot . createSVGTransform ( ) ;
const tlist = getTransformList ( selected ) ;
2018-05-18 04:02:30 +00:00
// dx and dy could be arrays
if ( dx . constructor === Array ) {
// if (i === 0) {
2018-05-18 06:41:43 +00:00
// selectedBBoxes[0].x += dx[0];
// selectedBBoxes[0].y += dy[0];
2018-05-18 04:02:30 +00:00
// }
xform . setTranslate ( dx [ i ] , dy [ i ] ) ;
} else {
// if (i === 0) {
2018-05-18 06:41:43 +00:00
// selectedBBoxes[0].x += dx;
// selectedBBoxes[0].y += dy;
2018-05-18 04:02:30 +00:00
// }
xform . setTranslate ( dx , dy ) ;
}
if ( tlist . numberOfItems ) {
tlist . insertItemBefore ( xform , 0 ) ;
} else {
tlist . appendItem ( xform ) ;
}
2018-05-18 03:25:45 +00:00
const cmd = recalculateDimensions ( selected ) ;
2018-05-18 04:02:30 +00:00
if ( cmd ) {
batchCmd . addSubCommand ( cmd ) ;
}
selectorManager . requestSelector ( selected ) . resize ( ) ;
}
}
if ( ! batchCmd . isEmpty ( ) ) {
if ( undoable ) {
addCommandToHistory ( batchCmd ) ;
}
call ( 'changed' , selectedElements ) ;
return batchCmd ;
}
2010-06-22 14:52:51 +00:00
} ;
2010-06-30 18:27:36 +00:00
// Function: cloneSelectedElements
2018-05-16 00:53:27 +00:00
// Create deep DOM copies (clones) of all selected elements and move them slightly
2010-06-30 18:27:36 +00:00
// from their originals
2018-05-16 08:32:44 +00:00
this . cloneSelectedElements = function ( x , y ) {
2018-05-18 03:25:45 +00:00
let i , elem ;
const batchCmd = new BatchCommand ( 'Clone Elements' ) ;
2018-05-18 04:02:30 +00:00
// find all the elements selected (stop at first null)
2018-05-18 03:25:45 +00:00
const len = selectedElements . length ;
2018-05-18 04:02:30 +00:00
function sortfunction ( a , b ) {
return ( $ ( b ) . index ( ) - $ ( a ) . index ( ) ) ; // causes an array to be sorted numerically and ascending
}
selectedElements . sort ( sortfunction ) ;
for ( i = 0 ; i < len ; ++ i ) {
elem = selectedElements [ i ] ;
if ( elem == null ) { break ; }
}
// use slice to quickly get the subset of elements we need
2018-05-18 03:25:45 +00:00
const copiedElements = selectedElements . slice ( 0 , i ) ;
2018-05-18 04:02:30 +00:00
this . clearSelection ( true ) ;
// note that we loop in the reverse way because of the way elements are added
// to the selectedElements array (top-first)
2018-05-18 03:25:45 +00:00
const drawing = getCurrentDrawing ( ) ;
2018-05-18 04:02:30 +00:00
i = copiedElements . length ;
while ( i -- ) {
// clone each element and replace it within copiedElements
elem = copiedElements [ i ] = drawing . copyElem ( copiedElements [ i ] ) ;
( currentGroup || drawing . getCurrentLayer ( ) ) . appendChild ( elem ) ;
2018-05-18 03:25:45 +00:00
batchCmd . addSubCommand ( new InsertElementCommand ( elem ) ) ;
2018-05-18 04:02:30 +00:00
}
if ( ! batchCmd . isEmpty ( ) ) {
addToSelection ( copiedElements . reverse ( ) ) ; // Need to reverse for correct selection-adding
this . moveSelectedElements ( x , y , false ) ;
addCommandToHistory ( batchCmd ) ;
}
2010-06-22 14:52:51 +00:00
} ;
2010-06-30 18:27:36 +00:00
// Function: alignSelectedElements
// Aligns selected elements
//
// Parameters:
// type - String with single character indicating the alignment type
2018-05-16 08:32:44 +00:00
// relativeTo - String that must be one of the following:
2010-06-30 18:27:36 +00:00
// "selected", "largest", "smallest", "page"
2018-05-16 08:32:44 +00:00
this . alignSelectedElements = function ( type , relativeTo ) {
2018-05-18 03:25:45 +00:00
const bboxes = [ ] ; // angles = [];
const len = selectedElements . length ;
2018-05-18 04:02:30 +00:00
if ( ! len ) { return ; }
2018-05-18 03:25:45 +00:00
let minx = Number . MAX _VALUE , maxx = Number . MIN _VALUE ,
miny = Number . MAX _VALUE , maxy = Number . MIN _VALUE ;
let curwidth = Number . MIN _VALUE , curheight = Number . MIN _VALUE ;
for ( let i = 0 ; i < len ; ++ i ) {
2018-05-18 04:02:30 +00:00
if ( selectedElements [ i ] == null ) { break ; }
2018-05-18 03:25:45 +00:00
const elem = selectedElements [ i ] ;
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
bboxes [ i ] = getStrokedBBoxDefaultVisible ( [ elem ] ) ;
2018-05-18 04:02:30 +00:00
// now bbox is axis-aligned and handles rotation
switch ( relativeTo ) {
case 'smallest' :
if ( ( ( type === 'l' || type === 'c' || type === 'r' ) &&
( curwidth === Number . MIN _VALUE || curwidth > bboxes [ i ] . width ) ) ||
( ( type === 't' || type === 'm' || type === 'b' ) &&
( curheight === Number . MIN _VALUE || curheight > bboxes [ i ] . height ) )
) {
minx = bboxes [ i ] . x ;
miny = bboxes [ i ] . y ;
maxx = bboxes [ i ] . x + bboxes [ i ] . width ;
maxy = bboxes [ i ] . y + bboxes [ i ] . height ;
curwidth = bboxes [ i ] . width ;
curheight = bboxes [ i ] . height ;
}
break ;
case 'largest' :
if ( ( ( type === 'l' || type === 'c' || type === 'r' ) &&
( curwidth === Number . MIN _VALUE || curwidth < bboxes [ i ] . width ) ) ||
( ( type === 't' || type === 'm' || type === 'b' ) &&
( curheight === Number . MIN _VALUE || curheight < bboxes [ i ] . height ) )
) {
minx = bboxes [ i ] . x ;
miny = bboxes [ i ] . y ;
maxx = bboxes [ i ] . x + bboxes [ i ] . width ;
maxy = bboxes [ i ] . y + bboxes [ i ] . height ;
curwidth = bboxes [ i ] . width ;
curheight = bboxes [ i ] . height ;
}
break ;
default : // 'selected'
if ( bboxes [ i ] . x < minx ) { minx = bboxes [ i ] . x ; }
if ( bboxes [ i ] . y < miny ) { miny = bboxes [ i ] . y ; }
if ( bboxes [ i ] . x + bboxes [ i ] . width > maxx ) { maxx = bboxes [ i ] . x + bboxes [ i ] . width ; }
if ( bboxes [ i ] . y + bboxes [ i ] . height > maxy ) { maxy = bboxes [ i ] . y + bboxes [ i ] . height ; }
break ;
}
} // loop for each element to find the bbox and adjust min/max
if ( relativeTo === 'page' ) {
minx = 0 ;
miny = 0 ;
maxx = canvas . contentW ;
maxy = canvas . contentH ;
}
2018-05-18 03:25:45 +00:00
const dx = new Array ( len ) ;
const dy = new Array ( len ) ;
for ( let i = 0 ; i < len ; ++ i ) {
2018-05-18 04:02:30 +00:00
if ( selectedElements [ i ] == null ) { break ; }
2018-05-18 03:25:45 +00:00
// const elem = selectedElements[i];
const bbox = bboxes [ i ] ;
2018-05-18 04:02:30 +00:00
dx [ i ] = 0 ;
dy [ i ] = 0 ;
switch ( type ) {
case 'l' : // left (horizontal)
dx [ i ] = minx - bbox . x ;
break ;
case 'c' : // center (horizontal)
dx [ i ] = ( minx + maxx ) / 2 - ( bbox . x + bbox . width / 2 ) ;
break ;
case 'r' : // right (horizontal)
dx [ i ] = maxx - ( bbox . x + bbox . width ) ;
break ;
case 't' : // top (vertical)
dy [ i ] = miny - bbox . y ;
break ;
case 'm' : // middle (vertical)
dy [ i ] = ( miny + maxy ) / 2 - ( bbox . y + bbox . height / 2 ) ;
break ;
case 'b' : // bottom (vertical)
dy [ i ] = maxy - ( bbox . y + bbox . height ) ;
break ;
}
}
this . moveSelectedElements ( dx , dy ) ;
2010-06-22 14:52:51 +00:00
} ;
2010-01-18 20:30:59 +00:00
2010-06-30 18:27:36 +00:00
// Group: Additional editor tools
2009-08-25 07:04:19 +00:00
2010-06-30 18:27:36 +00:00
this . contentW = getResolution ( ) . w ;
this . contentH = getResolution ( ) . h ;
2009-08-25 07:04:19 +00:00
2010-06-30 18:27:36 +00:00
// Function: updateCanvas
2018-05-16 00:53:27 +00:00
// Updates the editor canvas width/height/position after a zoom has occurred
2010-06-30 18:27:36 +00:00
//
// Parameters:
// w - Float with the new width
// h - Float with the new height
//
2018-05-16 00:53:27 +00:00
// Returns:
2010-06-30 18:27:36 +00:00
// Object with the following values:
// * x - The canvas' new x coordinate
// * y - The canvas' new y coordinate
2018-05-16 08:32:44 +00:00
// * oldX - The canvas' old x coordinate
// * oldY - The canvas' old y coordinate
2010-06-30 18:27:36 +00:00
// * d_x - The x position difference
// * d_y - The y position difference
2018-05-16 00:53:27 +00:00
this . updateCanvas = function ( w , h ) {
2018-05-18 04:02:30 +00:00
svgroot . setAttribute ( 'width' , w ) ;
svgroot . setAttribute ( 'height' , h ) ;
2018-05-18 03:25:45 +00:00
const bg = $ ( '#canvasBackground' ) [ 0 ] ;
const oldX = svgcontent . getAttribute ( 'x' ) ;
const oldY = svgcontent . getAttribute ( 'y' ) ;
const x = ( w / 2 - this . contentW * currentZoom / 2 ) ;
const y = ( h / 2 - this . contentH * currentZoom / 2 ) ;
2018-05-18 04:02:30 +00:00
2018-05-18 03:25:45 +00:00
assignAttributes ( svgcontent , {
2018-05-18 04:02:30 +00:00
width : this . contentW * currentZoom ,
height : this . contentH * currentZoom ,
2018-05-18 03:25:45 +00:00
x ,
y ,
viewBox : '0 0 ' + this . contentW + ' ' + this . contentH
2018-05-18 04:02:30 +00:00
} ) ;
2018-05-18 03:25:45 +00:00
assignAttributes ( bg , {
2018-05-18 04:02:30 +00:00
width : svgcontent . getAttribute ( 'width' ) ,
height : svgcontent . getAttribute ( 'height' ) ,
2018-05-18 03:25:45 +00:00
x ,
y
2018-05-18 04:02:30 +00:00
} ) ;
2018-05-18 03:25:45 +00:00
const bgImg = getElem ( 'background_image' ) ;
2018-05-18 04:02:30 +00:00
if ( bgImg ) {
2018-05-18 03:25:45 +00:00
assignAttributes ( bgImg , {
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
width : '100%' ,
height : '100%'
2018-05-18 04:02:30 +00:00
} ) ;
}
selectorManager . selectorParentGroup . setAttribute ( 'transform' , 'translate(' + x + ',' + y + ')' ) ;
runExtensions ( 'canvasUpdated' , { new _x : x , new _y : y , old _x : oldX , old _y : oldY , d _x : x - oldX , d _y : y - oldY } ) ;
2018-05-18 03:25:45 +00:00
return { x , y , old _x : oldX , old _y : oldY , d _x : x - oldX , d _y : y - oldY } ;
2013-02-15 15:51:58 +00:00
} ;
2010-06-22 14:52:51 +00:00
2010-06-30 18:27:36 +00:00
// Function: setBackground
// Set the background of the editor (NOT the actual document)
//
// Parameters:
// color - String with fill color to apply
// url - URL or path to image to use
2018-05-16 08:32:44 +00:00
this . setBackground = function ( color , url ) {
2018-05-18 03:25:45 +00:00
const bg = getElem ( 'canvasBackground' ) ;
const border = $ ( bg ) . find ( 'rect' ) [ 0 ] ;
let bgImg = getElem ( 'background_image' ) ;
2018-05-18 04:02:30 +00:00
border . setAttribute ( 'fill' , color ) ;
if ( url ) {
if ( ! bgImg ) {
bgImg = svgdoc . createElementNS ( NS . SVG , 'image' ) ;
2018-05-18 03:25:45 +00:00
assignAttributes ( bgImg , {
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
id : 'background_image' ,
width : '100%' ,
height : '100%' ,
preserveAspectRatio : 'xMinYMin' ,
style : 'pointer-events:none'
2018-05-18 04:02:30 +00:00
} ) ;
}
setHref ( bgImg , url ) ;
bg . appendChild ( bgImg ) ;
} else if ( bgImg ) {
bgImg . parentNode . removeChild ( bgImg ) ;
}
2013-02-15 15:51:58 +00:00
} ;
2010-06-22 14:52:51 +00:00
2010-06-30 18:27:36 +00:00
// Function: cycleElement
// Select the next/previous element within the current layer
//
// Parameters:
// next - Boolean where true = next and false = previous element
2018-05-16 08:32:44 +00:00
this . cycleElement = function ( next ) {
2018-05-18 03:25:45 +00:00
let num ;
const curElem = selectedElements [ 0 ] ;
let elem = false ;
const allElems = getVisibleElements ( currentGroup || getCurrentDrawing ( ) . getCurrentLayer ( ) ) ;
2018-05-18 04:02:30 +00:00
if ( ! allElems . length ) { return ; }
if ( curElem == null ) {
num = next ? allElems . length - 1 : 0 ;
elem = allElems [ num ] ;
} else {
2018-05-18 03:25:45 +00:00
let i = allElems . length ;
2018-05-18 04:02:30 +00:00
while ( i -- ) {
if ( allElems [ i ] === curElem ) {
num = next ? i - 1 : i + 1 ;
if ( num >= allElems . length ) {
num = 0 ;
} else if ( num < 0 ) {
num = allElems . length - 1 ;
}
elem = allElems [ num ] ;
break ;
}
}
}
selectOnly ( [ elem ] , true ) ;
call ( 'selected' , selectedElements ) ;
2013-02-15 15:51:58 +00:00
} ;
2010-06-22 14:52:51 +00:00
2010-06-30 18:27:36 +00:00
this . clear ( ) ;
2018-05-16 00:53:27 +00:00
// DEPRECATED: getPrivateMethods
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
// Since all methods are/should be public somehow, this function should be removed;
// we might require `import` in place of this in the future once ES6 Modules
// widespread
2010-06-30 18:27:36 +00:00
2010-06-22 14:52:51 +00:00
// Being able to access private methods publicly seems wrong somehow,
// but currently appears to be the best way to allow testing and provide
// access to them to plugins.
2018-05-16 08:32:44 +00:00
this . getPrivateMethods = function ( ) {
2018-05-18 03:25:45 +00:00
const obj = {
addCommandToHistory ,
setGradient ,
addSvgElementFromJson ,
assignAttributes ,
BatchCommand ,
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
buildCanvgCallback ,
2018-05-18 03:25:45 +00:00
call ,
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
canvg ,
2018-05-18 03:25:45 +00:00
ChangeElementCommand ,
copyElem ( elem ) { return getCurrentDrawing ( ) . copyElem ( elem ) ; } ,
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
decode64 ,
encode64 ,
executeAfterLoads ,
2018-05-18 03:25:45 +00:00
ffClone ,
findDefs ,
findDuplicateGradient ,
getElem ,
getId ,
getIntersectionList ,
getMouseTarget ,
getNextId ,
getPathBBox ,
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
getTypeMap ,
2018-05-18 03:25:45 +00:00
getUrlFromAttr ,
hasMatrixTransform ,
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
identifyLayers : draw . identifyLayers ,
2018-05-18 03:25:45 +00:00
InsertElementCommand ,
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
isChrome ,
2018-05-18 03:25:45 +00:00
isIdentity ,
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
isIE ,
2018-05-18 03:25:45 +00:00
logMatrix ,
matrixMultiply ,
MoveElementCommand ,
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
NS ,
2018-05-18 03:25:45 +00:00
preventClickDefault ,
recalculateAllSelectedDimensions ,
recalculateDimensions ,
remapElement ,
RemoveElementCommand ,
removeUnusedDefElems ,
round ,
runExtensions ,
sanitizeSvg ,
SVGEditTransformList ,
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
text2xml ,
2018-05-18 03:25:45 +00:00
toString ,
transformBox ,
transformListToTransform ,
transformPoint ,
walkTree
2018-05-18 04:02:30 +00:00
} ;
return obj ;
2010-06-22 14:52:51 +00:00
} ;
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`);
also expect one directory higher; incorporates #207 (@iuyiuy)
- Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons)
- Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through
the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for
better namespacing); incorporates #207 (@iuyiuy)
- Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine)
- Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed
- Fix: Update Atom feed reference in HTML
- Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes
- Enhancement: Move config-sample.js out of `editor` directory
- Enhancement: For `callback`-style extensions, also provide config object; add following
to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml
- Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel;
make Node build routine for converting modular source to non-modular,
use `loadStylesheets` for modular stylehsheet defining (but parallel loading);
- Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default).
- Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines
- Refactoring: Avoid embedded API adding inline JavaScript listener
- Refactoring: Move layers and context code to `draw.js`
- Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js`
- Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing)
- Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency
- Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules
- Refactoring: Further avoidance of quotes on properties (as possible)
- Refactoring: Use `class` in place of functions where intended as classes
- Refactoring: Consistency and granularity in extensions imports
- Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions
- Testing: Add node-static for automating (and accessing out-of-directory contents)
- Testing: Avoid HTML attributes for styling
- Testing: Add npm `test` script
- Testing: Comment out unused jQuery SVG test
- Testing: Add test1 and svgutils_performance_test to all tests page
- Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class
- npm: Update devDeps
- npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
} // End constructor
} // End class