Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(docs-ui): doc custom-range & hyperlink #3928

Merged
merged 76 commits into from
Nov 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
4a23d9e
feat: update
weird94 Oct 26, 2024
6f1be76
feat: update
weird94 Oct 26, 2024
5e8d47f
feat: update
weird94 Oct 26, 2024
faa9038
feat: update
weird94 Oct 26, 2024
a5c9a09
feat: update
weird94 Oct 28, 2024
22956d3
feat: update
weird94 Oct 28, 2024
b3e4582
feat: update
weird94 Oct 28, 2024
d212547
feat: update
weird94 Oct 29, 2024
25ea0b6
feat: update
weird94 Oct 29, 2024
29344a6
feat: update
weird94 Oct 29, 2024
28ab80e
feat: update
weird94 Oct 29, 2024
7f43ff9
feat: update
weird94 Oct 29, 2024
6eb8919
feat: update
weird94 Oct 29, 2024
0519521
feat: update
weird94 Oct 29, 2024
78201b6
Merge remote-tracking branch 'origin/dev' into refactor/doc-link
weird94 Oct 30, 2024
e61c26c
feat: update
weird94 Oct 30, 2024
9cde333
feat: update
weird94 Oct 30, 2024
9685493
feat: update
weird94 Oct 30, 2024
8b0b3e0
feat: update
weird94 Oct 30, 2024
11051bc
feat: update
weird94 Oct 30, 2024
a729379
feat: update
weird94 Oct 30, 2024
d8dea23
Merge remote-tracking branch 'origin/dev' into refactor/doc-link
weird94 Oct 30, 2024
791a64a
feat: update
weird94 Oct 30, 2024
ea11bbe
feat: update
weird94 Oct 30, 2024
9fd90cf
feat: update
weird94 Oct 30, 2024
f104e3f
feat: update
weird94 Oct 30, 2024
a870d8a
feat: update
weird94 Oct 30, 2024
411f0a1
feat: update
weird94 Oct 31, 2024
0fb0404
feat: update
weird94 Oct 31, 2024
41362cc
feat: update
weird94 Oct 31, 2024
421d5d0
Merge remote-tracking branch 'origin/dev' into refactor/doc-link
weird94 Oct 31, 2024
f434a79
fix: disable fx-bar add link
weird94 Oct 31, 2024
6d41f31
fix: label slice
weird94 Oct 31, 2024
8fe37d6
feat: update
weird94 Oct 31, 2024
bdd9766
feat: update
weird94 Oct 31, 2024
32529c9
feat: update
weird94 Oct 31, 2024
5f79299
feat: update
weird94 Oct 31, 2024
d84eff4
feat: update
weird94 Oct 31, 2024
62088eb
feat: update
weird94 Oct 31, 2024
460af83
feat: update
weird94 Oct 31, 2024
2cb59f1
feat: updat
weird94 Oct 31, 2024
e50cede
feat: update
weird94 Oct 31, 2024
8de2848
feat: update
weird94 Oct 31, 2024
ed57ebb
feat: update
weird94 Oct 31, 2024
9b9243e
feat: update
weird94 Oct 31, 2024
ec26125
feat: update
weird94 Oct 31, 2024
413a1e2
feat: update
weird94 Oct 31, 2024
eb6a47b
feat: update
weird94 Oct 31, 2024
f165893
feat: update
weird94 Oct 31, 2024
d28fe30
feat: update
weird94 Oct 31, 2024
3529ce7
feat: update
weird94 Oct 31, 2024
12e716f
feat: update
weird94 Oct 31, 2024
a4ce988
feat: update
weird94 Oct 31, 2024
4b95f4a
feat: update
weird94 Oct 31, 2024
224492c
feat: update
weird94 Nov 1, 2024
1e250a4
feat: update
weird94 Nov 1, 2024
3f754b6
feat: update
weird94 Nov 1, 2024
b76339a
feat: add test
weird94 Nov 1, 2024
0dd91ef
feat: upadte
weird94 Nov 1, 2024
781d575
Merge remote-tracking branch 'origin/dev' into refactor/doc-link-1
weird94 Nov 1, 2024
2b6aa46
feat: update
weird94 Nov 2, 2024
fd87782
feat: update
weird94 Nov 2, 2024
d1b93d2
feat: update
weird94 Nov 2, 2024
6660dca
feat: update
weird94 Nov 2, 2024
080304e
fix: https://github.com/dream-num/univer-pro/issues/3106
weird94 Nov 2, 2024
efb340f
feat: update
weird94 Nov 2, 2024
b35fb47
fix: update
weird94 Nov 2, 2024
075b65c
fix: update
weird94 Nov 2, 2024
c7caa9e
feat: update
weird94 Nov 2, 2024
f51b5fa
feat: update
weird94 Nov 2, 2024
07190ff
feat: update
weird94 Nov 2, 2024
dae0ac4
fix: https://github.com/dream-num/univer-pro/issues/3113
weird94 Nov 2, 2024
a7c9a87
feat: update
weird94 Nov 2, 2024
a9cd2f5
feat: update
weird94 Nov 2, 2024
28db562
feat: update
weird94 Nov 2, 2024
001cb9d
fix: https://github.com/dream-num/univer-pro/issues/3118
weird94 Nov 2, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
"dependencies": {
"@univerjs/protocol": "0.1.39-alpha.38",
"@wendellhu/redi": "0.16.1",
"fast-diff": "1.3.0",
"kdbush": "^4.0.2",
"lodash-es": "^4.17.21",
"nanoid": "5.0.8",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
* limitations under the License.
*/

import { describe, expect, it } from 'vitest';
import type { IDocumentBody } from '../../../types/interfaces';

import { describe, expect, it } from 'vitest';
import { BooleanNumber } from '../../../types/enum/text-style';
import { replaceInDocumentBody } from '../replacement';
import type { IDocumentBody } from '../../../types/interfaces';

function getTestDocumentBody() {
const documentBody = {
Expand Down Expand Up @@ -147,7 +147,7 @@ describe('test case in replaceInDocumentBody utils', () => {
],
} as IDocumentBody;

expect(replaceInDocumentBody(documentBody, '月色', 'Jocs')).toEqual(expectedBody);
expect(replaceInDocumentBody(documentBody, '月色', 'Jocs', true)).toEqual(expectedBody);
});

it('Should replace all `query` to `target` when `target` is empty', () => {
Expand Down Expand Up @@ -205,12 +205,12 @@ describe('test case in replaceInDocumentBody utils', () => {
],
} as IDocumentBody;

expect(replaceInDocumentBody(documentBody, '月色', '')).toEqual(expectedBody);
expect(replaceInDocumentBody(documentBody, '月色', '', true)).toEqual(expectedBody);
});

it('Should return the origin body when the query is empty', () => {
const documentBody = getTestDocumentBody();

expect(replaceInDocumentBody(documentBody, '', 'Jocs')).toEqual(documentBody);
expect(replaceInDocumentBody(documentBody, '', 'Jocs', true)).toEqual(documentBody);
});
});
14 changes: 12 additions & 2 deletions packages/core/src/docs/data-model/replacement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ import { DocumentDataModel } from './document-data-model';
import { JSONX } from './json-x/json-x';
import { TextX } from './text-x/text-x';

