Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | 2x 10x 3x 3x | /* * Copyright (c) 2021, salesforce.com, inc. * All rights reserved. * Licensed under the BSD 3-Clause license. * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause */ import { LightningElement, api } from 'lwc'; export default class SvgUploader extends LightningElement { static MAX_SIZE = 200000; @api fileName; @api fileContent; discardSvg = () => { this.dispatchEvent( new CustomEvent('uploadsvg', { detail: { fileName: '', fileContent: '' } }) ); }; get showOutputClass() { return this.fileName ? 'output show' : 'output'; } get showInputClass() { return this.fileName ? 'input' : 'input show'; } loadSvgFile = (e) => { const file = e.currentTarget.files[0]; if (file && file.size < SvgUploader.MAX_SIZE) { const reader = new FileReader(); reader.readAsText(file, 'UTF-8'); reader.onload = (re) => { if (re.target.result) { this.dispatchEvent( new CustomEvent('uploadsvg', { detail: { fileName: file.name, fileContent: re.target.result } }) ); } }; reader.onerror = (re) => { console.error(re); }; e.currentTarget.type = 'text'; e.currentTarget.type = 'file'; } }; } |