Added custom cells styles
This commit is contained in:
parent
81bf284591
commit
e7fc5f5614
|
|
@ -70,7 +70,6 @@ export class Scroller {
|
||||||
}
|
}
|
||||||
|
|
||||||
private handleKeydown = (event: KeyboardEvent) => {
|
private handleKeydown = (event: KeyboardEvent) => {
|
||||||
console.log(event.key)
|
|
||||||
//* Navigation
|
//* Navigation
|
||||||
if (['ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown'].includes(event.key)) {
|
if (['ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown'].includes(event.key)) {
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
|
|
@ -108,7 +107,7 @@ export class Scroller {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.key === 'F2') {
|
if (event.key === 'F2' || /^([a-z]|[а-я])$/.test(event.key.toLowerCase())) { //* English and Russian keyboard. Or F2 button
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
if (!this.root.selection.selectedCell) return;
|
if (!this.root.selection.selectedCell) return;
|
||||||
this.root.showEditor(this.root.selection.selectedCell)
|
this.root.showEditor(this.root.selection.selectedCell)
|
||||||
|
|
|
||||||
10
src/main.ts
10
src/main.ts
|
|
@ -45,14 +45,14 @@ export class Spreadsheet {
|
||||||
public cache: Cache
|
public cache: Cache
|
||||||
|
|
||||||
constructor(target: string | HTMLElement, props?: SpreadsheetConstructorProperties) {
|
constructor(target: string | HTMLElement, props?: SpreadsheetConstructorProperties) {
|
||||||
const config = createSampleConfig(10000, 600)
|
const config = createSampleConfig(2000, 600)
|
||||||
if (props?.view) {
|
if (props?.view) {
|
||||||
config.view = props.view
|
config.view = props.view
|
||||||
}
|
}
|
||||||
|
|
||||||
this.config = new Config(config)
|
this.config = new Config(config)
|
||||||
this.sheet = new Sheet(this)
|
this.sheet = new Sheet(this)
|
||||||
const data = createSampleData(10000, 600)
|
const data = createSampleData(2000, 600)
|
||||||
this.table = new Table(this)
|
this.table = new Table(this)
|
||||||
this.scroller = new Scroller(this)
|
this.scroller = new Scroller(this)
|
||||||
this.toolbar = new Toolbar(this)
|
this.toolbar = new Toolbar(this)
|
||||||
|
|
@ -67,6 +67,7 @@ export class Spreadsheet {
|
||||||
this.styles = new Styles()
|
this.styles = new Styles()
|
||||||
this.buildComponent()
|
this.buildComponent()
|
||||||
this.appendTableToTarget(target)
|
this.appendTableToTarget(target)
|
||||||
|
this.renderSheet()
|
||||||
}
|
}
|
||||||
|
|
||||||
private getInitialCache(): Cache {
|
private getInitialCache(): Cache {
|
||||||
|
|
@ -211,9 +212,8 @@ export class Spreadsheet {
|
||||||
|
|
||||||
const spreadsheet = new Spreadsheet('#spreadsheet', {
|
const spreadsheet = new Spreadsheet('#spreadsheet', {
|
||||||
view: {
|
view: {
|
||||||
height: 600,
|
height: 768,
|
||||||
width: 800
|
width: 1366
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
spreadsheet.renderSheet()
|
|
||||||
console.log(spreadsheet)
|
console.log(spreadsheet)
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,16 @@ export type CellConstructorProps = {
|
||||||
position: Position
|
position: Position
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface CellStylesConstructorProps {
|
||||||
|
fontSize: number
|
||||||
|
fontColor: string
|
||||||
|
background: string
|
||||||
|
borderColor: string
|
||||||
|
|
||||||
|
selectedBackground: string
|
||||||
|
selectedFontColor: string
|
||||||
|
}
|
||||||
|
|
||||||
export class CellStyles {
|
export class CellStyles {
|
||||||
fontSize: number = 16
|
fontSize: number = 16
|
||||||
fontColor: string = 'black'
|
fontColor: string = 'black'
|
||||||
|
|
@ -16,6 +26,12 @@ export class CellStyles {
|
||||||
|
|
||||||
selectedBackground = '#4287f5'
|
selectedBackground = '#4287f5'
|
||||||
selectedFontColor = '#ffffff'
|
selectedFontColor = '#ffffff'
|
||||||
|
|
||||||
|
constructor(props?: CellStylesConstructorProps) {
|
||||||
|
if (props) {
|
||||||
|
Object.assign(this, props) // Override default styles
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Position {
|
export class Position {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue