fix(editor): inline latex editor should not be shown when doc is readonly (#9794)
[BS-2442](https://linear.app/affine-design/issue/BS-2442/只读时-inline-latex-node-点击不应该弹出-modal)
This commit is contained in:
@@ -161,6 +161,9 @@ export class AffineLatexNode extends SignalWatcher(
|
|||||||
this.disposables.addFromEvent(this, 'click', e => {
|
this.disposables.addFromEvent(this, 'click', e => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
|
if (this.readonly) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.toggleEditor();
|
this.toggleEditor();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -212,6 +215,10 @@ export class AffineLatexNode extends SignalWatcher(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get readonly() {
|
||||||
|
return this.std.store.readonly;
|
||||||
|
}
|
||||||
|
|
||||||
@property({ attribute: false })
|
@property({ attribute: false })
|
||||||
accessor delta: DeltaInsert<AffineTextAttributes> = {
|
accessor delta: DeltaInsert<AffineTextAttributes> = {
|
||||||
insert: ZERO_WIDTH_SPACE,
|
insert: ZERO_WIDTH_SPACE,
|
||||||
|
|||||||
@@ -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.')
|
page.getByText('You do not have access or this content does not exist.')
|
||||||
).toBeVisible();
|
).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();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user