Chrome update breaks open file shortcuts

master
Mark MacKay 2021-10-09 16:22:07 -05:00
parent 9b6866991b
commit d2eac1a0e9
5 changed files with 32 additions and 40 deletions

View File

@ -73,6 +73,21 @@
color: var(--z3);
}
.menu_list input[type=file] {
-webkit-appearance: none;
position: absolute;
opacity: 0;
cursor: pointer;
left: 0;
right: 0;
top: 0;
bottom: 0;
display: block;
background: red;
z-index: 100;
}
.menu_list .menu_item.tool_button {
background: transparent;
border: none;

View File

@ -209,17 +209,6 @@ button:focus {
overflow: hidden;
}
input[type=file] {
-webkit-appearance: none;
position: absolute;
opacity: 0;
background: red;
z-index: 10;
height: 30px;
width: 100%;
transform: translate(-100%, 0);
}
.disabled {
opacity: 0.5;
cursor: default;

View File

@ -77,12 +77,14 @@
<div data-action="clear" id="tool_clear" class="menu_item">New Document</div>
<div id="tool_open" class="menu_item">
Open SVG... <span class="shortcut">⌘O</span></div>
<input type="file" accept="image/svg+xml" />
<input type="file" accept="image/svg+xml" />
Open SVG... <span class="shortcut" style="display: none;">⌘O</span>
</div>
<div id="tool_import" class="menu_item">
Place Image... <span class="shortcut">⌘K</span></div>
<input type="file" accept="image/*" />
Place Image... <span class="shortcut" style="display: none;">⌘K</span>
</div>
<div data-action="save" id="tool_save" class="menu_item">Save Image... <span class="shortcut">⌘S</span></div>
<div data-action="export" id="tool_export" class="menu_item">Export as PNG</div>
</div>

View File

@ -124,6 +124,7 @@ MD.Import = function(){
}
function open(){
console.log("open")
$openInput.trigger("click");
}

View File

@ -2193,11 +2193,10 @@ var getMouseTarget = this.getMouseTarget = function(evt) {
root_sctm = svgcontent.querySelector("g").getScreenCTM().inverse();
var pt = transformPoint( evt.pageX, evt.pageY, root_sctm ),
mouse_x = pt.x * current_zoom,
mouse_y = pt.y * current_zoom;
var pt = transformPoint( evt.pageX, evt.pageY, root_sctm );
var mouse_x = pt.x * current_zoom;
var mouse_y = pt.y * current_zoom;
evt.preventDefault();
if(right_click) {
@ -3940,9 +3939,6 @@ var pathActions = canvas.pathActions = function() {
if(current_mode === "path") {
// deselect when start draw
svgCanvas.removeFromSelection(svgCanvas.getSelectedElems())
mouse_x = start_x;
mouse_y = start_y;
@ -4050,7 +4046,7 @@ var pathActions = canvas.pathActions = function() {
var endseg = drawn_path.createSVGPathSegClosePath();
seglist.appendItem(newseg);
seglist.appendItem(endseg);
selectorManager.requestSelector(newpath).showGrips(true);
selectOnly([newpath], true);
} else if(len < 3) {
keep = false;
@ -4145,8 +4141,11 @@ var pathActions = canvas.pathActions = function() {
if(subpath) index += svgedit.path.path.segs.length;
svgedit.path.addPointGrip(index, x, y);
}
keep = true;
keep = true;
}
if (!keep || !newpath) clearSelection();
return;
}
@ -4156,7 +4155,7 @@ var pathActions = canvas.pathActions = function() {
svgedit.path.path.storeD();
var id = evt.target.id;
if (id.substr(0,14) == "pathpointgrip_") {
if (id.includes("pathpointgrip_")) {
// Select this point
var cur_pt = svgedit.path.path.cur_pt = parseInt(id.substr(14));
svgedit.path.path.dragging = [start_x, start_y];
@ -4174,7 +4173,7 @@ var pathActions = canvas.pathActions = function() {
} else {
svgedit.path.path.addPtsToSelection(cur_pt);
}
} else if(id.indexOf("ctrlpointgrip_") == 0) {
} else if(id.includes("ctrlpointgrip_")) {
svgedit.path.path.dragging = [start_x, start_y];
var parts = id.split('_')[1].split('c');
@ -4571,22 +4570,9 @@ var pathActions = canvas.pathActions = function() {
tlist.clear();
path.removeAttribute("transform");
var segList = path.pathSegList;
// Opera/win/non-EN throws an error here.
// TODO: Find out why!
// Presumed fixed in Opera 10.5, so commented out for now
// try {
var len = segList.numberOfItems;
// } catch(err) {
// var fixed_d = pathActions.convertPath(path);
// path.setAttribute('d', fixed_d);
// segList = path.pathSegList;
// var len = segList.numberOfItems;
// }
var len = segList.numberOfItems;
var last_x, last_y;
for (var i = 0; i < len; ++i) {
var seg = segList.getItem(i);
var type = seg.pathSegType;
@ -4604,7 +4590,6 @@ var pathActions = canvas.pathActions = function() {
reorientGrads(path, m);
},
zoomChange: function() {
if(current_mode == "pathedit") {