Files
outline/shared/editor/queries/findBlockInsertPos.test.ts
Tom Moor 128c240405 Render uploads with the same component as the uploaded node (#14117)
* feat: Render uploading images and videos with their node component

* fix: Insert uploaded block nodes next to the paragraph instead of inside it

* fix: Insert dropped block nodes on the nearest side of the paragraph

* feat: Fade in uploaded images and videos from their placeholder

* feat: Preview the new image while it replaces an existing one

* fix: Keep the placeholder size and preload pasted images after upload

* fix: Move the selection off an image while an upload replaces it

* feat: Play uploaded videos from the local file in the uploading editor

* feat: Display uploaded images from the local file in the uploading editor

* feat: Soften image and video corners, round them fully when selected

* feat: Render uploading attachments with the attachment component

* feat: Show the file size of an attachment while it uploads

* feat: Show upload progress on the placeholder instead of a toast

* fix: Fade the content of an uploading file but not its progress bar

* fix: Keep the local file of an upload when its placeholder is mapped away

* chore: Simplify upload placeholder state and remove unused progress callback

* Remove test

* fix: Address review feedback on upload placeholders

Expose upload progress to assistive technology outside the inert placeholder, free local files when the editor state is replaced, reuse the fadeIn animation and move the video wrapper class to EditorStyleHelper.

* chore: Move image and PDF wrapper class names to EditorStyleHelper

* feat: Scale in an upload placeholder when it appears

* chore: Make the upload placeholder scale-in more subtle
2026-10-17 12:12:25 -04:00

38 lines
1.2 KiB
TypeScript

import { doc, p, schema } from "@shared/test/editor";
import { findBlockInsertPos } from "./findBlockInsertPos";
const { video, image } = schema.nodes;
describe("findBlockInsertPos", () => {
// doc: <p>one</p><p></p><p>two</p>
const document = doc([p("one"), p(""), p("two")]);
it("returns the position before an empty paragraph", () => {
expect(findBlockInsertPos(document, 6, video)).toBe(5);
});
it("returns the position before a paragraph when at its start", () => {
expect(findBlockInsertPos(document, 1, video)).toBe(0);
});
it("returns the position after a paragraph when at its end", () => {
expect(findBlockInsertPos(document, 4, video)).toBe(5);
});
it("returns the position before a paragraph when nearer its start", () => {
expect(findBlockInsertPos(document, 2, video)).toBe(0);
});
it("returns the position after a paragraph when nearer its end", () => {
expect(findBlockInsertPos(document, 3, video)).toBe(5);
});
it("returns a position between blocks unchanged", () => {
expect(findBlockInsertPos(document, 7, video)).toBe(7);
});
it("returns the position unchanged for inline nodes", () => {
expect(findBlockInsertPos(document, 2, image)).toBe(2);
});
});