mirror of
https://github.com/dbeaver/cloudbeaver.git
synced 2026-09-24 16:04:36 +08:00
CB-3111 preserve leading spaces (#1458)
This commit is contained in:
@@ -51,4 +51,5 @@ export * from './svgToDataUri';
|
||||
export * from './uriToBlob';
|
||||
export * from './utf8ToBase64';
|
||||
export * from './createLastPromiseGetter';
|
||||
export * from './removeMetadataFromBase64';
|
||||
export * from './removeMetadataFromBase64';
|
||||
export * from './removeLineBreak';
|
||||
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
* CloudBeaver - Cloud Database Manager
|
||||
* Copyright (C) 2020-2022 DBeaver Corp and others
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0.
|
||||
* you may not use this file except in compliance with the License.
|
||||
*/
|
||||
|
||||
import { removeLineBreak } from './removeLineBreak';
|
||||
|
||||
describe('removeLineBreak', () => {
|
||||
it('should remove line break characters from a string', () => {
|
||||
const input = 'This is a\r\ntest string\nwith line breaks\r.';
|
||||
const expectedOutput = 'This is atest stringwith line breaks.';
|
||||
expect(removeLineBreak(input)).toEqual(expectedOutput);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,11 @@
|
||||
/*
|
||||
* CloudBeaver - Cloud Database Manager
|
||||
* Copyright (C) 2020-2022 DBeaver Corp and others
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0.
|
||||
* you may not use this file except in compliance with the License.
|
||||
*/
|
||||
|
||||
export function removeLineBreak(value: string) {
|
||||
return value.replace(/\r?\n|\r/g, '');
|
||||
}
|
||||
@@ -44,7 +44,7 @@
|
||||
|
||||
.text-formatter__value {
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
white-space: pre;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
|
||||
+6
-5
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
import { ResultDataFormat } from '@cloudbeaver/core-sdk';
|
||||
import { removeLineBreak } from '@cloudbeaver/core-utils';
|
||||
|
||||
import { DatabaseDataAction } from '../../DatabaseDataAction';
|
||||
import type { IDatabaseDataSource } from '../../IDatabaseDataSource';
|
||||
@@ -130,14 +131,14 @@ export class ResultSetFormatAction extends DatabaseDataAction<any, IDatabaseResu
|
||||
toDisplayString(value: IResultSetValue): string {
|
||||
value = this.getText(value);
|
||||
|
||||
if (typeof value === 'string' && value.length > 1000) {
|
||||
return value.split('').map(v => (v.charCodeAt(0) < 32 ? ' ' : v)).join('');
|
||||
}
|
||||
|
||||
if (value === null) {
|
||||
return '[null]';
|
||||
}
|
||||
|
||||
return String(value);
|
||||
if (typeof value === 'string' && value.length > 1000) {
|
||||
return removeLineBreak(value.split('').map(v => (v.charCodeAt(0) < 32 ? ' ' : v)).join(''));
|
||||
}
|
||||
|
||||
return removeLineBreak(String(value));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user