diff --git a/LICENCE b/LICENCE new file mode 100644 index 0000000..229e601 --- /dev/null +++ b/LICENCE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2021 typeguard, Inc. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/index.html b/index.html index a3b72c1..2a0e6ef 100644 --- a/index.html +++ b/index.html @@ -8,6 +8,7 @@
+
diff --git a/package.json b/package.json index b7a5f96..aca60f0 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "modern_spreadsheet", "private": false, - "version": "0.0.20", + "version": "0.0.21", "exports": { ".": { "import": "./dist/main.js", @@ -21,6 +21,7 @@ ], "type": "module", "homepage": "https://github.com/yazmeyaa/modern_spreadsheet", + "license": "MIT", "repository": { "type": "git", "url": "https://github.com/yazmeyaa/modern_spreadsheet" diff --git a/src/index.ts b/src/index.ts index d2e5c59..e1891f3 100644 --- a/src/index.ts +++ b/src/index.ts @@ -6,6 +6,9 @@ const loadButton = document.querySelector('#load_button') if(!saveButton || !loadButton) throw new Error("LOST") const sheet = new Spreadsheet('#spreadsheet') +const sheet2 = new Spreadsheet('#spreadsheet_2') + +console.log(sheet2) function saveDataToLS() { const serializableData = sheet.serializeData() @@ -20,4 +23,4 @@ function loadDataFromLS() { } saveButton.addEventListener('click', saveDataToLS) -loadButton.addEventListener('click', loadDataFromLS) \ No newline at end of file +loadButton.addEventListener('click', loadDataFromLS) diff --git a/src/main.ts b/src/main.ts index 46b7ea6..9122bd4 100644 --- a/src/main.ts +++ b/src/main.ts @@ -123,6 +123,14 @@ export default class Spreadsheet { this.table.element.append(this.editor.element) } + /**Destroy spreadsheet DOM element. + * + * May be usefull when need to rerender component. + */ + public destroy() { + this.table.element.remove() + } + private appendTableToTarget(target: string | HTMLElement) { if (typeof target === 'string') { const element = document.querySelector(target) @@ -134,6 +142,10 @@ export default class Spreadsheet { } } + /** Canvas rendering context 2D. + * + * Abble to draw on canvas with default CanvasAPI methods + */ get ctx() { return this.sheet.ctx } @@ -142,6 +154,7 @@ export default class Spreadsheet { return this.config.view } + /** Focusing on interactive part of spreadsheet */ focusTable() { this.scroller.element.focus() }