-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' into feature/PRT-1761-1
- Loading branch information
Showing
11 changed files
with
465 additions
and
339 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,87 @@ | ||
import type { | ||
DocumentEditorContainer, | ||
Selection, | ||
BaselineAlignment, | ||
DocumentEditor, | ||
HighlightColor, | ||
Strikethrough, | ||
Underline, | ||
} from "@syncfusion/ej2-documenteditor"; | ||
|
||
interface SelectionOffsets { | ||
end: string; | ||
start: string; | ||
interface SelectionData { | ||
characterFormat: SelectionCharacterFormatData; | ||
endOffset: string; | ||
startOffset: string; | ||
} | ||
|
||
interface SelectionCharacterFormatData { | ||
allCaps: boolean; | ||
baselineAlignment: BaselineAlignment; | ||
bold: boolean; | ||
fontColor: string; | ||
fontFamily: string; | ||
fontSize: number; | ||
highlightColor: HighlightColor; | ||
italic: boolean; | ||
strikethrough: Strikethrough; | ||
underline: Underline; | ||
} | ||
|
||
export class IaraSyncfusionSelectionManager { | ||
public get selection(): Selection { | ||
return this._editor.documentEditor.selection; | ||
} | ||
private _initialSelectionData: SelectionData; | ||
|
||
constructor(private _editor: DocumentEditorContainer) {} | ||
constructor(private _editor: DocumentEditor) { | ||
const characterFormat = this._editor.selection.characterFormat; | ||
this._initialSelectionData = { | ||
characterFormat: { | ||
allCaps: characterFormat.allCaps, | ||
baselineAlignment: characterFormat.baselineAlignment, | ||
bold: characterFormat.bold, | ||
fontColor: characterFormat.fontColor, | ||
fontFamily: characterFormat.fontFamily, | ||
fontSize: characterFormat.fontSize, | ||
highlightColor: characterFormat.highlightColor, | ||
italic: characterFormat.italic, | ||
strikethrough: characterFormat.strikethrough, | ||
underline: characterFormat.underline, | ||
}, | ||
endOffset: this._editor.selection.endOffset, | ||
startOffset: this._editor.selection.startOffset, | ||
}; | ||
} | ||
|
||
public getWordAfterSelection(selectionOffsets: SelectionOffsets): string { | ||
this.selection.extendToWordEnd(); | ||
const wordAfter = this.selection.text.trimEnd(); | ||
this.selection.select(selectionOffsets.start, selectionOffsets.end); | ||
public getWordAfterSelection(): string { | ||
this._editor.selection.extendToWordEnd(); | ||
const wordAfter = this._editor.selection.text.trimEnd(); | ||
return wordAfter; | ||
} | ||
|
||
public getWordBeforeSelection(selectionOffsets: SelectionOffsets): string { | ||
this.selection.extendToWordStart(); | ||
const wordBefore = this.selection.text.trimStart(); | ||
this.selection.select(selectionOffsets.start, selectionOffsets.end); | ||
public getWordBeforeSelection(): string { | ||
this._editor.selection.extendToWordStart(); | ||
const wordBefore = this._editor.selection.text.trimStart(); | ||
return wordBefore; | ||
} | ||
|
||
public resetSelection() { | ||
this._editor.selection.select( | ||
this._initialSelectionData.startOffset, | ||
this._initialSelectionData.endOffset | ||
); | ||
|
||
const charFormatProps: (keyof SelectionCharacterFormatData)[] = [ | ||
"allCaps", | ||
"baselineAlignment", | ||
"bold", | ||
"fontColor", | ||
"fontFamily", | ||
"fontSize", | ||
"highlightColor", | ||
"italic", | ||
"strikethrough", | ||
"underline", | ||
]; | ||
|
||
charFormatProps.forEach(prop => { | ||
(this._editor.selection.characterFormat as any)[prop] = | ||
this._initialSelectionData.characterFormat[prop]; | ||
}); | ||
} | ||
} |
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
Oops, something went wrong.