From 888b14e12116003bd7cf1cdda33126e34d03d9e5 Mon Sep 17 00:00:00 2001 From: Kevin Jahns Date: Tue, 25 Jun 2024 10:15:22 +0200 Subject: [PATCH] update prosemirror demo to use initProseMirrorState --- prosemirror/package-lock.json | 81 +++++++++++++++++++---------------- prosemirror/package.json | 2 +- prosemirror/prosemirror.js | 6 ++- 3 files changed, 50 insertions(+), 39 deletions(-) diff --git a/prosemirror/package-lock.json b/prosemirror/package-lock.json index 37d18f7..5478963 100644 --- a/prosemirror/package-lock.json +++ b/prosemirror/package-lock.json @@ -13,7 +13,7 @@ "prosemirror-model": "^1.13.1", "prosemirror-state": "^1.3.4", "prosemirror-view": "^1.18.7", - "y-prosemirror": "^1.0.5", + "y-prosemirror": "^1.2.8", "y-websocket": "^1.3.15", "yjs": "^13.5.8" } @@ -304,13 +304,14 @@ } }, "node_modules/lib0": { - "version": "0.2.88", - "resolved": "https://registry.npmjs.org/lib0/-/lib0-0.2.88.tgz", - "integrity": "sha512-KyroiEvCeZcZEMx5Ys+b4u4eEBbA1ch7XUaBhYpwa/nPMrzTjUhI4RfcytmQfYoTBPcdyx+FX6WFNIoNuJzJfQ==", + "version": "0.2.94", + "resolved": "https://registry.npmjs.org/lib0/-/lib0-0.2.94.tgz", + "integrity": "sha512-hZ3p54jL4Wpu7IOg26uC7dnEWiMyNlUrb9KoG7+xYs45WkQwpVvKFndVq2+pqLYKe1u8Fp3+zAfZHVvTK34PvQ==", "dependencies": { "isomorphic.js": "^0.2.4" }, "bin": { + "0ecdsa-generate-keypair": "bin/0ecdsa-generate-keypair.js", "0gentesthtml": "bin/gentesthtml.js", "0serve": "bin/0serve.js" }, @@ -403,9 +404,9 @@ } }, "node_modules/prosemirror-history": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/prosemirror-history/-/prosemirror-history-1.3.2.tgz", - "integrity": "sha512-/zm0XoU/N/+u7i5zepjmZAEnpvjDtzoPWW6VmKptcAnPadN/SStsBjMImdCEbb3seiNTpveziPTIrXQbHLtU1g==", + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/prosemirror-history/-/prosemirror-history-1.4.0.tgz", + "integrity": "sha512-UUiGzDVcqo1lovOPdi9YxxUps3oBFWAIYkXLu3Ot+JPv1qzVogRbcizxK3LhHmtaUxclohgiOVesRw5QSlMnbQ==", "dependencies": { "prosemirror-state": "^1.2.2", "prosemirror-transform": "^1.0.0", @@ -414,9 +415,9 @@ } }, "node_modules/prosemirror-inputrules": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/prosemirror-inputrules/-/prosemirror-inputrules-1.3.0.tgz", - "integrity": "sha512-z1GRP2vhh5CihYMQYsJSa1cOwXb3SYxALXOIfAkX8nZserARtl9LiL+CEl+T+OFIsXc3mJIHKhbsmRzC0HDAXA==", + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/prosemirror-inputrules/-/prosemirror-inputrules-1.4.0.tgz", + "integrity": "sha512-6ygpPRuTJ2lcOXs9JkefieMst63wVJBgHZGl5QOytN7oSZs3Co/BYbc3Yx9zm9H37Bxw8kVzCnDsihsVsL4yEg==", "dependencies": { "prosemirror-state": "^1.0.0", "prosemirror-transform": "^1.0.0" @@ -443,17 +444,17 @@ } }, "node_modules/prosemirror-model": { - "version": "1.19.3", - "resolved": "https://registry.npmjs.org/prosemirror-model/-/prosemirror-model-1.19.3.tgz", - "integrity": "sha512-tgSnwN7BS7/UM0sSARcW+IQryx2vODKX4MI7xpqY2X+iaepJdKBPc7I4aACIsDV/LTaTjt12Z56MhDr9LsyuZQ==", + "version": "1.21.1", + "resolved": "https://registry.npmjs.org/prosemirror-model/-/prosemirror-model-1.21.1.tgz", + "integrity": "sha512-IVBAuMqOfltTr7yPypwpfdGT+6rGAteVOw2FO6GEvCGGa1ZwxLseqC1Eax/EChDvG/xGquB2d/hLdgh3THpsYg==", "dependencies": { "orderedmap": "^2.0.0" } }, "node_modules/prosemirror-schema-list": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/prosemirror-schema-list/-/prosemirror-schema-list-1.3.0.tgz", - "integrity": "sha512-Hz/7gM4skaaYfRPNgr421CU4GSwotmEwBVvJh5ltGiffUJwm7C8GfN/Bc6DR1EKEp5pDKhODmdXXyi9uIsZl5A==", + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/prosemirror-schema-list/-/prosemirror-schema-list-1.4.0.tgz", + "integrity": "sha512-nZOIq/AkBSzCENxUyLm5ltWE53e2PLk65ghMN8qLQptOmDVixZlPqtMeQdiNw0odL9vNpalEjl3upgRkuJ/Jyw==", "dependencies": { "prosemirror-model": "^1.0.0", "prosemirror-state": "^1.0.0", @@ -471,19 +472,19 @@ } }, "node_modules/prosemirror-transform": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/prosemirror-transform/-/prosemirror-transform-1.8.0.tgz", - "integrity": "sha512-BaSBsIMv52F1BVVMvOmp1yzD3u65uC3HTzCBQV1WDPqJRQ2LuHKcyfn0jwqodo8sR9vVzMzZyI+Dal5W9E6a9A==", + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/prosemirror-transform/-/prosemirror-transform-1.9.0.tgz", + "integrity": "sha512-5UXkr1LIRx3jmpXXNKDhv8OyAOeLTGuXNwdVfg8x27uASna/wQkr9p6fD3eupGOi4PLJfbezxTyi/7fSJypXHg==", "dependencies": { - "prosemirror-model": "^1.0.0" + "prosemirror-model": "^1.21.0" } }, "node_modules/prosemirror-view": { - "version": "1.32.5", - "resolved": "https://registry.npmjs.org/prosemirror-view/-/prosemirror-view-1.32.5.tgz", - "integrity": "sha512-OZ8JSytiOr1mlxu8XSPJSNMn3sQrycbP12Peubwsnq9xiyQk4F58u9wOPJYSXXG/uOXZQNSAITRnScZPdjEh+A==", + "version": "1.33.8", + "resolved": "https://registry.npmjs.org/prosemirror-view/-/prosemirror-view-1.33.8.tgz", + "integrity": "sha512-4PhMr/ufz2cdvFgpUAnZfs+0xij3RsFysreeG9V/utpwX7AJtYCDVyuRxzWoMJIEf4C7wVihuBNMPpFLPCiLQw==", "dependencies": { - "prosemirror-model": "^1.16.0", + "prosemirror-model": "^1.20.0", "prosemirror-state": "^1.0.0", "prosemirror-transform": "^1.1.0" } @@ -554,9 +555,9 @@ "integrity": "sha512-dpojBhNsCNN7T82Tm7k26A6G9ML3NkhDsnw9n/eoxSRlVBB4CEtIQ/KTCLI2Fwf3ataSXRhYFkQi3SlnFwPvPQ==" }, "node_modules/ws": { - "version": "6.2.2", - "resolved": "https://registry.npmjs.org/ws/-/ws-6.2.2.tgz", - "integrity": "sha512-zmhltoSR8u1cnDsD43TX59mzoMZsLKqUweyYBAIvTngR3shc0W6aOZylZmq/7hqyVxPdi+5Ud2QInblgyE72fw==", + "version": "6.2.3", + "resolved": "https://registry.npmjs.org/ws/-/ws-6.2.3.tgz", + "integrity": "sha512-jmTjYU0j60B+vHey6TfR3Z7RD61z/hmxBS3VMSGIrroOWXQEneK1zNuotOUrGyBHQj0yrpsLHPWtigEFd13ndA==", "optional": true, "dependencies": { "async-limiter": "~1.0.0" @@ -589,12 +590,16 @@ } }, "node_modules/y-prosemirror": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/y-prosemirror/-/y-prosemirror-1.2.1.tgz", - "integrity": "sha512-czMBfB1eL2awqmOSxQM8cS/fsUOGE6fjvyPLInrh4crPxFiw67wDpwIW+EGBYKRa04sYbS0ScGj7ZgvWuDrmBQ==", + "version": "1.2.9", + "resolved": "https://registry.npmjs.org/y-prosemirror/-/y-prosemirror-1.2.9.tgz", + "integrity": "sha512-fThGIVmSqrqnG/ckywEGlHM9ElfILC4TcMZd5zxWPe/i+UuP97TEr4swsopRKG3Y+KHBVt4Y/5NVBC3AAsUoUg==", "dependencies": { "lib0": "^0.2.42" }, + "engines": { + "node": ">=16.0.0", + "npm": ">=8.0.0" + }, "funding": { "type": "GitHub Sponsors ❤", "url": "https://github.com/sponsors/dmonad" @@ -627,9 +632,9 @@ } }, "node_modules/y-websocket": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/y-websocket/-/y-websocket-1.5.0.tgz", - "integrity": "sha512-A8AO6XtnQlYwWFytWdkDCeXg4l8ghRTIw5h2YUgUYDmEC9ugWGIwYNW80yadhSFAF7CvuWTEkQNEpevnH6EiZw==", + "version": "1.5.4", + "resolved": "https://registry.npmjs.org/y-websocket/-/y-websocket-1.5.4.tgz", + "integrity": "sha512-Y3021uy0anOIHqAPyAZbNDoR05JuMEGjRNI8c+K9MHzVS8dWoImdJUjccljAznc8H2L7WkIXhRHZ1igWNRSgPw==", "dependencies": { "lib0": "^0.2.52", "lodash.debounce": "^4.0.8", @@ -639,6 +644,10 @@ "y-websocket": "bin/server.js", "y-websocket-server": "bin/server.js" }, + "engines": { + "node": ">=16.0.0", + "npm": ">=8.0.0" + }, "funding": { "type": "GitHub Sponsors ❤", "url": "https://github.com/sponsors/dmonad" @@ -652,9 +661,9 @@ } }, "node_modules/yjs": { - "version": "13.6.10", - "resolved": "https://registry.npmjs.org/yjs/-/yjs-13.6.10.tgz", - "integrity": "sha512-1JcyQek1vaMyrDm7Fqfa+pvHg/DURSbVo4VmeN7wjnTKB/lZrfIPhdCj7d8sboK6zLfRBJXegTjc9JlaDd8/Zw==", + "version": "13.6.18", + "resolved": "https://registry.npmjs.org/yjs/-/yjs-13.6.18.tgz", + "integrity": "sha512-GBTjO4QCmv2HFKFkYIJl7U77hIB1o22vSCSQD1Ge8ZxWbIbn8AltI4gyXbtL+g5/GJep67HCMq3Y5AmNwDSyEg==", "dependencies": { "lib0": "^0.2.86" }, diff --git a/prosemirror/package.json b/prosemirror/package.json index 616ef0a..1710ff6 100644 --- a/prosemirror/package.json +++ b/prosemirror/package.json @@ -11,7 +11,7 @@ "license": "UNLICENSE", "dependencies": { "yjs": "^13.5.8", - "y-prosemirror": "^1.0.5", + "y-prosemirror": "^1.2.8", "y-websocket": "^1.3.15", "prosemirror-example-setup": "^1.1.2", "prosemirror-model": "^1.13.1", diff --git a/prosemirror/prosemirror.js b/prosemirror/prosemirror.js index 9381706..cc7116d 100644 --- a/prosemirror/prosemirror.js +++ b/prosemirror/prosemirror.js @@ -2,7 +2,7 @@ import * as Y from 'yjs' import { WebsocketProvider } from 'y-websocket' -import { ySyncPlugin, yCursorPlugin, yUndoPlugin, undo, redo } from 'y-prosemirror' +import { ySyncPlugin, yCursorPlugin, yUndoPlugin, undo, redo, initProseMirrorDoc } from 'y-prosemirror' import { EditorState } from 'prosemirror-state' import { EditorView } from 'prosemirror-view' import { schema } from './schema.js' @@ -23,11 +23,13 @@ window.addEventListener('load', () => { editor.setAttribute('id', 'editor') const editorContainer = document.createElement('div') editorContainer.insertBefore(editor, null) + const { doc, mapping } = initProseMirrorDoc(yXmlFragment, schema) const prosemirrorView = new EditorView(editor, { state: EditorState.create({ + doc, schema, plugins: [ - ySyncPlugin(yXmlFragment), + ySyncPlugin(yXmlFragment, { mapping }), yCursorPlugin(provider.awareness), yUndoPlugin(), keymap({