From 993cfe4f3310369b681141d369ff967ddb0bc2f4 Mon Sep 17 00:00:00 2001 From: Sascha Lisson Date: Fri, 24 Nov 2023 19:00:41 +0100 Subject: [PATCH] use untyped model API to support editor rules generated by MPS (3) --- .../editor/kernelf/IncrementalLayouterAfterInsertJS.kt | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/kernelf-editor/src/jsTest/kotlin/org/modelix/editor/kernelf/IncrementalLayouterAfterInsertJS.kt b/kernelf-editor/src/jsTest/kotlin/org/modelix/editor/kernelf/IncrementalLayouterAfterInsertJS.kt index 58728509..d47ba14c 100644 --- a/kernelf-editor/src/jsTest/kotlin/org/modelix/editor/kernelf/IncrementalLayouterAfterInsertJS.kt +++ b/kernelf-editor/src/jsTest/kotlin/org/modelix/editor/kernelf/IncrementalLayouterAfterInsertJS.kt @@ -11,6 +11,7 @@ import org.modelix.kernelf.KernelfLanguages import org.modelix.metamodel.ModelData import org.modelix.metamodel.descendants import org.modelix.metamodel.ofType +import org.modelix.metamodel.untyped import org.modelix.model.ModelFacade import org.modelix.model.api.IBranch import org.modelix.model.api.PBranch @@ -36,7 +37,7 @@ open class IncrementalLayoutAfterInsertJS { val engine = EditorEngine(IncrementalEngine()) KernelfEditor.register(engine) testSuite = branch.computeRead { branch.getArea().getRoot().allChildren.ofType().models.rootNodes.ofType().first() } - editor = JsEditorComponent(engine, { editorState -> branch.computeRead { engine.createCell(editorState, testSuite) } }) + editor = JsEditorComponent(engine, { editorState -> branch.computeRead { engine.createCell(editorState, testSuite.untyped()) } }) assertTestItem = branch.computeRead { testSuite.descendants().drop(1).first() } editor.selectAfterUpdate { val cell = editor.resolveNodeCell(assertTestItem)!!.firstLeaf().nextLeafs(true).first { it.isVisible() } @@ -55,16 +56,17 @@ open class IncrementalLayoutAfterInsertJS { @Test fun domAfterInsert() { val containerElement = document.create.div() - var consumer = JSDom(containerElement.ownerDocument!!).let { vdom -> IncrementalVirtualDOMBuilder(vdom, vdom.wrap(containerElement)) } + val generatedHtmlMap = GeneratedHtmlMap() + var consumer = JSDom(containerElement.ownerDocument!!).let { vdom -> IncrementalVirtualDOMBuilder(vdom, vdom.wrap(containerElement), generatedHtmlMap) } val initialHtml = editor.getRootCell().layout.toHtml(consumer).unwrap().outerHTML editor.processKeyEvent(JSKeyboardEvent(JSKeyboardEventType.KEYDOWN, KnownKeys.Enter)) - consumer = JSDom(containerElement.ownerDocument!!).let { vdom -> IncrementalVirtualDOMBuilder(vdom, vdom.wrap(containerElement)) } + consumer = JSDom(containerElement.ownerDocument!!).let { vdom -> IncrementalVirtualDOMBuilder(vdom, vdom.wrap(containerElement), generatedHtmlMap) } val incrementalHtml = editor.getRootCell().layout.toHtml(consumer).unwrap().outerHTML editor.clearLayoutCache() - consumer = JSDom(containerElement.ownerDocument!!).let { vdom -> IncrementalVirtualDOMBuilder(vdom, vdom.wrap(containerElement)) } + consumer = JSDom(containerElement.ownerDocument!!).let { vdom -> IncrementalVirtualDOMBuilder(vdom, vdom.wrap(containerElement), generatedHtmlMap) } val nonIncrementalHtml = editor.getRootCell().layout.toHtml(consumer).unwrap().outerHTML assertEquals(nonIncrementalHtml, incrementalHtml) }