style: Apply Prettier formatting
Applied consistent code formatting across the project using Prettier, addressing minor style inconsistencies introduced in recent changes.
This commit is contained in:
11
GEMINI.md
11
GEMINI.md
@@ -73,3 +73,14 @@ The rich text editor component, previously based on Tiptap (`shad-editor`), has
|
|||||||
- **Wrapper Component Update:** The existing editor wrapper (`src/lib/elements/element_tiptap_editor.svelte`) was renamed to `src/lib/elements/element_codemirror_wrapper.svelte` and refactored to utilize the new CodeMirror component. Tiptap-specific logic and props were removed.
|
- **Wrapper Component Update:** The existing editor wrapper (`src/lib/elements/element_tiptap_editor.svelte`) was renamed to `src/lib/elements/element_codemirror_wrapper.svelte` and refactored to utilize the new CodeMirror component. Tiptap-specific logic and props were removed.
|
||||||
- **Component Usage Updates:** All Svelte components that previously imported and used the Tiptap wrapper were updated to import `element_codemirror_wrapper.svelte`. Unsupported props such as `default_minimal`, `show_button_kv`, `bind:new_html`, and `bind:changed` were removed from their usage.
|
- **Component Usage Updates:** All Svelte components that previously imported and used the Tiptap wrapper were updated to import `element_codemirror_wrapper.svelte`. Unsupported props such as `default_minimal`, `show_button_kv`, `bind:new_html`, and `bind:changed` were removed from their usage.
|
||||||
- **Dependency Cleanup:** `npm install` was run to remove unneeded packages, and `npm run format` was executed to ensure consistent code style.
|
- **Dependency Cleanup:** `npm install` was run to remove unneeded packages, and `npm run format` was executed to ensure consistent code style.
|
||||||
|
|
||||||
|
### CodeMirror Bug Fixes (2025-11-18)
|
||||||
|
|
||||||
|
Following the initial migration to CodeMirror, several issues were identified and resolved:
|
||||||
|
|
||||||
|
- **Initialization Errors:** An "Unrecognized extension value" error was fixed by refactoring `codemirror_modules.ts` to explicitly import individual CodeMirror extensions instead of relying on the `basicSetup` bundle. This ensures proper singleton usage and prevents module duplication.
|
||||||
|
- **Text Wrapping:** The `EditorView.lineWrapping` extension was added to `element_codemirror_editor.svelte` and `e_app_codemirror_v5.svelte` to enable text wrapping.
|
||||||
|
- **Content Saving:** Content binding issues were resolved in various IDAA components by correctly binding the `html_text` prop of the CodeMirror wrapper to the corresponding state variables.
|
||||||
|
- **Save Button Enablement:** The logic for enabling the "Save" button was fixed in `ae_idaa_comp__post_obj_id_edit.svelte` to correctly detect changes in the CodeMirror editor.
|
||||||
|
- **Editor Buttons:** A `TypeError` in the editor's formatting buttons was fixed by using `EditorSelection.range()` to correctly create selection ranges.
|
||||||
|
- **Component Renaming:** The `Tiptap_editor` component alias was renamed to `CodeMirror_wrapper` across the project for clarity, and the wrapper file was renamed to `element_codemirror_editor_wrapper.svelte`.
|
||||||
|
|||||||
6
TODO.md
6
TODO.md
@@ -49,7 +49,7 @@ This is a list of tasks to be completed before the next event/show/conference.
|
|||||||
|
|
||||||
### 2. Component Standardization
|
### 2. Component Standardization
|
||||||
|
|
||||||
- [ ] **CodeMirror Migration:** Plan and execute the replacement of the `shad-editor` and potentially other text editors (like Tiptap) with `CodeMirror` to standardize rich text editing.
|
- [x] **CodeMirror Migration:** Replaced all instances of the old Tiptap editor with a new CodeMirror wrapper. This includes fixing initialization errors, enabling text wrapping, and ensuring content is correctly saved.
|
||||||
- [ ] **Component Review:** Audit third-party components to understand their conventions and isolate them from internal standards.
|
- [ ] **Component Review:** Audit third-party components to understand their conventions and isolate them from internal standards.
|
||||||
|
|
||||||
---
|
---
|
||||||
@@ -83,7 +83,7 @@ These functions are frequently used and critical to the application's data flow.
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
- [ ] Improve the `e_app_codemirror_v5.svelte` component and plan the migration from Tiptap to CodeMirror for rich text editing.
|
- [x] Improve the `e_app_codemirror_v5.svelte` component and plan the migration from Tiptap to CodeMirror for rich text editing. The migration is complete, and the component has been improved to handle individual extensions and fix various bugs.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -190,7 +190,7 @@ These functions are frequently used and critical to the application's data flow.
|
|||||||
|
|
||||||
- [ ] **UI/UX:**
|
- [ ] **UI/UX:**
|
||||||
- [ ] Improve the UI for creating and editing posts and comments.
|
- [ ] Improve the UI for creating and editing posts and comments.
|
||||||
- [ ] Add a rich text editor for a better writing experience.
|
- [x] Add a rich text editor for a better writing experience.
|
||||||
- [ ] **Features:**
|
- [ ] **Features:**
|
||||||
- [ ] Implement user-specific features, such as editing their own posts and comments.
|
- [ ] Implement user-specific features, such as editing their own posts and comments.
|
||||||
|
|
||||||
|
|||||||
@@ -63,7 +63,10 @@
|
|||||||
...cm_modules.completionKeymap,
|
...cm_modules.completionKeymap,
|
||||||
...cm_modules.lintKeymap
|
...cm_modules.lintKeymap
|
||||||
]),
|
]),
|
||||||
cm_modules.markdown({ base: cm_modules.markdownLanguage, codeLanguages: cm_modules.languages }),
|
cm_modules.markdown({
|
||||||
|
base: cm_modules.markdownLanguage,
|
||||||
|
codeLanguages: cm_modules.languages
|
||||||
|
}),
|
||||||
theme_mode == 'dark' ? cm_modules.oneDark : cm_modules.EditorView.baseTheme(),
|
theme_mode == 'dark' ? cm_modules.oneDark : cm_modules.EditorView.baseTheme(),
|
||||||
cm_modules.EditorView.contentAttributes.of({ spellcheck: 'true' }), // Enable spell check
|
cm_modules.EditorView.contentAttributes.of({ spellcheck: 'true' }), // Enable spell check
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,11 @@ async function createEditor() {
|
|||||||
|
|
||||||
// If an existing instance exists (HMR / remount), destroy it first
|
// If an existing instance exists (HMR / remount), destroy it first
|
||||||
if (editor_view && typeof editor_view.destroy === 'function') {
|
if (editor_view && typeof editor_view.destroy === 'function') {
|
||||||
try { editor_view.destroy(); } catch (e) { /* ignore */ }
|
try {
|
||||||
|
editor_view.destroy();
|
||||||
|
} catch (e) {
|
||||||
|
/* ignore */
|
||||||
|
}
|
||||||
editor_view = null;
|
editor_view = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,9 +52,11 @@ async function createEditor() {
|
|||||||
...cm.lintKeymap
|
...cm.lintKeymap
|
||||||
]),
|
]),
|
||||||
cm.markdown ? cm.markdown({ base: cm.markdownLanguage }) : null,
|
cm.markdown ? cm.markdown({ base: cm.markdownLanguage }) : null,
|
||||||
cm.EditorView && cm.EditorView.updateListener ? cm.EditorView.updateListener.of((update: any) => {
|
cm.EditorView && cm.EditorView.updateListener
|
||||||
|
? cm.EditorView.updateListener.of((update: any) => {
|
||||||
if (update.docChanged) content = update.state.doc.toString();
|
if (update.docChanged) content = update.state.doc.toString();
|
||||||
}) : null
|
})
|
||||||
|
: null
|
||||||
].filter(Boolean);
|
].filter(Boolean);
|
||||||
|
|
||||||
// Create editor
|
// Create editor
|
||||||
@@ -70,7 +76,11 @@ onMount(async () => {
|
|||||||
|
|
||||||
onDestroy(() => {
|
onDestroy(() => {
|
||||||
if (editor_view && typeof editor_view.destroy === 'function') {
|
if (editor_view && typeof editor_view.destroy === 'function') {
|
||||||
try { editor_view.destroy(); } catch (e) { /* ignore */ }
|
try {
|
||||||
|
editor_view.destroy();
|
||||||
|
} catch (e) {
|
||||||
|
/* ignore */
|
||||||
|
}
|
||||||
editor_view = null;
|
editor_view = null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -123,9 +133,19 @@ const insertList = () => {
|
|||||||
|
|
||||||
<div class="codemirror-wrapper border rounded">
|
<div class="codemirror-wrapper border rounded">
|
||||||
<div class="toolbar p-1 bg-gray-100 border-b">
|
<div class="toolbar p-1 bg-gray-100 border-b">
|
||||||
<button type="button" on:click={() => wrapSelection('**')} class="px-2 py-1 rounded hover:bg-gray-200"><b>B</b></button>
|
<button
|
||||||
<button type="button" on:click={() => wrapSelection('*')} class="px-2 py-1 rounded hover:bg-gray-200"><i>I</i></button>
|
type="button"
|
||||||
<button type="button" on:click={insertList} class="px-2 py-1 rounded hover:bg-gray-200">List</button>
|
on:click={() => wrapSelection('**')}
|
||||||
|
class="px-2 py-1 rounded hover:bg-gray-200"><b>B</b></button
|
||||||
|
>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
on:click={() => wrapSelection('*')}
|
||||||
|
class="px-2 py-1 rounded hover:bg-gray-200"><i>I</i></button
|
||||||
|
>
|
||||||
|
<button type="button" on:click={insertList} class="px-2 py-1 rounded hover:bg-gray-200"
|
||||||
|
>List</button
|
||||||
|
>
|
||||||
</div>
|
</div>
|
||||||
<div bind:this={editor_container} class="h-full min-h-[150px] overflow-auto"></div>
|
<div bind:this={editor_container} class="h-full min-h-[150px] overflow-auto"></div>
|
||||||
</div>
|
</div>
|
||||||
@@ -425,7 +425,8 @@
|
|||||||
bind:html_text={description_new_html}
|
bind:html_text={description_new_html}
|
||||||
classes="preset-tonal-surface hover:preset-filled-surface-100-900"
|
classes="preset-tonal-surface hover:preset-filled-surface-100-900"
|
||||||
placeholder="Your content description here..."
|
placeholder="Your content description here..."
|
||||||
/> </label>
|
/>
|
||||||
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- <label for="content_html">Content (HTML)
|
<!-- <label for="content_html">Content (HTML)
|
||||||
|
|||||||
Reference in New Issue
Block a user