Compare commits

..

No commits in common. "3a2aad4d23ff991cf7fbe3365ec6d55a17994515" and "007685f62a1ecf635e31689f4a1b4b08b0cf65ce" have entirely different histories.

8 changed files with 10 additions and 69 deletions

View file

@ -34,7 +34,6 @@
"bootstrap-icons": "^1.10.3", "bootstrap-icons": "^1.10.3",
"nanoid": "^4.0.1", "nanoid": "^4.0.1",
"navaid": "^1.2.0", "navaid": "^1.2.0",
"regexparam": "^2.0.1",
"y-prosemirror": "^1.2.0", "y-prosemirror": "^1.2.0",
"y-protocols": "^1.0.5", "y-protocols": "^1.0.5",
"y-webrtc": "^10.2.4", "y-webrtc": "^10.2.4",

View file

@ -18,7 +18,6 @@ specifiers:
prosemirror-state: ~1.4.0 prosemirror-state: ~1.4.0
prosemirror-transform: ~1.7.0 prosemirror-transform: ~1.7.0
prosemirror-view: ~1.29.0 prosemirror-view: ~1.29.0
regexparam: ^2.0.1
svelte: ^3.55.1 svelte: ^3.55.1
svelte-check: ^2.10.3 svelte-check: ^2.10.3
tslib: ^2.5.0 tslib: ^2.5.0
@ -33,7 +32,6 @@ dependencies:
bootstrap-icons: 1.10.3 bootstrap-icons: 1.10.3
nanoid: 4.0.1 nanoid: 4.0.1
navaid: 1.2.0 navaid: 1.2.0
regexparam: 2.0.1
y-prosemirror: 1.2.0_vhy2hiocjqydif5dwvxgfnpihi y-prosemirror: 1.2.0_vhy2hiocjqydif5dwvxgfnpihi
y-protocols: 1.0.5 y-protocols: 1.0.5
y-webrtc: 10.2.4 y-webrtc: 10.2.4
@ -884,11 +882,6 @@ packages:
engines: {node: '>=6'} engines: {node: '>=6'}
dev: false dev: false
/regexparam/2.0.1:
resolution: {integrity: sha512-zRgSaYemnNYxUv+/5SeoHI0eJIgTL/A2pUtXUPLHQxUldagouJ9p+K6IbIZ/JiQuCEv2E2B1O11SjVQy3aMCkw==}
engines: {node: '>=8'}
dev: false
/resolve-from/4.0.0: /resolve-from/4.0.0:
resolution: {integrity: sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==} resolution: {integrity: sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==}
engines: {node: '>=4'} engines: {node: '>=4'}

View file

@ -11,7 +11,6 @@
import UnderlineIcon from "bootstrap-icons/icons/type-underline.svg"; import UnderlineIcon from "bootstrap-icons/icons/type-underline.svg";
import StrikethroughIcon from "bootstrap-icons/icons/type-strikethrough.svg"; import StrikethroughIcon from "bootstrap-icons/icons/type-strikethrough.svg";
import LinkIcon from "bootstrap-icons/icons/box-arrow-up-right.svg"; import LinkIcon from "bootstrap-icons/icons/box-arrow-up-right.svg";
import InternalLinkIcon from "bootstrap-icons/icons/folder-symlink.svg";
import CloseIcon from "bootstrap-icons/icons/x.svg"; import CloseIcon from "bootstrap-icons/icons/x.svg";
import type { Command } from "./ps-utils"; import type { Command } from "./ps-utils";
@ -24,7 +23,6 @@
} from "./ps-utils"; } from "./ps-utils";
import { refreshCoords as _refreshCoords } from "./bubblemenu/coords"; import { refreshCoords as _refreshCoords } from "./bubblemenu/coords";
import SimpleMarkItem from "./bubblemenu/SimpleMarkItem.svelte"; import SimpleMarkItem from "./bubblemenu/SimpleMarkItem.svelte";
import { nanoid } from "nanoid";
export let view: EditorView; export let view: EditorView;
export let state: EditorState; export let state: EditorState;
@ -119,13 +117,6 @@
runCommand(updateMark(view.state.schema.marks.link, { href: url })); runCommand(updateMark(view.state.schema.marks.link, { href: url }));
} }
function createInternalLink() {
const pageId = nanoid();
runCommand(
updateMark(view.state.schema.marks.internal_link, { id: pageId })
);
}
const svgStyle = "width: 100%; height: 100%"; const svgStyle = "width: 100%; height: 100%";
</script> </script>
@ -154,12 +145,6 @@
on:mousedown|preventDefault={startEditingLink} on:mousedown|preventDefault={startEditingLink}
><LinkIcon style={svgStyle} /></button ><LinkIcon style={svgStyle} /></button
> >
<button
type="button"
class:active={markIsActive(state, view.state.schema.marks.internal_link)}
on:mousedown|preventDefault={createInternalLink}
><InternalLinkIcon style={svgStyle} /></button
>
{:else if changingProp.type === "link"} {:else if changingProp.type === "link"}
<input <input
bind:this={linkInputEl} bind:this={linkInputEl}

