From 91cbf2260bd4272518abe6e15f611863e21b3e83 Mon Sep 17 00:00:00 2001 From: Nulo Date: Thu, 31 Aug 2023 10:36:21 -0300 Subject: [PATCH] traer cambios de enlaces de sutty/editor --- package.json | 1 + pnpm-lock.yaml | 20 +++ src/editor/Editor.svelte | 12 +- src/editor/bubblemenu/EditLinkMenu.svelte | 142 ++++++++++++++++++++++ src/editor/bubblemenu/LinkTooltip.svelte | 103 ++++++++++++++++ src/editor/bubblemenu/floatingUi.ts | 41 +++++++ src/editor/ps-utils.ts | 99 +++++++++++++-- 7 files changed, 406 insertions(+), 12 deletions(-) create mode 100644 src/editor/bubblemenu/EditLinkMenu.svelte create mode 100644 src/editor/bubblemenu/LinkTooltip.svelte create mode 100644 src/editor/bubblemenu/floatingUi.ts diff --git a/package.json b/package.json index 0ec3595..741fb5d 100644 --- a/package.json +++ b/package.json @@ -42,6 +42,7 @@ "vite": "^4.2.2" }, "dependencies": { + "@floating-ui/dom": "^1.5.1", "bootstrap-icons": "^1.10.4", "eva-icons": "^1.1.3", "idb-keyval": "^6.2.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4d06bde..786d592 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -5,6 +5,9 @@ settings: excludeLinksFromLockfile: false dependencies: + '@floating-ui/dom': + specifier: ^1.5.1 + version: 1.5.1 bootstrap-icons: specifier: ^1.10.4 version: 1.10.4 @@ -330,6 +333,23 @@ packages: dev: true optional: true + /@floating-ui/core@1.4.1: + resolution: {integrity: sha512-jk3WqquEJRlcyu7997NtR5PibI+y5bi+LS3hPmguVClypenMsCY3CBa3LAQnozRCtCrYWSEtAdiskpamuJRFOQ==} + dependencies: + '@floating-ui/utils': 0.1.1 + dev: false + + /@floating-ui/dom@1.5.1: + resolution: {integrity: sha512-KwvVcPSXg6mQygvA1TjbN/gh///36kKtllIF8SUm0qpFj8+rvYrpvlYdL1JoA71SHpDqgSSdGOSoQ0Mp3uY5aw==} + dependencies: + '@floating-ui/core': 1.4.1 + '@floating-ui/utils': 0.1.1 + dev: false + + /@floating-ui/utils@0.1.1: + resolution: {integrity: sha512-m0G6wlnhm/AX0H12IOWtK8gASEMffnX08RtKkCgTdHb9JpHKGloI7icFfLg9ZmQeavcvR0PKmzxClyuFPSjKWw==} + dev: false + /@jridgewell/gen-mapping@0.3.3: resolution: {integrity: sha512-HLhSWOLRi875zjjMG/r+Nv0oCW8umGb0BgEhyX3dDX3egwZtB8PqLnjz3yedt8R5StBrzcg4aBpnh8UA9D1BoQ==} engines: {node: '>=6.0.0'} diff --git a/src/editor/Editor.svelte b/src/editor/Editor.svelte index 3767be7..3a9f514 100644 --- a/src/editor/Editor.svelte +++ b/src/editor/Editor.svelte @@ -16,12 +16,17 @@ // import { placeholderPlugin } from "./upload"; import { baseKeymap } from "./keymap"; import type { WorldY } from "../lib/doc"; + import { writable } from "svelte/store"; + import EditLinkMenu from "./bubblemenu/EditLinkMenu.svelte"; + import LinkTooltip from "./bubblemenu/LinkTooltip.svelte"; export let doc: XmlFragment; export let worldY: WorldY; let wrapperEl: HTMLElement; + const editingLink = writable(false); + function createState(doc: XmlFragment): EditorState { return EditorState.create({ schema, @@ -69,9 +74,14 @@
{#if view} + + {/if} -
+
{#if view} {/if} diff --git a/src/editor/bubblemenu/EditLinkMenu.svelte b/src/editor/bubblemenu/EditLinkMenu.svelte new file mode 100644 index 0000000..06a125c --- /dev/null +++ b/src/editor/bubblemenu/EditLinkMenu.svelte @@ -0,0 +1,142 @@ + + + + + + + diff --git a/src/editor/bubblemenu/LinkTooltip.svelte b/src/editor/bubblemenu/LinkTooltip.svelte new file mode 100644 index 0000000..98d934b --- /dev/null +++ b/src/editor/bubblemenu/LinkTooltip.svelte @@ -0,0 +1,103 @@ + + +
+ + + + {link?.mark.attrs.href} + + + + +
+ + diff --git a/src/editor/bubblemenu/floatingUi.ts b/src/editor/bubblemenu/floatingUi.ts new file mode 100644 index 0000000..9e6f280 --- /dev/null +++ b/src/editor/bubblemenu/floatingUi.ts @@ -0,0 +1,41 @@ +import { readable, type Readable } from "svelte/store"; +import { + computePosition, + autoUpdate, + autoPlacement, + shift, + offset, +} from "@floating-ui/dom"; +import type { ComputePositionConfig } from "@floating-ui/dom/src/types"; +import type { MarkMatch } from "../ps-utils"; +import type { EditorView } from "prosemirror-view"; + +export type Style = string; + +export function floatingUi( + refEl: Element, + tooltipEl: HTMLElement, + options?: Partial, +): Readable