feat(lexical): add declarative rich text editor
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.
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
// @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()
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user