From 0491984ad3ae155f6ead0d026ebdc62bbc1434e5 Mon Sep 17 00:00:00 2001 From: Greg Shuflin Date: Sat, 26 Oct 2024 03:21:19 -0700 Subject: [PATCH] prosemirror boilerplate --- scribe/bun.lockb | Bin 25311 -> 33053 bytes scribe/index.html | 4 ++++ scribe/package.json | 7 ++++++- scribe/src/main.ts | 22 ++++++++++++++++++++++ scribe/src/prosemirror.ts | 21 +++++++++++++++++++++ 5 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 scribe/src/prosemirror.ts diff --git a/scribe/bun.lockb b/scribe/bun.lockb index 432ea94a49a3207323d7f032552f83759e975cb8..a4916e889aca6ddf96f4331bf69511fd7ea14e71 100755 GIT binary patch delta 9391 zcmc&(30PCtwoYQ0K?w*11VI@Dfd~PEATo%|4j^hAD*>V+qhWA1p{)v41iGu%S+sS) zt959_p`uh ze&BEl(iNF$at>z|1eP3*stcFHu>m&YSpeLRXH#IQ=6MFt4$tF&LSO{Y9(cTq+AafV zh38^EhhqlZiDz5jIw195477Fyv)zEhu>h7q&>fhrkY^Xd*>F5lgQ`+bWrVT1j08x7 z$d%>hWoB?V@`ALY%izW?n6m!u4?d@25U6997r2g0;F~2XmFecqc!NSK_@jT zRVEt2a}%}UEub|VT+rax8r-hIl|b71g&Hi-piF}!G^ohS&MwO5aJIsk6Ur|EIs$Vw z&!d6%93@8;1g0kx)<8GlQ+Rg)UI9}1ULftwN?>o`44^Y`qy__lw49CR`6b4bR@4aW z0c-%$QRs%AM_W|@4tP}#lrBmz!@*F8en9HT0!S--;GhoVJdo=50;%KWK-!|YK>Spb zkWssJEx**oEPu3TY5g!7wY99%_hc1k0^M*}}d@X6aecX5u#h|2rd7S!&! z{r;s<7szLyuH10!Mp*3t+j$4pI&^;(eb!#+l)2`ibVJ3!KHGfega?d0#2Y$y+8^)L zrHy|X_0i^S>lD-Xsdxi;g6(K`Ji^3mr~Sz3Li~k&$Zo!|KnPKaMuQ&W@K}vS7Bq<( zjUA-kw7khNNJAmzkx0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TX$e z4>#;IQdM90 zP+3Vg>fAnV;+9HC735yXJji^=eUJr^Y6zbUIK%~xXo2Hb-#bp=97rA{AL4=(Knfv6 z5I3Y4QUWQ3ltIcN$Vfy51gD9QGf&P!g$hZ4AnoDYiqj!Zg*g4;6iOsRQXsP+NTE2N z6KRliNCqSmk_E|zv*pGyF`v8Xia@Q`RhY{O#t@%z@zB5ncO3H0^DZ`T5 zn^m`2H{_h#vvzd(>x&iL&xtXZ3HXHz#|B?@y-{kDdHevx`hA67Lsv6n|LBEvw}$3^ ze#CMxbNUlk`iEoVt8ZJDupqkAtUAmhAn)FRwu6(R6wARGM0txNblZD!)Gav1bPQEW24Qz5BU8>8G#!h%8HpjUGf-v%Y%B zdp5^0Bl(|!5V_9l!w5vsRm?hha_Ls;1+JCspa#&}hvn{GJFM_VM zxRkmGn%Szl&AR2l`1M=ii6_%+ve4-&MBs&4*(@5kaieng=$K{M8$l~tRfky$jilLH z@;-ht)^fNULA&v6vv%6@>^Hj(&W^rjIhfVe7p*%t74AAYZdt1BbOT+@a;!MxcO|Z` z&n~bW%!2K?&5p)R>p#o1Ec@)_X;U465>NQ&hAdjTw(q?qmcu1Gt!`7@W=$CNkJ0?x zJE!hg4rbNZxAvus^L@3EmgP(=9Yt5O_*&O{wB)VqO{q5Na^^YtCt;RnuJBJUO?`YT z-fCJ>4kWg=0q?zkljPjpfi@i?QL_T}vn1*C#%J&CdJ$7bQifc0WKBEyOR diff --git a/scribe/index.html b/scribe/index.html index 0380b20..7ba140c 100644 --- a/scribe/index.html +++ b/scribe/index.html @@ -6,6 +6,7 @@ Tauri App + @@ -39,5 +40,8 @@

+ +
+
test
diff --git a/scribe/package.json b/scribe/package.json index bd997a5..d2df402 100644 --- a/scribe/package.json +++ b/scribe/package.json @@ -11,7 +11,12 @@ }, "dependencies": { "@tauri-apps/api": "^2", - "@tauri-apps/plugin-shell": "^2" + "@tauri-apps/plugin-shell": "^2", + "prosemirror-example-setup": "^1.2.3", + "prosemirror-schema-basic": "^1.2.3", + "prosemirror-schema-list": "^1.4.1", + "prosemirror-state": "^1.4.3", + "prosemirror-view": "^1.34.3" }, "devDependencies": { "@tauri-apps/cli": "^2", diff --git a/scribe/src/main.ts b/scribe/src/main.ts index 4783341..3473d70 100644 --- a/scribe/src/main.ts +++ b/scribe/src/main.ts @@ -1,5 +1,27 @@ import { invoke } from "@tauri-apps/api/core"; +import {EditorState} from "prosemirror-state" +import {EditorView} from "prosemirror-view" +import {Schema, DOMParser} from "prosemirror-model" +import {schema} from "prosemirror-schema-basic" +import {addListNodes} from "prosemirror-schema-list" +import {exampleSetup} from "prosemirror-example-setup" + +// Mix the nodes from prosemirror-schema-list into the basic schema to +// create a schema with list support. +const mySchema = new Schema({ + nodes: addListNodes(schema.spec.nodes, "paragraph block*", "block"), + marks: schema.spec.marks +}) + +window.view = new EditorView(document.querySelector("#editor"), { + state: EditorState.create({ + doc: DOMParser.fromSchema(mySchema).parse(document.querySelector("#content")), + plugins: exampleSetup({schema: mySchema}) + }) +}) + + let greetInputEl: HTMLInputElement | null; let greetMsgEl: HTMLElement | null; diff --git a/scribe/src/prosemirror.ts b/scribe/src/prosemirror.ts new file mode 100644 index 0000000..8bf62e9 --- /dev/null +++ b/scribe/src/prosemirror.ts @@ -0,0 +1,21 @@ +import {EditorState} from "prosemirror-state" +import {EditorView} from "prosemirror-view" +import {Schema, DOMParser} from "prosemirror-model" +import {schema} from "prosemirror-schema-basic" +import {addListNodes} from "prosemirror-schema-list" +import {exampleSetup} from "prosemirror-example-setup" + +// Mix the nodes from prosemirror-schema-list into the basic schema to +// create a schema with list support. +const mySchema = new Schema({ + nodes: addListNodes(schema.spec.nodes, "paragraph block*", "block"), + marks: schema.spec.marks +}) + +window.view = new EditorView(document.querySelector("#editor"), { + state: EditorState.create({ + doc: DOMParser.fromSchema(mySchema).parse(document.querySelector("#content")), + plugins: exampleSetup({schema: mySchema}) + }) +}) +