1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-07-30 04:23:11 +03:00

Lexical: Started converting drawio to TS

Converted events service to TS as part of this.
This commit is contained in:
Dan Brown
2024-07-18 11:19:11 +01:00
parent 5002a89754
commit 634b0aaa07
9 changed files with 142 additions and 112 deletions

View File

@ -1,11 +1,16 @@
# Lexical based editor todo
## In progress
- Add Type: Drawings
- Continue converting drawio to typescript
- Next step to convert http service to ts.
## Main Todo
- Alignments: Use existing classes for blocks
- Alignments: Handle inline block content (image, video)
- Add Type: Video/media/embed
- Add Type: Drawings
- Handle toolbars on scroll
- Table features
- Image paste upload
@ -20,6 +25,7 @@
- Link heading-based ID reference menu
- Image gallery integration for insert
- Image gallery integration for form
- Drawing gallery integration
## Bugs

View File

@ -2,7 +2,6 @@ import {EditorDecorator} from "../framework/decorator";
import {EditorUiContext} from "../framework/core";
import {$openCodeEditorForNode, CodeBlockNode} from "../../nodes/code-block";
import {$selectionContainsNode, $selectSingleNode} from "../../helpers";
import {context} from "esbuild";
import {BaseSelection} from "lexical";

View File

@ -1,12 +1,35 @@
import {EditorDecorator} from "../framework/decorator";
import {EditorUiContext} from "../framework/core";
import {$selectionContainsNode, $selectSingleNode} from "../../helpers";
import {$openCodeEditorForNode, CodeBlockNode} from "../../nodes/code-block";
import {BaseSelection} from "lexical";
import {$openDrawingEditorForNode, DiagramNode} from "../../nodes/diagram";
export class DiagramDecorator extends EditorDecorator {
protected completedSetup: boolean = false;
setup(context: EditorUiContext, element: HTMLElement) {
//
const diagramNode = this.getNode();
element.addEventListener('click', event => {
context.editor.update(() => {
$selectSingleNode(this.getNode());
})
});
element.addEventListener('dblclick', event => {
context.editor.getEditorState().read(() => {
$openDrawingEditorForNode(context.editor, (this.getNode() as DiagramNode));
});
});
const selectionChange = (selection: BaseSelection|null): void => {
element.classList.toggle('selected', $selectionContainsNode(selection, diagramNode));
};
context.manager.onSelectionChange(selectionChange);
this.onDestroy(() => {
context.manager.offSelectionChange(selectionChange);
});
this.completedSetup = true;
}