export function replaceInDocumentBody(body: IDocumentBody, query: string, target: string): IDocumentBody {
// TODO: this function should be replaced by replaceSelection
export function replaceInDocumentBody(body: IDocumentBody, query: string, target: string, caseSensitive: boolean): IDocumentBody {
if (query === '') {
return body;
}
Expand All @@ -36,7 +37,7 @@ export function replaceInDocumentBody(body: IDocumentBody, query: string, target
let index;

// eslint-disable-next-line no-cond-assign
while ((index = documentDataModel.getBody()!.dataStream.indexOf(query)) >= 0) {
while ((index = (caseSensitive ? documentDataModel.getBody()!.dataStream : documentDataModel.getBody()!.dataStream.toLowerCase()).indexOf(query)) >= 0) {
const textX = new TextX();
const jsonX = JSONX.getInstance();

Expand All @@ -58,6 +59,15 @@ export function replaceInDocumentBody(body: IDocumentBody, query: string, target
}];
}

if (sliceBody?.customRanges?.length) {
const customRange = sliceBody.customRanges[0];
replaceBody.customRanges = [{
...customRange,
startIndex: 0,
endIndex: target.length - 1,
}];
}

textX.insert(target.length, replaceBody);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,7 @@ describe('transform()', () => {
dataStream: '',
customRanges: [
{
startIndex: -1,
startIndex: 0,
endIndex: 0,
rangeId: 'rangeId',
rangeType: CustomRangeType.HYPERLINK,
Expand All @@ -746,7 +746,7 @@ describe('transform()', () => {
dataStream: '',
customRanges: [
{
startIndex: -1,
startIndex: 0,
endIndex: 0,
rangeId: 'rangeId',
rangeType: CustomRangeType.HYPERLINK,
Expand All @@ -768,7 +768,7 @@ describe('transform()', () => {
dataStream: '',
customRanges: [
{
startIndex: -1,
startIndex: 0,
endIndex: 0,
rangeId: 'rangeId',
rangeType: CustomRangeType.HYPERLINK,
Expand All @@ -790,7 +790,7 @@ describe('transform()', () => {
dataStream: '',
customRanges: [
{
startIndex: -1,
startIndex: 0,
endIndex: 0,
rangeId: 'rangeId',
rangeType: CustomRangeType.HYPERLINK,
Expand Down
Loading
Loading