feat: Add CSS chunking support and unify CSS file format#190
Open
kinboyw wants to merge 4 commits intoalangrainger:mainfrom
Open
feat: Add CSS chunking support and unify CSS file format#190kinboyw wants to merge 4 commits intoalangrainger:mainfrom
kinboyw wants to merge 4 commits intoalangrainger:mainfrom
Conversation
- Fix TypeScript error: add null check for previewMode.state - Add detectMediaTypeFromSignature() method to detect image/video types from magic bytes - Improve blob URL handling: detect media type before skipping - Add Content-Type header detection for file types - Improve file type validation: use detected type when URL extension is invalid - Skip blob URLs only if they don't contain recognizable media files This fixes the 415 Unsupported Media Type error when uploading notes with code styler plugin enabled, which generates blob URLs for codeblock icons. Fixes issues with: - Code Styler plugin blob URLs causing 415 errors - Invalid file type detection from blob URLs - Missing file type detection for media files
This commit implements CSS file chunking for large files and unifies the CSS data structure to use an array format for both single files and multiple chunks. Key changes: - Add splitCssIntoChunks() method to split large CSS files (>500KB) at rule boundaries to avoid breaking CSS syntax - Unify CSS data structure: use array format for both single files and multiple chunks in CheckFilesResult and NoteTemplate - Fix CSS byte length calculation using TextEncoder for accurate UTF-8 encoding (fixes ERR_CONTENT_LENGTH_MISMATCH) - Fix empty array check in processCss() to properly handle empty cssResult arrays - Add backward compatibility: auto-convert old CSS format to new array format - Generate unique hash for each chunk (includes chunk index) to ensure different filenames on server Benefits: - Large CSS files are automatically split into smaller chunks, improving page load performance - Unified array format simplifies server-side processing - Each chunk has unique hash for proper server-side validation - Backward compatible with existing shared notes Files changed: - src/api.ts: Update CheckFilesResult interface to use array format - src/NoteTemplate.ts: Update css field to use array format - src/note.ts: Add chunking logic and update CSS processing
…and blob URL detection
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR implements CSS file chunking for large files and unifies the CSS data structure to use an array format for both single files and multiple chunks.
Changes
splitCssIntoChunks()method to split large CSS files at rule boundaries (>500KB threshold)Array<{ url: string, hash: string }>for both single files and multiple chunksTextEncoderfor accurate UTF-8 encoding (fixesERR_CONTENT_LENGTH_MISMATCH)processCss()to properly handle emptycssResultarraysFiles modified:
src/api.ts: UpdateCheckFilesResultinterface to use array formatsrc/NoteTemplate.ts: Updatecssfield to use array formatsrc/note.ts: Add chunking logic and update CSS processingBenefits
Testing
Related Issues
Fixes issues with:
ERR_CONTENT_LENGTH_MISMATCHfor large CSS filesTechnical Details
CSS Chunking Algorithm
}) to avoid breaking CSS syntaxTextEncoderfor accurate byte size calculationsha1(chunkIndex-chunkContentHash-totalChunks)