Commit graph

49 commits

Author SHA1 Message Date
boojack
b6f42cbe6b
chore: upgrade frontend to React 19 (#5940) 2026-05-08 22:10:48 +08:00
Steven
664b8c5629 fix(ui): unify metadata component styles across MemoView and MemoEditor
Align header padding, text color, background tokens, and item row styles
across CodeBlock, AttachmentList, RelationList, and LocationDisplay so all
metadata panels follow the same visual pattern.
2026-02-26 23:18:11 +08:00
Johnny
98eaff1277 style: adjust spacing and background colors for improved UI consistency across components 2026-01-26 21:49:26 +08:00
Johnny
7154ce0228 feat: implement markdown components for enhanced rendering 2026-01-23 09:04:42 +08:00
Johnny
f87f728b0f
feat: react query migration (#5379) 2025-12-24 22:59:18 +08:00
Steven
f9dd7ad853 style: improve code block styling and formatting
- Adjust CodeBlock styling for better layout and spacing
- Reorganize copy button positioning with absolute positioning
- Simplify button styling and reduce icon sizes
- Wrap MermaidBlock in pre tag for consistent structure
- Format useDropdownMenuSubHoverDelay hook call for readability

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2025-12-22 21:27:50 +08:00
Steven
b1a52f20ed fix(web): add clipboard fallback for CodeBlock copy button in non-secure contexts
The CodeBlock component was refactored in v0.25.3 to use navigator.clipboard.writeText(),
which requires HTTPS or localhost. This caused the copy button to fail silently for users
accessing Memos over HTTP.

This fix adds a fallback to the copy-to-clipboard library (already used by all other
copy operations in the codebase) when the native clipboard API is unavailable or fails,
ensuring the copy button works reliably in all deployment scenarios.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-15 22:51:34 +08:00
Steven
4668c4714b refactor(web): improve MemoContent security and maintainability
Security improvements:
- Add rehype-sanitize for XSS protection in markdown content
- Remove DOMPurify and deprecated __html code block feature
- Extract sanitize schema to constants with comprehensive documentation

Maintainability improvements:
- Extract SANITIZE_SCHEMA to constants.ts for better organization
- Create utils.ts with shared code extraction utilities
- Refactor CodeBlock and MermaidBlock to use shared utilities
- Rename PreProps to CodeBlockProps for clarity
- Reduce code duplication across components

Dependency cleanup:
- Remove explicit katex dependency (now transitive via rehype-katex)
- Remove @matejmazur/react-katex (unused)
- Remove dompurify (replaced by rehype-sanitize)
- Update vite config to remove katex-vendor chunk

Changes: 7 files changed, 84 insertions(+), 100 deletions(-)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-02 22:45:22 +08:00
Steven
81da20c905 refactor: simplify theme/locale to user preferences and improve initialization
Remove theme and locale from instance settings to eliminate duplication and
simplify the codebase. These are user-specific preferences and should only
exist in user settings, not instance-wide settings.

Backend changes:
- Remove theme from InstanceGeneralSetting proto
- Remove locale from InstanceCustomProfile proto
- Update instance service converters to remove theme/locale handling
- Simplify RSS feed to use static locale

Frontend changes:
- Remove theme/locale from instanceStore state
- Create unified initialization flow with clear fallback priority:
  * Theme: user setting → localStorage → system preference
  * Locale: user setting → browser language
- Add applyUserPreferences() to centralize theme/locale application
- Simplify App.tsx by removing redundant state synchronization
- Update all components to use new helper functions:
  * getThemeWithFallback() for theme resolution
  * getLocaleWithFallback() for locale resolution
- Remove theme/locale selectors from instance profile dialog

Theme utilities refactor:
- Organize code into clear sections with JSDoc comments
- Extract localStorage operations into getStoredTheme/setStoredTheme helpers
- Split DOM manipulation into focused functions
- Improve type safety with Theme and ResolvedTheme types
- Reduce code duplication and improve maintainability

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-02 09:08:46 +08:00
Steven
05f7c9606b fix: add HTML sanitization and dynamic theme loading 2025-11-26 20:34:52 +08:00
Johnny
fb736c20d3
feat(web): add Mermaid diagram support in markdown (#5242)
Co-authored-by: Claude <noreply@anthropic.com>
2025-11-09 14:13:10 +08:00
Steven
d693142dd4 feat(web): enhance code blocks with copy button and fix link navigation
Add custom code block renderer with language display and copy functionality. Links now open in new windows, and clicking image links no longer triggers both link navigation and image preview.

- Add CodeBlock component with copy-to-clipboard button and language label
- Configure all markdown links to open in new windows with target="_blank"
- Fix image link behavior to prevent duplicate actions when clicked

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-28 22:06:07 +08:00
Claude
739fd2cde6 refactor: update markdown parser
- Removed the `nodes` field from the `Memo` interface in `memo_service.ts`.
- Updated the `createBaseMemo` function and the `Memo` message functions to reflect the removal of `nodes`.
- Cleaned up the serialization and deserialization logic accordingly.

chore: remove code-inspector-plugin from Vite configuration

- Deleted the `codeInspectorPlugin` from the Vite configuration in `vite.config.mts`.
- Simplified the plugins array to include only `react` and `tailwindcss`.
2025-10-26 11:28:40 +08:00
Steven
f44b0850f4 feat: enhance CodeBlock component with theme-aware syntax highlighting 2025-09-16 19:08:28 +08:00
Steven
383553d3c8 feat: add DOMPurify for sanitizing HTML content in CodeBlock component 2025-09-10 20:52:51 +08:00
Johnny
e93f3cbb8b refactor: unify theme and apperance 2025-08-17 11:27:59 +08:00
Steven
d7ced7b738 fix: code block style in dark mode 2025-07-18 19:25:29 +08:00
Maximilian Krauß
c4baba8527
fix(syntax-highlighting): adds missing CSS imports to CodeBlock.tsx (#4890) 2025-07-17 21:23:42 +08:00
Johnny
35928ce5ba chore: unify colors 2025-07-06 13:55:08 +08:00
Johnny
a3de61a141 chore: fix dark mode 2025-07-05 11:40:49 +08:00
Johnny
db4b1f5fde chore: tweak styles 2025-07-05 11:26:59 +08:00
Johnny
91be2f68d1
feat: variant colors (#4816) 2025-07-04 23:03:13 +08:00
Johnny
493832aeb4 refactor: unify components 2025-07-01 19:29:48 +08:00
Johnny
f5c64849d2 chore: upgrade tailwindcss to v4 2025-06-07 10:15:12 +08:00
Steven
72babbb393 fix: dark mode of highlight.js 2025-05-20 23:58:22 +08:00
Johnny
b770042a8a refactor: migrate eslint 2025-04-01 00:04:43 +08:00
Johnny
09c50a8419 fix: codeblock highlight 2025-03-30 23:49:51 +08:00
johnnyjoy
0b85cb567e chore(frontend): fix clsx 2025-02-01 22:04:29 +08:00
Steven
67c1a46346 chore: remove html renderer sanitizes 2024-11-05 22:44:37 +08:00
Steven
c4b52c68b5 fix: max height of memo content compact mode 2024-10-15 20:07:55 +08:00
ti777777
6f3d5762ca
fix: iframe rendering (#3916)
* fix iframe rendering

* fix eslint check
2024-09-12 08:54:33 +08:00
Michel Heusschen
2dbf92f7f1
perf: reduce bundle size by 21% with direct icon imports (#3844) 2024-08-28 22:55:28 +08:00
andrigamerita
d264f45979
fix: code blocks of unknown languages cause HTML injection (#3711)
* fix: code blocks of unknown languages cause HTML injection

A code block of unknown language (that is, a language not treated as special by Memos and not handled by highlight.js) should fall back on rendering its plaintext content. However, the content is never properly escaped before it is appended to the DOM, and thus any string that happens to contain HTML is unsafely rendered. This commit fixes the issue by ensuring that, when none of the previous cases handle the text, any HTML entities are escaped first.

* Update CodeBlock.tsx to conform to eslint
2024-07-19 08:32:58 +08:00
Steven
e8ed437ca3 fix: purify html before render 2024-06-04 23:10:54 +08:00
Steven
584c669068 chore: tweak max width 2024-05-09 22:10:27 +08:00
Steven
d8aeec993c chore: replace classnames with clsx 2024-04-28 00:58:40 +08:00
Dubzer
8ee56bd29f
feat: add code wrapping option on mobile devices (#3196)
* feat: add code wrapping option on mobile devices

* Minor changes

* oopsie
2024-04-10 22:03:47 +08:00
Steven
7d5f603482 chore: update compact view 2024-03-04 11:21:48 +08:00
Steven
4378816e44 chore: tweak i18n 2024-02-21 23:02:18 +08:00
Kristián
03d67d5a00
feat: add mermaid support in codeblock (#2971) 2024-02-19 15:10:58 +08:00
Steven
a76b86f18a chore: fix highlight code 2024-02-06 20:59:17 +08:00
Steven
c522e1450a chore: update codeblock style 2024-02-01 21:38:28 +08:00
Steven
8ce6a32aac feat: use gomark wasm in frontend 2024-01-31 22:25:24 +08:00
Steven
8c6292925e chore: update code block styles 2024-01-28 15:41:11 +08:00
Steven
932f636d84 chore: update codeblock renderer 2024-01-27 19:09:10 +08:00
Mark Zhao
bd1cf62761
feat: enable iframe rendering in markdown code block (#2799)
* enable iframe rendering in code block

* fix eslint issue
2024-01-20 11:36:45 +08:00
Steven
f563b58a85 chore: fix renderer props 2024-01-05 08:47:43 +08:00
Steven
96140f3875 chore: tweak dark mode styles 2024-01-03 23:12:50 +08:00
Steven
a3feeceace chore: remove component v1 suffix 2023-12-22 08:29:02 +08:00
Renamed from web/src/components/MemoContentV1/CodeBlock.tsx (Browse further)