fixed editor

This commit is contained in:
Jan Prochazka
2021-03-27 10:38:49 +01:00
parent 987fe6095a
commit 4f58d2ff80
3 changed files with 28 additions and 12 deletions

View File

@@ -108,6 +108,7 @@
category: 'Data grid',
name: 'Copy to clipboard',
keyText: 'Ctrl+C',
disableHandleKeyText: 'Ctrl+C',
testEnabled: () => getCurrentDataGrid() != null,
onClick: () => getCurrentDataGrid().copyToClipboard(),
});
@@ -1051,6 +1052,7 @@
invalidateCommands();
}}
on:paste={handlePaste}
on:copy={copyToClipboard}
/>
<table
class="table"

View File

@@ -31,6 +31,7 @@
category: 'Data grid',
name: 'Copy to clipboard',
keyText: 'Ctrl+C',
disableHandleKeyText: 'Ctrl+C',
testEnabled: () => getCurrentDataForm() != null,
onClick: () => getCurrentDataForm().copyToClipboard(),
});
@@ -353,6 +354,7 @@
function createMenu() {
return [
{ command: 'dataForm.switchToTable' },
{ command: 'dataForm.copyToClipboard' },
{ divider: true },
{ command: 'dataForm.filterSelected' },
{ command: 'dataForm.addToFilter' },
@@ -526,6 +528,7 @@
invalidateCommands();
}}
on:keydown={handleKeyDown}
on:copy={copyToClipboard}
/>
</div>
{#if rowCountInfo}

View File

@@ -52,6 +52,10 @@
let clientWidth;
let clientHeight;
const stdOptions = {
showPrintMargin: false,
};
$: theme = $currentThemeDefinition?.themeType == 'dark' ? 'twilight' : 'github';
export function getEditor(): ace.Editor {
@@ -86,7 +90,10 @@
$: watchOptions(options);
function watchOptions(newOption: any) {
if (editor) {
editor.setOptions(newOption);
editor.setOptions({
...stdOptions,
newOption,
});
}
}
@@ -124,7 +131,10 @@
contentBackup = value;
setEventCallBacks();
if (options) {
editor.setOptions(options);
editor.setOptions({
...stdOptions,
options,
});
}
editor.container.addEventListener('contextmenu', handleContextMenu);
@@ -141,16 +151,17 @@
});
function setEventCallBacks() {
editor.onBlur = () => dispatch('blur');
editor.onChangeMode = obj => dispatch('changeMode', obj);
editor.onCommandKey = (err, hashId, keyCode) => dispatch('commandKey', { err, hashId, keyCode });
editor.onCopy = () => dispatch('copy');
editor.onCursorChange = () => dispatch('cursorChange');
editor.onCut = () => dispatch('cut');
editor.onDocumentChange = (obj: { data: any }) => dispatch('documentChange', obj);
editor.onFocus = () => dispatch('focus');
editor.onPaste = text => dispatch('paste', text);
editor.onSelectionChange = obj => dispatch('selectionChange', obj);
// editor.onBlur = () => dispatch('blur');
// editor.onChangeMode = obj => dispatch('changeMode', obj);
// editor.onCommandKey = (err, hashId, keyCode) => dispatch('commandKey', { err, hashId, keyCode });
// editor.onCopy = () => dispatch('copy');
// editor.onCursorChange = () => dispatch('cursorChange');
// editor.onCut = () => dispatch('cut');
// editor.onDocumentChange = (obj: { data: any }) => dispatch('documentChange', obj);
// editor.onFocus = () => dispatch('focus');
// editor.onPaste = text => dispatch('paste', text);
// editor.onSelectionChange = obj => dispatch('selectionChange', obj);
editor.setReadOnly(readOnly);
editor.on('change', function () {
const content = editor.getValue();