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.
TypeScript appcrdteditorelectronknowledge-basemarkdownmironotesnotionnotion-alternativerustrust-langrust-languagetabletableviewwhiteboardwikiworkspace
fix(editor): inline latex editor should not be shown when doc is readonly (#9794)
donteatfriedricef995f216bddc
diff --git a/blocksuite/affine/components/src/rich-text/inline/presets/nodes/latex-node/latex-node.ts b/blocksuite/affine/components/src/rich-text/inline/presets/nodes/latex-node/latex-node.tsindex 6f0feaf8b9..0812896bb4 100644--- a/blocksuite/affine/components/src/rich-text/inline/presets/nodes/latex-node/latex-node.ts+++ b/blocksuite/affine/components/src/rich-text/inline/presets/nodes/latex-node/latex-node.ts@@ -161,6 +161,9 @@ export class AffineLatexNode extends SignalWatcher(this.disposables.addFromEvent(this, 'click', e => {e.preventDefault();e.stopPropagation();+ if (this.readonly) {+ return;+ }this.toggleEditor();});@@ -212,6 +215,10 @@ export class AffineLatexNode extends SignalWatcher();}+ get readonly() {+ return this.std.store.readonly;+ }+@property({ attribute: false })accessor delta: DeltaInsert<AffineTextAttributes> = {insert: ZERO_WIDTH_SPACE,diff --git a/tests/affine-cloud/e2e/share-page.spec.ts b/tests/affine-cloud/e2e/share-page.spec.tsindex 7407605ae6..46a3b50727 100644--- a/tests/affine-cloud/e2e/share-page.spec.ts+++ b/tests/affine-cloud/e2e/share-page.spec.ts@@ -347,3 +347,61 @@ test('Should show no permission page when the share page is not found', async ({page.getByText('You do not have access or this content does not exist.')).toBeVisible();});++test('Inline latex modal should be not shown in shared mode when clicking', async ({+ page,+ browser,+}) => {+ await page.reload();+ await waitForEditorLoad(page);+ await createLocalWorkspace(+ {+ name: 'test',+ },+ page+ );+ await enableCloudWorkspaceFromShareButton(page);+ const title = getBlockSuiteEditorTitle(page);+ await title.pressSequentially('TEST TITLE', {+ delay: 50,+ });+ await page.keyboard.press('Enter', { delay: 50 });++ await page.keyboard.type('$$E=mc^2$$');+ await page.keyboard.press('Space');++ // there should be a inline latex node+ const latexLocator = page.locator('affine-latex-node');+ await expect(latexLocator).toBeVisible();++ // click the latex node+ // the latex editor should be shown when the doc can be editing+ await latexLocator.click();+ const modalLocator = page.locator('.latex-editor-container');+ await expect(modalLocator).toBeVisible();++ // enable share page and copy page link+ await enableShare(page);+ await page.getByTestId('share-menu-copy-link-button').click();+ await page.getByTestId('share-link-menu-copy-page').click();++ // check share page is accessible+ {+ const context = await browser.newContext();+ await skipOnboarding(context);+ const url: string = await page.evaluate(() =>+ navigator.clipboard.readText()+ );+ const page2 = await context.newPage();+ await page2.goto(url);+ await waitForEditorLoad(page2);++ // click the latex node+ const latexLocator = page2.locator('affine-latex-node');+ await latexLocator.click();++ // the latex editor should not be shown when the doc is readonly+ const modalLocator = page2.locator('.latex-editor-container');+ await expect(modalLocator).not.toBeVisible();+ }+});