(INCOMPLETE: ES6 Module conversion and linting)
- Breaking change: Require `new` with `EmbeddedSVGEdit` (allows us to use `class` internally)
- Breaking change: If `svgcanvas.setUiStrings` must now be called if not using editor in order
to get strings (for sake of i18n) (and if using path.js alone, must also have its `setUiStrings` called)
- Breaking change (ext-overview-window): Avoid global `overviewWindowGlobals`
- Breaking change (ext-imagelib): Change to object-based encoding for namespacing of
messages (though keep stringifying/parsing ourselves until we remove IE9 support)
- Breaking change: Rename `jquery.js` to `jquery.min.js`
- Breaking change: Remove `scoped` attribute from `style`; it is now deprecated and
obsolete; also move to head (after other stylesheets)
- Enhancement: Make SpinButton plugin independent of SVGEdit via
generic state object for tool_scale
- Enhancement: Remove now unused Python l10n scripts (#238)
- Enhancement: ES6 Modules (including jQuery plugins but not jQuery)
- Enhancement: Further JSDoc (incomplete)
- Enhancement (Optimization): Compress images using imageoptim (and add
npm script) (per #215)
- Fix: i18nize path.js strings and canvas notifications
- Fix: Attempt i18n for ext-markers
- Refactoring (ext-storage): Move locale info to own file imported by the extension (toward modularity; still should be split into separate files by language and *dynamically* imported, but we'll wait for better `import` support to refactor this)
- Refactoring: For imagelib, add local jQuery copy (using old 1.4.4 as had
been using from server)
- Refactoring: For MathJax, add local copy (using old 2.3 as had been using from
server); server had not been working
- Refactoring: Remove `use strict` (implicit in modules)
- Refactoring: Remove trailing whitespace, fix some code within comments
- Refactoring: Expect `jQuery` global rather than `$` for better modularity
(also to adapt line later once available via `import`)
- Refactoring: Prefer `const` (and then `let`)
- Refactoring: Add block scope keywords closer to first block in which they appear
- Refactoring: Use ES6 `class`
- Refactoring `$.isArray` -> `Array.isArray` and avoid some other jQuery core methods
with simple VanillaJS replacements
- Refactoring: Use abbreviated object property syntax
- Refactoring: Object destructuring
- Refactoring: Remove `uiStrings` contents in svg-editor.js (obtains from locale)
- Refactoring: Add favicon to embedded API file
- Refactoring: Use arrow functions for brief functions (incomplete)
- Refactoring: Use `Array.prototype.includes`/`String.prototype.includes`;
`String.prototype.startsWith`, `String.prototype.trim`
- Refactoring: Remove now unnecessary svgutils do/while resetting of variables
- Refactoring: Use shorthand methods for object literals (avoid ": function")
- Refactoring: Avoid quoting object property keys where unnecessary
- Refactoring: Just do truthy/falsey check for lengths in place of comparison to 0
- Refactoring (Testing): Avoid jQuery usage within most test files (defer script,
also in preparation for future switch to ES6 modules for tests)
- Refactoring: Make jpicker variable declaration indent bearable
- Refactoring (Linting): Finish svgcanvas.js
- Docs: Mention in comment no longer an entry file as before
- Docs: Migrate old config, extensions, and FAQ docs
- Licensing: Indicate MIT is license type of rgbcolor; rename/add license file name for
jgraduate and screencast to reflect type (Apache 2.0); rename file to reflect it
contains license information (of type MIT) for Raphael icons
This commit is contained in:
118
docs/ConfigOptions.md
Normal file
118
docs/ConfigOptions.md
Normal file
@@ -0,0 +1,118 @@
|
||||
# Introduction
|
||||
|
||||
As of version 2.5, SVG-edit has several configuration settings that can be overridden either by adding URL parameters or by setting the options in JavaScript. As of version 2.7, a few among these options related to paths are disallowed via URL though they can still be set by `svgEditor.setConfig`.
|
||||
|
||||
## How to set the options
|
||||
|
||||
Options can be set using `svgEditor.setConfig(options)`, where `options` is an object literal of keys and values. This must be run before the actual page or DOM is loaded, otherwise it will have no effect. Note that one may create a `config.js` file within the "editor" directory and add such configuration directives to it without needing to modify the repository editor code (and note version 2.8 adds support for a custom.css file for the same purpose).
|
||||
|
||||
## Example:
|
||||
|
||||
```js
|
||||
svgEditor.setConfig({
|
||||
dimensions: [320, 240],
|
||||
canvas_expansion: 5,
|
||||
initFill: {
|
||||
color: '0000FF'
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
This will set the default width/height of the image, the size of the outside canvas, and the default "fill" color.
|
||||
|
||||
The same options can be set in the URL like this:
|
||||
|
||||
```
|
||||
.../svg-editor.html?dimensions=300,240&canvas_expansion=5&initFill[color]=0000FF
|
||||
```
|
||||
|
||||
As of version 2.7, if options are set both using `.setConfig()` as well as in the URL, the `.setConfig()` value will be used. The reverse was true in previous versions but was changed for security reasons.
|
||||
|
||||
One may optionally pass another object to `.setConfig()` as the second argument to further adjust configuration behavior.
|
||||
|
||||
If an `overwrite` boolean is set to false on this additional object, it will, as occurs with all URL type configurations, prevent the current configuration from overwriting any explicitly set previous configurations. The default is true except for URLs which always are false.
|
||||
|
||||
If an `allowInitialUserOverride` boolean is set to true, it will allow subsequent configuration overwriting via URL (e.g., if you do want the user to have the option to override certain or your (`config.js`) `.setConfig()` directives via URL while still wishing to provide them with your own default value, you should add this property).
|
||||
|
||||
## Configurable options
|
||||
|
||||
Note that those items marked as preferences are configuration items which can also be set via the UI (and specifically via Editor Options except where mentioned). Those items which appear in the UI but are not treated internally as preferences are marked with "Maybe" as their status may change.
|
||||
|
||||
| Property | Description | Default | Preference | |:---------|:------------|:--------|:-----------|
|
||||
| `lang` | Two-letter language code. The language must exist in the Editor Preferences language list | Default to "en" if `locale.js` detection does not detect another language | Yes |
|
||||
| `bkgd_url` | Background raster image URL. This image will fill the background of the document, useful for tracing purposes | (none) | Yes |
|
||||
| `img_save` | Defines whether included raster images should be saved as Data URIs when possible, or as URL references. Must be either 'embed' or 'ref'. Settable in the Document Properties dialog. | embed | Yes |
|
||||
| `dimensions` | The default width/height of a new document. Use an array in `setConfig` (e.g., `[800, 600]`) and comma separated numbers in the URL | `[640, 480]` | Maybe |
|
||||
| `initFill[color]` | The initial fill color. Must be a hex code string. | FF0000 (solid red) | No |
|
||||
| `initFill[opacity]` | The initial fill opacity. Must be a number between 0 and 1 | 1 | No |
|
||||
| `initStroke[color]` | The initial stroke color. Must be a hex code. | 000000 (solid black) | No |
|
||||
| `initStroke[width]` | The initial stroke width. Must be a positive number. | 5 | No |
|
||||
| `initStroke[opacity]` | The initial stroke opacity. Must be a number between 0 and 1 | 1 | No |
|
||||
| `initTool` | The initially selected tool. Must be either the ID of the button for the tool, or the ID without "tool_" prefix_| select | No |
|
||||
| `exportWindowType` | New as of 2.8. Can be "new" or "same" to indicate whether new windows will be generated for each export; the window.name of the export window is namespaced based on the `canvasName` (and incremented if "new" is selected as the type) | new | No |
|
||||
| `imgPath` | The path where the SVG icons are located, with trailing slash. Note that as of version 2.7, this is not configurable by URL for security reasons. | `images/` | No |
|
||||
| `jGraduatePath` | The path where jGraduate images are located. Note that as of version 2.7, this is not configurable by URL for security reasons. | `jgraduate/images/` | No |
|
||||
| `langPath` | The path where the language files are located, with trailing slash. Note that as of version 2.7, this is not configurable by URL for security reasons. | `locale/` | No |
|
||||
| `extPath` | The path used for extension files, with trailing slash. Note that as of version 2.7, this is not configurable by URL for security reasons. | `extensions/` | No |
|
||||
| `extensions` | Extensions to load on startup. Use an array in setConfig and comma separated file names in the URL. Note that as of version 2.7, paths containing "/", "\", or ":", are disallowed for security reasons. Although previous versions of this list would entirely override the default list, as of version 2.7, the defaults will always be added to this explicit list unless the configuration `noDefaultExtensions` is included. | `['ext-overview_window.js','ext-markers.js','ext-connector.js','ext-eyedropper.js','ext-shapes.js','ext-imagelib.js','ext-grid.js','ext-polygon.js','ext-star.js','ext-panning.js','ext-storage.js']` | No |
|
||||
| `showlayers` | Open the layers side-panel by default | `false` | No |
|
||||
| `wireframe` | Start in wireframe mode | `false` | No |
|
||||
| `gridSnapping` | Enable snap to grid by default. Set in Editor Options. | `false` | Maybe |
|
||||
| `gridColor` | Set in Editor Options. | #000 (black) | Maybe |
|
||||
| `baseUnit` | Set in Editor Options. | px | Maybe |
|
||||
| `snappingStep` | Set the default grid snapping value. Set in Editor Options. | 10 | Maybe |
|
||||
| `showRulers` | Initial state of ruler display (v2.6). Set in Editor Options. | `true` | Maybe |
|
||||
| `no_save_warning` | A boolean that when `true` prevents the warning dialog box from appearing when closing/reloading the page. Mostly useful for testing. | `false` | No |
|
||||
| `canvas_expansion` | The minimum area visible outside the canvas, as a multiple of the image dimensions. The larger the number, the more one can scroll outside the canvas. | 3 | No |
|
||||
| `show_outside_canvas` | A boolean that defines whether or not elements outside the canvas should be visible; set by `svgcanvas.js` | `true` | No |
|
||||
| `iconsize` | Size of the toolbar icons. Must be one of the following: 's', 'm', 'l', 'xl' | Will default to 's' if the window height is smaller than the minimum height and 'm' otherwise | Yes |
|
||||
| `bkgd_color` | Canvas background color | #FFF (white) | Yes |
|
||||
| `selectNew` | Initial state of option to automatically select objects after they are created (v2.6) | `true` | No |
|
||||
| `save_notice_done` | Used to track alert status | `false` | Yes |
|
||||
| `export_notice_done` | Used to track alert status | `false` | Yes |
|
||||
| `allowedOrigins` | Used by `ext-xdomain-messaging.js` to indicate which origins are permitted for cross-domain messaging (e.g., between the embedded editor and main editor code). Besides explicit domains, one might add '' to allow all domains (not recommended for privacy/data integrity of your user's content!), `window.location.origin` for allowing the same origin (should be safe if you trust all apps on your domain), 'null' to allow `file://` URL usage| `[]` | Maybe |
|
||||
| `canvasName` | Used to namespace storage provided via `ext-storage.js`; you can use this if you wish to have multiple independent instances of SVG Edit on the same domain | default | No |
|
||||
| `initOpacity` | Initial opacity (multiplied by 100) | 1 | No |
|
||||
| `colorPickerCSS` | Object of CSS properties mapped to values (for jQuery) to apply to the color picker. A `null` value (the default) will cause the CSS to default to `left` with a position equal to that of the fill_color or stroke_color element minus 140, and a `bottom` equal to 40 | `null` (see description) | No |
|
||||
| `preventAllURLConfig` | Set to `true` (in `config.js`; extension loading is too late!) to override the ability for URLs to set non-content configuration (including extension config) | `false` | No |
|
||||
| `preventURLContentLoading` | Set to `true` (in `config.js`; extension loading is too late!) to override the ability for URLs to set URL-based SVG content | `false` | No |
|
||||
| `lockExtensions` | Set to `true` (in config.js; extension loading is too late!) to override the ability for URLs to set their own extensions; disallowed in URL setting. There is no need for this when `preventAllURLConfig` is used. | `false` | No |
|
||||
| `noDefaultExtensions` | If set to `true`, prohibits automatic inclusion of default extensions (though "extensions" can still be used to add back any desired default extensions along with any other extensions); can only be meaningfully used in `config.js` or in the URL | `false` | No |
|
||||
| `showGrid` | Set by `ext-grid.js`; determines whether or not to show the grid by default | `false` | No |
|
||||
| `noStorageOnLoad` | Some interaction with `ext-storage.js`; prevents even the loading of previously saved local storage | `false` | No |
|
||||
| `forceStorage` | Some interaction with `ext-storage.js`; strongly discouraged from modification as it bypasses user privacy by preventing them from choosing whether to keep local storage or not | `false` | No |
|
||||
| `emptyStorageOnDecline` | Used by `ext-storage.js`; empty any prior storage if the user declines to store | `false` | No |
|
||||
| `paramurl` | This is available via URL only. Deprecated and removed in trunk. Allowed an un-encoded URL within the query string (use "url" or "source" with a data: URI instead) | (None) | No |
|
||||
| `selectNew` | Set by svgcanvas.js; used by mouseUp; it true, will replace the selection with the current element and show grips | `true` | No |
|
||||
|
||||
## Preload a file
|
||||
|
||||
It is also possible to start the editor with preloaded SVG file, using the following methods.
|
||||
|
||||
However, one should bear in mind that if one wishes to immediately set a particular string, especially if in config.js (and prevent the user from saving their own text), one should first set the config option "noStorageOnLoad" to false or otherwise any previous local storage may overwrite your own string.
|
||||
|
||||
```js
|
||||
// Serialized string:
|
||||
svgEditor.loadFromString('...');
|
||||
|
||||
// Data URI:
|
||||
svgEditor.loadFromDataURI('data:image/svg+xml;base64,...');
|
||||
|
||||
// Local URL:
|
||||
svgEditor.loadFromURL('images/logo.svg');
|
||||
```
|
||||
|
||||
Or as URL parameter:
|
||||
|
||||
```js
|
||||
// Data URI
|
||||
'?source=' + encodeURIComponent('data:image/svg+xml;utf8,') + encodeURIComponent(/*...*/)
|
||||
|
||||
// Data URI (base 64):
|
||||
'?source=' + encodeURIComponent('data:image/svg+xml;base64,' + /* ... */); // data%3Aimage%2Fsvg%2Bxml%3Bbase64%2C ...
|
||||
|
||||
// Local URL:
|
||||
'?url=' + encodeURIComponent('images/logo.svg'); // images%2Flogo.svg
|
||||
```
|
||||
|
||||
**Note:** There is currently a bug that prevents data URIs ending with equals (=) characters from being parsed. Removing these characters seem to allow the import to work as expected.
|
||||
314
docs/ExtensionDocs.md
Normal file
314
docs/ExtensionDocs.md
Normal file
@@ -0,0 +1,314 @@
|
||||
# Introduction
|
||||
|
||||
As of version 2.5, SVG-Edit has support for extensions. This an (in-progress) guide for creating SVG-Edit plugins.
|
||||
|
||||
## Basic format
|
||||
|
||||
SVG-Edit plugins are standalone JavaScript files that can be either included in the HTML file or loaded using setConfig or through the URL (see ConfigOptions for usage).
|
||||
|
||||
Note that if you create a `config.js` file in the "editor" directory, this will be used to execute commands before extensions are loaded, e.g., if you wish to make configuration changes which affect extension loading behavior. Normally, however, it should be preferable for modularity to use the extension mechanism, as this can allow you or users to customize which extensions are loaded (whereas `config.js` will always run if present).
|
||||
|
||||
This is the general format for an extension:
|
||||
|
||||
```js
|
||||
svgEditor.addExtension('extensionName', function (methods) {
|
||||
return extensionData;
|
||||
});
|
||||
```
|
||||
|
||||
The first parameter (`extensionName`) is the unique name for this extension.
|
||||
|
||||
The second parameter is a function that supplies methods and variables from svgCanvas and can return an object that includes properties and functions related to the extension.
|
||||
|
||||
The basic Hello world extension can be used as an example on how to create a basic extension. This extension adds a "mode" button to the bottom of the left panel that changes the mode, then shows a "Hello world" message whenever the canvas is clicked on. See [extension in action](https://svg-edit.github.io/svgedit/releases/svg-edit-2.8.1/svg-editor.html?extensions=ext-helloworld.js).
|
||||
|
||||
The basic structure of this plugin looks like this:
|
||||
|
||||
```js
|
||||
svgEditor.addExtension('Hello World', function () {
|
||||
|
||||
// Returning an object is optional as of v2.7+
|
||||
return {
|
||||
// name: '', // A name has traditionally been added but apparently not needed?
|
||||
svgicons: 'extensions/helloworld-icon.xml',
|
||||
buttons: [{...}],
|
||||
mouseDown() {
|
||||
...
|
||||
},
|
||||
mouseUp(opts) {
|
||||
...
|
||||
}
|
||||
};
|
||||
});
|
||||
```
|
||||
|
||||
Note how the returned properties include information on the buttons, as well as the functions that should be run when certain events take place.
|
||||
|
||||
## Creating buttons
|
||||
|
||||
Buttons can appear either in the mode panel (left panel) or the context panel (top panel, changes depending on selection). Their icons can either consist of SVG icons (recommended) or just raster images.
|
||||
|
||||
Each button is an object with the following properties (added to the array "buttons" on the object provided by the extension):
|
||||
|
||||
| Property | Description | Required? |
|
||||
|:---------|:------------|:----------|
|
||||
| `id` (string) | A unique identifier for this button. If SVG icons are used, this must match the ID used in the icon file. | Yes |
|
||||
| `type` (string) | Type of button. Must be either 'mode' or 'context' | Yes |
|
||||
| `title` (string) | The tooltip text that will appear when the user hovers over the icon | Yes |
|
||||
| `icon` (string) | The file path to the raster version of the icon. | Only if no svgicons is supplied |
|
||||
| `svgicon` (string) | If absent, will utilize the button "id"; used to set "placement" on the svgIcons call | No |
|
||||
| `list` (string) | Points to the "id" of a context_tools item of type "button-select" into which the button will be added as a panel list item | No |
|
||||
| `position` (integer) | The numeric index for placement; defaults to last position (as of the time of extension addition) if not present | No |
|
||||
| `panel` (string) | The ID of the context panel to be included, if type is "context". | Only if type is "context" |
|
||||
| `events` (object) | DOM event names with associated functions. Example: {'click': function() { alert('Button was clicked') } } | Yes |
|
||||
| `includeWith` (object) | Object with flyout menu data (see following properties) | No |
|
||||
| `includeWith[button]` (string) | jQuery selector of the existing button to be joined. Example: '#tool_line' | Yes (if includeWith is used) |
|
||||
| `includeWith[isDefault]` (boolean) | Option indicating whether button is default in flyout list or not | No |
|
||||
| `isDefault` (boolean) | Whether or not the default is the default | No |
|
||||
| `includeWith[position]` (integer) | Position of icon in flyout list, will be added to end if not indicated | No |
|
||||
| `key` (string) | The key to bind to the button | No |
|
||||
|
||||
## Creating SVG icons
|
||||
|
||||
The SVG-Edit project uses icons created using basic SVG (generally using SVG-Edit as design tool), and extensions are encouraged to do so too. This allows the interface toolbars to be resized and icons to be reused at various sizes. If your extension uses multiple icons, they can all be stored in the same file. To specify icon file used, set the path under the extension's returned svgicons property.
|
||||
|
||||
An SVG icon file is an XML document that consists of a root SVG element with child group elements (`<g></g>`). Each of these has an ID that should match the ID specified in the associated button object. Its content should be the SVG source of the icon. See the Hello World icon as an example.
|
||||
|
||||
For further information, see the SVG Icon Loader project.
|
||||
|
||||
## Creating context tools
|
||||
|
||||
Context tools appear in the top toolbar whenever a certain type of element is selected.
|
||||
|
||||
These are added by the extension returning an object with the property "context_tools".
|
||||
|
||||
| Property | Description | Required? |
|
||||
|:---------|:------------|:----------|
|
||||
| `panel` (string) | The ID of the existing panel for the tool to be added to | Yes |
|
||||
| `container_id` (string) | The ID to be given to the tool's container element | No |
|
||||
| `type` (string) | The type of tool being added. Must be one of the following: 'tool_button', 'select', 'input' | Yes |
|
||||
| `id` (string) | The ID of the actual tool element | Yes |
|
||||
| `events` (object) | DOM event names with associated functions. Example: {'change': function() { alert('Option was changed') } } | Yes |
|
||||
| `options` (object) | List of options and their labels for select tools. Example: `{'1': 'One', '2': 'Two', 'all': 'All' } | Only for "select" tools |
|
||||
| `defval` (string) | Default value | No |
|
||||
| `label` (string) | Label associated with the tool, visible in the UI | No |
|
||||
| `title` (string) | The tooltip text that will appear when the user hovers over the tool | Yes |
|
||||
| `size` (integer) | Value of the "size" attribute of the tool input | No |
|
||||
| `spindata` (object) | When added to a tool of type "input", this tool becomes a "spinner" which allows the number to be in/decreased. For data required see The SpinButton script | No |
|
||||
| `colnum` (integer) | Added as part of the option list class. | No |
|
||||
|
||||
## SVG-Edit events
|
||||
|
||||
Most plugins will want to run functions when certain events are triggered. This is a list of the current events that can be hooked onto. All events are optional.
|
||||
|
||||
| Event | Description | Parameters | Return value expected | |:------|:------------|:-----------|:----------------------|
|
||||
| `mouseDown` | The main (left) mouse button is held down on the canvas area | Supplies an object with these properties: `evt` (the event object), `start_x` (x coordinate on canvas), `start_y` (y coordinate on canvas), `selectedElements` (an array of the selected Elements) | An optional object with started: true to indicate that creating/editing has started |
|
||||
| `mouseMove` | The mouse is moved on the canvas area | Same as for `mouseDown`, but with a selected property that refers to the first selected element | None |
|
||||
| `mouseUp` | The main (left) mouse button is released (anywhere) | Same as for `mouseDown` | An optional object with these properties: `element` (the element being affected), `keep` (boolean that indicates if the current element should be kept) `started` (boolean that indicates if editing should still be considered as "started") |
|
||||
| `zoomChanged` | The zoom level is changed | Supplies the new zoom level as a number (not percentage) | None |
|
||||
| `selectedChanged` | The element selection has changed (elements were added/removed from selection | Supplies an object with these properties: `elems` (array of the newly selected elements), `selectedElement` (the single selected element), `multiselected` (a boolean that indicates whether one or more elements was selected) | None |
|
||||
| `elementChanged` | One or more elements were changed | Object with properties: `elems` (array of the affected elements) | None |
|
||||
| `elementTransition` | Called when part of element is in process of changing, generally on mousemove actions like rotate, move, etc. | Object with properties: `elems` (array of transitioning elements) | None |
|
||||
| `toolButtonStateUpdate` | The bottom panel was updated | Object with these properties: `nofill` (boolean that indicates fill is disabled), `nostroke` (boolean that indicates stroke is disabled) | None |
|
||||
| `langChanged` | The language was changed | Two-letter code of the new language | None |
|
||||
| `langReady` | Invoked as soon as the locale is ready | An object with properties "lang" containing the two-letter language code and "uiStrings" as an alias for svgEditor.uiStrings | None |
|
||||
| `addlangData` | Means for an extension to add locale data | The two-letter language code | Object with "data" property set to an object containing two-letter language codes keyed to an array of objects with "id" and "title" or "textContent" properties |
|
||||
| `callback` | Invoked upon addition of the extension, or, if svgicons are set, then after the icons are ready | None | None |
|
||||
| `canvasUpdated` | Invoked upon updates to the canvas | Object with properties: new_x, new_y, old_x, old_y, d_x, d_y | None |
|
||||
| `onNewDocument` | Called when new image is created | None | None |
|
||||
| `workareaResized` | Called when sidepanel is resized or toggled | None | None |
|
||||
|
||||
## Helper functions
|
||||
|
||||
A variety of methods can be accessed within plugins. In the future, we hope to have them all properly documented, for now here is the current list of function/variable names.
|
||||
|
||||
## `svgCanvas` variables
|
||||
|
||||
These are supplied in an object through the first parameter of the extension function (see "methods" variable in above example).
|
||||
|
||||
| Name | Description |
|
||||
|:-----|:------------|
|
||||
| `svgroot` (element) | The workarea's root SVG element. NOT the root SVG element of the image being edited |
|
||||
| `svgcontent` (element) | The root SVG element of the image being edited |
|
||||
| `nonce` (number) | The unique identifier given to this image |
|
||||
| `selectorManager` (object) | The object that manages selection information |
|
||||
|
||||
## `svgEditor` public methods
|
||||
|
||||
| Name | Description | Params | Return value |
|
||||
|:-----|:------------|:-------|:-------------|
|
||||
| `setCustomHandlers()` | Override default SVG open, save, and export behaviors | Accepts object with all optional properties, `open`, `save`, and `exportImage`; `open` is not passed any parameters; `saved` is passed a string containing the SVG; `exportImage` is passed an object containing the properties: `svg` with the SVG contents as a string, `datauri` with the contents as a data URI, `issues` with an array of UI strings pertaining to relevant known CanVG issues, `type` indicating the chosen image type ("PNG", "JPEG", "BMP", "WEBP") (or, as planned for 3.0.0, "PDF" type), `mimeType` for the MIME type, `exportWindowName` as a convenience for passing along a window.name to target a window on which the export could be added, and `quality` as a decimal between 0 and 1 (for use with JPEG or WEBP) | (None) | | ... | ... | ... | ... |
|
||||
|
||||
## `svgCanvas` private methods
|
||||
|
||||
These are supplied in an object through the first parameter of the extension function (see `methods` variable in above example).
|
||||
|
||||
| Name | Description |
|
||||
|:-----|:------------|
|
||||
| `addCommandToHistory()` | |
|
||||
| `addGradient()` | |
|
||||
| `addSvgElementFromJson()` | |
|
||||
| `assignAttributes()` | |
|
||||
| `BatchCommand()` | |
|
||||
| `call()` | |
|
||||
| `ChangeElementCommand()` | |
|
||||
| `cleanupElement()` | |
|
||||
| `copyElem()` | |
|
||||
| `ffClone()` | |
|
||||
| `findDefs()` | |
|
||||
| `findDuplicateGradient()` | |
|
||||
| `fromXml()` | |
|
||||
| `getElem()` | |
|
||||
| `getId()` | |
|
||||
| `getIntersectionList()` | |
|
||||
| `getNextId()` | |
|
||||
| `getPathBBox()` | |
|
||||
| `getUrlFromAttr()` | |
|
||||
| `hasMatrixTransform()` | |
|
||||
| `identifyLayers()` | |
|
||||
| `InsertElementCommand()` | |
|
||||
| `isIdentity()` | |
|
||||
| `logMatrix()` | |
|
||||
| `matrixMultiply()` | |
|
||||
| `MoveElementCommand()` | |
|
||||
| `preventClickDefault()` | |
|
||||
| `recalculateAllSelectedDimensions()` | |
|
||||
| `recalculateDimensions()` | |
|
||||
| `remapElement()` | |
|
||||
| `RemoveElementCommand()` | |
|
||||
| `removeUnusedGrads()` | |
|
||||
| `resetUndoStack()` | |
|
||||
| `round()` | |
|
||||
| `runExtensions()` | |
|
||||
| `sanitizeSvg()` | |
|
||||
| `Selector()` | |
|
||||
| `SelectorManager()` | |
|
||||
| `shortFloat()` | |
|
||||
| `svgCanvasToString()` | |
|
||||
| `SVGEditTransformList()` | |
|
||||
| `svgToString()` | |
|
||||
| `toString()` | |
|
||||
| `toXml()` | |
|
||||
| `transformBox()` | |
|
||||
| `transformListToTransform()` | |
|
||||
| `transformPoint()` | |
|
||||
| `transformToObj()` | |
|
||||
| `walkTree()` | |
|
||||
|
||||
## `svgCanvas` public methods
|
||||
|
||||
| Name | Description |
|
||||
|:-----|:------------|
|
||||
| `addToSelection()` | |
|
||||
| `alignSelectedElements()` | |
|
||||
| `beginUndoableChange()` | |
|
||||
| `bind()` | |
|
||||
| `changeSelectedAttribute()` | |
|
||||
| `changeSelectedAttributeNoUndo()` | |
|
||||
| `clear()` | |
|
||||
| `clearSelection()` | |
|
||||
| `cloneSelectedElements()` | |
|
||||
| `convertToPath()` | |
|
||||
| `createLayer()` | |
|
||||
| `cycleElement()` | |
|
||||
| `deleteCurrentLayer()` | |
|
||||
| `deleteSelectedElements()` | |
|
||||
| `each()` | |
|
||||
| `embedImage()` | |
|
||||
| `finishUndoableChange()` | |
|
||||
| `fixOperaXML()` | |
|
||||
| `getBBox()` | |
|
||||
| `getBold()` | |
|
||||
| `getContentElem()` | |
|
||||
| `getCurrentLayer()` | |
|
||||
| `getEditorNS()` | |
|
||||
| `getFillColor()` | |
|
||||
| `getFillOpacity()` | |
|
||||
| `getFontFamily()` | |
|
||||
| `getFontSize()` | |
|
||||
| `getHistoryPosition()` | |
|
||||
| `getImageTitle()` | |
|
||||
| `getItalic()` | |
|
||||
| `getLayer()` | |
|
||||
| `getLayerOpacity()` | |
|
||||
| `getLayerVisibility()` | |
|
||||
| `getMode()` | |
|
||||
| `getNextRedoCommandText()` | |
|
||||
| `getNextUndoCommandText()` | |
|
||||
| `getNumLayers()` | |
|
||||
| `getOffset()` | |
|
||||
| `getOpacity()` | |
|
||||
| `getPrivateMethods()` | |
|
||||
| `getRedoStackSize()` | |
|
||||
| `getResolution()` | |
|
||||
| `getRootElem()` | |
|
||||
| `getRotationAngle()` | |
|
||||
| `getSelectedElems()` | |
|
||||
| `getStrokeColor()` | |
|
||||
| `getStrokeOpacity()` | |
|
||||
| `getStrokeStyle()` | |
|
||||
| `getStrokeWidth()` | |
|
||||
| `getStrokedBBox()` | |
|
||||
| `getSvgString()` | |
|
||||
| `getText()` | |
|
||||
| `getTransformList()` | |
|
||||
| `getUndoStackSize()` | |
|
||||
| `getUrlFromAttr()` | |
|
||||
| `getVersion()` | |
|
||||
| `getVisibleElements()` | |
|
||||
| `getZoom()` | |
|
||||
| `groupSelectedElements()` | |
|
||||
| `importSvgString()` | |
|
||||
| `isValidUnit()` | |
|
||||
| `linkControlPoints()` | |
|
||||
| `matrixMultiply()` | |
|
||||
| `moveSelectedElements()` | |
|
||||
| `moveSelectedToLayer()` | |
|
||||
| `moveToBottomSelectedElement()` | |
|
||||
| `moveToTopSelectedElement()` | |
|
||||
| `open()` | |
|
||||
| `randomizeIds()` | |
|
||||
| `ready()` | |
|
||||
| `redo()` | |
|
||||
| `removeFromSelection()` | |
|
||||
| `renameCurrentLayer()` | |
|
||||
| `runExtensions()` | |
|
||||
| `save()` | |
|
||||
| `selectAllInCurrentLayer()` | |
|
||||
| `setBBoxZoom()` | |
|
||||
| `setBackground()` | |
|
||||
| `setBold()` | |
|
||||
| `setConfig()` | |
|
||||
| `setCurrentLayer()` | |
|
||||
| `setCurrentLayerPosition()` | |
|
||||
| `setFillColor()` | |
|
||||
| `setFillOpacity()` | |
|
||||
| `setFillPaint()` | |
|
||||
| `setFontFamily()` | |
|
||||
| `setFontSize()` | |
|
||||
| `setIdPrefix()` | |
|
||||
| `setImageTitle()` | |
|
||||
| `setImageURL()` | |
|
||||
| `setItalic()` | |
|
||||
| `setLayerOpacity()` | |
|
||||
| `setLayerVisibility()` | |
|
||||
| `setMode()` | |
|
||||
| `setOpacity()` | |
|
||||
| `setRectRadius()` | |
|
||||
| `setResolution()` | |
|
||||
| `setRotationAngle()` | |
|
||||
| `setSegType()` | |
|
||||
| `setStrokeColor()` | |
|
||||
| `setStrokeOpacity()` | |
|
||||
| `setStrokePaint()` | |
|
||||
| `setStrokeStyle()` | |
|
||||
| `setStrokeWidth()` | |
|
||||
| `setSvgString()` | |
|
||||
| `setTextContent()` | |
|
||||
| `setUiStrings()` | |
|
||||
| `setZoom()` | |
|
||||
| `smoothControlPoints()` | |
|
||||
| `undo()` | |
|
||||
| `ungroupSelectedElement()` | |
|
||||
| `updateCanvas()` | |
|
||||
| `updateElementFromJson()` | |
|
||||
54
docs/FrequentlyAskedQuestions.md
Normal file
54
docs/FrequentlyAskedQuestions.md
Normal file
@@ -0,0 +1,54 @@
|
||||
**NOTE: The following may contain outdated content.**
|
||||
|
||||
**Q: Why doesn't SVG-edit work in Internet Explorer 6-7-8?**
|
||||
|
||||
A: SVG-edit only works in IE6-7-8 if you have installed the Google Chrome Frame plugin. Internet Explorer 8 and under do not natively support Scalable Vector Graphics (SVG), however IE9+ does, and thus is supported starting in SVG-edit 2.6
|
||||
|
||||
In theory there are several other possibilities that could allow SVG-edit to work in IE: * someone gets it to work with the SVG Web shim * someone gets it to work with IE and the Adobe SVG Viewer * someone gets it to work with another SVG plugin
|
||||
|
||||
**Q: How can I make SVG-edit save files on my server?**
|
||||
|
||||
A: As of SVG-edit 2.5.1, an extension is available that overrides the default open/save behavior and instead uses PHP files to allow proper open/save dialog boxes. You can include the extension by adding `ext-server_opensave.js` to the `curConfig.extension` array in `svg-editor.js` or through other methods mentioned on our ConfigOptions page.
|
||||
|
||||
For other server-saving behavior you'll want to modify `ext-server_opensave.js` or the `filesave.php` file, both available under `editor/extensions/`.
|
||||
|
||||
**Q: How can I set the stroke to 'none'?**
|
||||
|
||||
A: Shift-clicking palette squares sets the Stroke paint value. Thus, you can shift-click on the None box (red x on white background) to clear the Stroke paint.
|
||||
|
||||
**Q: How can I help?**
|
||||
|
||||
A: See How to participate
|
||||
|
||||
**Q: How can I select an element when it's hidden or behind another one?**
|
||||
|
||||
A: Select an object. Shift+O will select the previous object Shift+P will select the next object. Using the wireframe mode may also help in seeing hidden objects.
|
||||
|
||||
**Q: How can I edit shapes that have been grouped?**
|
||||
|
||||
A: Double-click the group and you will shift the editing context to the group. The rest of the image will not be editable while you are in the group context. Once you are done editing inside the group, press Escape.
|
||||
|
||||
**Q: Can I trace over a raster (PNG, JPEG...) image?**
|
||||
|
||||
A: Yes, there are two methods you can use as of SVG-edit 2.4. 1. Go to the Document Properties, and enter the URL of the image under "Editor Background". This image will then fill the background without being saved as part of the image.
|
||||
|
||||
Add a layer from the layer panel. Then draw a raster image (image icon) and enter your URL. Use the layer above this one to trace over the image without moving. Note that you can also hide/show layers to help your work.
|
||||
|
||||
**Q: How do I use the Wave Gadget?**
|
||||
|
||||
A: (Note that this information refers to the SVG-edit 2.3 Wave Gadget, the Wave Gadget has not been worked on for years though) Go to this wave wavesandbox.com!w+W7VzCLZk%A and there will be a button on the bottom that says "Install" and when you are editing things, you will see a SVG-edit icon in your toolbar that you can click to include the gadget into any blip.
|
||||
|
||||
**Q: How do I copy the style of an object to other(s)?**
|
||||
|
||||
A:
|
||||
|
||||
- Select the object you want to copy the style from. You'll see its Fill and Stroke style attributes displayed in the bottom toolbar.
|
||||
- Holding Shift to keep the first object selected, select one or several other objects.
|
||||
- Open the colorpicker by clicking on the color blocks in the bottom toolbar. If you want to copy the fill, select the Fill block. If you want to copy the stroke, select the Stroke block.
|
||||
- Hit "Ok" in the colorpicker
|
||||
|
||||
The other objects will get the Fill or the Stroke of the first object.
|
||||
|
||||
**Q: How can I serve SVG graphic editor from my own server?**
|
||||
|
||||
A: You need to download the latest version to your server and unzip. The exact commands/instructions are here: <http://howik.com/Improve_your_user%27s_experience_by_adding_svg_graphic_editor_to_your_website_in_less_than_2_minutes>
|
||||
Reference in New Issue
Block a user