// Delete line (or cut)
if ( cm.somethingSelected() ) return true;
- var field = cm.marceditor.getCurrentField();
- if ( field ) field.delete();
+ cm.execCommand('deleteLine');
},
'Shift-Ctrl-X': function( cm ) {
return this.field._subfieldsInvalid();
},
+ delete: function() {
+ this.cm.replaceRange( "", { line: this.field.line, ch: this.start }, { line: this.field.line, ch: this.end }, 'marcAware' );
+ },
focus: function() {
this.cm.setCursor( { line: this.field.line, ch: this.contentsStart } );
},
$.each( subfields, function( i, subfield ) {
var next = subfields[ i + 1 ];
- field.addSubfield( [ subfield.code, line.substring( subfield.ch + 3, next ? next.ch : line.length ) ] );
+ field.addSubfield( [ subfield.code, line.substring( subfield.ch + 2, next ? next.ch : line.length ) ] );
} );
field.sourceLine = i;
$inputs.each( function( i ) {
$(this).on( 'keydown.marc-tab', function( e ) {
- if ( e.which != 9 ) return; // Tab
+ // Cheap hack to disable backspace and special keys
+ if ( ( this.nodeName.toLowerCase() == 'select' && e.which == 9 ) || e.ctrlKey ) {
+ e.preventDefault();
+ return;
+ } else if ( e.which != 9 ) { // Tab
+ return;
+ }
var span = widget.mark.find();
var cur = editor.cm.getCursor();
ActivateAt: function( editor, cur, idx ) {
var marks = editor.findMarksAt( cur );
- if ( !marks.length ) return false;
+ if ( !marks.length || !marks[0].widget ) return false;
var $input = $(marks[0].widget.node).find('input, select').eq(idx || 0);
if ( !$input.length ) return false;
if ( marks.length ) {
if ( marks[0].id == id ) {
return;
- } else {
+ } else if ( marks[0].widget ) {
marks[0].widget.clearToText();
}
}