mirror of
https://github.com/BookStackApp/BookStack.git
synced 2026-01-03 23:42:28 +03:00
Lexical: Revamped image node resize method
Changed from using a decorator to using a helper that watches for image selections to then display a resize helper. Also changes resizer to use a ghost and apply changes on end instead of continuosly during resize.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import {
|
||||
$createNodeSelection,
|
||||
$createParagraphNode,
|
||||
$createParagraphNode, $createRangeSelection,
|
||||
$getRoot,
|
||||
$getSelection, $isDecoratorNode,
|
||||
$isElementNode,
|
||||
@@ -106,6 +106,18 @@ export function $selectSingleNode(node: LexicalNode) {
|
||||
$setSelection(nodeSelection);
|
||||
}
|
||||
|
||||
export function $toggleSelection(editor: LexicalEditor) {
|
||||
const lastSelection = getLastSelection(editor);
|
||||
|
||||
if (lastSelection) {
|
||||
window.requestAnimationFrame(() => {
|
||||
editor.update(() => {
|
||||
$setSelection(lastSelection.clone());
|
||||
})
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export function $selectionContainsNode(selection: BaseSelection | null, node: LexicalNode): boolean {
|
||||
if (!selection) {
|
||||
return false;
|
||||
@@ -122,7 +134,11 @@ export function $selectionContainsNode(selection: BaseSelection | null, node: Le
|
||||
}
|
||||
|
||||
export function $selectionContainsAlignment(selection: BaseSelection | null, alignment: CommonBlockAlignment): boolean {
|
||||
const nodes = $getBlockElementNodesInSelection(selection);
|
||||
|
||||
const nodes = [
|
||||
...(selection?.getNodes() || []),
|
||||
...$getBlockElementNodesInSelection(selection)
|
||||
];
|
||||
for (const node of nodes) {
|
||||
if (nodeHasAlignment(node) && node.getAlignment() === alignment) {
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user