View file

@ -22,10 +22,8 @@
import MenuBar from "./MenuBar.svelte"; import MenuBar from "./MenuBar.svelte";
import { placeholderPlugin } from "./upload"; import { placeholderPlugin } from "./upload";
import { baseKeymap } from "./keymap"; import { baseKeymap } from "./keymap";
import type { WorldY } from "../lib/doc";
export let doc: XmlFragment; export let doc: XmlFragment;
export let worldY: WorldY;
let wrapperEl: HTMLElement; let wrapperEl: HTMLElement;

View file

@ -6,8 +6,8 @@
import { commandListener, markIsActive } from "../ps-utils"; import { commandListener, markIsActive } from "../ps-utils";
export let view: EditorView; export let view: EditorView<any>;
export let state: EditorState; export let state: EditorState<any>;
export let type: MarkType; export let type: MarkType;
export let small: boolean = false; export let small: boolean = false;

View file

@ -1,6 +1,4 @@
import { Schema } from "prosemirror-model"; import { Schema } from "prosemirror-model";
import { parse, inject } from "regexparam";
import { routes } from "../lib/routes";
const hex = (x: string) => ("0" + parseInt(x).toString(16)).slice(-2); const hex = (x: string) => ("0" + parseInt(x).toString(16)).slice(-2);
// https://stackoverflow.com/a/3627747 // https://stackoverflow.com/a/3627747
@ -317,36 +315,6 @@ export const schema = new Schema({
return ["a", attrs]; return ["a", attrs];
}, },
}, },
internal_link: {
attrs: {
id: {},
},
inclusive: false,
parseDOM: [
{
tag: "a[href]",
// TODO: untested
getAttrs(dom) {
dom = dom as HTMLElement;
const href = dom.getAttribute("href");
if (href.startsWith("/w/")) {
return {
id: parse(routes.Page).pattern.exec(href)[1],
};
} else return false;
},
},
],
toDOM(node) {
return [
"a",
{
href: node.attrs.id,
//inject(routes.Page, {world:})
},
];
},
},
code: { code: {
parseDOM: [{ tag: "code" }], parseDOM: [{ tag: "code" }],

View file

@ -19,12 +19,7 @@ export function generateNewWorld(): WorldIdentifier {
}; };
} }
// when creating a webrtc provider for a second time in the same room, it freaks out.
// cache the previous doc and return that instead
let worldYCache: { [key: string]: WorldY } = {};
export function getWorldY(world: WorldIdentifier): WorldY { export function getWorldY(world: WorldIdentifier): WorldY {
if (worldYCache[world.room]) return worldYCache[world.room];
const ydoc = new Y.Doc(); const ydoc = new Y.Doc();
const provider = new WebrtcProvider(world.room, ydoc, { const provider = new WebrtcProvider(world.room, ydoc, {
password: world.password, password: world.password,
@ -34,11 +29,9 @@ export function getWorldY(world: WorldIdentifier): WorldY {
"wss://y-webrtc-signaling-us.herokuapp.com", "wss://y-webrtc-signaling-us.herokuapp.com",
], ],
}); });
const worldY = { ydoc, webrtcProvider: provider }; return { ydoc, webrtcProvider: provider };
worldYCache[world.room] = worldY;
return worldY;
} }
export function getWorldPage(ydoc: Y.Doc, pageId: string): Y.XmlFragment { export function getWorldPage(ydoc: Y.Doc, pageId: string): Y.XmlFragment {
return ydoc.getXmlFragment(`page/${pageId}`); return ydoc.getXmlFragment(`doc/${pageId}`);
} }

View file

@ -23,11 +23,16 @@
} }
$: docPromise = loadDoc(worldId, pageId); $: docPromise = loadDoc(worldId, pageId);
onDestroy(async () => {
const doc = await docPromise;
doc.worldY.webrtcProvider.destroy();
});
</script> </script>
<a class="no-color" href={routes.ChooseWorld}>🠔 Elegir otro mundo</a> <a class="no-color" href={routes.ChooseWorld}>🠔 Elegir otro mundo</a>
{#await docPromise then doc} {#await docPromise then doc}
<Editor doc={doc.doc} worldY={doc.worldY} /> <Editor doc={doc.doc} />
{:catch error} {:catch error}
{error} {error}
<a href={routes.ChooseWorld}>Volver al inicio</a> <a href={routes.ChooseWorld}>Volver al inicio</a>