-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: add reviewpad.yml file * Update reviewpad.yml * ✨ options to `Editor.insert*` * 📝 options to `Editor.insert*` * ✨ getDefaultInsertLocation * ✨ getDefaultInsertLocation * ✨ getDefaultInsertLocation * 📝 consistent selection * Create tasty-lizards-remain.md * Update tasty-lizards-remain.md --------- Co-authored-by: reviewpad[bot] <104832597+reviewpad[bot]@users.noreply.github.com> Co-authored-by: Dylan Schiemann <dylan@dojotoolkit.org>
- Loading branch information
1 parent
48c18b5
commit 01f0210
Showing
12 changed files
with
92 additions
and
60 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
'slate': patch | ||
--- | ||
|
||
`Editor.insertFragment`, `Editor.insertNode`, `Editor.insertText` now accept `options`. | ||
For all insert methods, the default location is now the editor selection if `at` is not defined, or the end of document if `editor.selection` is not defined. |
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,6 +1,10 @@ | ||
import { Transforms } from '../interfaces/transforms' | ||
import { EditorInterface } from '../interfaces/editor' | ||
|
||
export const insertNode: EditorInterface['insertNode'] = (editor, node) => { | ||
Transforms.insertNodes(editor, node) | ||
export const insertNode: EditorInterface['insertNode'] = ( | ||
editor, | ||
node, | ||
options | ||
) => { | ||
Transforms.insertNodes(editor, node, options) | ||
} |
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { Editor, Location } from '../interfaces' | ||
|
||
/** | ||
* Get the default location to insert content into the editor. | ||
* By default, use the selection as the target location. But if there is | ||
* no selection, insert at the end of the document since that is such a | ||
* common use case when inserting from a non-selected state. | ||
*/ | ||
export const getDefaultInsertLocation = (editor: Editor): Location => { | ||
if (editor.selection) { | ||
return editor.selection | ||
} else if (editor.children.length > 0) { | ||
return Editor.end(editor, []) | ||
} else { | ||
return [0] | ||
} | ||
} |
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