diff --git a/src/editor/extensions/ext-connector/ext-connector.js b/src/editor/extensions/ext-connector/ext-connector.js index acdf2b41..22d161c1 100644 --- a/src/editor/extensions/ext-connector/ext-connector.js +++ b/src/editor/extensions/ext-connector/ext-connector.js @@ -640,13 +640,13 @@ export default { return {remove}; }, toolButtonStateUpdate (opts) { + const button = document.getElementById('mode_connect'); if (opts.nostroke) { - if ($('#mode_connect').hasClass('tool_button_current')) { + if (button.pressed === true) { svgEditor.clickSelect(); } } - $('#mode_connect') - .toggleClass('disabled', opts.nostroke); + button.disabled = opts.nostroke; } }; } diff --git a/src/editor/extensions/ext-grid/ext-grid.js b/src/editor/extensions/ext-grid/ext-grid.js index 666b1473..5d9f95a7 100644 --- a/src/editor/extensions/ext-grid/ext-grid.js +++ b/src/editor/extensions/ext-grid/ext-grid.js @@ -146,24 +146,10 @@ export default { updateGrid(svgCanvas.getZoom()); } $('#canvasGrid').toggle(showGrid); - $('#view_grid').toggleClass('push_button_pressed tool_button'); + document.getElementById('view_grid').pressed = showGrid; } - const buttons = [{ - id: 'view_grid', - icon: 'grid.png', - type: 'context', - panel: 'editor_panel', - events: { - click () { - svgEditor.curConfig.showGrid = showGrid = !showGrid; - gridUpdate(); - } - } - }]; return { name: strings.name, - svgicons: 'grid-icon.xml', - zoomChanged (zoom) { if (showGrid) { updateGrid(zoom); } }, @@ -172,9 +158,13 @@ export default { gridUpdate(); } }, - buttons: strings.buttons.map((button, i) => { - return Object.assign(buttons[i], button); - }) + events: { + id: 'view_grid', + click () { + svgEditor.curConfig.showGrid = showGrid = !showGrid; + gridUpdate(); + } + } }; } }; diff --git a/src/editor/extensions/ext-helloworld/ext-helloworld.js b/src/editor/extensions/ext-helloworld/ext-helloworld.js index 4c3d383b..89e583e8 100644 --- a/src/editor/extensions/ext-helloworld/ext-helloworld.js +++ b/src/editor/extensions/ext-helloworld/ext-helloworld.js @@ -33,33 +33,16 @@ export default { const svgCanvas = svgEditor.canvas; return { name: strings.name, - // For more notes on how to make an icon file, see the source of - // the helloworld-icon.xml - svgicons: 'helloworld-icon.xml', - - // Multiple buttons can be added in this array - buttons: [{ + events: [{ // Must match the icon ID in helloworld-icon.xml id: 'hello_world', - - // Fallback, e.g., for `file:///` access - icon: 'helloworld.png', - - // This indicates that the button will be added to the "mode" - // button panel on the left side - type: 'mode', - // Tooltip text title: strings.buttons[0].title, - - // Events - events: { - click () { - // The action taken when the button is clicked on. - // For "mode" buttons, any other button will - // automatically be de-pressed. - svgCanvas.setMode('hello_world'); - } + click () { + // The action taken when the button is clicked on. + // For "mode" buttons, any other button will + // automatically be de-pressed. + svgCanvas.setMode('hello_world'); } }], // This is triggered when the main mouse button is pressed down diff --git a/src/editor/extensions/ext-markers/ext-markers.js b/src/editor/extensions/ext-markers/ext-markers.js index e91a1d0e..6ee754a7 100644 --- a/src/editor/extensions/ext-markers/ext-markers.js +++ b/src/editor/extensions/ext-markers/ext-markers.js @@ -121,7 +121,7 @@ export default { function setIcon (pos, id) { if (id.substr(0, 1) !== '\\') { id = '\\textmarker'; } const ci = '#' + idPrefix + pos + '_' + id.substr(1); - svgEditor.setIcon('#cur_' + pos + '_marker_list', $(ci).children()); + // svgEditor.setIcon('#cur_' + pos + '_marker_list', $(ci).children()); $(ci).addClass('current').siblings().removeClass('current'); } diff --git a/src/editor/extensions/ext-polygon/ext-polygon.js b/src/editor/extensions/ext-polygon/ext-polygon.js index ab5d9ab8..20f67ebf 100644 --- a/src/editor/extensions/ext-polygon/ext-polygon.js +++ b/src/editor/extensions/ext-polygon/ext-polygon.js @@ -33,22 +33,6 @@ export default { // edg = 0, // undoCommand = 'Not image'; started, newFO; - - // const ccZoom; - // const wEl, hEl; - // const wOffset, hOffset; - // const ccRBG; - // const ccOpacity; - // const brushW, brushH; - - // const ccDebug = document.getElementById('debugpanel'); - - /* const properlySourceSizeTextArea = function(){ - // TODO: remove magic numbers here and get values from CSS - const height = $('#svg_source_container').height() - 80; - $('#svg_source_textarea').css('height', height); - }; */ - /** * @param {boolean} on * @returns {void} @@ -102,55 +86,13 @@ export default { * @param {string} tex The itex text. * @returns {boolean} This function returns false if the set was unsuccessful, true otherwise. */ - /* - function setItexString(tex) { - const mathns = 'http://www.w3.org/1998/Math/MathML', - xmlnsns = 'http://www.w3.org/2000/xmlns/', - ajaxEndpoint = '../../itex'; - const elt = selElems[0]; - try { - const math = svgdoc.createElementNS(mathns, 'math'); - math.setAttributeNS(xmlnsns, 'xmlns', mathns); - math.setAttribute('display', 'inline'); - const semantics = document.createElementNS(mathns, 'semantics'); - const annotation = document.createElementNS(mathns, 'annotation'); - annotation.setAttribute('encoding', 'application/x-tex'); - annotation.textContent = tex; - const mrow = document.createElementNS(mathns, 'mrow'); - semantics.append(mrow, annotation); - math.append(semantics); - // make an AJAX request to the server, to get the MathML - $.post(ajaxEndpoint, {tex, display: 'inline'}, function(data){ - const children = data.documentElement.childNodes; - while (children.length > 0) { - mrow.append(svgdoc.adoptNode(children[0], true)); - } - svgCanvas.sanitizeSvg(math); - svgCanvas.call('changed', [elt]); - }); - elt.firstChild.replaceWith(math); - svgCanvas.call('changed', [elt]); - svgCanvas.clearSelection(); - } catch(e) { - console.log(e); - return false; - } - - return true; - } - */ - const buttons = [{ + const events = { id: 'tool_polygon', - icon: 'polygon.png', - type: 'mode', - position: 11, - events: { - click () { - svgCanvas.setMode('polygon'); - showPanel(true); - } + click () { + svgCanvas.setMode('polygon'); + showPanel(true); } - }]; + }; const contextTools = [{ type: 'input', panel: 'polygon_panel', @@ -164,11 +106,8 @@ export default { } }]; return { - newUI: true, name: strings.name, - buttons: strings.buttons.map((button, i) => { - return Object.assign(buttons[i], button); - }), + events, context_tools: strings.contextTools.map((contextTool, i) => { return Object.assign(contextTools[i], contextTool); }), diff --git a/src/editor/extensions/ext-shapes/ext-shapes.js b/src/editor/extensions/ext-shapes/ext-shapes.js index ae12d761..545140ab 100644 --- a/src/editor/extensions/ext-shapes/ext-shapes.js +++ b/src/editor/extensions/ext-shapes/ext-shapes.js @@ -7,23 +7,10 @@ * */ -const loadExtensionTranslation = async function (lang) { - let translationModule; - try { - translationModule = await import(`./locale/${encodeURIComponent(lang)}.js`); - } catch (_error) { - // eslint-disable-next-line no-console - console.error(`Missing translation (${lang}) - using 'en'`); - translationModule = await import(`./locale/en.js`); - } - return translationModule.default; -}; - export default { name: 'shapes', - async init ({$}) { + init ({$}) { const svgEditor = this; - const strings = await loadExtensionTranslation(svgEditor.curPrefs.lang); const canv = svgEditor.canvas; const svgroot = canv.getRootElem(); let lastBBox = {}; @@ -35,21 +22,15 @@ export default { let startX; let startY; - const buttons = [{ - id: 'tool_shapelib_show', - type: 'mode_flyout', - events: { - click () { - canv.setMode(modeId); - } + const events = { + id: 'tool_shapelib', + click () { + canv.setMode(modeId); } - }]; + }; return { - newUI: true, - buttons: strings.buttons.map((button, i) => { - return Object.assign(buttons[i], button); - }), + events, callback () { // should later register the event }, @@ -57,7 +38,7 @@ export default { const mode = canv.getMode(); if (mode !== modeId) { return undefined; } - const currentD = document.getElementById('tool_shapelib_show').dataset.draw; + const currentD = document.getElementById('tool_shapelib').dataset.draw; startX = opts.start_x; const x = startX; startY = opts.start_y; diff --git a/src/editor/images/grid.png b/src/editor/images/grid.png deleted file mode 100644 index 75e400ef..00000000 Binary files a/src/editor/images/grid.png and /dev/null differ diff --git a/src/editor/images/grid-icon.xml b/src/editor/images/grid.svg similarity index 77% rename from src/editor/images/grid-icon.xml rename to src/editor/images/grid.svg index 3ec53911..4a2167fa 100644 --- a/src/editor/images/grid-icon.xml +++ b/src/editor/images/grid.svg @@ -1,13 +1,3 @@ - + \ No newline at end of file diff --git a/src/editor/index.html b/src/editor/index.html index 0c5b5057..1db526a3 100644 --- a/src/editor/index.html +++ b/src/editor/index.html @@ -96,6 +96,7 @@