Skip to content

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

755 B
Raw Blame
import type { Page } from '@playwright/test';

export async function getStringFromRichText(
  page: Page,
  index = 0
): Promise<string> {
  await page.waitForTimeout(50);
  return page.evaluate(
    ([index]) => {
      const editorHost = document.querySelector('editor-host');
      const richTexts = editorHost?.querySelectorAll('rich-text');

      if (!richTexts) {
        throw new Error('Cannot find rich-text');
      }

      const editor = (richTexts[index] as any).inlineEditor;
      return editor.yText.toString();
    },
    [index]
  );
}

// Why? we can't import from `@blocksuite/affine/std/inline` because playwright will throw an error
export const ZERO_WIDTH_FOR_EMPTY_LINE =
  process.env.BROWSER === 'webkit' ? '\u200C' : '\u200B';