Skip to content

Commit c412e7f

Browse files
committed
- support custom class names in cells
1 parent 27c2c0d commit c412e7f

File tree

9 files changed

+41
-10
lines changed

9 files changed

+41
-10
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Change Logs
22

3+
## v0.1.6
4+
5+
- support custom class names in cells
6+
7+
38
## v0.1.5
49

510
- make it possible to add node instead of pure text.

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ initialize:
4141
- `idx`: {row, col}. default {row: true, col: true}
4242
- `size`: {row, col}. force cell size, in array by order.
4343
- default: {row: [], col: []}
44+
- `class`: {row, col}. additional cell class name, in array by order, as space separated string.
45+
- default: {row: [], col: []}
4446
- `editing`: false to disable editing. default true.
4547
- (TBD) in the future we should be able to:
4648
- set edit permission ( e.g., edit, comment )

dist/index.js

Lines changed: 10 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"name": "@plotdb/sheet",
44
"license": "MIT",
55
"description": "spreadsheet",
6-
"version": "0.1.5",
6+
"version": "0.1.6",
77
"main": "dist/index.js",
88
"homepage": "https://github.com/plotdb/sheet",
99
"files": [

src/index.ls

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ sheet = (opt={}) ->
4141
@evt-handler = {}
4242
@_data = opt.data or []
4343
@size = ({row: [], col: []} <<< opt.size){row, col}
44+
@cls = ({row: [], col: []} <<< opt.class){row, col}
4445
@_editing = if opt.editing? => !!opt.editing else true
4546
@dim = col: (opt.{}dim.col or 30), row: (opt.{}dim.row or 30)
4647
@frozen = ({col: 0, row: 0} <<< (opt.frozen or {})){col, row}
@@ -258,7 +259,14 @@ sheet.prototype = Object.create(Object.prototype) <<< do
258259
else [@_data[][@pos.row + y - @xif.row.1][@pos.col + x - @xif.col.1], "cell"]
259260
if !(content?) => content = ""
260261
261-
n.className = className
262+
clsext = if x >= @xif.col.0 and y >= @xif.row.0 =>
263+
(
264+
(@cls.col[@pos.col + x - @xif.col.1] or '') + ' ' +
265+
(@cls.row[@pos.row + y - @xif.row.1] or '')
266+
)
267+
else ''
268+
n.className = (className + ' ' + clsext)
269+
262270
if content != null =>
263271
# TODO support advanced content
264272
if typeof(content) == \object =>

web/static/assets/lib/@plotdb/sheet/dev/index.js

Lines changed: 10 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

web/static/assets/lib/@plotdb/sheet/dev/index.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)