Compare commits

..

No commits in common. "master" and "v1.1.0" have entirely different histories.

6 changed files with 10 additions and 111 deletions

View File

@ -1,76 +0,0 @@
# Mini excel app
## _Small application covering the basic functionality of Excel_
The application is a SPA consisting of two screens
- Dashboard (Create new table or open saved)
- Excel (Excel table editing page)
Technologies used in this project:
- Typescript
- ES6+
- SCSS
- Redux
- Webpack 5
- Jest
## Implemented functionality
- Resize table rows/columns
- Navigation and selection of cells using the function keys (Ctrl, Shift, Arrows), or using the mouse
- Mathematical calculations in a formula
- Ability to add/remove columns via context menu (right mouse button)
- Changing cell style: size, font, alignment
- Saving to LocalStorage, also implemented the ability to delete certain tables
## Installation
Requires [Node.js](https://nodejs.org/) v16+ to run.
Install the dependencies and devDependencies and start the server.
```sh
npm install
```
For development run the command to create local webpack dev server
```sh
npm run start
```
For build use
```sh
npm run build
```
For deploy edit deploy config file `configs/deploy/sftp-configs.js`
```sh
module.exports = {
config: {
host: 'host',
port: 'port',
username: 'username',
password: 'password',
},
directory: 'path to directory'
};
```
and run
```sh
npm run deploy
```
Testing
Run jest test by
```sh
npm run test
```
or
```sh
npm run test-watch
```
## License
MIT

View File

@ -1,10 +0,0 @@
module.exports = {
config: {
host: 'host',
port: 'port',
username: 'username',
password: 'password',
},
directory: 'directory'
};

View File

@ -3,9 +3,9 @@
const path = require('path'); const path = require('path');
const SftpClient = require('ssh2-sftp-client'); const SftpClient = require('ssh2-sftp-client');
const dotenv = require('dotenv'); const dotenv = require('dotenv');
const { config, directory } = require('./configs/deploy/sftp-config'); const { config } = require('./configs/deploy/sftp-config');
const REMOTE_DIRECTORY = directory; const REMOTE_DIRECTORY = '/var/www/mysite/excel';
const LOCAL_DIRECTORY = path.join(__dirname, 'dist'); const LOCAL_DIRECTORY = path.join(__dirname, 'dist');
const dotenvPath = path.join(__dirname, '..', '.env'); const dotenvPath = path.join(__dirname, '..', '.env');

View File

@ -1,6 +1,6 @@
{ {
"name": "excel-course", "name": "excel-course",
"version": "1.1.0", "version": "1.0.0",
"main": "index.js", "main": "index.js",
"devDependencies": { "devDependencies": {
"@babel/core": "^7.18.6", "@babel/core": "^7.18.6",

View File

@ -190,7 +190,7 @@ export class SelectionManager {
}); });
} }
getSiblingCellBySide(side: 'left' | 'right' | 'down' | 'up', $cell = this.$currentSelectedCell): Dom | undefined { getNeighbourCellBySide(side: 'left' | 'right' | 'down' | 'up', $cell = this.$currentSelectedCell): Dom | undefined {
if (!$cell?.isExist) { if (!$cell?.isExist) {
console.error('Нет стартовой ячейки'); console.error('Нет стартовой ячейки');
return; return;
@ -235,7 +235,7 @@ export class SelectionManager {
const $current = this.$currentSelectedCell || this.rootTable.focusManager.$currentFocusedCell || this.$currentSelectedCell?.[0]; const $current = this.$currentSelectedCell || this.rootTable.focusManager.$currentFocusedCell || this.$currentSelectedCell?.[0];
if (!$current?.isExist) return; if (!$current?.isExist) return;
const $movingCell = this.getSiblingCellBySide(side, $current); const $movingCell = this.getNeighbourCellBySide(side, $current);
if (!$movingCell?.isExist || !$movingCell) { if (!$movingCell?.isExist || !$movingCell) {
console.error('Ошибка, не найдена ячейка для перемещения'); console.error('Ошибка, не найдена ячейка для перемещения');
return; return;
@ -295,16 +295,9 @@ export class SelectionManager {
this.$currentSelectedCell && this.rootTable.focusManager.focusCell(this.$currentSelectedCell); this.$currentSelectedCell && this.rootTable.focusManager.focusCell(this.$currentSelectedCell);
} }
if (event.key === 'Enter' || event.key === 'Tab') {
let side;
if (event.key === 'Enter' && !event.shiftKey) side = 'down';
if (event.key === 'Tab') side = event.shiftKey ? 'left' : 'right';
side && this.moveSelectionTo(side);
}
return; return;
} }
event.preventDefault(); event.preventDefault();
let $cell: Dom | undefined; let $cell: Dom | undefined;
@ -351,7 +344,7 @@ export class SelectionManager {
if (!side) return; if (!side) return;
$cell = this.getSiblingCellBySide(side, this.$currentSelectedCell || this.$firstSelectedCell); $cell = this.getNeighbourCellBySide(side, this.$currentSelectedCell || this.$firstSelectedCell);
if (event.ctrlKey && $cell?.isExist) { if (event.ctrlKey && $cell?.isExist) {
this.addCellToSelection($cell); this.addCellToSelection($cell);
@ -369,7 +362,7 @@ export class SelectionManager {
return; return;
} }
$cell = this.getSiblingCellBySide(side, this.$firstSelectedCell || this.$currentSelectedCell); $cell = this.getNeighbourCellBySide(side, this.$firstSelectedCell || this.$currentSelectedCell);
if (!$cell || !$cell.isExist) return; if (!$cell || !$cell.isExist) return;
this.selectCell($cell); this.selectCell($cell);

View File

@ -50,16 +50,8 @@ export class Table extends ExcelComponent {
this.initTable(); this.initTable();
this.$onEventFromObserver('formula:input', (text) => { this.$onEventFromObserver('formula:input', this.updateTextInCell);
if (!this.focusManager.$currentFocusedCell) this.updateTextInCell(text, this.selectionManager.$currentSelectedCell, true); // this.$onEventFromObserver('formula:enter-press', () => this.selection.$currentCell.focus());
else this.updateTextInCell(text, this.focusManager.$currentFocusedCell, true);
});
this.$onEventFromObserver('formula:enter-press', () => {
this.focusManager.focusCell(this.selectionManager.$currentSelectedCell);
this.updateTextInCell(this.selectionManager.$currentSelectedCell?.text, this.focusManager.$currentFocusedCell, false);
});
this.$onEventFromObserver('toolbar:applyStyle', this.updateCurrentStyles); this.$onEventFromObserver('toolbar:applyStyle', this.updateCurrentStyles);
this.$onEventFromObserver('toolbar:add-row', this.addNewRowHandler); this.$onEventFromObserver('toolbar:add-row', this.addNewRowHandler);
this.$onEventFromObserver('toolbar:remove-row', this.removeRowHandler); this.$onEventFromObserver('toolbar:remove-row', this.removeRowHandler);