diff --git a/frontend/src/app/render_wasm/api/texts.cljs b/frontend/src/app/render_wasm/api/texts.cljs index 6da007450f..1c591576b3 100644 --- a/frontend/src/app/render_wasm/api/texts.cljs +++ b/frontend/src/app/render_wasm/api/texts.cljs @@ -141,6 +141,7 @@ heap (mem/get-heap-u8)] (.set heap (js/Uint8Array. buffer) metadata-offset))) + (prn "set_shape_text_content") (h/call wasm/internal-module "_set_shape_text_content")) (def ^:private emoji-pattern #"[\uD83C-\uDBFF][\uDC00-\uDFFF]|[\u2600-\u27BF]") diff --git a/frontend/text-editor/src/editor/controllers/SelectionController.js b/frontend/text-editor/src/editor/controllers/SelectionController.js index 1aef008821..bc90438201 100644 --- a/frontend/text-editor/src/editor/controllers/SelectionController.js +++ b/frontend/text-editor/src/editor/controllers/SelectionController.js @@ -1382,13 +1382,10 @@ export class SelectionController extends EventTarget { */ insertParagraph() { if (this.isParagraphEnd) { - console.log('a') return this.insertParagraphAfter(); } else if (this.isParagraphStart) { - console.log('b') return this.insertParagraphBefore(); } - console.log('c') return this.splitParagraph(); } @@ -1402,16 +1399,18 @@ export class SelectionController extends EventTarget { this.removeSelected(); - const newParagraph = splitParagraph( - currentParagraph, - currentInline, - this.focusOffset, - ); - currentParagraph.after(newParagraph); - - this.#mutations.update(currentParagraph); - this.#mutations.add(newParagraph); - + if (currentParagraph && currentInline) { + const newParagraph = splitParagraph( + currentParagraph, + currentInline, + this.focusOffset, + ); + currentParagraph.after(newParagraph); + this.#mutations.update(currentParagraph); + this.#mutations.add(newParagraph); + } else { + console.log(this.#focusNode) + } // FIXME: Missing collapse? } diff --git a/render-wasm/src/render/text.rs b/render-wasm/src/render/text.rs index 2df1bf137d..b9e1d3d681 100644 --- a/render-wasm/src/render/text.rs +++ b/render-wasm/src/render/text.rs @@ -53,6 +53,7 @@ pub fn render( continue; } + // Performs the text layout. skia_paragraph.layout(shape.bounds().width()); let paragraph_height = skia_paragraph.height(); diff --git a/render-wasm/src/wasm/text.rs b/render-wasm/src/wasm/text.rs index af6f55ab61..9e4dcc3d43 100644 --- a/render-wasm/src/wasm/text.rs +++ b/render-wasm/src/wasm/text.rs @@ -11,6 +11,7 @@ pub extern "C" fn clear_shape_text() { }); } +// TODO: We should modify text content in a smarter way. #[no_mangle] pub extern "C" fn set_shape_text_content() { let bytes = mem::bytes();