Skip to content

Commit

Permalink
Merge pull request #126 from phr0:multi-icon-upload
Browse files Browse the repository at this point in the history
Add multi icon upload support
  • Loading branch information
hschwentner authored Nov 23, 2022
2 parents bf780ed + 206c875 commit cb6d187
Show file tree
Hide file tree
Showing 2 changed files with 773 additions and 772 deletions.
23 changes: 12 additions & 11 deletions app/domain-story-modeler/features/import/import.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,15 @@ export function setTitleInputLast(title) {
titleInputLast = title;
}

function importIcon(file) {
const reader = new FileReader();
const endIndex = file.name.lastIndexOf('.');
let name = sanitizeIconName(file.name.substring(0, endIndex));

reader.onload = ev => addIMGToIconDictionary(ev.target.result, name + '-custom');
reader.readAsDataURL(file);
}

export function initImports(
elementRegistry,
version,
Expand All @@ -108,16 +117,8 @@ export function initImports(
};

document.getElementById('importIcon').onchange = function() {
const inputIcon = document.getElementById('importIcon').files[0];
let reader = new FileReader();
const endIndex = inputIcon.name.lastIndexOf('.');
let name = sanitizeIconName(inputIcon.name.substring(0, endIndex));

reader.onloadend = function(e) {
addIMGToIconDictionary(e.target.result, name + '-custom');
};

reader.readAsDataURL(inputIcon);
let fileList = Array.from(document.getElementById('importIcon').files);
fileList.forEach(importIcon);
};

document.getElementById('importConfig').onchange = function() {
Expand Down Expand Up @@ -411,4 +412,4 @@ function closeBrokenSVGDialog() {
function closeBrokenDSTDialog() {
brokenDSTInfo.style.display = 'none';
modal.style.display = 'none';
}
}
Loading

0 comments on commit cb6d187

Please sign in to comment.