-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Split out slate dom package (#5734)
* Copied some things from slate-react into new react-dom package * Refactor slate-react to use slate-dom * Fixed failing tests * Created changeset * Ran fix:prettier * Fixed name * Removed duplicate code * Fixed import * Restored linting rule * Bumped slate-dom version * Bumped slate dependency version * Added export of IS_NODE_MAP_DIRTY after rebase
- Loading branch information
Showing
37 changed files
with
1,847 additions
and
1,559 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-react': minor | ||
'slate-dom': minor | ||
--- | ||
|
||
Split out slate-dom package |
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,64 @@ | ||
{ | ||
"name": "slate-dom", | ||
"description": "Tools for building completely customizable richtext editors with React.", | ||
"version": "0.110.2", | ||
"license": "MIT", | ||
"repository": "git://github.com/ianstormtaylor/slate.git", | ||
"main": "dist/index.js", | ||
"module": "dist/index.es.js", | ||
"types": "dist/index.d.ts", | ||
"umd": "dist/slate-dom.js", | ||
"umdMin": "dist/slate-dom.min.js", | ||
"sideEffects": false, | ||
"files": [ | ||
"dist/" | ||
], | ||
"dependencies": { | ||
"@juggle/resize-observer": "^3.4.0", | ||
"direction": "^1.0.4", | ||
"is-hotkey": "^0.2.0", | ||
"is-plain-object": "^5.0.0", | ||
"lodash": "^4.17.21", | ||
"scroll-into-view-if-needed": "^3.1.0", | ||
"tiny-invariant": "1.3.1" | ||
}, | ||
"devDependencies": { | ||
"@babel/runtime": "^7.23.2", | ||
"@types/is-hotkey": "^0.1.8", | ||
"@types/jest": "29.5.6", | ||
"@types/jsdom": "^21.1.4", | ||
"@types/lodash": "^4.14.200", | ||
"@types/resize-observer-browser": "^0.1.8", | ||
"slate": "^0.110.2", | ||
"slate-hyperscript": "^0.100.0", | ||
"source-map-loader": "^4.0.1" | ||
}, | ||
"peerDependencies": { | ||
"slate": ">=0.99.0" | ||
}, | ||
"umdGlobals": { | ||
"slate": "Slate" | ||
}, | ||
"keywords": [ | ||
"canvas", | ||
"contenteditable", | ||
"docs", | ||
"document", | ||
"edit", | ||
"editor", | ||
"editable", | ||
"html", | ||
"immutable", | ||
"markdown", | ||
"medium", | ||
"paper", | ||
"react", | ||
"rich", | ||
"richtext", | ||
"richtext", | ||
"slate", | ||
"text", | ||
"wysiwyg", | ||
"wysiwym" | ||
] | ||
} |
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,45 @@ | ||
import { BaseRange, BaseText } from 'slate' | ||
import { DOMEditor } from './plugin/dom-editor' | ||
|
||
declare module 'slate' { | ||
interface CustomTypes { | ||
Editor: DOMEditor | ||
Text: BaseText & { | ||
placeholder?: string | ||
onPlaceholderResize?: (node: HTMLElement | null) => void | ||
// FIXME: is unknown correct here? | ||
[key: string]: unknown | ||
} | ||
Range: BaseRange & { | ||
placeholder?: string | ||
onPlaceholderResize?: (node: HTMLElement | null) => void | ||
// FIXME: is unknown correct here? | ||
[key: string]: unknown | ||
} | ||
} | ||
} | ||
|
||
declare global { | ||
interface Window { | ||
MSStream: boolean | ||
} | ||
interface DocumentOrShadowRoot { | ||
getSelection(): Selection | null | ||
} | ||
|
||
interface CaretPosition { | ||
readonly offsetNode: Node | ||
readonly offset: number | ||
getClientRect(): DOMRect | null | ||
} | ||
|
||
interface Document { | ||
caretPositionFromPoint(x: number, y: number): CaretPosition | null | ||
} | ||
|
||
interface Node { | ||
getRootNode(options?: GetRootNodeOptions): Document | ShadowRoot | ||
} | ||
} | ||
|
||
export {} |
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,89 @@ | ||
// Plugin | ||
export { DOMEditor, type DOMEditorInterface } from './plugin/dom-editor' | ||
export { withDOM } from './plugin/with-dom' | ||
|
||
// Utils | ||
export { TRIPLE_CLICK } from './utils/constants' | ||
|
||
export { | ||
applyStringDiff, | ||
mergeStringDiffs, | ||
normalizePoint, | ||
normalizeRange, | ||
normalizeStringDiff, | ||
StringDiff, | ||
targetRange, | ||
TextDiff, | ||
verifyDiffState, | ||
} from './utils/diff-text' | ||
|
||
export { | ||
DOMElement, | ||
DOMNode, | ||
DOMPoint, | ||
DOMRange, | ||
DOMSelection, | ||
DOMStaticRange, | ||
DOMText, | ||
getActiveElement, | ||
getDefaultView, | ||
getSelection, | ||
hasShadowRoot, | ||
isAfter, | ||
isBefore, | ||
isDOMElement, | ||
isDOMNode, | ||
isDOMSelection, | ||
isPlainTextOnlyPaste, | ||
isTrackedMutation, | ||
normalizeDOMPoint, | ||
} from './utils/dom' | ||
|
||
export { | ||
CAN_USE_DOM, | ||
HAS_BEFORE_INPUT_SUPPORT, | ||
IS_ANDROID, | ||
IS_CHROME, | ||
IS_FIREFOX, | ||
IS_FIREFOX_LEGACY, | ||
IS_IOS, | ||
IS_WEBKIT, | ||
IS_UC_MOBILE, | ||
IS_WECHATBROWSER, | ||
} from './utils/environment' | ||
|
||
export { default as Hotkeys } from './utils/hotkeys' | ||
|
||
export { Key } from './utils/key' | ||
|
||
export { | ||
isElementDecorationsEqual, | ||
isTextDecorationsEqual, | ||
} from './utils/range-list' | ||
|
||
export { | ||
EDITOR_TO_ELEMENT, | ||
EDITOR_TO_FORCE_RENDER, | ||
EDITOR_TO_KEY_TO_ELEMENT, | ||
EDITOR_TO_ON_CHANGE, | ||
EDITOR_TO_PENDING_ACTION, | ||
EDITOR_TO_PENDING_DIFFS, | ||
EDITOR_TO_PENDING_INSERTION_MARKS, | ||
EDITOR_TO_PENDING_SELECTION, | ||
EDITOR_TO_PLACEHOLDER_ELEMENT, | ||
EDITOR_TO_SCHEDULE_FLUSH, | ||
EDITOR_TO_USER_MARKS, | ||
EDITOR_TO_USER_SELECTION, | ||
EDITOR_TO_WINDOW, | ||
ELEMENT_TO_NODE, | ||
IS_COMPOSING, | ||
IS_FOCUSED, | ||
IS_NODE_MAP_DIRTY, | ||
IS_READ_ONLY, | ||
MARK_PLACEHOLDER_SYMBOL, | ||
NODE_TO_ELEMENT, | ||
NODE_TO_INDEX, | ||
NODE_TO_KEY, | ||
NODE_TO_PARENT, | ||
PLACEHOLDER_SYMBOL, | ||
} from './utils/weak-maps' |
Oops, something went wrong.