#65 restore the feature of start/end marker lines

This commit is contained in:
Agriya Dev5
2021-01-19 21:17:05 +05:30
parent 7ea99e484a
commit 8c6ad08e08
21 changed files with 102 additions and 36 deletions

View File

@@ -42,6 +42,7 @@ export class SePromptDialog extends HTMLElement {
} }
break; break;
default: default:
// eslint-disable-next-line no-console
console.error('unkonw attr for:', name, 'newValue =', newValue); console.error('unkonw attr for:', name, 'newValue =', newValue);
break; break;
} }

View File

@@ -121,7 +121,7 @@ export default {
function setIcon (pos, id) { function setIcon (pos, id) {
if (id.substr(0, 1) !== '\\') { id = '\\textmarker'; } if (id.substr(0, 1) !== '\\') { id = '\\textmarker'; }
const ci = '#' + idPrefix + pos + '_' + id.substr(1); 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'); $(ci).addClass('current').siblings().removeClass('current');
} }
@@ -508,7 +508,7 @@ export default {
buttons.push({ buttons.push({
id: idPrefix + pos + '_' + id, id: idPrefix + pos + '_' + id,
svgicon: id, svgicon: id,
icon: 'markers-' + id + '.png', icon: id + '.svg',
title, title,
type: 'context', type: 'context',
events: {click: setArrowFromButton}, events: {click: setArrowFromButton},
@@ -565,7 +565,7 @@ export default {
return { return {
name: strings.name, name: strings.name,
svgicons: 'markers-icons.xml', svgicons: '',
callback () { callback () {
$('#marker_panel').addClass('toolset').hide(); $('#marker_panel').addClass('toolset').hide();
}, },

View File

@@ -0,0 +1,3 @@
<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" width="24" height="24" xmlns:xlink="http://www.w3.org/1999/xlink" class="svg_icon"><svg xmlns="http://www.w3.org/2000/svg" viewBox="-60 -60 120 120">
<path stroke-width="10" stroke="#f9bc01" fill="#f9bc01" d="m-30,-30l0,60l60,0l0,-60z"/>
</svg></svg>

After

Width:  |  Height:  |  Size: 331 B

View File

@@ -0,0 +1,3 @@
<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" width="24" height="24" xmlns:xlink="http://www.w3.org/1999/xlink" class="svg_icon"><svg xmlns="http://www.w3.org/2000/svg" viewBox="-60 -60 120 120">
<path stroke-width="10" stroke="#f9bc01" fill="none" d="m-30,-30l0,60l60,0l0,-60z"/>
</svg></svg>

After

Width:  |  Height:  |  Size: 328 B

View File

@@ -0,0 +1,3 @@
<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" width="24" height="24" xmlns:xlink="http://www.w3.org/1999/xlink" class="svg_icon"><svg xmlns="http://www.w3.org/2000/svg" viewBox="-60 -60 120 120">
<path stroke-width="10" stroke="#f9bc01" fill="none" d="m-20,50l40,-100"/>
</svg></svg>

After

Width:  |  Height:  |  Size: 318 B

View File

@@ -0,0 +1,3 @@
<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" width="24" height="24" xmlns:xlink="http://www.w3.org/1999/xlink" class="svg_icon"><svg xmlns="http://www.w3.org/2000/svg" viewBox="-60 -60 120 120">
<path stroke-width="10" stroke="#f9bc01" fill="#f9bc01" d="m-50,0l100,40l-30,-40l30,-40z"/>
</svg></svg>

After

Width:  |  Height:  |  Size: 335 B

View File

@@ -0,0 +1,3 @@
<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" width="24" height="24" xmlns:xlink="http://www.w3.org/1999/xlink" class="svg_icon"><svg xmlns="http://www.w3.org/2000/svg" viewBox="-60 -60 120 120">
<path stroke-width="10" stroke="#f9bc01" fill="none" d="m-50,0l100,40l-30,-40l30,-40z"/>
</svg></svg>

After

Width:  |  Height:  |  Size: 332 B

View File

@@ -0,0 +1,3 @@
<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" width="24" height="24" xmlns:xlink="http://www.w3.org/1999/xlink" class="svg_icon"><svg xmlns="http://www.w3.org/2000/svg" viewBox="-60 -60 120 120">
<circle stroke-width="10" stroke="#f9bc01" fill="#f9bc01" cy="0" cx="0" r="30"/>
</svg></svg>

After

Width:  |  Height:  |  Size: 324 B

View File

@@ -0,0 +1,3 @@
<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" width="24" height="24" xmlns:xlink="http://www.w3.org/1999/xlink" class="svg_icon"><svg xmlns="http://www.w3.org/2000/svg" viewBox="-60 -60 120 120">
<circle stroke-width="10" stroke="#f9bc01" fill="none" cy="0" cx="0" r="30"/>
</svg></svg>

After

Width:  |  Height:  |  Size: 321 B

View File

@@ -0,0 +1,3 @@
<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" width="24" height="24" xmlns:xlink="http://www.w3.org/1999/xlink" class="svg_icon"><svg xmlns="http://www.w3.org/2000/svg" viewBox="-60 -60 120 120">
<path stroke-width="10" stroke="#f9bc01" fill="#f9bc01" d="m-50,0l100,0"/>
</svg></svg>

After

Width:  |  Height:  |  Size: 318 B

View File

@@ -0,0 +1,3 @@
<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" width="24" height="24" xmlns:xlink="http://www.w3.org/1999/xlink" class="svg_icon"><svg xmlns="http://www.w3.org/2000/svg" viewBox="-60 -60 120 120">
<path stroke-width="10" stroke="#f9bc01" fill="none" d="m-20,-50l40,100"/>
</svg></svg>

After

Width:  |  Height:  |  Size: 318 B

View File

@@ -0,0 +1,3 @@
<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" width="24" height="24" xmlns:xlink="http://www.w3.org/1999/xlink" class="svg_icon"><svg xmlns="http://www.w3.org/2000/svg" viewBox="-60 -60 120 120">
<path stroke-width="10" stroke="#f9bc01" fill="#f9bc01" d="m50,0l-100,40l30,-40l-30,-40z"/>
</svg></svg>

After

Width:  |  Height:  |  Size: 335 B

View File

@@ -0,0 +1,3 @@
<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" width="24" height="24" xmlns:xlink="http://www.w3.org/1999/xlink" class="svg_icon"><svg xmlns="http://www.w3.org/2000/svg" viewBox="-60 -60 120 120">
<path stroke-width="10" stroke="#f9bc01" fill="none" d="m50,0l-100,40l30,-40l-30,-40z"/>
</svg></svg>

After

Width:  |  Height:  |  Size: 332 B

View File

@@ -0,0 +1,3 @@
<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" width="24" height="24" xmlns:xlink="http://www.w3.org/1999/xlink" class="svg_icon"><svg xmlns="http://www.w3.org/2000/svg" viewBox="-60 -60 120 120">
<path stroke-width="10" stroke="#f9bc01" fill="none" d="m-40,-20l80,0l-70,60l30,-80l30,80z"/>
</svg></svg>

After

Width:  |  Height:  |  Size: 337 B

View File

@@ -0,0 +1,3 @@
<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" width="24" height="24" xmlns:xlink="http://www.w3.org/1999/xlink" class="svg_icon"><svg xmlns="http://www.w3.org/2000/svg" viewBox="-60 -60 120 120">
<text xml:space="preserve" text-anchor="middle" font-family="serif" font-size="120" y="40" x="0" stroke-width="0" stroke="#f9bc01" fill="#f9bc01">T</text>
</svg></svg>

After

Width:  |  Height:  |  Size: 392 B

View File

@@ -0,0 +1,3 @@
<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" width="24" height="24" xmlns:xlink="http://www.w3.org/1999/xlink" class="svg_icon"><svg xmlns="http://www.w3.org/2000/svg" viewBox="-60 -60 120 120">
<path stroke-width="10" stroke="#f9bc01" fill="#f9bc01" d="M-30,30 L0,-30 L30,30 Z"/>
</svg></svg>

After

Width:  |  Height:  |  Size: 329 B

View File

@@ -0,0 +1,3 @@
<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" width="24" height="24" xmlns:xlink="http://www.w3.org/1999/xlink" class="svg_icon"><svg xmlns="http://www.w3.org/2000/svg" viewBox="-60 -60 120 120">
<path stroke-width="10" stroke="#f9bc01" fill="none" d="M-30,30 L0,-30 L30,30 Z"/>
</svg></svg>

After

Width:  |  Height:  |  Size: 326 B

View File

@@ -0,0 +1,3 @@
<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" width="24" height="24" xmlns:xlink="http://www.w3.org/1999/xlink" class="svg_icon"><svg xmlns="http://www.w3.org/2000/svg" viewBox="-60 -60 120 120">
<path stroke-width="10" stroke="#f9bc01" fill="none" d="m0,-50l0,100"/>
</svg></svg>

After

Width:  |  Height:  |  Size: 315 B

View File

@@ -0,0 +1,3 @@
<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" width="24" height="24" xmlns:xlink="http://www.w3.org/1999/xlink" class="svg_icon"><svg xmlns="http://www.w3.org/2000/svg" viewBox="-60 -60 120 120">
<path stroke-width="10" stroke="#f9bc01" fill="#f9bc01" d="m-30,30l60,-60m0,60l-60,-60"/>
</svg></svg>

After

Width:  |  Height:  |  Size: 333 B

View File

@@ -722,5 +722,8 @@ ul li.current {
z-index: 20001; z-index: 20001;
} }
/* ------------ */
.dropdown li.tool_button {
width: 24px;
}

View File

@@ -17,7 +17,7 @@
*/ */
import './touch.js'; import './touch.js';
import {isWebkit, isChrome, isMac, isTouch} from '../common/browser.js'; import {isChrome, isMac, isTouch} from '../common/browser.js';
import {convertUnit, isValidUnit} from '../common/units.js'; import {convertUnit, isValidUnit} from '../common/units.js';
import SvgCanvas from '../svgcanvas/svgcanvas.js'; import SvgCanvas from '../svgcanvas/svgcanvas.js';
@@ -861,7 +861,6 @@ class Editor extends EditorStartup {
const w = shower.outerWidth(); const w = shower.outerWidth();
this.css({left: (left + w) * editor.tool_scale, top}); this.css({left: (left + w) * editor.tool_scale, top});
}); });
return;
} }
/** /**
@@ -886,7 +885,6 @@ class Editor extends EditorStartup {
* @param {PlainObject<string, module:SVGEditor.ToolButton>} holders Key is a selector * @param {PlainObject<string, module:SVGEditor.ToolButton>} holders Key is a selector
* @returns {void} * @returns {void}
*/ */
// eslint-disable-next-line class-methods-use-this
setupFlyouts (holders) { setupFlyouts (holders) {
const allHolders = {}; const allHolders = {};
$.each(holders, function (holdSel, btnOpts) { $.each(holders, function (holdSel, btnOpts) {
@@ -936,7 +934,7 @@ class Editor extends EditorStartup {
}); });
} }
if ($(this).hasClass('disabled')) { return false; } if ($(this).hasClass('disabled')) { return false; }
/* if (toolButtonClick(showSel)) { /* if (toolButtonClick(showSel)) {
options.fn(); options.fn();
} */ } */
const icon = (options.icon) ? $.getSvgIcon(options.icon, true) : $(options.sel).children().eq(0).clone(); const icon = (options.icon) ? $.getSvgIcon(options.icon, true) : $(options.sel).children().eq(0).clone();
@@ -1002,8 +1000,7 @@ class Editor extends EditorStartup {
// $('#tools_rect').mouseleave(function () { $('#tools_rect').fadeOut(); }); // $('#tools_rect').mouseleave(function () { $('#tools_rect').fadeOut(); });
}); });
this.setFlyoutTitles(); this.setFlyoutTitles();
this.setFlyoutPositions(); // this.setFlyoutPositions();
console.log("1011 after --->")
} }
/** /**
@@ -1020,6 +1017,23 @@ class Editor extends EditorStartup {
return div; return div;
} }
/**
* @function module:SVGEditor.setIcon
* @param {string|Element|external:jQuery} elem
* @param {string|external:jQuery} iconId
* @returns {void}
*/
setIcon (elem, iconId) {
// eslint-disable-next-line max-len
const icon = (typeof iconId === 'string') ? $('<img src="' + this.configObj.curConfig.imgPath + iconId + '">') : iconId.clone();
if (!icon) {
// Todo: Investigate why this still occurs in some cases
console.log('NOTE: Icon image missing: ' + iconId); // eslint-disable-line no-console
return;
}
$(elem).empty().append(icon);
}
/** /**
* @param {string} elemSel * @param {string} elemSel
* @param {string} listSel * @param {string} listSel
@@ -1031,8 +1045,9 @@ class Editor extends EditorStartup {
* @todo Combine this with `addDropDown` or find other way to optimize. * @todo Combine this with `addDropDown` or find other way to optimize.
* @returns {void} * @returns {void}
*/ */
// eslint-disable-next-line class-methods-use-this
addAltDropDown (elemSel, listSel, callback, opts) { addAltDropDown (elemSel, listSel, callback, opts) {
// eslint-disable-next-line no-shadow
const self = this;
const button = $(elemSel); const button = $(elemSel);
const {dropUp} = opts; const {dropUp} = opts;
const list = $(listSel); const list = $(listSel);
@@ -1041,7 +1056,7 @@ class Editor extends EditorStartup {
} }
list.find('li').bind('mouseup', function (...args) { list.find('li').bind('mouseup', function (...args) {
if (opts.seticon) { if (opts.seticon) {
// setIcon('#cur_' + button[0].id, $(this).children()); self.setIcon('#cur_' + button[0].id, $(this).children());
$(this).addClass('current').siblings().removeClass('current'); $(this).addClass('current').siblings().removeClass('current');
} }
callback.apply(this, ...args); callback.apply(this, ...args);
@@ -1088,7 +1103,7 @@ class Editor extends EditorStartup {
onButton = true; onButton = true;
}); });
} }
}; }
/** /**
* @param {external:Window} win * @param {external:Window} win
@@ -1097,6 +1112,7 @@ class Editor extends EditorStartup {
* @returns {Promise<void>|void} Resolves to `undefined` * @returns {Promise<void>|void} Resolves to `undefined`
*/ */
async extAdded (win, ext) { async extAdded (win, ext) {
// eslint-disable-next-line no-shadow
const self = this; const self = this;
const btnSelects = []; const btnSelects = [];
if (!ext) { if (!ext) {
@@ -1174,7 +1190,9 @@ class Editor extends EditorStartup {
break; break;
} case 'button-select': { } case 'button-select': {
html = '<div id="' + tool.id + '" class="dropdown toolset" title="' + tool.title + '">' + html = '<div id="' + tool.id + '" class="dropdown toolset" title="' + tool.title + '">' +
'<div id="cur_' + tool.id + '" class="icon_label"></div><button></button></div>'; '<div id="cur_' + tool.id + '" class="icon_label"></div>' +
'<button><img class="svg_icon" src="./images/arrow_down.svg" alt="icon" width="7" height="7"></button>' +
'</div>';
const list = $('<ul id="' + tool.id + '_opts"></ul>').appendTo('#option_lists'); const list = $('<ul id="' + tool.id + '_opts"></ul>').appendTo('#option_lists');
@@ -1184,6 +1202,13 @@ class Editor extends EditorStartup {
// Creates the tool, hides & adds it, returns the select element // Creates the tool, hides & adds it, returns the select element
/* const dropdown = */ $(html).appendTo(panel).children(); /* const dropdown = */ $(html).appendTo(panel).children();
btnSelects.push({
elem: ('#' + tool.id),
list: ('#' + tool.id + '_opts'),
title: tool.title,
callback: tool.events.change,
cur: ('#cur_' + tool.id)
});
break; break;
} case 'input': { } case 'input': {
html = '<label' + contId + '>' + html = '<label' + contId + '>' +
@@ -1244,7 +1269,6 @@ class Editor extends EditorStartup {
* @property {module:SVGEditor.Key} [key] The key to bind to the button * @property {module:SVGEditor.Key} [key] The key to bind to the button
*/ */
// Add buttons given by extension // Add buttons given by extension
console.log(ext.buttons);
$.each(ext.buttons, function (i, /** @type {module:SVGEditor.Button} */ btn) { $.each(ext.buttons, function (i, /** @type {module:SVGEditor.Button} */ btn) {
let {id} = btn; let {id} = btn;
let num = i; let num = i;
@@ -1252,12 +1276,11 @@ class Editor extends EditorStartup {
while ($('#' + id).length) { while ($('#' + id).length) {
id = btn.id + '_' + (++num); id = btn.id + '_' + (++num);
} }
console.log(id);
let icon; let icon;
if (!svgicons) { if (!svgicons) {
console.log(btn.icon);
icon = $( icon = $(
'<img src="' + btn.icon + '<img src="' + self.configObj.curConfig.imgPath + btn.icon +
(btn.title ? '" alt="' + btn.title : '') + (btn.title ? '" alt="' + btn.title : '') +
'">' '">'
); );
@@ -1271,7 +1294,6 @@ class Editor extends EditorStartup {
placementObj['#' + id] = svgicon; placementObj['#' + id] = svgicon;
} }
} }
console.log(placementObj);
let cls, parent; let cls, parent;
// Set button up according to its type // Set button up according to its type
@@ -1294,13 +1316,13 @@ class Editor extends EditorStartup {
parent = '#main_menu ul'; parent = '#main_menu ul';
break; break;
} }
let flyoutHolder, showBtn, refData, refBtn; // refData
let flyoutHolder, showBtn, refBtn;
const button = $((btn.list || btn.type === 'app_menu') ? '<li/>' : '<div/>') const button = $((btn.list || btn.type === 'app_menu') ? '<li/>' : '<div/>')
.attr('id', id) .attr('id', id)
.attr('title', btn.title) .attr('title', btn.title)
.addClass(cls); .addClass(cls);
if (!btn.includeWith && !btn.list) { if (!btn.includeWith && !btn.list) {
console.log('1306');
if ('position' in btn) { if ('position' in btn) {
if ($(parent).children().eq(btn.position).length) { if ($(parent).children().eq(btn.position).length) {
$(parent).children().eq(btn.position).before(button); $(parent).children().eq(btn.position).before(button);
@@ -1364,19 +1386,15 @@ class Editor extends EditorStartup {
button.append('<div>').append(btn.title); button.append('<div>').append(btn.title);
} }
} else if (btn.list) { } else if (btn.list) {
console.log('1370');
// Add button to list // Add button to list
button.addClass('push_button'); button.addClass('push_button');
$('#' + btn.list + '_opts').append(button); $('#' + btn.list + '_opts').append(button);
if (btn.isDefault) { if (btn.isDefault) {
$('#cur_' + btn.list).append(button.children().clone()); $('#cur_' + btn.list).append(button.children().clone());
const svgicon = btn.svgicon || btn.id; const svgicon = btn.svgicon || btn.id;
placementObj['#cur_' + btn.list] = svgicon; placementObj['#cur_' + btn.list] = svgicon;
console.log(placementObj);
} }
} else if (btn.includeWith) { } else if (btn.includeWith) {
console.log('1380');
// Add to flyout menu / make flyout menu // Add to flyout menu / make flyout menu
const opts = btn.includeWith; const opts = btn.includeWith;
// opts.button, default, position // opts.button, default, position
@@ -1426,13 +1444,10 @@ class Editor extends EditorStartup {
// curH.reverse(); // curH.reverse();
} }
} }
console.log(svgicons);
if (!svgicons) { if (!svgicons) {
button.append(icon); button.append(icon);
} }
console.log(btn.list);
if (!btn.list) { if (!btn.list) {
console.log('1436');
// Add given events to button // Add given events to button
$.each(btn.events, function (name, func) { $.each(btn.events, function (name, func) {
if (name === 'click' && btn.type === 'mode') { if (name === 'click' && btn.type === 'mode') {
@@ -1462,15 +1477,11 @@ class Editor extends EditorStartup {
}); });
} }
self.setupFlyouts(holders); self.setupFlyouts(holders);
console.log("1471------------->");
}); });
$.each(btnSelects, function () { $.each(btnSelects, function () {
self.addAltDropDown(this.elem, this.list, this.callback, {seticon: true}); self.addAltDropDown(this.elem, this.list, this.callback, {seticon: true});
}); });
console.log(svgicons); /* if (svgicons) {
if (svgicons) {
console.log(`${this.configObj.curConfig.imgPath}${svgicons}`);
return new Promise((resolve, reject) => { // eslint-disable-line promise/avoid-new return new Promise((resolve, reject) => { // eslint-disable-line promise/avoid-new
$.svgIcons(`${this.configObj.curConfig.imgPath}${svgicons}`, { $.svgIcons(`${this.configObj.curConfig.imgPath}${svgicons}`, {
w: 24, h: 24, w: 24, h: 24,
@@ -1489,7 +1500,7 @@ class Editor extends EditorStartup {
} }
}); });
}); });
} } */
} }
if (ext.events) { if (ext.events) {
this.leftPanelHandlers.add(ext.events.id, ext.events.click); this.leftPanelHandlers.add(ext.events.id, ext.events.click);