Skip to content
This repository has been archived by the owner on Dec 15, 2021. It is now read-only.

Commit

Permalink
fixed Firefox bug and issue #2
Browse files Browse the repository at this point in the history
  • Loading branch information
asselinpaul committed Feb 13, 2018
1 parent f7e508c commit f728180
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 17 deletions.
8 changes: 7 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
0.1.0 / 08-07-2015
==================

* Initial release
* Initial release

0.1.3 / 13-02-2018
==================

* Fixed Firefox specific bugs
* Fixed issue: multiple handsontable is not supported in a single page due to getElementsByClassName #2
7 changes: 1 addition & 6 deletions demo/handsontable/handsontable.full.js
Original file line number Diff line number Diff line change
Expand Up @@ -15726,12 +15726,7 @@ function checkboxRenderer(instance, TD, row, col, prop, value, cellProperties) {
} else if (value === null) {
dom.addClass(input, 'noValue');
TD.appendChild(input);
} else {
input.style.display = 'none';
dom.addClass(input, BAD_VALUE_CLASS);
TD.appendChild(input);
TD.appendChild(document.createTextNode('#bad-value#'));
}
}
if (cellProperties.readOnly) {
eventManager.addEventListener(input, 'click', preventDefault);
} else {
Expand Down
5 changes: 1 addition & 4 deletions demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,7 @@ <h1>MediumEditor HandsOnTable</h1>
</p>
</div>
</div>

<script type="text/javascript"
src="../bower_components/medium-editor/dist/js/medium-editor.js">
</script>
<script type="text/javascript" src="../bower_components/medium-editor/dist/js/medium-editor.js"></script>
<script type="text/javascript" src="../dist/js/medium-editor-handsontable.js">
</script>

Expand Down
43 changes: 39 additions & 4 deletions dist/js/medium-editor-handsontable.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ var contextMenu;
}

function parse() {
var spreadsheets = document.getElementsByClassName('handsontable');
var spreadsheets = document.getElementsByClassName('medium-text-handsontable');
for (var k = 0; k < spreadsheets.length; k++) {
if (spreadsheets[k].id !== '') {
var id = spreadsheets[k].id;
Expand Down Expand Up @@ -301,7 +301,7 @@ var contextMenu;
//initialise a blank two dimensional array
var data = new Array(parseInt(rows) + 1);
for (var i = 0; i < data.length; i++) {
data[i] = new Array(parseInt(cols) + 1);
data[i] = Array(parseInt(cols) + 1).fill("");
}

draw(container, data, contextMenuBool, readOnlyBool);
Expand All @@ -313,7 +313,7 @@ var contextMenu;
var text = getSelectionText(this._doc);

html += text;
html += '<div id="spreadsheet' + id + '"></div>';
html += ' <div id="spreadsheet' + id + '"> </div> ';
return html;
}
};
Expand All @@ -325,14 +325,49 @@ var contextMenu;
container.dataset.data = JSON.stringify(data);
}

var checkboxRenderer;

checkboxRenderer = function(instance, td, row, col, prop, value, cellProperties) {
Handsontable.renderers.TextRenderer.apply(this, arguments);
if (value = '') {
td.html = '<input type="checkbox">'
}
td.style.backgroundColor = 'yellow';

};

function draw(container, data, contextMenuBool, readOnlyBool) {
var contextMenuOptions;
if (contextMenuBool) {
contextMenuOptions = ['row_above', 'row_below', '---------', 'col_left',
'col_right', '---------', 'remove_row', 'remove_col',
'---------', 'undo', 'redo', 'make_read_only',
'---------', 'alignment', {
key: 'add_checkmark',
name: 'Insert checkmark',
callback: function(key, selection) {
for (var i = selection.start.col; i <= selection.end.col; i++) {
for (var j = selection.start.row; j <= selection.end.row; j++) {
this.setDataAtCell(j, i, '<input type="checkbox">');

}
}
}
}

];
} else {
contextMenuOptions = false;
}
var html = new Handsontable(container, {
data: data,
className: "medium-text-handsontable",
rowHeaders: true,
colHeaders: true,
contextMenu: contextMenuBool,
contextMenu: contextMenuOptions,
autoWrapCol: true,
autoWrapRow: true,
renderer: 'html',
placeholder: ' ',
autoColumnSize: true,
readOnly: readOnlyBool,
Expand Down
2 changes: 1 addition & 1 deletion dist/js/medium-editor-handsontable.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "medium-editor-handsontable",
"version": "0.1.2",
"version": "0.1.3",
"author": "Paul Asselin <pa.asselin@gmail.com>",
"description": "MediumEditor extension to allow handsontable spreadsheets.",
"main": "dist/js/medium-editor-handsontable.js",
Expand Down

0 comments on commit f728180

Please sign in to comment.