1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-09 08:46:35 +02:00

Update dependencies to React 18, Node 20, TS 5.2, etc. (#5528)

* incremental upgrade to React 18, TS 4.9, etc.

* update yarn config

* fix build

* minor cleanup in type definitions

* incremental updates for TS 5.0

* fix build

* upgrade to typescript 5.2

* update dependencies

* fix lint issues

* update to latest Playwright version

* update changesets dep

* update emotion/css

* incremental dependency updates

* more small dependency updates

* upgrade prettier and eslint

* fix lint issues

* update dependencies rollup

* fix @types/node resolution to restore linting

* update tiny-invariant dependency

* update dependencies

* update dependencies lerna

* upgrade react-router-dom

* update @types/react and @types/node

* update babel dependencies

* udpate simple-git-hooks

* update @types/node resolution

* update lint-staged

* remove cypress from dependency list

* update @types/node to support Node 20

* update workflows to Node 20

* set resolutions for @types/react

* downgrade @types/react to 18.2.28

* update mocha

* update rimraf

* update @types/js-dom

* remove .lintstagedrc.js

* upgrade next to latest

* v0.61.4

* update lerna

* update faker and rollup

* update immer

* fix yarn clean command

* attempt to fix integration tests

* attempt to stabilize integration tests

* wip fix integration tests

* skip unstable integration test

* Add changeset

---------

Co-authored-by: Dalibor Tosic <dalibortosic00@gmail.com>
Co-authored-by: Nikola <nikolabijelic14@gmail.com>
This commit is contained in:
Dylan Schiemann
2023-10-20 08:34:24 -07:00
committed by GitHub
parent 623f44521e
commit c4c14882ed
92 changed files with 8036 additions and 8905 deletions

View File

@@ -209,62 +209,64 @@ export function createText(
* Create a top-level `Editor` object.
*/
export const createEditor = (makeEditor: () => Editor) => (
tagName: string,
attributes: { [key: string]: any },
children: any[]
): Editor => {
const otherChildren: any[] = []
let selectionChild: Range | undefined
export const createEditor =
(makeEditor: () => Editor) =>
(
tagName: string,
attributes: { [key: string]: any },
children: any[]
): Editor => {
const otherChildren: any[] = []
let selectionChild: Range | undefined
for (const child of children) {
if (Range.isRange(child)) {
selectionChild = child
} else {
otherChildren.push(child)
}
}
const descendants = resolveDescendants(otherChildren)
const selection: Partial<Range> = {}
const editor = makeEditor()
Object.assign(editor, attributes)
editor.children = descendants as Element[]
// Search the document's texts to see if any of them have tokens associated
// that need incorporated into the selection.
for (const [node, path] of Node.texts(editor)) {
const anchor = getAnchorOffset(node)
const focus = getFocusOffset(node)
if (anchor != null) {
const [offset] = anchor
selection.anchor = { path, offset }
for (const child of children) {
if (Range.isRange(child)) {
selectionChild = child
} else {
otherChildren.push(child)
}
}
if (focus != null) {
const [offset] = focus
selection.focus = { path, offset }
const descendants = resolveDescendants(otherChildren)
const selection: Partial<Range> = {}
const editor = makeEditor()
Object.assign(editor, attributes)
editor.children = descendants as Element[]
// Search the document's texts to see if any of them have tokens associated
// that need incorporated into the selection.
for (const [node, path] of Node.texts(editor)) {
const anchor = getAnchorOffset(node)
const focus = getFocusOffset(node)
if (anchor != null) {
const [offset] = anchor
selection.anchor = { path, offset }
}
if (focus != null) {
const [offset] = focus
selection.focus = { path, offset }
}
}
}
if (selection.anchor && !selection.focus) {
throw new Error(
`Slate hyperscript ranges must have both \`<anchor />\` and \`<focus />\` defined if one is defined, but you only defined \`<anchor />\`. For collapsed selections, use \`<cursor />\` instead.`
)
}
if (selection.anchor && !selection.focus) {
throw new Error(
`Slate hyperscript ranges must have both \`<anchor />\` and \`<focus />\` defined if one is defined, but you only defined \`<anchor />\`. For collapsed selections, use \`<cursor />\` instead.`
)
}
if (!selection.anchor && selection.focus) {
throw new Error(
`Slate hyperscript ranges must have both \`<anchor />\` and \`<focus />\` defined if one is defined, but you only defined \`<focus />\`. For collapsed selections, use \`<cursor />\` instead.`
)
}
if (!selection.anchor && selection.focus) {
throw new Error(
`Slate hyperscript ranges must have both \`<anchor />\` and \`<focus />\` defined if one is defined, but you only defined \`<focus />\`. For collapsed selections, use \`<cursor />\` instead.`
)
}
if (selectionChild != null) {
editor.selection = selectionChild
} else if (Range.isRange(selection)) {
editor.selection = selection
}
if (selectionChild != null) {
editor.selection = selectionChild
} else if (Range.isRange(selection)) {
editor.selection = selection
}
return editor
}
return editor
}