mirror of
https://github.com/jupyter/notebook.git
synced 2025-04-06 13:50:29 +08:00
Merge pull request #1482 from yuvipanda/readonly-cells
Respect 'editable' cell metadata
This commit is contained in:
commit
dd4b052403
@ -501,11 +501,20 @@ define([
|
||||
if (data.metadata !== undefined) {
|
||||
this.metadata = data.metadata;
|
||||
}
|
||||
// upgrade cell's editable metadata if not defined
|
||||
if (this.metadata.editable === undefined) {
|
||||
this.metadata.editable = this.is_editable();
|
||||
}
|
||||
// upgrade cell's deletable metadata if not defined
|
||||
if (this.metadata.deletable === undefined) {
|
||||
this.metadata.deletable = this.is_deletable();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* can the cell be split into two cells (false if not deletable)
|
||||
*
|
||||
* @method is_splittable
|
||||
**/
|
||||
Cell.prototype.is_splittable = function () {
|
||||
@ -522,14 +531,28 @@ define([
|
||||
};
|
||||
|
||||
/**
|
||||
* is the cell deletable? only false (undeletable) if
|
||||
* metadata.deletable is explicitly false -- everything else
|
||||
* is the cell edtitable? only false (readonly) if
|
||||
* metadata.editable is explicitly false -- everything else
|
||||
* counts as true
|
||||
*
|
||||
* @method is_editable
|
||||
**/
|
||||
Cell.prototype.is_editable = function () {
|
||||
if (this.metadata.editable === false) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
/**
|
||||
* is the cell deletable? only false (undeletable) if
|
||||
* metadata.deletable is explicitly false or if the cell is not
|
||||
* editable -- everything else counts as true
|
||||
*
|
||||
* @method is_deletable
|
||||
**/
|
||||
Cell.prototype.is_deletable = function () {
|
||||
if (this.metadata.deletable === false) {
|
||||
if (this.metadata.deletable === false || !this.is_editable()) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -169,6 +169,8 @@ define([
|
||||
if (that.keyboard_manager) {
|
||||
that.keyboard_manager.enable();
|
||||
}
|
||||
|
||||
that.code_mirror.setOption('readOnly', !that.is_editable());
|
||||
});
|
||||
this.code_mirror.on('keydown', $.proxy(this.handle_keyevent,this));
|
||||
$(this.code_mirror.getInputField()).attr("spellcheck", "false");
|
||||
|
@ -103,6 +103,7 @@ define([
|
||||
if (that.keyboard_manager) {
|
||||
that.keyboard_manager.enable();
|
||||
}
|
||||
that.code_mirror.setOption('readOnly', !that.is_editable());
|
||||
});
|
||||
this.code_mirror.on('keydown', $.proxy(this.handle_keyevent,this))
|
||||
// The tabindex=-1 makes this div focusable.
|
||||
|
Loading…
x
Reference in New Issue
Block a user