-
Notifications
You must be signed in to change notification settings - Fork 161
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Content Model: Improve adjustWordSelection
- Loading branch information
1 parent
5cef7ba
commit 311a01c
Showing
4 changed files
with
188 additions
and
33 deletions.
There are no files selected for viewing
29 changes: 26 additions & 3 deletions
29
packages-content-model/roosterjs-content-model-dom/lib/modelApi/creators/createText.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,37 @@ | ||
import { ContentModelSegmentFormat, ContentModelText } from 'roosterjs-content-model-types'; | ||
import { addCode, addLink } from '../common/addDecorators'; | ||
import { | ||
ContentModelCode, | ||
ContentModelLink, | ||
ContentModelSegmentFormat, | ||
ContentModelText, | ||
} from 'roosterjs-content-model-types'; | ||
|
||
/** | ||
* Create a ContentModelText model | ||
* @param text Text of this model | ||
* @param format @optional The format of this model | ||
* @param link @optional The link decorator | ||
* @param code @option The code decorator | ||
*/ | ||
export function createText(text: string, format?: ContentModelSegmentFormat): ContentModelText { | ||
return { | ||
export function createText( | ||
text: string, | ||
format?: ContentModelSegmentFormat, | ||
link?: ContentModelLink, | ||
code?: ContentModelCode | ||
): ContentModelText { | ||
const result: ContentModelText = { | ||
segmentType: 'Text', | ||
text: text, | ||
format: format ? { ...format } : {}, | ||
}; | ||
|
||
if (link) { | ||
addLink(result, link); | ||
} | ||
|
||
if (code) { | ||
addCode(result, code); | ||
} | ||
|
||
return result; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters