From fb13f5c7dcbcdea635eaeb2fb2bda186549196e0 Mon Sep 17 00:00:00 2001 From: Francis Meng Date: Fri, 21 Jun 2024 11:11:36 -0700 Subject: [PATCH 1/4] Expose splittext pi --- packages/roosterjs-content-model-api/lib/index.ts | 1 + .../lib/publicApi/utils}/splitTextSegment.ts | 7 ++++++- .../lib/autoFormat/hyphen/transformHyphen.ts | 2 +- .../lib/autoFormat/numbers/transformFraction.ts | 2 +- .../lib/autoFormat/numbers/transformOrdinals.ts | 2 +- .../lib/markdown/utils/setFormat.ts | 2 +- .../test/pluginUtils/splitTextSegmentTest.ts | 2 +- 7 files changed, 12 insertions(+), 6 deletions(-) rename packages/{roosterjs-content-model-plugins/lib/pluginUtils => roosterjs-content-model-api/lib/publicApi/utils}/splitTextSegment.ts (81%) diff --git a/packages/roosterjs-content-model-api/lib/index.ts b/packages/roosterjs-content-model-api/lib/index.ts index 4209e3a1a5c..f9c82153f78 100644 --- a/packages/roosterjs-content-model-api/lib/index.ts +++ b/packages/roosterjs-content-model-api/lib/index.ts @@ -18,6 +18,7 @@ export { setTextColor } from './publicApi/segment/setTextColor'; export { changeFontSize } from './publicApi/segment/changeFontSize'; export { applySegmentFormat } from './publicApi/segment/applySegmentFormat'; export { changeCapitalization } from './publicApi/segment/changeCapitalization'; +export { splitTextSegment } from './publicApi/utils/splitTextSegment'; export { insertImage } from './publicApi/image/insertImage'; export { setListStyle } from './publicApi/list/setListStyle'; export { setListStartNumber } from './publicApi/list/setListStartNumber'; diff --git a/packages/roosterjs-content-model-plugins/lib/pluginUtils/splitTextSegment.ts b/packages/roosterjs-content-model-api/lib/publicApi/utils/splitTextSegment.ts similarity index 81% rename from packages/roosterjs-content-model-plugins/lib/pluginUtils/splitTextSegment.ts rename to packages/roosterjs-content-model-api/lib/publicApi/utils/splitTextSegment.ts index 4f7a034e8ae..b26623d43d2 100644 --- a/packages/roosterjs-content-model-plugins/lib/pluginUtils/splitTextSegment.ts +++ b/packages/roosterjs-content-model-api/lib/publicApi/utils/splitTextSegment.ts @@ -5,7 +5,12 @@ import type { } from 'roosterjs-content-model-types'; /** - * @internal + * Split given text segments from the given range + * @param textSegment segment to split + * @param parent parent paragraph the text segment exist in + * @param start starting point of the split + * @param end ending point of the split + * @returns text segment from the indicated split. */ export function splitTextSegment( textSegment: ContentModelText, diff --git a/packages/roosterjs-content-model-plugins/lib/autoFormat/hyphen/transformHyphen.ts b/packages/roosterjs-content-model-plugins/lib/autoFormat/hyphen/transformHyphen.ts index faf8a0bc51e..3d9e6907564 100644 --- a/packages/roosterjs-content-model-plugins/lib/autoFormat/hyphen/transformHyphen.ts +++ b/packages/roosterjs-content-model-plugins/lib/autoFormat/hyphen/transformHyphen.ts @@ -1,4 +1,4 @@ -import { splitTextSegment } from '../../pluginUtils/splitTextSegment'; +import { splitTextSegment } from 'roosterjs-content-model-api'; import type { ContentModelText, FormatContentModelContext, diff --git a/packages/roosterjs-content-model-plugins/lib/autoFormat/numbers/transformFraction.ts b/packages/roosterjs-content-model-plugins/lib/autoFormat/numbers/transformFraction.ts index 098fb556b7c..73012fdb174 100644 --- a/packages/roosterjs-content-model-plugins/lib/autoFormat/numbers/transformFraction.ts +++ b/packages/roosterjs-content-model-plugins/lib/autoFormat/numbers/transformFraction.ts @@ -1,4 +1,4 @@ -import { splitTextSegment } from '../../pluginUtils/splitTextSegment'; +import { splitTextSegment } from 'roosterjs-content-model-api'; import type { ContentModelText, FormatContentModelContext, diff --git a/packages/roosterjs-content-model-plugins/lib/autoFormat/numbers/transformOrdinals.ts b/packages/roosterjs-content-model-plugins/lib/autoFormat/numbers/transformOrdinals.ts index 2bef05ac209..49da2c899be 100644 --- a/packages/roosterjs-content-model-plugins/lib/autoFormat/numbers/transformOrdinals.ts +++ b/packages/roosterjs-content-model-plugins/lib/autoFormat/numbers/transformOrdinals.ts @@ -1,4 +1,4 @@ -import { splitTextSegment } from '../../pluginUtils/splitTextSegment'; +import { splitTextSegment } from 'roosterjs-content-model-api'; import type { ContentModelText, FormatContentModelContext, diff --git a/packages/roosterjs-content-model-plugins/lib/markdown/utils/setFormat.ts b/packages/roosterjs-content-model-plugins/lib/markdown/utils/setFormat.ts index 9d03d41447c..875945c877f 100644 --- a/packages/roosterjs-content-model-plugins/lib/markdown/utils/setFormat.ts +++ b/packages/roosterjs-content-model-plugins/lib/markdown/utils/setFormat.ts @@ -1,5 +1,5 @@ import { formatTextSegmentBeforeSelectionMarker } from 'roosterjs-content-model-api'; -import { splitTextSegment } from '../../pluginUtils/splitTextSegment'; +import { splitTextSegment } from 'roosterjs-content-model-api'; import type { ContentModelCodeFormat, diff --git a/packages/roosterjs-content-model-plugins/test/pluginUtils/splitTextSegmentTest.ts b/packages/roosterjs-content-model-plugins/test/pluginUtils/splitTextSegmentTest.ts index 5d9363fc413..46e09a6ce2f 100644 --- a/packages/roosterjs-content-model-plugins/test/pluginUtils/splitTextSegmentTest.ts +++ b/packages/roosterjs-content-model-plugins/test/pluginUtils/splitTextSegmentTest.ts @@ -1,5 +1,5 @@ import { ContentModelParagraph, ContentModelText } from 'roosterjs-content-model-types'; -import { splitTextSegment } from '../../lib/pluginUtils/splitTextSegment'; +import { splitTextSegment } from 'roosterjs-content-model-api'; describe('splitTextSegment', () => { function runTest( From 69b4c28c6d5990e1c386283ed87d5bd72d43dfe4 Mon Sep 17 00:00:00 2001 From: Francis Meng Date: Mon, 24 Jun 2024 15:50:35 -0700 Subject: [PATCH 2/4] fix build --- .../lib/markdown/utils/setFormat.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/roosterjs-content-model-plugins/lib/markdown/utils/setFormat.ts b/packages/roosterjs-content-model-plugins/lib/markdown/utils/setFormat.ts index 875945c877f..3205c5ce8b0 100644 --- a/packages/roosterjs-content-model-plugins/lib/markdown/utils/setFormat.ts +++ b/packages/roosterjs-content-model-plugins/lib/markdown/utils/setFormat.ts @@ -1,6 +1,7 @@ -import { formatTextSegmentBeforeSelectionMarker } from 'roosterjs-content-model-api'; -import { splitTextSegment } from 'roosterjs-content-model-api'; - +import { + formatTextSegmentBeforeSelectionMarker, + splitTextSegment, +} from 'roosterjs-content-model-api'; import type { ContentModelCodeFormat, ContentModelSegmentFormat, From b2d5f2f88ebfa37426c192ace54fd8bf9856b2e5 Mon Sep 17 00:00:00 2001 From: Francis Meng Date: Wed, 26 Jun 2024 13:51:59 -0700 Subject: [PATCH 3/4] Update --- packages/roosterjs-content-model-api/lib/index.ts | 2 +- .../lib/publicApi/{utils => segment}/splitTextSegment.ts | 0 .../test/publicApi/segment}/splitTextSegmentTest.ts | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) rename packages/roosterjs-content-model-api/lib/publicApi/{utils => segment}/splitTextSegment.ts (100%) rename packages/{roosterjs-content-model-plugins/test/pluginUtils => roosterjs-content-model-api/test/publicApi/segment}/splitTextSegmentTest.ts (96%) diff --git a/packages/roosterjs-content-model-api/lib/index.ts b/packages/roosterjs-content-model-api/lib/index.ts index f9c82153f78..ffcaca8e65a 100644 --- a/packages/roosterjs-content-model-api/lib/index.ts +++ b/packages/roosterjs-content-model-api/lib/index.ts @@ -18,7 +18,7 @@ export { setTextColor } from './publicApi/segment/setTextColor'; export { changeFontSize } from './publicApi/segment/changeFontSize'; export { applySegmentFormat } from './publicApi/segment/applySegmentFormat'; export { changeCapitalization } from './publicApi/segment/changeCapitalization'; -export { splitTextSegment } from './publicApi/utils/splitTextSegment'; +export { splitTextSegment } from './publicApi/segment/splitTextSegment'; export { insertImage } from './publicApi/image/insertImage'; export { setListStyle } from './publicApi/list/setListStyle'; export { setListStartNumber } from './publicApi/list/setListStartNumber'; diff --git a/packages/roosterjs-content-model-api/lib/publicApi/utils/splitTextSegment.ts b/packages/roosterjs-content-model-api/lib/publicApi/segment/splitTextSegment.ts similarity index 100% rename from packages/roosterjs-content-model-api/lib/publicApi/utils/splitTextSegment.ts rename to packages/roosterjs-content-model-api/lib/publicApi/segment/splitTextSegment.ts diff --git a/packages/roosterjs-content-model-plugins/test/pluginUtils/splitTextSegmentTest.ts b/packages/roosterjs-content-model-api/test/publicApi/segment/splitTextSegmentTest.ts similarity index 96% rename from packages/roosterjs-content-model-plugins/test/pluginUtils/splitTextSegmentTest.ts rename to packages/roosterjs-content-model-api/test/publicApi/segment/splitTextSegmentTest.ts index 46e09a6ce2f..3d1b4779059 100644 --- a/packages/roosterjs-content-model-plugins/test/pluginUtils/splitTextSegmentTest.ts +++ b/packages/roosterjs-content-model-api/test/publicApi/segment/splitTextSegmentTest.ts @@ -1,5 +1,5 @@ import { ContentModelParagraph, ContentModelText } from 'roosterjs-content-model-types'; -import { splitTextSegment } from 'roosterjs-content-model-api'; +import { splitTextSegment } from '../../../lib/publicApi/segment/splitTextSegment'; describe('splitTextSegment', () => { function runTest( From a66addd2f94d5e8e788ab1ef96a481f5b3bbd43f Mon Sep 17 00:00:00 2001 From: Francis Meng Date: Wed, 26 Jun 2024 15:18:30 -0700 Subject: [PATCH 4/4] consolidate dependencies --- .../lib/autoFormat/link/createLinkAfterSpace.ts | 3 +-- .../lib/picker/getQueryString.ts | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/roosterjs-content-model-plugins/lib/autoFormat/link/createLinkAfterSpace.ts b/packages/roosterjs-content-model-plugins/lib/autoFormat/link/createLinkAfterSpace.ts index 91d293953ac..95898e30d08 100644 --- a/packages/roosterjs-content-model-plugins/lib/autoFormat/link/createLinkAfterSpace.ts +++ b/packages/roosterjs-content-model-plugins/lib/autoFormat/link/createLinkAfterSpace.ts @@ -1,5 +1,4 @@ -import { matchLink } from 'roosterjs-content-model-api'; -import { splitTextSegment } from '../../pluginUtils/splitTextSegment'; +import { matchLink, splitTextSegment } from 'roosterjs-content-model-api'; import type { ContentModelText, FormatContentModelContext, diff --git a/packages/roosterjs-content-model-plugins/lib/picker/getQueryString.ts b/packages/roosterjs-content-model-plugins/lib/picker/getQueryString.ts index c52ddc76e9e..5e156477737 100644 --- a/packages/roosterjs-content-model-plugins/lib/picker/getQueryString.ts +++ b/packages/roosterjs-content-model-plugins/lib/picker/getQueryString.ts @@ -1,4 +1,4 @@ -import { splitTextSegment } from '../pluginUtils/splitTextSegment'; +import { splitTextSegment } from 'roosterjs-content-model-api'; import type { ContentModelText, ShallowMutableContentModelParagraph,