focus and placeholder for ProseMirrorEditor

master
Niko PLP 5 months ago
parent 74137c4bdd
commit 0a5c03ebd1
  1. 7
      ng-app/src/apps/ProseMirrorEditor.svelte
  2. 1
      ng-app/src/apps/ProseMirrorViewer.svelte
  3. 1
      ng-app/src/locales/en.json

@ -24,6 +24,7 @@
cur_tab_deregister_on_save, cur_tab_deregister_on_save,
cur_tab_branch_class cur_tab_branch_class
} from "../tab"; } from "../tab";
import { t } from "svelte-i18n";
import * as Y from 'yjs' import * as Y from 'yjs'
// @ts-ignore // @ts-ignore
@ -38,6 +39,8 @@
const ydoc = new Y.Doc() const ydoc = new Y.Doc()
const yxml = ydoc.getXmlFragment('ng') const yxml = ydoc.getXmlFragment('ng')
let view;
ydoc.on('update', async (update, origin) => { ydoc.on('update', async (update, origin) => {
console.log(update,origin); console.log(update,origin);
if (!origin.local) { if (!origin.local) {
@ -82,6 +85,8 @@
for (const h of history) { for (const h of history) {
Y.applyUpdate(ydoc, h.YXml, {local:true}) Y.applyUpdate(ydoc, h.YXml, {local:true})
} }
view.focus()
}); });
onDestroy(()=>{ onDestroy(()=>{
@ -94,6 +99,8 @@
className="prosemirror-editor" className="prosemirror-editor"
{editorState} {editorState}
debounceChangeEventsInterval=2000 debounceChangeEventsInterval=2000
placeholder={$t("doc.type_your_text_here")}
bind:view={view}
/> />
</div> </div>

@ -68,6 +68,7 @@
</script> </script>
<div class="grow p-5"> <div class="grow p-5">
{#if source} {#if source}
<div class="post-rich-text"> <div class="post-rich-text">

@ -44,6 +44,7 @@
"view_graph": "View Graph", "view_graph": "View Graph",
"results": "Results", "results": "Results",
"empty": "Empty", "empty": "Empty",
"type_your_text_here": "Type your text here",
"sparql_update": "SPARQL Update", "sparql_update": "SPARQL Update",
"no_triples": "No triples in this Graph.", "no_triples": "No triples in this Graph.",
"start_editing": "Start editing", "start_editing": "Start editing",

Loading…
Cancel
Save