From aa526601315a1598fb557832c33599e49b6ba4ba Mon Sep 17 00:00:00 2001 From: Ying Zhong <0x00eeee@gmail.com> Date: Sun, 27 Sep 2026 21:56:57 +0800 Subject: [PATCH] Remove "table" from default inlineRendering --- README.md | 4 ++-- dist/lite/markedit-preview.js | 2 +- dist/markedit-preview.js | 2 +- src/support/settings.ts | 2 +- tests/hiddenSyntax/block.test.ts | 2 +- tests/hiddenSyntax/table.test.ts | 15 ++++++++------- tests/settings.test.ts | 4 ++-- 7 files changed, 16 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index e44609e..c1d4250 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ In [settings.json](https://github.com/MarkEdit-app/MarkEdit/wiki/Customization#a "hidePreviewButtons": true, "syntaxAutoDetect": false, "imageHoverPreview": false, - "inlineRendering": ["table", "math", "mermaid"], + "inlineRendering": ["math", "mermaid"], "themeName": "github", "styledHtmlColorScheme": "auto", "mathDelimiters": [], @@ -68,7 +68,7 @@ In [settings.json](https://github.com/MarkEdit-app/MarkEdit/wiki/Customization#a - `syntaxAutoDetect`: Whether to enable automatic language detection for syntax highlighting in code blocks (not applicable for lite build). - `imageHoverPreview`: Whether to enable image preview on hover. - `inlineImages` (deprecated): Whether Mixed mode renders images inline, defaults to `false`. Use `inlineRendering` instead; an explicit `inlineRendering` array takes precedence. -- `inlineRendering`: Types rendered inline in Mixed mode: `"table"`, `"math"`, `"mermaid"`, `"image"`, and `"html"`. Defaults to `["table", "math", "mermaid"]`; use `[]` to disable all rendering. Math and Mermaid rendering require the full build. +- `inlineRendering`: Types rendered inline in Mixed mode: `"table"`, `"math"`, `"mermaid"`, `"image"`, and `"html"`. Defaults to `["math", "mermaid"]`; use `[]` to disable all rendering. Math and Mermaid rendering require the full build. - `themeName`: Set the preview color theme, available themes can be found in the [`styles/themes`](styles/themes) folder. Use `"none"` to disable preview styling and render the raw HTML. - `styledHtmlColorScheme`: Determine the color scheme of saving styled html files, valid values are `light`, `dark`, and `auto`. - `mathDelimiters`: Customize math delimiters for KaTeX rendering (not applicable for lite build), each delimiter object has `left`, `right`, and `display` properties, defaults to `$...$`, `$$...$$`, `\(...\)`, and `\[...\]`. diff --git a/dist/lite/markedit-preview.js b/dist/lite/markedit-preview.js index be392d6..a647930 100644 --- a/dist/lite/markedit-preview.js +++ b/dist/lite/markedit-preview.js @@ -45,7 +45,7 @@ ${t} `}}function fh(e){try{const t=ah(e,{schema:Ea});if(t!==null&&typeof t=="object"&&!Array.isArray(t)&&Object.keys(t).length>0)return t}catch{}}function za(e,t){const n=Object.entries(e);return n.length===0?"":` ${n.map(([o,u])=>`${t(o)}${ho(u,t)}`).join(` `)} -`}function ho(e,t){if(e==null)return"";if(e instanceof Date)return t(hh(e));if(Array.isArray(e))return e.every(ph)?e.map(r=>ho(r,t)).join(", "):``;if(typeof e=="object"){const n=za(e,t);return n===""?"":`${n}
`}return t(String(e))}function hh(e){if(Number.isNaN(e.getTime()))return"";const t=e.toISOString();return t.endsWith("T00:00:00.000Z")?t.slice(0,10):t}function ph(e){if(e==null||e instanceof Date)return!0;const t=typeof e;return t==="string"||t==="number"||t==="boolean"||t==="bigint"}const Io={rootValueKey:"extension.markeditPreview",defaultModes:["edit","side-by-side","preview","syntax-hidden"],defaultPreset:"default"},mh=$t(M.MarkEdit.userSettings),we=$t(mh[Io.rootValueKey]),qa=$t(we.changeMode),Ba=$t(we.markdownIt),bh=bn(we.syncScroll);bn(we.hidePreviewButtons);bn(we.syntaxAutoDetect,!1);const gh=bn(we.imageHoverPreview,!1),yh=bn(we.inlineImages,!1),Ha=Array.isArray(we.inlineRendering)?we.inlineRendering.filter(e=>e==="image"||e==="table"||e==="math"||e==="mermaid"||e==="html"):yh?["image","table","math","mermaid"]:["table","math","mermaid"],ar=we.themeName??"github",$a=ar==="none",Gr=we.styledHtmlColorScheme??we.styledHtmlTheme??"auto";we.mathDelimiters;const kh=qa.modes??Io.defaultModes,ti=$t(qa.hotKey),xh=Ba.preset??Io.defaultPreset,wh=$t(Ba.options);function $t(e,t={}){return e??t}function bn(e,t=!0){return e??t}const Va=`.markdown-body { +`}function ho(e,t){if(e==null)return"";if(e instanceof Date)return t(hh(e));if(Array.isArray(e))return e.every(ph)?e.map(r=>ho(r,t)).join(", "):``;if(typeof e=="object"){const n=za(e,t);return n===""?"":`${n}
`}return t(String(e))}function hh(e){if(Number.isNaN(e.getTime()))return"";const t=e.toISOString();return t.endsWith("T00:00:00.000Z")?t.slice(0,10):t}function ph(e){if(e==null||e instanceof Date)return!0;const t=typeof e;return t==="string"||t==="number"||t==="boolean"||t==="bigint"}const Io={rootValueKey:"extension.markeditPreview",defaultModes:["edit","side-by-side","preview","syntax-hidden"],defaultPreset:"default"},mh=$t(M.MarkEdit.userSettings),we=$t(mh[Io.rootValueKey]),qa=$t(we.changeMode),Ba=$t(we.markdownIt),bh=bn(we.syncScroll);bn(we.hidePreviewButtons);bn(we.syntaxAutoDetect,!1);const gh=bn(we.imageHoverPreview,!1),yh=bn(we.inlineImages,!1),Ha=Array.isArray(we.inlineRendering)?we.inlineRendering.filter(e=>e==="image"||e==="table"||e==="math"||e==="mermaid"||e==="html"):yh?["image","math","mermaid"]:["math","mermaid"],ar=we.themeName??"github",$a=ar==="none",Gr=we.styledHtmlColorScheme??we.styledHtmlTheme??"auto";we.mathDelimiters;const kh=qa.modes??Io.defaultModes,ti=$t(qa.hotKey),xh=Ba.preset??Io.defaultPreset,wh=$t(Ba.options);function $t(e,t={}){return e??t}function bn(e,t=!0){return e??t}const Va=`.markdown-body { --base-size-16: 1rem; --base-size-24: 1.5rem; --base-size-4: 0.25rem; diff --git a/dist/markedit-preview.js b/dist/markedit-preview.js index bcc3bb4..28b64e9 100644 --- a/dist/markedit-preview.js +++ b/dist/markedit-preview.js @@ -45,7 +45,7 @@ ${e} `}}function t$e(t){try{const e=jFe(t,{schema:Ahe});if(e!==null&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length>0)return e}catch{}}function zhe(t,e){const r=Object.entries(t);return r.length===0?"":` ${r.map(([i,a])=>`${e(i)}${oP(a,e)}`).join(` `)} -`}function oP(t,e){if(t==null)return"";if(t instanceof Date)return e(r$e(t));if(Array.isArray(t))return t.every(n$e)?t.map(n=>oP(n,e)).join(", "):``;if(typeof t=="object"){const r=zhe(t,e);return r===""?"":`${r}
`}return e(String(t))}function r$e(t){if(Number.isNaN(t.getTime()))return"";const e=t.toISOString();return e.endsWith("T00:00:00.000Z")?e.slice(0,10):e}function n$e(t){if(t==null||t instanceof Date)return!0;const e=typeof t;return e==="string"||e==="number"||e==="boolean"||e==="bigint"}const SG={rootValueKey:"extension.markeditPreview",defaultModes:["edit","side-by-side","preview","syntax-hidden"],defaultPreset:"default"},i$e=_2(wr.MarkEdit.userSettings),Zo=_2(i$e[SG.rootValueKey]),Uhe=_2(Zo.changeMode),Ghe=_2(Zo.markdownIt),a$e=Nx(Zo.syncScroll),s$e=Nx(Zo.hidePreviewButtons),o$e=Nx(Zo.syntaxAutoDetect,!1),l$e=Nx(Zo.imageHoverPreview,!1),c$e=Nx(Zo.inlineImages,!1),qhe=Array.isArray(Zo.inlineRendering)?Zo.inlineRendering.filter(t=>t==="image"||t==="table"||t==="math"||t==="mermaid"||t==="html"):c$e?["image","table","math","mermaid"]:["table","math","mermaid"],G5=Zo.themeName??"github",Yhe=G5==="none",zg=Zo.styledHtmlColorScheme??Zo.styledHtmlTheme??"auto",Oj=Zo.mathDelimiters,u$e=Uhe.modes??SG.defaultModes,Nj=_2(Uhe.hotKey),d$e=Ghe.preset??SG.defaultPreset,h$e=_2(Ghe.options);function _2(t,e={}){return t??e}function Nx(t,e=!0){return t??e}const Vhe=`.markdown-body { +`}function oP(t,e){if(t==null)return"";if(t instanceof Date)return e(r$e(t));if(Array.isArray(t))return t.every(n$e)?t.map(n=>oP(n,e)).join(", "):``;if(typeof t=="object"){const r=zhe(t,e);return r===""?"":`${r}
`}return e(String(t))}function r$e(t){if(Number.isNaN(t.getTime()))return"";const e=t.toISOString();return e.endsWith("T00:00:00.000Z")?e.slice(0,10):e}function n$e(t){if(t==null||t instanceof Date)return!0;const e=typeof t;return e==="string"||e==="number"||e==="boolean"||e==="bigint"}const SG={rootValueKey:"extension.markeditPreview",defaultModes:["edit","side-by-side","preview","syntax-hidden"],defaultPreset:"default"},i$e=_2(wr.MarkEdit.userSettings),Zo=_2(i$e[SG.rootValueKey]),Uhe=_2(Zo.changeMode),Ghe=_2(Zo.markdownIt),a$e=Nx(Zo.syncScroll),s$e=Nx(Zo.hidePreviewButtons),o$e=Nx(Zo.syntaxAutoDetect,!1),l$e=Nx(Zo.imageHoverPreview,!1),c$e=Nx(Zo.inlineImages,!1),qhe=Array.isArray(Zo.inlineRendering)?Zo.inlineRendering.filter(t=>t==="image"||t==="table"||t==="math"||t==="mermaid"||t==="html"):c$e?["image","math","mermaid"]:["math","mermaid"],G5=Zo.themeName??"github",Yhe=G5==="none",zg=Zo.styledHtmlColorScheme??Zo.styledHtmlTheme??"auto",Oj=Zo.mathDelimiters,u$e=Uhe.modes??SG.defaultModes,Nj=_2(Uhe.hotKey),d$e=Ghe.preset??SG.defaultPreset,h$e=_2(Ghe.options);function _2(t,e={}){return t??e}function Nx(t,e=!0){return t??e}const Vhe=`.markdown-body { --base-size-16: 1rem; --base-size-24: 1.5rem; --base-size-4: 0.25rem; diff --git a/src/support/settings.ts b/src/support/settings.ts index 7f03e7c..671b7b7 100644 --- a/src/support/settings.ts +++ b/src/support/settings.ts @@ -29,7 +29,7 @@ export const inlineImages = toBoolean(rootValue.inlineImages, false); export const inlineRendering: readonly InlineRenderingType[] = Array.isArray(rootValue.inlineRendering) ? rootValue.inlineRendering.filter((value): value is InlineRenderingType => value === 'image' || value === 'table' || value === 'math' || value === 'mermaid' || value === 'html') - : inlineImages ? ['image', 'table', 'math', 'mermaid'] : ['table', 'math', 'mermaid']; + : inlineImages ? ['image', 'math', 'mermaid'] : ['math', 'mermaid']; export const themeName = (rootValue.themeName ?? 'github') as string; export const showRawHtml = themeName === 'none'; diff --git a/tests/hiddenSyntax/block.test.ts b/tests/hiddenSyntax/block.test.ts index b36bf5c..10c4c50 100644 --- a/tests/hiddenSyntax/block.test.ts +++ b/tests/hiddenSyntax/block.test.ts @@ -33,7 +33,7 @@ describe('Inline rendering options', () => { test.each(options.map(rendering => ({ rendering })))('renders only the configured types: $rendering', ({ rendering }) => { editor.setUp(source, createHiddenSyntaxExtension(rendering)); window.editor.dispatch({ selection: { anchor: source.length } }); - const enabled = rendering ?? ['table', 'math', 'mermaid']; + const enabled = rendering ?? ['math', 'mermaid']; for (const type of Object.keys(selectors) as InlineRenderingType[]) { expect(window.editor.dom.querySelector(selectors[type]) !== null).toBe(enabled.includes(type)); } diff --git a/tests/hiddenSyntax/table.test.ts b/tests/hiddenSyntax/table.test.ts index ba9030a..1db61f1 100644 --- a/tests/hiddenSyntax/table.test.ts +++ b/tests/hiddenSyntax/table.test.ts @@ -5,7 +5,7 @@ import { EditorSelection, EditorState } from '@codemirror/state'; import { EditorView, keymap, runScopeHandlers } from '@codemirror/view'; import { standardKeymap } from '@codemirror/commands'; import { codeFolding, foldedRanges, foldEffect, unfoldEffect } from '@codemirror/language'; -import { hiddenSyntaxExtension } from '../../src/hiddenSyntax'; +import { createHiddenSyntaxExtension } from '../../src/hiddenSyntax'; import { TableWidget } from '../../src/hiddenSyntax/components/table'; import * as renderer from '../../src/render'; import * as editor from '../support/editor'; @@ -14,13 +14,14 @@ const editorConfig = vi.hoisted(() => ({ theme: 'github-light' })); vi.mock('markedit-api', () => ({ MarkEdit: { editorConfig } })); beforeEach(() => { editorConfig.theme = 'github-light'; }); +const tableSyntaxExtension = createHiddenSyntaxExtension(['table']); const table = '| Name | Value |\n| :--- | ---: |\n| **bold** | [link][target] |'; const source = `${table}\n\nAfter\n\n[target]: https://example.com`; const widget = () => window.editor.dom.querySelector('.cm-md-syntaxHiddenTable'); const renderedTable = () => widget()?.shadowRoot?.querySelector('table'); function setUp(text = source) { - editor.setUp(text, [hiddenSyntaxExtension, codeFolding(), EditorState.allowMultipleSelections.of(true)]); + editor.setUp(text, [tableSyntaxExtension, codeFolding(), EditorState.allowMultipleSelections.of(true)]); window.editor.dispatch({ selection: { anchor: text.length } }); } @@ -81,7 +82,7 @@ describe('Hidden tables', () => { ['github-light', false, '#ffffff', '#1f2328'], ] as const)('uses the %s editor palette', (name, isDark, background, foreground) => { editorConfig.theme = name; - editor.setUp(source, [hiddenSyntaxExtension, EditorView.darkTheme.of(isDark)]); + editor.setUp(source, [tableSyntaxExtension, EditorView.darkTheme.of(isDark)]); window.editor.dispatch({ selection: { anchor: source.length } }); const css = widget()?.shadowRoot?.querySelector('style')?.textContent; @@ -91,7 +92,7 @@ describe('Hidden tables', () => { test('updates the palette in place and stops observing after destruction', () => { editorConfig.theme = 'cobalt'; - editor.setUp(source, [hiddenSyntaxExtension, EditorView.darkTheme.of(true)]); + editor.setUp(source, [tableSyntaxExtension, EditorView.darkTheme.of(true)]); window.editor.dispatch({ selection: { anchor: source.length } }); const container = widget(); const theme = container?.shadowRoot?.querySelector('style'); @@ -202,7 +203,7 @@ describe('Hidden tables', () => { test.each(['ArrowRight', 'ArrowLeft'])('%s reveals source at the table boundary', async key => { const prefix = 'Before\n\n'; const text = `${prefix}${table}\n# After\n\n[target]: https://example.com`; - editor.setUp(text, [hiddenSyntaxExtension, keymap.of(standardKeymap)]); + editor.setUp(text, [tableSyntaxExtension, keymap.of(standardKeymap)]); const boundary = key === 'ArrowRight' ? prefix.length : prefix.length + table.length; const start = boundary + (key === 'ArrowRight' ? -1 : 1); @@ -221,7 +222,7 @@ describe('Hidden tables', () => { ] as const)('preserves CodeMirror table-skipping movement for %s, shift: %s', async (key, shiftKey) => { const prefix = 'Before\n\n'; const text = `${prefix}${source}`; - editor.setUp(text, [hiddenSyntaxExtension, keymap.of(standardKeymap)]); + editor.setUp(text, [tableSyntaxExtension, keymap.of(standardKeymap)]); const before = prefix.length - 1; const after = prefix.length + table.length + 1; @@ -270,7 +271,7 @@ describe('Hidden tables', () => { test.each(['ArrowLeft', 'ArrowRight', 'typing'])('reveals source on %s after vertical arrival at the next blank line', async action => { const text = `${table}\n \nAfter\n\n[target]: https://example.com`; - editor.setUp(text, [hiddenSyntaxExtension, keymap.of(standardKeymap)]); + editor.setUp(text, [tableSyntaxExtension, keymap.of(standardKeymap)]); const start = table.length + 2; window.editor.dispatch({ selection: EditorSelection.create([EditorSelection.cursor(start, 0, undefined, 24)]) }); await vi.waitFor(() => expect(renderedTable()).toBeTruthy()); diff --git a/tests/settings.test.ts b/tests/settings.test.ts index 664bcc5..0a85aad 100644 --- a/tests/settings.test.ts +++ b/tests/settings.test.ts @@ -12,7 +12,7 @@ describe('Inline rendering settings', () => { test.each([true, false])('preserves deprecated inlineImages: %s', async enabled => { settings.inlineImages = enabled; const { inlineRendering } = await import('../src/support/settings'); - expect(inlineRendering).toEqual(enabled ? ['image', 'table', 'math', 'mermaid'] : ['table', 'math', 'mermaid']); + expect(inlineRendering).toEqual(enabled ? ['image', 'math', 'mermaid'] : ['math', 'mermaid']); }); test.each([ @@ -29,7 +29,7 @@ describe('Inline rendering settings', () => { test.each([undefined, null, false, 'image', {}])('uses defaults for a non-array value: %j', async value => { settings.inlineRendering = value; const { inlineRendering } = await import('../src/support/settings'); - expect(inlineRendering).toEqual(['table', 'math', 'mermaid']); + expect(inlineRendering).toEqual(['math', 'mermaid']); }); test.each([