group each plugin in its own folder
This commit is contained in:
BIN
src/editor/.DS_Store
vendored
BIN
src/editor/.DS_Store
vendored
Binary file not shown.
@@ -10,10 +10,11 @@
|
||||
export default {
|
||||
name: 'arrows',
|
||||
async init (S) {
|
||||
const strings = await S.importLocale();
|
||||
const svgEditor = this;
|
||||
// eslint-disable-next-line node/no-unsupported-features/es-syntax
|
||||
const {default: strings} = await import(`./locale/${svgEditor.curPrefs.lang}.js`);
|
||||
const svgCanvas = svgEditor.canvas;
|
||||
const // {svgcontent} = S,
|
||||
const
|
||||
addElem = svgCanvas.addSVGElementFromJson,
|
||||
{nonce, $} = S,
|
||||
prefix = 'se_arrow_';
|
||||
@@ -73,7 +74,6 @@ export default {
|
||||
return null;
|
||||
}
|
||||
return svgCanvas.getElem(m[1]);
|
||||
// return svgCanvas.getElem(m.groups.id);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -6,7 +6,7 @@
|
||||
* @copyright 2010 Jeff Schiller
|
||||
*
|
||||
*/
|
||||
import '../../common/svgpathseg.js';
|
||||
import '../../../common/svgpathseg.js';
|
||||
|
||||
// This extension adds a simple button to the contextual panel for paths
|
||||
// The button toggles whether the path is open or closed
|
||||
@@ -13,13 +13,12 @@ export default {
|
||||
const svgEditor = this;
|
||||
const svgCanvas = svgEditor.canvas;
|
||||
const {getElem} = svgCanvas;
|
||||
const {$, svgroot, importLocale} = S,
|
||||
const {$, svgroot} = S,
|
||||
addElem = svgCanvas.addSVGElementFromJson,
|
||||
selManager = S.selectorManager,
|
||||
connSel = '.se_connector',
|
||||
// connect_str = '-SE_CONNECT-',
|
||||
elData = $.data;
|
||||
const strings = await importLocale();
|
||||
|
||||
let startX,
|
||||
startY,
|
||||
@@ -334,20 +333,8 @@ export default {
|
||||
svgCanvas.getEditorNS(true);
|
||||
}
|
||||
});
|
||||
// updateConnectors();
|
||||
}
|
||||
|
||||
// $(svgroot).parent().mousemove(function (e) {
|
||||
// // if (started
|
||||
// // || svgCanvas.getMode() !== 'connector'
|
||||
// // || e.target.parentNode.parentNode !== svgcontent) return;
|
||||
//
|
||||
// console.log('y')
|
||||
// // if (e.target.parentNode.parentNode === svgcontent) {
|
||||
// //
|
||||
// // }
|
||||
// });
|
||||
|
||||
const buttons = [{
|
||||
id: 'mode_connect',
|
||||
type: 'mode',
|
||||
@@ -363,7 +350,8 @@ export default {
|
||||
}
|
||||
}
|
||||
}];
|
||||
|
||||
// eslint-disable-next-line node/no-unsupported-features/es-syntax
|
||||
const {default: strings} = await import(`./locale/${svgEditor.curPrefs.lang}.js`);
|
||||
return {
|
||||
name: strings.name,
|
||||
svgicons: 'conn.svg',
|
||||
@@ -5,7 +5,7 @@ export default {
|
||||
],
|
||||
buttons: [
|
||||
{
|
||||
title: 'Connect two objects'
|
||||
title: 'Connecter deux objets'
|
||||
}
|
||||
]
|
||||
};
|
||||
@@ -10,8 +10,9 @@
|
||||
export default {
|
||||
name: 'eyedropper',
|
||||
async init (S) {
|
||||
const strings = await S.importLocale();
|
||||
const svgEditor = this;
|
||||
// eslint-disable-next-line node/no-unsupported-features/es-syntax
|
||||
const {default: strings} = await import(`./locale/${svgEditor.curPrefs.lang}.js`);
|
||||
const {$, ChangeElementCommand} = S, // , svgcontent,
|
||||
// svgdoc = S.svgroot.parentNode.ownerDocument,
|
||||
svgCanvas = svgEditor.canvas,
|
||||
@@ -11,13 +11,14 @@ export default {
|
||||
name: 'foreignobject',
|
||||
async init (S) {
|
||||
const svgEditor = this;
|
||||
const {$, text2xml, NS, importLocale} = S;
|
||||
const {$, text2xml, NS} = S;
|
||||
const svgCanvas = svgEditor.canvas;
|
||||
const
|
||||
// {svgcontent} = S,
|
||||
// addElem = svgCanvas.addSVGElementFromJson,
|
||||
svgdoc = S.svgroot.parentNode.ownerDocument;
|
||||
const strings = await importLocale();
|
||||
// eslint-disable-next-line node/no-unsupported-features/es-syntax
|
||||
const {default: strings} = await import(`./locale/${svgEditor.curPrefs.lang}.js`);
|
||||
|
||||
const properlySourceSizeTextArea = function () {
|
||||
// TODO: remove magic numbers here and get values from CSS
|
||||
@@ -9,9 +9,10 @@
|
||||
|
||||
export default {
|
||||
name: 'grid',
|
||||
async init ({$, NS, getTypeMap, importLocale}) {
|
||||
const strings = await importLocale();
|
||||
async init ({$, NS, getTypeMap}) {
|
||||
const svgEditor = this;
|
||||
// eslint-disable-next-line node/no-unsupported-features/es-syntax
|
||||
const {default: strings} = await import(`./locale/${svgEditor.curPrefs.lang}.js`);
|
||||
const svgCanvas = svgEditor.canvas;
|
||||
const svgdoc = document.getElementById('svgcanvas').ownerDocument,
|
||||
{assignAttributes} = svgCanvas,
|
||||
@@ -15,9 +15,9 @@
|
||||
export default {
|
||||
name: 'helloworld',
|
||||
async init ({$, importLocale}) {
|
||||
// See `/editor/extensions/ext-locale/helloworld/`
|
||||
const strings = await importLocale();
|
||||
const svgEditor = this;
|
||||
// eslint-disable-next-line node/no-unsupported-features/es-syntax
|
||||
const {default: strings} = await import(`./locale/${svgEditor.curPrefs.lang}.js`);
|
||||
const svgCanvas = svgEditor.canvas;
|
||||
return {
|
||||
name: strings.name,
|
||||
@@ -9,31 +9,13 @@
|
||||
|
||||
export default {
|
||||
name: 'imagelib',
|
||||
async init ({$, decode64, importLocale, dropXMLInternalSubset}) {
|
||||
const imagelibStrings = await importLocale();
|
||||
|
||||
const modularVersion = !('svgEditor' in window) ||
|
||||
!window.svgEditor ||
|
||||
window.svgEditor.modules !== false;
|
||||
|
||||
async init ({$, decode64, dropXMLInternalSubset}) {
|
||||
const svgEditor = this;
|
||||
// eslint-disable-next-line node/no-unsupported-features/es-syntax
|
||||
const {default: imagelibStrings} = await import(`./locale/${svgEditor.curPrefs.lang}.js`);
|
||||
|
||||
const {uiStrings, canvas: svgCanvas} = svgEditor;
|
||||
|
||||
imagelibStrings.imgLibs = imagelibStrings.imgLibs.map(({name, url, description}) => {
|
||||
// Todo: Adopt some standard formatting library like `fluent.js` instead
|
||||
url = url
|
||||
// Keep these regexes as is in prep. for switching to `u` flag
|
||||
// which will require escaping
|
||||
.replace(
|
||||
// eslint-disable-next-line unicorn/better-regex
|
||||
/\{modularVersion\}/g,
|
||||
modularVersion
|
||||
? (imagelibStrings.moduleEnding || '-es')
|
||||
: ''
|
||||
);
|
||||
return {name, url, description};
|
||||
});
|
||||
const allowedImageLibOrigins = imagelibStrings.imgLibs.map(({url}) => {
|
||||
try {
|
||||
return new URL(url).origin;
|
||||
@@ -12,7 +12,7 @@ export default {
|
||||
imgLibs: [
|
||||
{
|
||||
name: 'Demo library (local)',
|
||||
url: '{path}imagelib/index{modularVersion}.html',
|
||||
url: '{path}imagelib/index.html',
|
||||
description: 'Demonstration library for SVG-edit on this server'
|
||||
},
|
||||
{
|
||||
@@ -12,7 +12,7 @@ export default {
|
||||
imgLibs: [
|
||||
{
|
||||
name: 'Demo library (local)',
|
||||
url: '{path}imagelib/index{modularVersion}.html',
|
||||
url: '{path}imagelib/index.html',
|
||||
description: 'Demonstration library for SVG-edit on this server'
|
||||
},
|
||||
{
|
||||
@@ -30,7 +30,7 @@ export default {
|
||||
/*
|
||||
{
|
||||
name: 'Openclipart',
|
||||
url: '{path}imagelib/openclipart{modularVersion}.html',
|
||||
url: '{path}imagelib/openclipart.html',
|
||||
description: 'Share and Use Images. Over 100,000 Public Domain SVG Images and Growing.'
|
||||
}
|
||||
*/
|
||||
@@ -12,7 +12,7 @@ export default {
|
||||
imgLibs: [
|
||||
{
|
||||
name: 'Demo library (local)',
|
||||
url: '{path}imagelib/index{modularVersion}.html',
|
||||
url: '{path}imagelib/index.html',
|
||||
description: 'Demonstration library for SVG-edit on this server'
|
||||
},
|
||||
{
|
||||
@@ -12,7 +12,7 @@ export default {
|
||||
imgLibs: [
|
||||
{
|
||||
name: 'Demo library (local)',
|
||||
url: '{path}imagelib/index{modularVersion}.html',
|
||||
url: '{path}imagelib/index.html',
|
||||
description: 'Demonstration library for SVG-edit on this server'
|
||||
},
|
||||
{
|
||||
@@ -12,7 +12,7 @@ export default {
|
||||
imgLibs: [
|
||||
{
|
||||
name: 'Demo library (local)',
|
||||
url: '{path}imagelib/index{modularVersion}.html',
|
||||
url: '{path}imagelib/index.html',
|
||||
description: 'Demonstration library for SVG-edit on this server'
|
||||
},
|
||||
{
|
||||
@@ -12,7 +12,7 @@ export default {
|
||||
imgLibs: [
|
||||
{
|
||||
name: 'Demo library (local)',
|
||||
url: '{path}imagelib/index{modularVersion}.html',
|
||||
url: '{path}imagelib/index.html',
|
||||
description: 'Demonstration library for SVG-edit on this server'
|
||||
},
|
||||
{
|
||||
@@ -12,7 +12,7 @@ export default {
|
||||
imgLibs: [
|
||||
{
|
||||
name: 'Demo library (local)',
|
||||
url: '{path}imagelib/index{modularVersion}.html',
|
||||
url: '{path}imagelib/index.html',
|
||||
description: 'Demonstration library for SVG-edit on this server'
|
||||
},
|
||||
{
|
||||
@@ -12,7 +12,7 @@ export default {
|
||||
imgLibs: [
|
||||
{
|
||||
name: 'Demo library (local)',
|
||||
url: '{path}imagelib/index{modularVersion}.html',
|
||||
url: '{path}imagelib/index.html',
|
||||
description: 'Demonstration library for SVG-edit on this server'
|
||||
},
|
||||
{
|
||||
@@ -12,7 +12,7 @@ export default {
|
||||
imgLibs: [
|
||||
{
|
||||
name: 'Demo library (local)',
|
||||
url: '{path}imagelib/index{modularVersion}.html',
|
||||
url: '{path}imagelib/index.html',
|
||||
description: 'Demonstration library for SVG-edit on this server'
|
||||
},
|
||||
{
|
||||
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
@@ -32,8 +32,9 @@
|
||||
export default {
|
||||
name: 'markers',
|
||||
async init (S) {
|
||||
const strings = await S.importLocale();
|
||||
const svgEditor = this;
|
||||
// eslint-disable-next-line node/no-unsupported-features/es-syntax
|
||||
const {default: strings} = await import(`./locale/${svgEditor.curPrefs.lang}.js`);
|
||||
const {$} = S;
|
||||
const svgCanvas = svgEditor.canvas;
|
||||
const // {svgcontent} = S,
|
||||
@@ -10,9 +10,10 @@
|
||||
|
||||
export default {
|
||||
name: 'mathjax',
|
||||
async init ({$, importLocale}) {
|
||||
const strings = await importLocale();
|
||||
async init ({$}) {
|
||||
const svgEditor = this;
|
||||
// eslint-disable-next-line node/no-unsupported-features/es-syntax
|
||||
const {default: strings} = await import(`./locale/${svgEditor.curPrefs.lang}.js`);
|
||||
const svgCanvas = svgEditor.canvas;
|
||||
|
||||
// Configuration of the MathJax extention.
|
||||
@@ -180,27 +181,6 @@ export default {
|
||||
// MathJax preprocessing has to ignore most of the page.
|
||||
$('body').addClass('tex2jax_ignore');
|
||||
|
||||
// Now get (and run) the MathJax Library.
|
||||
// Todo: insert script with modules once widely supported
|
||||
// and if MathJax (and its `TeX-AMS-MML_SVG.js` dependency) ends up
|
||||
// providing an ES6 module export: https://github.com/mathjax/MathJax/issues/1998
|
||||
/*
|
||||
const modularVersion = !('svgEditor' in window) ||
|
||||
!window.svgEditor ||
|
||||
window.svgEditor.modules !== false;
|
||||
// Add as second argument to `importScript`
|
||||
{
|
||||
type: modularVersion
|
||||
? 'module' // Make this the default when widely supported
|
||||
: 'text/javascript'
|
||||
}
|
||||
// If only using modules, just use this:
|
||||
const {default: MathJax} = await importModule( // or `import()` when widely supported
|
||||
svgEditor.curConfig.extIconsPath + mathjaxSrcSecure
|
||||
);
|
||||
*/
|
||||
// We use `extIconsPath` here for now as it does not vary with
|
||||
// the modular type as does `extPath`
|
||||
try {
|
||||
// eslint-disable-next-line node/no-unsupported-features/es-syntax
|
||||
await import(mathjaxSrcSecure);
|
||||
@@ -13,8 +13,9 @@
|
||||
export default {
|
||||
name: 'panning',
|
||||
async init ({importLocale}) {
|
||||
const strings = await importLocale();
|
||||
const svgEditor = this;
|
||||
// eslint-disable-next-line node/no-unsupported-features/es-syntax
|
||||
const {default: strings} = await import(`./locale/${svgEditor.curPrefs.lang}.js`);
|
||||
const svgCanvas = svgEditor.canvas;
|
||||
const buttons = [{
|
||||
id: 'ext-panning',
|
||||
@@ -11,7 +11,7 @@ export default {
|
||||
const svgEditor = this;
|
||||
const svgCanvas = svgEditor.canvas;
|
||||
const addElem = svgCanvas.addSVGElementFromJson;
|
||||
const {$, importLocale} = S; // {svgcontent},
|
||||
const {$} = S; // {svgcontent},
|
||||
let
|
||||
selElems,
|
||||
// editingitex = false,
|
||||
@@ -22,7 +22,8 @@ export default {
|
||||
// newFOG, newFOGParent, newDef, newImageName, newMaskID,
|
||||
// undoCommand = 'Not image',
|
||||
// modeChangeG, ccZoom, wEl, hEl, wOffset, hOffset, ccRgbEl, brushW, brushH;
|
||||
const strings = await importLocale();
|
||||
// eslint-disable-next-line node/no-unsupported-features/es-syntax
|
||||
const {default: strings} = await import(`./locale/${svgEditor.curPrefs.lang}.js`);
|
||||
const markerTypes = {
|
||||
nomarker: {},
|
||||
forwardslash:
|
||||
@@ -11,10 +11,11 @@ export default {
|
||||
async init (S) {
|
||||
const svgEditor = this;
|
||||
const svgCanvas = svgEditor.canvas;
|
||||
const {$, importLocale} = S, // {svgcontent}
|
||||
const {$} = S, // {svgcontent}
|
||||
// addElem = svgCanvas.addSVGElementFromJson,
|
||||
editingitex = false;
|
||||
const strings = await importLocale();
|
||||
// eslint-disable-next-line node/no-unsupported-features/es-syntax
|
||||
const {default: strings} = await import(`./locale/${svgEditor.curPrefs.lang}.js`);
|
||||
let selElems,
|
||||
// svgdoc = S.svgroot.parentNode.ownerDocument,
|
||||
// newFOG, newFOGParent, newDef, newImageName, newMaskID, modeChangeG,
|
||||
@@ -7,13 +7,14 @@
|
||||
* adopted for moinmoins item storage. It sends in one post png and svg data
|
||||
* (I agree to dual license my work to additional GPLv2 or later)
|
||||
*/
|
||||
import {canvg} from '../../external/canvg/canvg.js';
|
||||
import {canvg} from '../../../external/canvg/canvg.js';
|
||||
|
||||
export default {
|
||||
name: 'server_moinsave',
|
||||
async init ({$, encode64, importLocale}) {
|
||||
const strings = await importLocale();
|
||||
const svgEditor = this;
|
||||
// eslint-disable-next-line node/no-unsupported-features/es-syntax
|
||||
const {default: strings} = await import(`./locale/${svgEditor.curPrefs.lang}.js`);
|
||||
const svgCanvas = svgEditor.canvas;
|
||||
const saveSvgAction = '/+modify';
|
||||
|
||||
@@ -6,13 +6,14 @@
|
||||
* @copyright 2010 Alexis Deveria
|
||||
*
|
||||
*/
|
||||
import {canvg} from '../../external/canvg/canvg.js';
|
||||
import {canvg} from '../../../external/canvg/canvg.js';
|
||||
|
||||
export default {
|
||||
name: 'server_opensave',
|
||||
async init ({$, decode64, encode64, importLocale}) {
|
||||
const strings = await importLocale();
|
||||
async init ({$, decode64, encode64}) {
|
||||
const svgEditor = this;
|
||||
// eslint-disable-next-line node/no-unsupported-features/es-syntax
|
||||
const {default: strings} = await import(`./locale/${svgEditor.curPrefs.lang}.js`);
|
||||
const {
|
||||
curConfig: {
|
||||
extPath,
|
||||
@@ -9,9 +9,10 @@
|
||||
|
||||
export default {
|
||||
name: 'shapes',
|
||||
async init ({$, importLocale}) {
|
||||
const strings = await importLocale();
|
||||
async init ({$}) {
|
||||
const svgEditor = this;
|
||||
// eslint-disable-next-line node/no-unsupported-features/es-syntax
|
||||
const {default: strings} = await import(`./locale/${svgEditor.curPrefs.lang}.js`);
|
||||
const canv = svgEditor.canvas;
|
||||
const svgroot = canv.getRootElem();
|
||||
let lastBBox = {};
|
||||
@@ -12,7 +12,7 @@ export default {
|
||||
const svgEditor = this;
|
||||
const svgCanvas = svgEditor.canvas;
|
||||
|
||||
const {$, importLocale} = S; // {svgcontent},
|
||||
const {$} = S; // {svgcontent},
|
||||
let
|
||||
selElems,
|
||||
// editingitex = false,
|
||||
@@ -23,7 +23,8 @@ export default {
|
||||
// newFOG, newFOGParent, newDef, newImageName, newMaskID,
|
||||
// undoCommand = 'Not image',
|
||||
// modeChangeG, ccZoom, wEl, hEl, wOffset, hOffset, ccRgbEl, brushW, brushH;
|
||||
const strings = await importLocale();
|
||||
// eslint-disable-next-line node/no-unsupported-features/es-syntax
|
||||
const {default: strings} = await import(`./locale/${svgEditor.curPrefs.lang}.js`);
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -8,9 +8,10 @@
|
||||
|
||||
export default {
|
||||
name: 'webappfind',
|
||||
async init ({importLocale, $}) {
|
||||
const strings = await importLocale();
|
||||
async init ({$}) {
|
||||
const svgEditor = this;
|
||||
// eslint-disable-next-line node/no-unsupported-features/es-syntax
|
||||
const {default: strings} = await import(`./locale/${svgEditor.curPrefs.lang}.js`);
|
||||
const saveMessage = 'save',
|
||||
readMessage = 'read',
|
||||
excludedMessages = [readMessage, saveMessage];
|
||||
@@ -1,29 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>-</title>
|
||||
<link rel="icon" type="image/png" href="../../images/logo.png" />
|
||||
|
||||
<!-- Lacking browser support -->
|
||||
<script nomodule="" src="../../redirect-on-no-module-support.js"></script>
|
||||
<script type="module" src="../../redirect-on-lacking-support.js"></script>
|
||||
|
||||
<!-- As yet no ES6 -->
|
||||
<script src="../../jquery.min.js"></script>
|
||||
|
||||
<!-- ES6+ polyfills (Babel) -->
|
||||
<script src="../../external/core-js-bundle/minified.js"></script>
|
||||
<script src="../../external/regenerator-runtime/runtime.js"></script>
|
||||
|
||||
<script type="module" src="index.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>Select an image:</h1>
|
||||
<a href="smiley.svg">smiley.svg</a>
|
||||
<br/>
|
||||
<a href="../../images/logo.png">logo.png</a>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,30 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<!-- AUTO-GENERATED FROM imagelib/index-es.html; DO NOT EDIT; use build/build-html.js to build -->
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>-</title>
|
||||
<link rel="icon" type="image/png" href="../../images/logo.png" />
|
||||
|
||||
<!-- Lacking browser support -->
|
||||
<script nomodule="" src="../../redirect-on-no-module-support.js"></script>
|
||||
<script type="module" src="../../redirect-on-lacking-support.js"></script>
|
||||
|
||||
<!-- As yet no ES6 -->
|
||||
<script src="../../jquery.min.js"></script>
|
||||
|
||||
<!-- ES6+ polyfills (Babel) -->
|
||||
<script src="../../external/core-js-bundle/minified.js"></script>
|
||||
<script src="../../external/regenerator-runtime/runtime.js"></script>
|
||||
|
||||
<script defer="defer" src="../../../../dist/extensions/imagelib/index.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>Select an image:</h1>
|
||||
<a href="smiley.svg">smiley.svg</a>
|
||||
<br/>
|
||||
<a href="../../images/logo.png">logo.png</a>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,25 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<!-- AUTO-GENERATED FROM imagelib/openclipart-es.html; DO NOT EDIT; use build/build-html.js to build -->
|
||||
<html lang="en" dir="ltr">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>-</title>
|
||||
<link rel="icon" type="image/png" href="../../images/logo.png" />
|
||||
|
||||
<!-- Lacking browser support -->
|
||||
<script nomodule="" src="../../redirect-on-no-module-support.js"></script>
|
||||
<script type="module" src="../../redirect-on-lacking-support.js"></script>
|
||||
|
||||
<!-- Browser polyfills -->
|
||||
<script src="../../../../dist/dom-polyfill.js"></script>
|
||||
|
||||
<!-- ES6+ polyfills (Babel) -->
|
||||
<script src="../../external/core-js-bundle/minified.js"></script>
|
||||
<script src="../../external/regenerator-runtime/runtime.js"></script>
|
||||
|
||||
<script defer="defer" src="../../../../dist/extensions/imagelib/openclipart.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -45,14 +45,7 @@ svgEditor.setConfig({
|
||||
|
||||
// EXTENSION CONFIG
|
||||
svgEditor.setConfig({
|
||||
extensions: [
|
||||
// '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'
|
||||
],
|
||||
// noDefaultExtensions can only be meaningfully used in
|
||||
// `svgedit-config-es.js` or in the URL
|
||||
extensions: [],
|
||||
noDefaultExtensions: false
|
||||
});
|
||||
|
||||
|
||||
@@ -103,19 +103,6 @@ export const setStrings = function (type, obj, ids) {
|
||||
* @param {string} langParam
|
||||
* @returns {module:locale.AddLangExtensionLocaleData}
|
||||
*/
|
||||
|
||||
let editor_;
|
||||
/**
|
||||
* Sets the current editor instance (on which `addLangData`) exists.
|
||||
* @function init
|
||||
* @memberof module:locale
|
||||
* @param {module:locale.LocaleEditorInit} editor
|
||||
* @returns {void}
|
||||
*/
|
||||
export const init = (editor) => {
|
||||
editor_ = editor;
|
||||
};
|
||||
|
||||
/**
|
||||
* @typedef {PlainObject} module:locale.LangAndData
|
||||
* @property {string} langParam
|
||||
@@ -128,17 +115,7 @@ export const init = (editor) => {
|
||||
* @fires module:svgcanvas.SvgCanvas#event:ext_addLangData
|
||||
* @returns {Promise<module:locale.LangAndData>} Resolves to [`LangAndData`]{@link module:locale.LangAndData}
|
||||
*/
|
||||
export const readLang = async function (langData) {
|
||||
const more = await editor_.addLangData(langParam);
|
||||
$.each(more, function (i, m) {
|
||||
if (m.data) {
|
||||
langData = $.merge(langData, m.data);
|
||||
}
|
||||
});
|
||||
|
||||
// Old locale file, do nothing for now.
|
||||
if (!langData.tools) { return undefined; }
|
||||
|
||||
export const readLang = function (langData) {
|
||||
const {
|
||||
tools,
|
||||
// misc,
|
||||
|
||||
@@ -42,8 +42,7 @@ import jQueryPluginDBox from '../svgcanvas/dbox.js';
|
||||
|
||||
import {
|
||||
readLang, putLocale,
|
||||
setStrings,
|
||||
init as localeInit
|
||||
setStrings
|
||||
} from './locale.js';
|
||||
|
||||
const {$q} = Utils;
|
||||
@@ -130,17 +129,17 @@ const callbacks = [],
|
||||
* @type {string[]}
|
||||
*/
|
||||
defaultExtensions = [
|
||||
'ext-connector.js',
|
||||
'ext-eyedropper.js',
|
||||
'ext-grid.js',
|
||||
'ext-imagelib.js',
|
||||
'ext-markers.js',
|
||||
'ext-overview_window.js',
|
||||
'ext-panning.js',
|
||||
'ext-polygon.js',
|
||||
'ext-shapes.js',
|
||||
'ext-star.js',
|
||||
'ext-storage.js'
|
||||
'ext-connector',
|
||||
'ext-eyedropper',
|
||||
'ext-grid',
|
||||
'ext-imagelib',
|
||||
'ext-markers',
|
||||
'ext-overview_window',
|
||||
'ext-panning',
|
||||
'ext-polygon',
|
||||
'ext-shapes',
|
||||
'ext-star',
|
||||
'ext-storage'
|
||||
],
|
||||
/**
|
||||
* @typedef {"@default"|string} module:SVGEditor.Stylesheet `@default` will automatically load all of the default CSS paths for SVGEditor
|
||||
@@ -157,7 +156,7 @@ const callbacks = [],
|
||||
* @property {string} [canvasName="default"] 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
|
||||
* @property {boolean} [no_save_warning=false] If `true`, prevents the warning dialog box from appearing when closing/reloading the page. Mostly useful for testing.
|
||||
* @property {string} [imgPath="images/"] 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.
|
||||
* @property {string} [extPath="extensions/"] The path used for extension files, with trailing slash. Default will be changed to `../dist/extensions/` if this is a modular load. Note that as of version 2.7, this is not configurable by URL for security reasons.
|
||||
* @property {string} [extPath="extensions/"] 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.
|
||||
* @property {boolean} [preventAllURLConfig=false] Set to `true` to override the ability for URLs to set non-content configuration (including extension config). Must be set early, i.e., in `svgedit-config-iife.js`; extension loading is too late!
|
||||
* @property {boolean} [preventURLContentLoading=false] Set to `true` to override the ability for URLs to set URL-based SVG content. Must be set early, i.e., in `svgedit-config-iife.js`; extension loading is too late!
|
||||
* @property {boolean} [lockExtensions=false] Set to `true` 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. Must be set early, i.e., in `svgedit-config-iife.js`; extension loading is too late!
|
||||
@@ -231,7 +230,7 @@ const callbacks = [],
|
||||
no_save_warning: false,
|
||||
// PATH CONFIGURATION
|
||||
// The following path configuration items are disallowed in the URL (as should any future path configurations)
|
||||
extPath: './extensions/', // Default will be changed if this is a non-modular load
|
||||
extPath: './extensions/',
|
||||
imgPath: './images/',
|
||||
// DOCUMENT PROPERTIES
|
||||
// Change the following to a preference (already in the Document Properties dialog)?
|
||||
@@ -319,41 +318,6 @@ async function loadSvgString (str, {noAlert} = {}) {
|
||||
throw new Error('Error loading SVG');
|
||||
}
|
||||
|
||||
/**
|
||||
* @function module:SVGEditor~getImportLocale
|
||||
* @param {PlainObject} defaults
|
||||
* @param {string} defaults.defaultLang
|
||||
* @param {string} defaults.defaultName
|
||||
* @returns {module:SVGEditor~ImportLocale}
|
||||
*/
|
||||
function getImportLocale ({defaultLang, defaultName}) {
|
||||
/**
|
||||
* @function module:SVGEditor~ImportLocale
|
||||
* @param {PlainObject} localeInfo
|
||||
* @param {string} [localeInfo.name] Defaults to `defaultName` of {@link module:SVGEditor~getImportLocale}
|
||||
* @param {string} [localeInfo.lang=defaultLang] Defaults to `defaultLang` of {@link module:SVGEditor~getImportLocale}
|
||||
* @returns {Promise<module:locale.LocaleStrings>} Resolves to {@link module:locale.LocaleStrings}
|
||||
*/
|
||||
return async function importLocaleDefaulting ({name = defaultName, lang = defaultLang} = {}) {
|
||||
/**
|
||||
*
|
||||
* @param {string} language
|
||||
* @returns {Promise<module:locale.LocaleStrings>} Resolves to {@link module:locale.LocaleStrings}
|
||||
*/
|
||||
async function importLocale (language) {
|
||||
const url = `${curConfig.extPath}ext-locale/${name}/${language}.js`;
|
||||
// eslint-disable-next-line node/no-unsupported-features/es-syntax
|
||||
const locale = await import(url);
|
||||
return locale.default;
|
||||
}
|
||||
try {
|
||||
return await importLocale(lang);
|
||||
} catch (err) {
|
||||
return importLocale('en');
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* EXPORTS.
|
||||
*/
|
||||
@@ -797,7 +761,6 @@ editor.init = function () {
|
||||
* @returns {Promise<module:locale.LangAndData>} Resolves to result of {@link module:locale.readLang}
|
||||
*/
|
||||
const extAndLocaleFunc = async function () {
|
||||
// const lang = ('lang' in curPrefs) ? curPrefs.lang : null;
|
||||
const {langParam, langData} = await editor.putLocale(editor.pref('lang'), goodLangs);
|
||||
await setLang(langParam, langData);
|
||||
|
||||
@@ -809,13 +772,6 @@ editor.init = function () {
|
||||
try {
|
||||
await Promise.all(
|
||||
curConfig.extensions.map(async (extname) => {
|
||||
const extensionName = extname.match(/^ext-(.+)\.js/);
|
||||
// const {extName} = extname.match(/^ext-(?<extName>.+)\.js/).groups;
|
||||
if (!extensionName) { // Ensure URL cannot specify some other unintended file in the extPath
|
||||
return undefined;
|
||||
}
|
||||
const url = curConfig.extPath + extname;
|
||||
|
||||
/**
|
||||
* @tutorial ExtensionDocs
|
||||
* @typedef {PlainObject} module:SVGEditor.ExtensionObject
|
||||
@@ -826,16 +782,14 @@ editor.init = function () {
|
||||
/**
|
||||
* @type {module:SVGEditor.ExtensionObject}
|
||||
*/
|
||||
const url = `${curConfig.extPath}${extname}/${extname}.js`;
|
||||
// eslint-disable-next-line node/no-unsupported-features/es-syntax
|
||||
const imported = await import(url);
|
||||
const {name = extensionName[1], init} = imported.default;
|
||||
// const {name = extName, init} = imported;
|
||||
const importLocale = getImportLocale({defaultLang: langParam, defaultName: name});
|
||||
return editor.addExtension(name, (init && init.bind(editor)), {$, importLocale});
|
||||
const {name = extname, init} = imported.default;
|
||||
return editor.addExtension(name, (init && init.bind(editor)), {$, langParam});
|
||||
} catch (err) {
|
||||
// Todo: Add config to alert any errors
|
||||
console.log(err); // eslint-disable-line no-console
|
||||
console.error('Extension failed to load: ' + extname + '; ' + err); // eslint-disable-line no-console
|
||||
console.error('Extension failed to load: ' + extname + '; ', err); // eslint-disable-line no-console
|
||||
return undefined;
|
||||
}
|
||||
})
|
||||
@@ -2874,34 +2828,19 @@ editor.init = function () {
|
||||
}
|
||||
};
|
||||
|
||||
const extsPreLang = [];
|
||||
/**
|
||||
* @param {external:Window} win
|
||||
* @param {module:svgcanvas.SvgCanvas#event:extension_added} ext
|
||||
* @listens module:svgcanvas.SvgCanvas#event:extension_added
|
||||
* @returns {Promise<void>|void} Resolves to `undefined`
|
||||
*/
|
||||
const extAdded = async function (win, ext) {
|
||||
const extAdded = function (win, ext) {
|
||||
if (!ext) {
|
||||
return undefined;
|
||||
}
|
||||
let cbCalled = false;
|
||||
let resizeDone = false;
|
||||
|
||||
if (ext.langReady) {
|
||||
if (editor.langChanged) { // We check for this since the "lang" pref could have been set by storage
|
||||
const lang = editor.pref('lang');
|
||||
await ext.langReady({
|
||||
lang,
|
||||
uiStrings,
|
||||
importLocale: getImportLocale({defaultLang: lang, defaultName: ext.name})
|
||||
});
|
||||
loadedExtensionNames.push(ext.name);
|
||||
} else {
|
||||
extsPreLang.push(ext);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear resize timer if present and if not previously performed,
|
||||
* perform an icon resize.
|
||||
@@ -6090,16 +6029,15 @@ editor.init = function () {
|
||||
// revnums += svgCanvas.getVersion();
|
||||
// $('#copyright')[0].setAttribute('title', revnums);
|
||||
|
||||
const loadedExtensionNames = [];
|
||||
/**
|
||||
* @function module:SVGEditor.setLang
|
||||
* @param {string} lang The language code
|
||||
* @param {module:locale.LocaleStrings} allStrings See {@tutorial LocaleDocs}
|
||||
* @fires module:svgcanvas.SvgCanvas#event:ext_langReady
|
||||
* @fires module:svgcanvas.SvgCanvas#event:ext_langChanged
|
||||
* @returns {Promise<void>} A Promise which resolves to `undefined`
|
||||
* @returns {void} A Promise which resolves to `undefined`
|
||||
*/
|
||||
const setLang = editor.setLang = async function (lang, allStrings) {
|
||||
const setLang = editor.setLang = function (lang, allStrings) {
|
||||
editor.langChanged = true;
|
||||
editor.pref('lang', lang);
|
||||
$('#lang_select').val(lang);
|
||||
@@ -6127,28 +6065,6 @@ editor.init = function () {
|
||||
populateLayers();
|
||||
}
|
||||
|
||||
// In case extensions loaded before the locale, now we execute a callback on them
|
||||
if (extsPreLang.length) {
|
||||
await Promise.all(extsPreLang.map((ext) => {
|
||||
loadedExtensionNames.push(ext.name);
|
||||
return ext.langReady({
|
||||
lang,
|
||||
uiStrings,
|
||||
importLocale: getImportLocale({defaultLang: lang, defaultName: ext.name})
|
||||
});
|
||||
}));
|
||||
extsPreLang.length = 0;
|
||||
} else {
|
||||
loadedExtensionNames.forEach((loadedExtensionName) => {
|
||||
svgCanvas.runExtension(
|
||||
loadedExtensionName,
|
||||
'langReady',
|
||||
/** @type {module:svgcanvas.SvgCanvas#event:ext_langReady} */ {
|
||||
lang, uiStrings, importLocale: getImportLocale({defaultLang: lang, defaultName: loadedExtensionName})
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
svgCanvas.runExtensions('langChanged', /** @type {module:svgcanvas.SvgCanvas#event:ext_langChanged} */ lang);
|
||||
|
||||
// Update flyout tooltips
|
||||
@@ -6171,51 +6087,9 @@ editor.init = function () {
|
||||
$('#tool_pos' + this.id.substr(10))[0].title = this.title;
|
||||
});
|
||||
};
|
||||
localeInit(
|
||||
/**
|
||||
* @implements {module:locale.LocaleEditorInit}
|
||||
*/
|
||||
{
|
||||
/**
|
||||
* Gets an array of results from extensions with a `addLangData` method,
|
||||
* returning an object with a `data` property set to its locales (to be
|
||||
* merged with regular locales).
|
||||
* @param {string} langParam
|
||||
* @fires module:svgcanvas.SvgCanvas#event:ext_addLangData
|
||||
* @todo Can we forego this in favor of `langReady` (or forego `langReady`)?
|
||||
* @returns {module:locale.AddLangExtensionLocaleData[]}
|
||||
*/
|
||||
addLangData (langParam) {
|
||||
return svgCanvas.runExtensions(
|
||||
'addLangData',
|
||||
/**
|
||||
* @function
|
||||
* @type {module:svgcanvas.ExtensionVarBuilder}
|
||||
* @param {string} name
|
||||
* @returns {module:svgcanvas.SvgCanvas#event:ext_addLangData}
|
||||
*/
|
||||
(name) => { // We pass in a function as we don't know the extension name here when defining this `addLangData` method
|
||||
return {
|
||||
lang: langParam,
|
||||
importLocale: getImportLocale({defaultLang: langParam, defaultName: name})
|
||||
};
|
||||
},
|
||||
true
|
||||
);
|
||||
},
|
||||
curConfig
|
||||
}
|
||||
);
|
||||
|
||||
// Load extensions
|
||||
// Bit of a hack to run extensions in local Opera/IE9
|
||||
if (document.location.protocol === 'file:') {
|
||||
setTimeout(extAndLocaleFunc, 100);
|
||||
} else {
|
||||
// Returns a promise (if we wanted to fire 'extensions-loaded' event,
|
||||
// potentially useful to hide interface as some extension locales
|
||||
// are only available after this)
|
||||
extAndLocaleFunc();
|
||||
}
|
||||
extAndLocaleFunc();
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user