Skip to content

Playwright refactor fixes #436

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Dec 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,5 @@ jobs:
if: always()
with:
name: playwright-report
path: playwright-report/
path: tests/playwright-report/
retention-days: 30
7 changes: 4 additions & 3 deletions examples/editor/src/style.css
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
.editor {
margin: 0 calc((100% - 731px) / 2);
height: 100%;
margin-top: 8px;
/* height: 100%; */
}

body {
margin: 0;
}

.root {
/* .root {
height: 100%;
width: 100%;
}
} */
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import fs from "node:fs";
import path from "node:path";
import { afterEach, beforeEach, describe, expect, it } from "vitest";
import { BlockNoteEditor } from "../../../BlockNoteEditor";

import {
BlockSchema,
PartialBlock,
Expand Down Expand Up @@ -34,6 +35,16 @@ async function convertToMarkdownAndCompareSnapshots<
"/" +
snapshotName +
"/markdown.md";

// vitest empty snapshots are broken on CI. might be fixed on next vitest, use workaround for now
if (!md.length && process.env.CI) {
if (
fs.readFileSync(path.join(__dirname, snapshotPath), "utf8").length === 0
) {
// both are empty, so it's fine
return;
}
}
expect(md).toMatchFileSnapshot(snapshotPath);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isNodeSelection, isTextSelection, posToDOMRect } from "@tiptap/core";
import { isNodeSelection, posToDOMRect } from "@tiptap/core";
import { EditorState, Plugin, PluginKey } from "prosemirror-state";
import { EditorView } from "prosemirror-view";

Expand Down Expand Up @@ -29,15 +29,7 @@ export class FormattingToolbarView {
state: EditorState;
from: number;
to: number;
}) => boolean = ({ state }) => {
const { selection } = state;
const { empty } = selection;

if (!isTextSelection(selection)) {
return false;
}
return !empty;
};
}) => boolean = ({ state }) => !state.selection.empty;

constructor(
private readonly editor: BlockNoteEditor<
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,15 @@ function setSelectionToNextContentEditableBlock<
S extends StyleSchema
>(editor: BlockNoteEditor<BSchema, I, S>) {
let block = editor.getTextCursorPosition().block;
let contentType = editor.blockSchema[block.type].content as
| "inline"
| "table"
| "none";
let contentType = editor.blockSchema[block.type].content;

while (contentType === "none") {
editor.setTextCursorPosition(block, "end");
block = editor.getTextCursorPosition().nextBlock!;
contentType = editor.blockSchema[block.type].content as
| "inline"
| "table"
| "none";
editor.setTextCursorPosition(block, "end");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
"type": "image",
"attrs": {
"textAlignment": "left",
"backgroundColor": "default",
"url": "https://www.pulsecarshalton.co.uk/wp-content/uploads/2016/08/jk-placeholder-image.jpg",
"caption": "",
"width": 462
Expand Down Expand Up @@ -96,7 +95,6 @@
"type": "image",
"attrs": {
"textAlignment": "left",
"backgroundColor": "default",
"url": "https://www.pulsecarshalton.co.uk/wp-content/uploads/2016/08/jk-placeholder-image.jpg",
"caption": "",
"width": 462
Expand Down
2 changes: 1 addition & 1 deletion tests/src/end-to-end/images/images.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { compareDocToSnapshot, focusOnEditor } from "../../utils/editor";
import { dragAndDropBlock } from "../../utils/mouse";
import { executeSlashCommand } from "../../utils/slashmenu";

const IMAGE_UPLOAD_PATH = "tests/end-to-end/images/placeholder.png";
const IMAGE_UPLOAD_PATH = "src/end-to-end/images/placeholder.png";
const IMAGE_EMBED_URL =
"https://www.pulsecarshalton.co.uk/wp-content/uploads/2016/08/jk-placeholder-image.jpg";

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.