From 7ac4b7571f4226b5fdecb871dab0d2593182406d Mon Sep 17 00:00:00 2001 From: Alf Eaton Date: Thu, 8 Jun 2023 09:43:27 +0100 Subject: [PATCH] Fix Markdown story (#13220) GitOrigin-RevId: d5cf8a66aee0043673c998e69b1a423085cc1e71 --- .../source-editor/source-editor.stories.tsx | 39 +++++++++++-------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/services/web/frontend/stories/source-editor/source-editor.stories.tsx b/services/web/frontend/stories/source-editor/source-editor.stories.tsx index 0d1abb4fae..9b62719a3b 100644 --- a/services/web/frontend/stories/source-editor/source-editor.stories.tsx +++ b/services/web/frontend/stories/source-editor/source-editor.stories.tsx @@ -32,7 +32,7 @@ const settings = { export const Latex = (args: any, { globals: { theme } }: any) => { useScope({ editor: { - sharejs_doc: mockDoc(content.tex), + sharejs_doc: mockDoc(content.tex, changes.tex), open_doc_name: 'example.tex', }, settings: { @@ -47,7 +47,7 @@ export const Latex = (args: any, { globals: { theme } }: any) => { export const Markdown = (args: any, { globals: { theme } }: any) => { useScope({ editor: { - sharejs_doc: mockDoc(content.md), + sharejs_doc: mockDoc(content.md, changes.md), open_doc_name: 'example.md', }, settings: { @@ -62,7 +62,7 @@ export const Markdown = (args: any, { globals: { theme } }: any) => { export const Visual = (args: any, { globals: { theme } }: any) => { useScope({ editor: { - sharejs_doc: mockDoc(content.tex), + sharejs_doc: mockDoc(content.tex, changes.tex), open_doc_name: 'example.tex', showVisual: true, }, @@ -105,7 +105,7 @@ export const Visual = (args: any, { globals: { theme } }: any) => { const MAX_DOC_LENGTH = 2 * 1024 * 1024 // window.maxDocLength -const mockDoc = (content: string) => { +const mockDoc = (content: string, changes: Array> = []) => { const mockShareJSDoc = { getText() { return content @@ -142,24 +142,29 @@ const mockDoc = (content: string) => { // Do nothing }, ranges: { - changes: [ - { - id: '1', - op: { - i: 'Your introduction goes here! Simply start writing your document and use the Recompile button to view the updated PDF preview. Examples of commonly used commands and features are listed below, to help you get started.', - p: 583, - }, - meta: { - user_id: '1', - ts: new Date().toString(), - }, - }, - ], + changes, comments: [], }, } } +const changes: Record>> = { + tex: [ + { + id: '1', + op: { + i: 'Your introduction goes here! Simply start writing your document and use the Recompile button to view the updated PDF preview. Examples of commonly used commands and features are listed below, to help you get started.', + p: 583, + }, + meta: { + user_id: '1', + ts: new Date().toString(), + }, + }, + ], + md: [], +} + const content = { tex: `\\documentclass{article}