Skip to content

feat(editor): add lowlight code blocks - #3199

Merged
AlexAndBear merged 11 commits into
mainfrom
feat/editor-codeblock-syntax-highlighting
Aug 24, 2026
Merged

feat(editor): add lowlight code blocks#3199
AlexAndBear merged 11 commits into
mainfrom
feat/editor-codeblock-syntax-highlighting

Conversation

@AlexAndBear

@AlexAndBear AlexAndBear commented Aug 21, 2026

Copy link
Copy Markdown
Member

Description

image

This PR adds syntax-highlighted code blocks to the Tiptap editor using @tiptap/extension-code-block-lowlight and a dedicated code block node view with language selection.

It also switches Highlight.js themes based on the active app theme (isDark):

  • light mode: atom-one-light
  • dark mode: atom-one-dark

Related Issue

  • Fixes N/A

How Has This Been Tested?

  • test environment: local development environment
  • test case 1: ./node_modules/.bin/vue-tsc --declaration --noEmit --project packages/web-pkg/tsconfig.build.json
  • test case 2: verified code block language selector rendering and position in the editor node view
  • test case 3: verified theme stylesheet switches between atom-one-light and atom-one-dark when theme changes

Types of changes

  • Bugfix
  • Enhancement (a change that doesn't break existing code or deployments)
  • Breaking change (a modification that affects current functionality)
  • Technical debt (addressing code that needs refactoring or improvements)
  • Tests (adding or improving tests)
  • Documentation (updates or additions to documentation)
  • Maintenance (like dependency updates or tooling adjustments)

@AlexAndBear
AlexAndBear force-pushed the feat/editor-codeblock-syntax-highlighting branch from d9d0c36 to 79db1de Compare August 21, 2026 23:50
@AlexAndBear AlexAndBear changed the title feat(editor): add lowlight code blocks with atom one theme switching feat(editor): add lowlight code blocks Aug 21, 2026
@AlexAndBear

Copy link
Copy Markdown
Member Author

Build Size Comparison

I compared the build sizes between main and this PR branch to assess the impact of adding lowlight for syntax highlighting.

Editor Chunk Size

main branch:

  • dist/js/chunks/editor-*.mjs: 783.32 kB (gzip: 240.58 kB)

This PR (with lowlight):

  • dist/js/chunks/editor-*.mjs: 962.76 kB (gzip: 297.01 kB)

Impact

  • Uncompressed: +179.44 kB (+22.9%)
  • Gzipped: +56.43 kB (+23.4%)

The lowlight package (including the highlight.js themes) adds approximately 56 kB (gzipped) to the editor bundle. This is a noticeable but reasonable increase for syntax highlighting functionality.

@JammingBen

Copy link
Copy Markdown
Member

I think it's fine for the scope of this PR, but we're already getting a warning about the biggest chunk, and now it's even more big. So we should make the editor components async and/or put them into dedicated chunks (kinda already a to-do in #3033).

@JammingBen JammingBen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few findings from my side:

  • Inline blocks via single backticks like this lost their styling.
  • The select is editable in read-only mode.
  • The select overflows the code block initially, which looks a bit off. Maybe reduce its size? Or more general: do we really need this? 馃檲 I feel like this feature gets mostly used by technical users that now how to work with code blocks.
Image

Comment thread packages/web-pkg/src/editor/components/CodeBlockComponent.vue Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good that you moved it 馃憤

@AlexAndBear

AlexAndBear commented Aug 24, 2026

Copy link
Copy Markdown
Member Author

A few findings from my side:

  • Inline blocks via single backticks like this lost their styling.
  • The select is editable in read-only mode.
  • The select overflows the code block initially, which looks a bit off. Maybe reduce its size? Or more general: do we really need this? 馃檲 I feel like this feature gets mostly used by technical users that now how to work with code blocks.
Image

Hmm I would keep the select, as it also indicates which languages are supported for code hilighting 馃

@github-project-automation github-project-automation Bot moved this to Qualification in OpenCloud Team Board Aug 24, 2026
@AlexAndBear AlexAndBear moved this from Qualification to In Progress in OpenCloud Team Board Aug 24, 2026
@AlexAndBear
AlexAndBear merged commit 908d7bc into main Aug 24, 2026
31 checks passed
@AlexAndBear
AlexAndBear deleted the feat/editor-codeblock-syntax-highlighting branch August 24, 2026 08:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants