一些检查失败了
automerge / automerge (push) Has been cancelled
react-native-android-build-apk / AssembleRelease (push) Has been cancelled
Build macOS M1 / Main (push) Has been cancelled
Joplin Continuous Integration / Main (macos-15-intel) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-11-vs2026-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-2025) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04-arm) (push) Has been cancelled
Joplin UI tests / Main (ubuntu-22.04) (push) Has been cancelled
Joplin UI tests / Main (windows-2025) (push) Has been cancelled
Joplin UI tests / Mobile (push) Has been cancelled
Close stale issues / ProcessStaleIssues (push) Has been cancelled
45 行
1.4 KiB
TypeScript
45 行
1.4 KiB
TypeScript
import { FrameLocator, Locator, Page } from '@playwright/test';
|
|
import BaseEditor from './BaseEditor';
|
|
import EditorCodeDialog from './EditorCodeDialog';
|
|
|
|
export default class RichTextEditor implements BaseEditor {
|
|
public readonly container: Locator;
|
|
public readonly content: FrameLocator;
|
|
public readonly codeEditor: EditorCodeDialog;
|
|
public readonly body: Locator;
|
|
|
|
public constructor(parent: Locator, page: Page) {
|
|
this.container = parent.locator('iframe[title="Rich Text Area"]');
|
|
this.content = this.container.contentFrame();
|
|
this.codeEditor = new EditorCodeDialog(page);
|
|
this.body = this.content.locator('body');
|
|
}
|
|
|
|
public async waitFor() {
|
|
await this.container.waitFor();
|
|
await this.content.locator('body').waitFor();
|
|
}
|
|
|
|
public async focusContent() {
|
|
// eslint-disable-next-line no-restricted-properties -- The focusHandler wrapper can't be used here, since Playwright's focus needs to be awaited
|
|
await this.body.focus();
|
|
}
|
|
|
|
public async typeText(text: string) {
|
|
await this.body.waitFor();
|
|
await this.focusContent();
|
|
await this.body.pressSequentially(text);
|
|
}
|
|
|
|
public async getSearchMatches() {
|
|
return this.body.evaluate(() => {
|
|
const highlights = CSS.highlights.get('jop-search-highlight') ?? new Set();
|
|
const result = [];
|
|
for (const highlight of highlights) {
|
|
result.push(highlight.toString());
|
|
}
|
|
return result;
|
|
});
|
|
}
|
|
}
|