Commit Graph
260 Commits
Author SHA1 Message Date
Doocs Bot 516efead5c chore: release CLI (#2003) 2026-10-30 15:54:35 +08:00
ziven 9915a8e89b build(release): automate CLI releases with Changesets (#2001) 2026-10-30 14:04:39 +08:00
Libin YANG 0bbfe56b67 chore(deps): upgrade project dependencies (#1996)
Bump compatible releases, including wrangler 4.151.2, CodeMirror view 6.43.15, and typescript-eslint 8.72.0. Retarget the CodeMirror view patch and raise undici to 8.12.3 now that the HTTP/2 content-encoding regression is fixed.
2026-10-21 22:37:41 +08:00
Michael YangandClaude Opus 5.5 67bba7d68b fix(mermaid): share pending render for concurrent re-renders (#1997)
A preview re-render while a diagram is still rendering (e.g. when MathJax
fires md:mathjax-ready) started a second mermaid.render with the same
element id. The two runs measured each other's temporary elements and the
cached SVG lost its viewBox, class and max-width, so the diagram rendered
blank. Share the in-flight render per cache key instead.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21 22:35:45 +08:00
Libin YANG f8d9126823 chore(deps): upgrade project dependencies (#1995)
Bump compatible releases, including pnpm 12.14.0 and wrangler 4.151.1, and retarget the Mermaid flowchart label patch to 12.2.0.
2026-10-17 10:12:56 +08:00
Libin YANG 1bdad48d20 fix(mermaid): stop flowchart labels from clipping (#1991)
Raise flowchart wrappingWidth to 300 so a typical bilingual line fits, and patch Mermaid so wider html labels wrap on fractional device pixel ratios instead of being clipped.

Closes #1989
2026-10-12 11:27:37 +08:00
Libin YANG d9132ab5a1 chore(deps): upgrade project dependencies (#1985) 2026-10-09 09:50:23 +08:00
Libin YANG 9bae922611 chore(deps): bump dependencies to latest compatible versions (#1978)
Upgrade pnpm to 12.6.0 and refresh direct packages, including VueUse 15,
Mermaid 12, and juice 12.2.0. Keep Prettier 2.8.8, TypeScript 6.0.3, and
the wrangler 4.134.0 preview-deploy pin.
2026-09-29 17:37:06 +08:00
Libin YANG 2cd2b354e6 chore(deps): bump pnpm, wrangler, CodeMirror, and related packages (#1972) 2026-09-22 19:54:26 +08:00
Libin YANG cbcd3756e5 chore(deps): bump wrangler, vue, AWS SDK, and related packages (#1966)
Bump catalog wrangler and workers-types, plus web/vue toolchain
patch/minor updates. Intentionally leave prettier 2.8.8, typescript 6,
mermaid 11, vueuse 14, and pnpm 11 unchanged.
2026-09-18 11:42:30 +08:00
Libin YANG 8770fde1d2 chore(deps): bump wrangler, CodeMirror, vsce, and related packages (#1964) 2026-09-16 19:27:09 +08:00
Libin YANG a988db7bd2 chore(deps): bump pnpm, wrangler, lucide, and related packages (#1961)
Leave prettier, TypeScript, and mermaid on pinned majors.
2026-09-14 20:11:40 +08:00
Libin YANG 75f09a0b44 perf(emoji): speed up search, panel, upload, and renderer scans (#1952)
Add pinyin/alias search, window the emoji grid, parallelize uploads, and bound emoji start() scans so long documents skip URL/time colons.
2026-09-10 11:05:58 +08:00
Libin YANG e14b55645c chore(deps): bump wrangler, vitest, isomorphic-dompurify, and related packages (#1951) 2026-09-10 10:22:35 +08:00
RandLibin YANG 9ec3f68e6d feat(emoji): add cloud sticker packs and an <Emoji> inline component (#1949)
Co-authored-by: Libin YANG <contact@yanglibin.info>
2026-09-10 10:05:36 +08:00
Libin YANG 62cd665b16 chore(deps): bump pnpm, CodeMirror, AWS SDK, and related packages (#1943)
Refresh catalog, security overrides, and CI pnpm pins. Rebase the @codemirror/view patch onto 6.43.10.
2026-09-01 11:42:55 +08:00
Libin YANG 6e7632d380 perf(core): bound extension start() scans and memoize render output (#1942)
marked calls every registered extension's `start()` at each block boundary
and passes the whole remaining source, so a `/^.../m` scan per extension
turned long articles into quadratic work. Restrict block-level scans to the
current paragraph and replace the regexes with non-allocating indexOf-based
helpers in a shared `utils/scan` module.

Also memoize code highlighting and formula typesetting, which the preview
otherwise redoes for every untouched block on each keystroke batch. Pending
KaTeX placeholders stay uncached so they still resolve once MathJax loads.

Parse time for a 186k-character article drops from 928ms to 584ms, and the
gain grows with document size (1.34x at 6k chars, 1.68x at 93k). Rendered
HTML is byte-identical to the previous implementation across the bundled
example documents.
2026-08-30 20:01:06 +08:00
Libin YANG 7622b816db chore(deps): bump wrangler, zod, and related packages (#1941)
Refresh catalog entries (@cloudflare/workers-types, wrangler, zod), the
tinyexec override, and direct deps across web, vscode, and md-cli, then
refresh transitive deps via `pnpm update -r` and `pnpm dedupe`.

Keep typescript at ~6.0.3 because @typescript-eslint 8.68.0 declares a
`typescript >=4.8.4 <6.1.0` peer range, so TS 7 would break lint.

Also drop the stale front-matter patch entry from AGENTS.md; that patch
was removed when front-matter was replaced.
2026-08-29 15:42:26 +08:00
Libin YANG 9227e937cf feat(theme): make link color and blockquote background configurable (#1939)
The same link colour (#576b95) was copy-pasted into all three built-in themes, and the blockquote background was only reachable through a shell-injected token, so both had to be overridden with custom CSS.

Link colour becomes an always-emitted --md-link-color, defaulting to the blue every theme already used. The theme-colour preset is stored as a literal var(--md-primary-color) so links keep tracking the primary colour rather than freezing its value at pick time.

Blockquote background cannot use the same shape: only the default theme has a background, while grace and simple are deliberately background-free. Declaring the variable unconditionally would give them a grey box they never had, so it is only declared when the user picks a non-default value and each theme keeps its own value as the var() fallback.

That relies on processCSS resolving a var() whose fallback is another var(), and on it leaving the unresolvable shell token intact. Both behaviours are now covered by tests, along with nested color-mix resolution.
2026-08-29 08:51:42 +08:00
Libin YANG 5adb849ac7 feat(theme): make line height and block spacing configurable (#1938)
Line height sat hard-coded as 1.75 in base.css and every vertical block margin was a literal in the theme CSS, so tightening or loosening an article meant hand-writing custom CSS across a dozen selectors.

Line height becomes --md-line-height. Block spacing becomes --md-block-spacing, a unitless multiplier applied to the margins each theme already defines rather than one flat value: a single length would collapse the theme's rhythm, where an h2 deliberately sits further from the text than a paragraph. Themes keep their proportions while the whole scale moves together.

The calc() indirection is safe for the WeChat paste because processCSS already flattens var() and calc() before juice inlines the styles; its multiplication branch handles a length times a unitless operand. cssVariables.test.ts pins that behaviour, which had no coverage before.

Both fields are optional end to end, so settings persisted before this change keep rendering identically and existing generateCSSVariables callers (VSCode preview, theme export) needed no signature change.
2026-08-29 08:43:55 +08:00
Libin YANG 83bf5583f5 feat(core): support GitHub-style emoji shortcodes (#1937)
Adds an inline extension turning 🚀 into an emoji character, so documents written on GitHub, Obsidian or Typora keep rendering the same glyphs instead of leaking raw shortcodes into the article.

The shortcode table is bundled in-repo rather than pulled from a dependency. The established emoji packages either carry several transitive dependencies or have negligible download counts, neither of which suits a widely used editor. The table is curated (515 entries) instead of the full ~1900-entry Unicode set, which would otherwise land in the deferred renderer chunk for a feature most articles use a handful of times.

Only names present in the table are consumed, so incidental colon pairs like 'ratio 3:4:5' and unknown names stay literal rather than disappearing. Emoji are emitted as bare characters with no wrapper element, leaving nothing for WeChat's sanitizer to strip and no theme CSS to keep in sync.
2026-08-29 08:27:51 +08:00
Libin YANG 91256df56a feat(core): add superscript syntax and theme strikethrough (#1936)
Superscript had no syntax at all, so ^2^ leaked through as literal text. Adds a markup_superscript inline extension rendering semantic <sup>, which degrades correctly even where the theme CSS is missing.

Unlike the sibling markup delimiters, superscript is meant to sit directly after a word char (x^2^), so it opts out of the shared word-boundary filtering and instead requires whitespace-free content. That keeps prose like 'a ^ b' and dangling carets like '2^10' literal. Ruby's [text]^(annotation) form is unaffected: its tokenizer is registered later and therefore runs first.

Subscript is deliberately left out because it would need the same single ~ delimiter already taken by the wavy-line extension.

Also gives <del> a theme class so strikethrough colour is themeable instead of relying on the browser default.
2026-08-29 08:14:00 +08:00
Libin YANG 1c2c2f4139 chore(deps): bump pnpm, wrangler, vue, and related packages (#1934)
Keep Prettier at 2.8.8 and TypeScript at 6.0.3 because vue-tsc still requires the TS 6 compiler API.
2026-08-28 10:19:17 +08:00
Libin YANG 48c6964bc6 chore(deps): bump js-yaml, AWS SDK, and related packages (#1933)
Upgrade catalog workers-types, marked, and isomorphic-dompurify. Treat empty YAML front matter as an empty mapping for js-yaml 5. Keep prettier 2.8.8 and typescript ~6.0.3.
2026-08-25 20:00:43 +08:00
Libin YANG 1a8dc8c073 refactor: replace yup and front-matter, upgrade MCP to 2.x (#1927) 2026-08-23 11:08:23 +08:00
Libin YANG 03b4b78f0a perf: defer core renderer load and cap cloud sync payloads (#1924)
Lazy-load @md/core on the web app to shrink the initial bundle. Reject oversized sync pushes with plan quotas, client-side batches, and D1-safe row limits.
2026-08-21 16:48:50 +08:00
Libin YANG 00cf64fcf1 chore(deps): bump workers-types, vite, mermaid, and related packages (#1922)
Bump catalog workers-types, uuid, and vitest; web AWS SDK, lucide,
Cloudflare vite-plugin, and vite; core mermaid and infographic.
Kept prettier 2.8.8, typescript ~6.0.3, and @types/vscode.
2026-08-20 20:30:01 +08:00
YangFong d7e8b9ca80 refactor: remove deprecated baseUrl from tsconfigs (#1921)
baseUrl is deprecated in TypeScript 6.0 and scheduled for removal in 7.0. Since TS 4.1, path aliases resolve relative to the tsconfig directory, so the option is redundant and can be dropped without changing resolution behavior.
2026-08-20 20:03:40 +08:00
Libin YANG 435c7d132b chore(deps): bump CodeMirror, vue-tsc, and workers-types (#1915) 2026-08-16 21:17:57 +08:00
Libin YANG 761b4f4b42 chore(deps): bump wrangler, vscode types, and related packages (#1910)
Align @types/vscode and engines.vscode at 1.125.0 so vsce packaging
stays valid. Bump wrangler to ^4.122.0 so @cloudflare/vite-plugin
1.52.0 can land after the npmmirror lag that blocked 1.51.2.
2026-08-13 19:55:54 +08:00
Libin YANG 4a1eb2025c fix(core): add boundary rules to markup extension delimiters (#1904)
* fix(core): add boundary rules to markup extension delimiters

Intraword text like `C++是最好的语言,C++是最好的语言` had its two `++`
pairs matched as underline delimiters. Require the opening delimiter to
not directly follow an ASCII letter/digit (checked across inline token
boundaries), and disallow whitespace right inside the delimiters, so
`x==1==y`, `v1~2~3` and `++ text ++` stay literal as well. CJK intraword
usage such as `把++重点++标出` keeps rendering.


* fix(core): drop regex lookbehind from markup boundary rules

Regex lookbehind throws a SyntaxError at parse time in JS engines
without support (older WebViews), which would crash the whole renderer
on load. Enforce the same boundaries without it: scan delimiter runs in
`start` and check the preceding char manually, and require the content''s
final char via an explicit non-whitespace character class.
2026-08-10 15:02:35 +08:00
Libin YANG 4aaa1ee278 perf(web): editor rendering & storage performance, fix history preview overflow (#1898)
- Group posts by parent id once instead of re-filtering per tree node
- Collect headings during render instead of parsing the output HTML
- Debounce reactive persistence behind an in-memory overlay so sync
  reads stay current; snapshot pending writes to localStorage on
  pagehide and restore them on next launch so no state is lost
- Skip off-screen rendering via content-visibility for the post tree,
  search results, and diff lines
- Preload the post-slider chunk when idle; pre-bundle diff-match-patch
  so the dev server stops force-reloading on first interaction
2026-08-07 17:15:48 +08:00
Libin YANGandCursor 6ca214b7c3 fix(web): editor search & persistence fixes, keyboard a11y, cleanups (#1896)
* fix(web): fix post search misses and history restore timestamp

- extract search logic to lib/search-posts with a 250ms debounce; count matches via String.match (avoids stale-lastIndex misses of a reused global RegExp across posts) in a single scan for results and totals together
- render search results and history version entries as real buttons; make the history list width responsive on narrow screens
- bump post.updateDatetime on history restore so restored content is picked up by update-time sorting and cloud sync

Co-authored-by: Cursor <cursoragent@cursor.com>

* perf(web): replace deep post watches with signature watchers

- watch per-post signatures (id/title/content length/updateDatetime ms/parent/history length/collapsed) instead of deep-traversing every post on each editor commit; the old deep watch compared identical object identities and never persisted edits
- collect dirty post ids in a set and flush once per debounce window, so rapid edits across different posts are all saved (shared single-argument debounce used to drop earlier posts)
- inject heading anchor ids during render instead of assigning output twice, avoiding a second preview DOM rebuild

Co-authored-by: Cursor <cursoragent@cursor.com>

* refactor: dedupe escapeHtml/delay helpers and remove dead code

- share one escapeHtml in apps/api share pages and reuse @md/core's in the formula dialog
- centralize the delay() helper used by preview boot, PNG export and the editor header
- drop unused createTable/checkImage utilities and a stale debug comment

Co-authored-by: Cursor <cursoragent@cursor.com>

* feat(web): improve keyboard accessibility across editor UI

- make drag-drop upload areas, syntax help cards, JSON preview expanders and the footer line/col indicator keyboard-operable (real buttons or role/tabindex + Enter/Space)
- reveal hover-only controls (post item menu, table cell delete buttons) on keyboard focus via focus-visible
- add missing aria-labels to icon-only buttons, role=tablist to the CSS editor tabs, role=checkbox to multi-select, and move the collapse toggle out of the post row button to avoid nested interactives

Co-authored-by: Cursor <cursoragent@cursor.com>

* test(core): add render tests for footnote, toc, ruby, markup, slider and alert extensions

Co-authored-by: Cursor <cursoragent@cursor.com>

* ci: unify web type-check with build and include @md/shared in tests

- run the package's own vue-tsc --build --force for type-check:web so CI catches the same errors as pnpm web build
- add @md/shared tests to the root test script

Co-authored-by: Cursor <cursoragent@cursor.com>

* fix(ci): commit generated auto-import/components dts for type-check job

vue-tsc --build --force builds the referenced tsconfig.app.json, which includes auto-imports.d.ts and components.d.ts. Both were gitignored, so the CI type-check job (no prior vite build to regenerate them) failed with TS2304 for every auto-imported global (ref, useDark, useToggle, ...).

The previous vue-tsc --noEmit ran on the solution-style root tsconfig (files: [] + references) and checked zero files, which is why CI was green while real errors slipped through.

Co-authored-by: Cursor <cursoragent@cursor.com>

* fix(web): guard zero-width search matches and clean up a11y semantics

- ignore zero-width regex matches when counting, highlighting and snippeting so empty-matching patterns (a*, ^, \b) neither match every post nor inflate counts to O(content length); replace skips zero-width positions and inserts the replacement literally
- give the multi-select checkbox an accessible name (new common.selectPost message)
- move the CSS tab more-actions button out of the role=tab element so each tab is a single focus stop

Co-authored-by: Cursor <cursoragent@cursor.com>

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-07 14:25:03 +08:00
Libin YANG 64573a9a31 feat(web): add visual table editor dialog (#1895)
- create and edit GFM tables in a dialog with row/column steppers,
  per-column alignment cycling, and cell keyboard navigation
- open in edit mode from the editor context menu (position-aware via
  posAtCoords), the insert dropdown, slash command, and command palette
- click a table in the preview to edit it, mapped positionally through
  a marked-parity scanner (fence/blockquote/indentation aware)
- preserve original indentation on update, re-locate tables safely when
  the document changed while the dialog is open, and swallow surplus
  blank lines on delete
- guard ResizablePanel.resize() calls against reka-ui mount races
2026-08-07 10:24:58 +08:00
Libin YANG 0e5ac74a38 build(deps): bump dependencies to latest compatible versions (#1893)
- catalog: @codemirror/view 6.43.8, workers-types 5.20260804.1,
  marked 18.0.9, tsx 4.23.7, wrangler 4.119.0
- shared: @codemirror/lang-html 6.4.12, lang-markdown 6.5.2
- core: mermaid 11.16.1
- web: vue 3.5.41, juice 12.1.2, aws-sdk s3 3.1103.0,
  @cloudflare/vite-plugin 1.51.0, unplugin-auto-import 21.1.0
- api: hono 4.13.0
- migrate pnpm patches for @codemirror/view and juice to the new
  versions (MeasureRequest export, macOS Alt+Shift, parseCSS guard)

Skipped on purpose: prettier 3.x (pinned to 2.8.8), typescript 7.x
(major), @types/vscode (kept aligned with engines.vscode 1.120).
2026-08-06 08:17:27 +08:00
Libin YANG adf6c62aa7 perf(web): cut initial JS bundle by ~620 kB (#1886)
- Scope the manualChunks highlight.js rule to the package root so
  @antv/infographic's select-highlight.js no longer drags roughjs,
  measury fonts, culori and tinycolor2 onto the critical path
  (highlight chunk: 281 kB -> 57 kB min)
- Only pin core @lezer packages (common/lr/highlight/markdown/html)
  in the codemirror chunk; language grammars follow the lazy
  LanguageDescription.load() chunks again (1,019 kB -> 624 kB min)
- Drop css/javascript language setups from the shared editor barrel;
  lazy consumers import them via '@md/shared/editor/css' and
  '@md/shared/editor/javascript' instead
- Replace jszip with fflate (already bundled via @md/core) for the
  CSS-theme and posts ZIP exports; remove the jszip dependency
- Fix Vite native-config-loader warnings: replace __dirname with
  fileURLToPath(import.meta.url) and add the .ts extension to the
  local plugin import
2026-08-02 08:15:19 +08:00
Libin YANG 7e6511f547 fix(web): parse text/plain JSON responses in mp image upload (#1878)
WeChat's media/uploadimg endpoint returns a JSON body with a text/plain
Content-Type. The fetch wrapper that replaced axios only parsed
application/json responses, so the body stayed a string, res.url was
undefined, and the client reported "no URL returned" even though the
image had been uploaded successfully.

Restore axios-like lenient JSON parsing for non-JSON content types and
surface the WeChat errcode/errmsg detail in mp token/upload errors.

#1877
2026-07-30 09:58:44 +08:00
Libin YANG af2eeaa26d build(deps): bump dependencies to latest compatible versions (#1875) 2026-07-29 20:58:58 +08:00
Libin YANG 74b2723d38 build(deps): bump dependencies to latest compatible versions (#1871) 2026-07-29 20:13:51 +08:00
Libin YANG 4d2b6a939d fix: use uuidv4 helper instead of crypto.randomUUID (#1836)
Avoid crashes when served over plain HTTP (e.g. Docker on a LAN IP),
where crypto.randomUUID is unavailable outside secure contexts.
2026-07-16 10:48:19 +08:00
Libin YANG 54562cf4d7 build(deps): bump pinia to 4.0.2 and refresh workspace deps (#1832)
Drop the pinia exports types patch after verifying vue-tsc works without it, and bump wrangler, Cloudflare Vite plugin, AWS SDK, and CodeMirror markdown.
2026-07-16 08:07:21 +08:00
Libin YANG e49ee92c05 chore: tighten secret examples and CI caching (#1830)
Remove the ineffective secret_scanning ignore, replace scanner-triggering
placeholder credentials, drop dead scripts/exports, and enable pnpm
cache with frozen lockfile in CI.
2026-07-15 14:53:34 +08:00
Libin YANG d43f51da68 feat(marketplace): add community theme marketplace and in-app notifications (#1808)
Ship theme publish/review/install with sample markdown preview, admin moderation,
and system notifications (footer bell) for pending/approve/reject without email.
2026-07-13 21:21:55 +08:00
Libin YANG 87f2abfea5 feat(web): localize custom CSS default template and tips UI (#1799)
Move usage guidance into an i18n tips dialog, provide locale-specific skeleton templates, and keep the CSS editor font stable across language switches.
2026-07-12 10:46:37 +08:00
YangFong d2c2432f3d feat(core): set katex svg color via inline style (#1792)
Stop baking #333 into formulas and remap only dark grayscale diagram
ink so Mermaid chromatic borders stay intact while text follows WeChat
reader color.

Close #1788
2026-07-11 14:28:35 +08:00
Libin YANG 58f09a8897 build: centralize shared deps with pnpm catalog and dedupe (#1791)
Move cross-package toolchain versions into a workspace catalog, declare
CodeMirror where it is imported, unify typescript-eslint via overrides,
and run pnpm dedupe to shrink the lockfile.
2026-07-11 13:38:58 +08:00
Libin YANG c254c00c2a build: bump workspace dependencies to latest patch releases (#1790)
Upgrade hono, AWS SDK, Cloudflare workers-types, eslint, and
@codemirror/lang-yaml; refresh the lockfile. Keep prettier 2.8.8
and TypeScript 6 pinned.
2026-07-11 11:24:03 +08:00
Libin YANG 22ca9fea7f chore: unify code comments to English (#1789)
Translate valuable Chinese comments and remove noise that only restates the next line. Document the English-comment convention in AGENTS.md and CONTRIBUTING.md. Leave i18n and user-facing strings unchanged.
2026-07-11 11:01:28 +08:00
Libin YANG b2294fdafe perf(web): reduce bundle size with lazy loads and leaner deps (#1787)
Drop uuid/es-toolkit/spark-md5/axios/language-data from the hot path,
lazy-load html-to-image/crypto-js/image compression, shrink highlight.js
and CodeMirror fence languages, and replace axios with a fetch wrapper.
2026-07-11 10:21:03 +08:00
Libin YANG 800e109b32 perf(web): skip unchanged renders and split oversized editor UI (#1786)
Add debounce+max-wait preview scheduling and fingerprint skip in renderStore.
Extract scroll-sync/post-tree helpers with tests; cover API origin/sanitize.
Extend type-check to vscode/mcp; split Footer and CustomComponent form panels.
2026-07-11 09:37:29 +08:00