Adopt latest API breakage

This commit is contained in:
Alexandru Dima 2019-09-30 15:46:51 +02:00
parent dc793af002
commit e0636d94ff
No known key found for this signature in database
GPG key ID: 6E58D7B045760DA0

View file

@ -179,98 +179,116 @@ function createButton(label, onClick) {
function createOptions(editor) {
var options = document.getElementById('options');
let lineNumbers;
options.appendChild(createOptionToggle(
editor,
'lineNumbers',
function(config) {
return config.viewInfo.renderLineNumbers;
function() {
return (lineNumbers === false ? false : true);
},
function(editor, newValue) {
editor.updateOptions({ lineNumbers: newValue ? 'on': 'off' });
}
lineNumbers = newValue;
editor.updateOptions({ lineNumbers: lineNumbers ? 'on' : 'off' });
},
));
let glyphMargin;
options.appendChild(createOptionToggle(
editor,
'glyphMargin',
function(config) {
return config.viewInfo.glyphMargin;
function() {
return (glyphMargin === false ? false : true);
},
function(editor, newValue) {
editor.updateOptions({ glyphMargin: newValue });
glyphMargin = newValue;
editor.updateOptions({ glyphMargin: glyphMargin });
}
));
let minimap;
options.appendChild(createOptionToggle(
editor,
'minimap',
function(config) {
return config.viewInfo.minimap.enabled;
function() {
return (minimap === false ? false : true);
},
function(editor, newValue) {
editor.updateOptions({ minimap: { enabled: newValue } });
minimap = newValue;
editor.updateOptions({ minimap: { enabled: minimap } });
}
));
let roundedSelection;
options.appendChild(createOptionToggle(
editor,
'roundedSelection',
function(config) {
return config.viewInfo.roundedSelection;
function() {
return (roundedSelection === false ? false : true);
},
function(editor, newValue) {
editor.updateOptions({ roundedSelection: newValue });
roundedSelection = newValue;
editor.updateOptions({ roundedSelection: roundedSelection });
}
));
let scrollBeyondLastLine;
options.appendChild(createOptionToggle(
editor,
'scrollBeyondLastLine',
function(config) {
return config.viewInfo.scrollBeyondLastLine;
function() {
return (scrollBeyondLastLine === false ? false : true);
}, function(editor, newValue) {
editor.updateOptions({ scrollBeyondLastLine: newValue });
scrollBeyondLastLine = newValue;
editor.updateOptions({ scrollBeyondLastLine: scrollBeyondLastLine });
}
));
let renderWhitespace;
options.appendChild(createOptionToggle(
editor,
'renderWhitespace',
function(config) {
return config.viewInfo.renderWhitespace;
function() {
return (renderWhitespace === true ? true : false);
}, function(editor, newValue) {
editor.updateOptions({ renderWhitespace: newValue });
renderWhitespace = newValue;
editor.updateOptions({ renderWhitespace: renderWhitespace });
}
));
let readOnly;
options.appendChild(createOptionToggle(
editor,
'readOnly',
function(config) {
return config.readOnly;
function() {
return (readOnly === true ? true : false);
},
function(editor, newValue) {
editor.updateOptions({ readOnly: newValue });
readOnly = newValue;
editor.updateOptions({ readOnly: readOnly });
}
));
let wordWrap;
options.appendChild(createOptionToggle(
editor,
'wordWrap',
function(config) {
return config.wrappingInfo.isViewportWrapping;
function() {
return (wordWrap === true ? true : false);
}, function(editor, newValue) {
editor.updateOptions({ wordWrap: newValue ? 'on' : 'off' });
wordWrap = newValue;
editor.updateOptions({ wordWrap: wordWrap ? 'on' : 'off' });
}
));
let folding;
options.appendChild(createOptionToggle(
editor,
'folding',
function(config) {
return config.contribInfo.folding;
function() {
return (folding === false ? false : true);
}, function(editor, newValue) {
editor.updateOptions({ folding: newValue });
folding = newValue;
editor.updateOptions({ folding: folding });
}
));
}
@ -290,7 +308,7 @@ function createOptionToggle(editor, labelText, stateReader, setState) {
domNode.appendChild(label);
var renderState = function() {
input.checked = stateReader(editor.getConfiguration());
input.checked = stateReader();
};
renderState();
@ -298,7 +316,7 @@ function createOptionToggle(editor, labelText, stateReader, setState) {
renderState();
});
input.onchange = function() {
setState(editor, !stateReader(editor.getConfiguration()));
setState(editor, !stateReader());
};
return domNode;