0d817537be
Introduce @workspace/lexical with composable actions, toolbars, embeds, rich-text nodes, media uploads, selection utilities, HTML serialization, and theme styling.\n\nLocalize built-in controls through MessageDescriptor catalogs for English and Simplified Chinese, while providing an English I18nProvider fallback for standalone editor use. Include focused unit coverage for actions, controls, serialization, plugins, public API, and catalogs.
30 lines
870 B
TypeScript
30 lines
870 B
TypeScript
// @vitest-environment jsdom
|
|
|
|
import { describe, expect, it } from "vitest"
|
|
|
|
import { createSelectionAnchor } from "./selection-anchor"
|
|
|
|
describe("createSelectionAnchor", () => {
|
|
it("does not use a browser selection outside the editor", () => {
|
|
const rootElement = document.createElement("div")
|
|
const externalElement = document.createElement("p")
|
|
const externalText = document.createTextNode("outside")
|
|
|
|
externalElement.append(externalText)
|
|
document.body.append(rootElement, externalElement)
|
|
|
|
const range = document.createRange()
|
|
range.selectNodeContents(externalText)
|
|
|
|
const selection = window.getSelection()
|
|
selection?.removeAllRanges()
|
|
selection?.addRange(range)
|
|
|
|
expect(createSelectionAnchor(rootElement)).toBe(rootElement)
|
|
|
|
selection?.removeAllRanges()
|
|
rootElement.remove()
|
|
externalElement.remove()
|
|
})
|
|
})
|