Skip to content

Commit aa28b96

Browse files
author
QuantLab
committed
minor fix to xls toolbar
1 parent 2d6a81e commit aa28b96

3 files changed

Lines changed: 19 additions & 61 deletions

File tree

packages/spreadsheet/src/panel.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ import {
4747
*/
4848
const SPREADSHEET_PANEL_CLASS = 'jp-SpreadsheetPanel';
4949

50-
const SPREADSHEET_PANEL_TOOLBAR_CLASS = 'jp-Spreadsheet-toolbar';
50+
const SPREADSHEET_TOOLBAR_CLASS = 'jp-Spreadsheet-toolbar';
5151

52-
const SPREADSHEET_PANEL_SPREADSHEET_CLASS = 'jp-SpreadsheetPanel-spreadsheet';
52+
const SPREADSHEET_CLASS = 'jp-Spreadsheet';
5353

5454
/**
5555
* The class name added to a dirty widget.
@@ -81,15 +81,15 @@ class SpreadsheetPanel extends Widget implements DocumentRegistry.IReadyWidget {
8181

8282
// Toolbar
8383
let toolbar = new Toolbar();
84-
toolbar.addClass(SPREADSHEET_PANEL_TOOLBAR_CLASS);
84+
toolbar.addClass(SPREADSHEET_TOOLBAR_CLASS);
8585

8686
// spreadsheet
8787
let ssOptions = {
8888
languagePreference: options.languagePreference,
8989
contentFactory: contentFactory
9090
};
9191
let spreadsheet = this.spreadsheet = contentFactory.createSpreadsheet(ssOptions);
92-
spreadsheet.addClass(SPREADSHEET_PANEL_SPREADSHEET_CLASS);
92+
spreadsheet.addClass(SPREADSHEET_CLASS);
9393

9494
layout.addWidget(toolbar);
9595
layout.addWidget(this.spreadsheet);

packages/spreadsheet/src/toolbar.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,8 @@ function createColorSwitcherNode(prompt: string): HTMLElement {
310310
let option = document.createElement('option');
311311
option.value = t.toLowerCase();
312312
option.textContent = t;
313-
option.style.backgroundColor = t;
313+
if(option.value != prompt)
314+
option.style.backgroundColor = t;
314315
select.appendChild(option);
315316
}
316317
select.className = TOOLBAR_DROPDOWN_CLASS;

packages/spreadsheet/src/widget.ts

Lines changed: 13 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import * as Handsontable
2323
/**
2424
* The class name added to a spreadsheet widget.
2525
*/
26-
const SPREADSHEET_CLASS = 'jp-Spreadsheet';
26+
//const SPREADSHEET_CLASS = 'jp-Spreadsheet';
2727

2828

2929
/**
@@ -38,7 +38,7 @@ class Spreadsheet extends Widget {
3838
*/
3939
constructor(options: Spreadsheet.IOptions) {
4040
super();
41-
this.addClass(SPREADSHEET_CLASS);
41+
//this.addClass(SPREADSHEET_CLASS);
4242

4343
}
4444

@@ -189,61 +189,18 @@ class Spreadsheet extends Widget {
189189
for(r = r1; r <= r2; r++){
190190
for(c = c1; c <= c2; c++){
191191
let existing = cell.filter( (item:filterItem) => item.row === r && item.col === c)[0];
192-
switch(property){
193-
case 'fontWeight':
194-
if(existing != null){
195-
if(existing.fontWeight == value)
196-
existing.fontWeight = '';
197-
else
198-
existing.fontWeight = value;
199-
}else{
200-
cell.push({row: r, col: c, fontWeight: value})
201-
}
202-
break;
203-
case 'fontStyle':
204-
if(existing != null){
205-
if(existing.fontStyle == value)
206-
existing.fontStyle = '';
207-
else
208-
existing.fontStyle = value;
209-
}else{
210-
cell.push({row: r, col: c, fontStyle: value})
211-
}
212-
break;
213-
case 'className':
214-
if(existing != null){
215-
if(existing.className == value)
216-
existing.className = '';
217-
else
218-
existing.className = value;
219-
}else{
220-
cell.push({row: r, col: c, className: value})
221-
}
222-
break;
223-
case 'background':
224-
if(existing != null){
225-
if(existing.background == value)
226-
existing.background = '';
227-
else
228-
existing.background = value;
229-
}else{
230-
cell.push({row: r, col: c, background: value})
231-
}
232-
break;
233-
case 'color':
234-
if(existing != null){
235-
if(existing.color == value)
236-
existing.color = '';
237-
else
238-
existing.color = value;
239-
}else{
240-
cell.push({row: r, col: c, color: value})
241-
}
242-
break;
243-
default:
244-
break;
192+
if(existing != null && existing != undefined){
193+
if(existing.hasOwnProperty(property) && existing[property] == value)
194+
existing[property] = '';
195+
else
196+
existing[property] = value;
197+
}else{
198+
let cellStyle:any = {};
199+
cellStyle['row'] = r;
200+
cellStyle['col'] = c;
201+
cellStyle[property] = value;
202+
cell.push(cellStyle);
245203
}
246-
247204
}
248205
}
249206

0 commit comments

Comments
 (0)