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>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="spreadsheet"></div>
|
<div id="spreadsheet"></div>
|
||||||
|
<div id="spreadsheet_2"></div>
|
||||||
<button id="save_button">Save sheet</button>
|
<button id="save_button">Save sheet</button>
|
||||||
<button id="load_button">Load sheet</button>
|
<button id="load_button">Load sheet</button>
|
||||||
<script type="module" src="/src/index.ts"></script>
|
<script type="module" src="/src/index.ts"></script>
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "modern_spreadsheet",
|
"name": "modern_spreadsheet",
|
||||||
"private": false,
|
"private": false,
|
||||||
"version": "0.0.20",
|
"version": "0.0.21",
|
||||||
"exports": {
|
"exports": {
|
||||||
".": {
|
".": {
|
||||||
"import": "./dist/main.js",
|
"import": "./dist/main.js",
|
||||||
|
|
@ -21,6 +21,7 @@
|
||||||
],
|
],
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"homepage": "https://github.com/yazmeyaa/modern_spreadsheet",
|
"homepage": "https://github.com/yazmeyaa/modern_spreadsheet",
|
||||||
|
"license": "MIT",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/yazmeyaa/modern_spreadsheet"
|
"url": "https://github.com/yazmeyaa/modern_spreadsheet"
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,9 @@ const loadButton = document.querySelector('#load_button')
|
||||||
if(!saveButton || !loadButton) throw new Error("LOST")
|
if(!saveButton || !loadButton) throw new Error("LOST")
|
||||||
|
|
||||||
const sheet = new Spreadsheet('#spreadsheet')
|
const sheet = new Spreadsheet('#spreadsheet')
|
||||||
|
const sheet2 = new Spreadsheet('#spreadsheet_2')
|
||||||
|
|
||||||
|
console.log(sheet2)
|
||||||
|
|
||||||
function saveDataToLS() {
|
function saveDataToLS() {
|
||||||
const serializableData = sheet.serializeData()
|
const serializableData = sheet.serializeData()
|
||||||
|
|
|
||||||
13
src/main.ts
13
src/main.ts
|
|
@ -123,6 +123,14 @@ export default class Spreadsheet {
|
||||||
this.table.element.append(this.editor.element)
|
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) {
|
private appendTableToTarget(target: string | HTMLElement) {
|
||||||
if (typeof target === 'string') {
|
if (typeof target === 'string') {
|
||||||
const element = document.querySelector(target)
|
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() {
|
get ctx() {
|
||||||
return this.sheet.ctx
|
return this.sheet.ctx
|
||||||
}
|
}
|
||||||
|
|
@ -142,6 +154,7 @@ export default class Spreadsheet {
|
||||||
return this.config.view
|
return this.config.view
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Focusing on interactive part of spreadsheet */
|
||||||
focusTable() {
|
focusTable() {
|
||||||
this.scroller.element.focus()
|
this.scroller.element.focus()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue