parent
68542c816c
commit
d4e3dcc687
|
|
@ -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.
|
||||
|
|
@ -8,6 +8,7 @@
|
|||
</head>
|
||||
<body>
|
||||
<div id="spreadsheet"></div>
|
||||
<div id="spreadsheet_2"></div>
|
||||
<button id="save_button">Save sheet</button>
|
||||
<button id="load_button">Load sheet</button>
|
||||
<script type="module" src="/src/index.ts"></script>
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
loadButton.addEventListener('click', loadDataFromLS)
|
||||
|
|
|
|||
13
src/main.ts
13
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()
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue