Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added ability to modify text alignment, cell and table properties (background and border color, border width) #88

Open
wants to merge 34 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
f24c3a1
Added ability to modify table style properties
YoofiBP Nov 17, 2021
f953635
Modified README
YoofiBP Nov 18, 2021
db46010
Added loading of predifined style
YoofiBP Nov 18, 2021
a4330b4
Added support for text alignment
YoofiBP Nov 18, 2021
98c96d8
Added support for text alignment
YoofiBP Nov 18, 2021
6911fc1
Modified package deets
YoofiBP Nov 18, 2021
f22b8e2
Fixed alignmennt bug
YoofiBP Nov 18, 2021
4a7d96e
Fixed alignmennt bug
YoofiBP Nov 18, 2021
d707cd6
Fixed alignmennt bug
YoofiBP Nov 18, 2021
39d067d
Fixed alignmennt bug
YoofiBP Nov 18, 2021
4579a09
Fixed alignmennt bug
YoofiBP Nov 18, 2021
a51277b
Fixed alignmennt bug
YoofiBP Nov 18, 2021
9c6e126
Fixed alignmennt bug
YoofiBP Nov 18, 2021
3fc43b8
Fixed alignment bug
YoofiBP Nov 18, 2021
393c281
Added first stab of cell styling
YoofiBP Nov 18, 2021
7d9d469
Added first stab of cell styling
YoofiBP Nov 19, 2021
f6a58f3
Completed ability to add cell styling to table
YoofiBP Nov 19, 2021
9c93311
v1.0.1
YoofiBP Nov 19, 2021
b4571e1
Load default styles
YoofiBP Nov 19, 2021
6e2ef5c
v1.0.2
YoofiBP Nov 19, 2021
3b40893
Added console log
YoofiBP Nov 19, 2021
f52c720
v1.0.3
YoofiBP Nov 19, 2021
00babe4
v1.0.1
YoofiBP Nov 19, 2021
1747fcf
Added babel to enable es6 syntax. Fix bug preventing saved styles fro…
YoofiBP Nov 19, 2021
58e36f0
Added comments, typedefs and annotations for documentation
YoofiBP Jan 7, 2022
b0be8d1
Removed support for text alignment in favor of extracting that capabi…
YoofiBP Feb 8, 2022
24ac304
Removed support for text alignment in favor of extracting that capabi…
YoofiBP Feb 8, 2022
fdbe51f
Bug fixes preventig table styles
YoofiBP Apr 13, 2022
92c9e08
Minor update
YoofiBP Apr 13, 2022
2e18e8c
Minor update
YoofiBP Apr 13, 2022
04fe381
Remove ability to set table border width
YoofiBP Apr 14, 2022
900a798
Remove ability to set table border width
YoofiBP Apr 14, 2022
b85bee4
Add word break
YoofiBP Apr 22, 2022
5bcb67b
Add word break
YoofiBP Apr 22, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"presets": [
["@babel/preset-env", {
"useBuiltIns": "usage",
"corejs": "3",
"targets": {
"browsers": [
"last 5 versions",
"ie >= 8"
]
}
}]
]
}
8 changes: 0 additions & 8 deletions .eslintrc

This file was deleted.

85 changes: 80 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
# Table tool

The Table Block for the [Editor.js](https://editorjs.io). Finally improved.
The A Modified Table Block for [Editor.js](https://editorjs.io). Finally improved.

![](https://capella.pics/41294cec-a2b3-4157-8399-ffefed3d8ffd.jpg)
![](https://i.postimg.cc/wMgY2jVY/Screenshot-2022-01-07-at-4-46-13-PM.png)
![](https://i.postimg.cc/V6jcXCXF/Screenshot-2022-01-07-at-4-46-23-PM.png)

## Installation

Get the package

```shell
npm i --save @editorjs/table
npm i chalkboard-table
```
or

```shell
yarn add @editorjs/table
yarn add chalkboard-table
```

## Usage
Expand Down Expand Up @@ -63,13 +65,65 @@ This Tool returns `data` in the following format
| -------------- | ------------ | ----------------------------------------- |
| `withHeadings` | `boolean` | Uses the first line as headings |
| `content` | `string[][]` | two-dimensional array with table contents |
| `tableProperties` | `object` | object with table style properties |
| `cellProperties` | `array` | two-dimensional array with table style properties corresponding to the `content` data structure |
| `textAlignment` | `string` | Alignnment of all text in table |

```json
{
"type" : "table",
"data" : {
"withHeadings": true,
"content" : [ [ "Kine", "Pigs", "Chicken" ], [ "1 pcs", "3 pcs", "12 pcs" ], [ "100$", "200$", "150$" ] ]
"content" : [ [ "Kine", "Pigs", "Chicken" ], [ "1 pcs", "3 pcs", "12 pcs" ], [ "100$", "200$", "150$" ] ],
"tableProperties": {
"borderColor": "#fffff",
"backgroundColor": "#fffff",
"borderWidth": "1px"
},
"cellProperties": [[{
"borderColor": "#fffff",
"backgroundColor": "#fffff",
"borderWidth": "1px"
},
{
"borderColor": "#fffff",
"backgroundColor": "#fffff",
"borderWidth": "1px"
},
{
"borderColor": "#fffff",
"backgroundColor": "#fffff",
"borderWidth": "1px"
}],[{
"borderColor": "#fffff",
"backgroundColor": "#fffff",
"borderWidth": "1px"
},
{
"borderColor": "#fffff",
"backgroundColor": "#fffff",
"borderWidth": "1px"
},
{
"borderColor": "#fffff",
"backgroundColor": "#fffff",
"borderWidth": "1px"
}],[{
"borderColor": "#fffff",
"backgroundColor": "#fffff",
"borderWidth": "1px"
},
{
"borderColor": "#fffff",
"backgroundColor": "#fffff",
"borderWidth": "1px"
},
{
"borderColor": "#fffff",
"backgroundColor": "#fffff",
"borderWidth": "1px"
}]],
"textAlignment": "center"
}
}
```
Expand All @@ -82,10 +136,31 @@ If you're using this tool and editor.js in your business, please consider suppor

# About CodeX

<img align="right" width="120" height="120" src="https://codex.so/public/app/img/codex-logo.svg" hspace="50">
<img alt="codex" align="right" width="120" height="120" src="https://codex.so/public/app/img/codex-logo.svg" hspace="50">

CodeX is a team of digital specialists around the world interested in building high-quality open source products on a global market. We are [open](https://codex.so/join) for young people who want to constantly improve their skills and grow professionally with experiments in leading technologies.

| 🌐 | Join 👋 | Twitter | Instagram |
| -- | -- | -- | -- |
| [codex.so](https://codex.so) | [codex.so/join](https://codex.so/join) |[@codex_team](http://twitter.com/codex_team) | [@codex_team](http://instagram.com/codex_team) |

# Version Log
2.0.1 - Initial Version with table properties

2.0.2 - Added support for rendering saved properties

2.0.3 - Adding support for aligning table text

2.0.4 - Fixed bug preventing alignment showing in saved data

2.0.5 - Alignment bug

2.0.6 - Don't ask

2.0.7 - Trying something

2.0.8 - Cleaning

2.0.9 - Still here

2.1.0 - Completed adding cell properties
127 changes: 110 additions & 17 deletions example.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,114 @@

<script>

const sampleData = {
"time": 1637357541154,
"blocks": [
{
"id": "XXVTfnMlcE",
"type": "table",
"data": {
"withHeadings": true,
"content": [
[
"English",
"Russian",
"Japanese"
],
[
"Sweet",
"Сладкий",
"あまい"
],
[
"Good morning",
"Доброе утро",
"おはようございます"
]
],
"tableProperties": {
"backgroundColor": "#c91818",
"borderColor": "#e8e8eb",
"borderWidth": "1px"
},
"textAlignment": "left",
"cellProperties": [
[
{
"backgroundColor": "#c91818",
"borderColor": "#e8e8eb",
"borderWidth": "1px"
},
{
"backgroundColor": "#c91818",
"borderColor": "#e8e8eb",
"borderWidth": "1px"
},
{
"backgroundColor": "#c91818",
"borderColor": "#e8e8eb",
"borderWidth": "1px"
}
],
[
{
"backgroundColor": "#32a852",
"borderColor": "#e8e8eb",
"borderWidth": "1px"
},
{
"backgroundColor": "#c91818",
"borderColor": "#e8e8eb",
"borderWidth": "1px"
},
{
"backgroundColor": "#c91818",
"borderColor": "#e8e8eb",
"borderWidth": "1px"
}
],
[
{
"backgroundColor": "#c91818",
"borderColor": "#e8e8eb",
"borderWidth": "1px"
},
{
"backgroundColor": "#c91818",
"borderColor": "#e8e8eb",
"borderWidth": "1px"
},
{
"backgroundColor": "#c91818",
"borderColor": "#e8e8eb",
"borderWidth": "1px"
}
]
]
}
}
],
"version": "2.22.2"
}

const originalData = {
time: 1625072989362,
blocks: [
{
id: "XXVTfnMlcE",
type: "table",
data: {
withHeadings: true,
content: [
["English", "Russian", "Japanese"],
["Sweet", "Сладкий", "あまい"],
["Good morning", "Доброе утро", "おはようございます"]]
}
}
],
version: "2.22.1"
}

const editor = new EditorJS({
autofocus: true,
tools: {
Expand All @@ -52,23 +160,8 @@
inlineToolbar: true,
}
},
data: {
time: 1625072989362,
blocks: [
{
id: "XXVTfnMlcE",
type: "table",
data: {
withHeadings: true,
content: [
["English", "Russian", "Japanese"],
["Sweet", "Сладкий", "あまい"],
["Good morning", "Доброе утро", "おはようございます"]]
}
}
],
version: "2.22.1"
}
data: sampleData,
readOnly: false
});

const saveButton = document.querySelector('.save-button');
Expand Down
22 changes: 16 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"name": "@editorjs/table",
"name": "chalkboard-test-table",
"description": "Table for Editor.js",
"version": "2.0.1",
"version": "2.1.6",
"license": "MIT",
"main": "./dist/table.js",
"scripts": {
"build": "webpack --mode production",
"build:dev": "webpack --mode development --watch",
"build:dev": "npx webpack --mode development --watch",
"lint": "eslint -c ./.eslintrc --ext .js --fix ."
},
"repository": "https://github.com/editor-js/table",
"repository": "https://github.com/YoofiBP/table",
"author": {
"name": "CodeX Team",
"email": "[email protected]"
Expand All @@ -22,18 +22,28 @@
"editorjs"
],
"devDependencies": {
"@babel/core": "^7.16.0",
"@babel/preset-env": "^7.16.4",
"autoprefixer": "^9.3.1",
"babel-loader": "^8.2.3",
"css-loader": "^1.0.0",
"cssnano": "^4.1.7",
"eslint": "^5.8.0",
"eslint-config-codex": "github:codex-team/eslint-config",
"postcss-import": "^12.0.1",
"postcss-loader": "^3.0.0",
"postcss-nested": "^4.1.0",
"postcss-nesting": "^7.0.0",
"style-loader": "^0.23.1",
"svg-inline-loader": "^0.8.0",
"webpack": "^4.29.5",
"webpack-cli": "^3.2.3"
"webpack-cli": "^4.9.1",
"webpack-dev-server": "^4.5.0"
},
"dependencies": {
"@babel/runtime": "^7.16.3",
"chalkboard-plugins": "^1.0.9",
"core-js": "3",
"react": "^17.0.2",
"react-dom": "^17.0.2"
}
}
12 changes: 12 additions & 0 deletions src/img/cell-properties.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions src/img/table-properties.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading