-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Unbind formatting form Selection ranges (#93)
* Unbind formatting form Selection ranges * Remove unused var * Remove resolved todo * Fix InlineParentNode.insertAfter method & add isActive state for inline toolbar buttons * Fix lint & build * Send event if selection is lost for the input * Fix lint & tests
- Loading branch information
Showing
13 changed files
with
158 additions
and
76 deletions.
There are no files selected for viewing
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
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,18 +1,25 @@ | ||
import type { TextRange } from '@editorjs/model'; | ||
import { getBoundaryPointByAbsoluteOffset } from './getRelativeIndex.js'; | ||
|
||
/** | ||
* Function, that surrounds passed range with passed html element | ||
* | ||
* @param range - range to be surrounded | ||
* @param wrapper - wrapper to surround the range | ||
* @param wrapper - element to surround the range | ||
* @param inputElement - element, where the range is located | ||
* @param textRange - range to be surrounded | ||
*/ | ||
export function surround(range: Range, wrapper: HTMLElement): void { | ||
const inlineElement = wrapper; | ||
export function surround(wrapper: HTMLElement, inputElement: HTMLElement, textRange: TextRange): void { | ||
const range = document.createRange(); | ||
|
||
range.setStart(...getBoundaryPointByAbsoluteOffset(inputElement, textRange[0])); | ||
range.setEnd(...getBoundaryPointByAbsoluteOffset(inputElement, textRange[1])); | ||
|
||
const extracted = range.extractContents(); | ||
|
||
/** | ||
* Insert contents from range to new inline element and put created element in range | ||
*/ | ||
inlineElement.appendChild(extracted); | ||
wrapper.appendChild(extracted); | ||
|
||
range.insertNode(inlineElement); | ||
range.insertNode(wrapper); | ||
} |
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
Oops, something went wrong.
2639073
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Coverage report for
./packages/model
Test suite run success
405 tests passing in 24 suites.
Report generated by 🧪jest coverage report action from 2639073
2639073
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Coverage report for
./packages/collaboration-manager
Test suite run success
6 tests passing in 1 suite.
Report generated by 🧪jest coverage report action from 2639073