mirror of
				https://github.com/zadam/trilium.git
				synced 2025-11-03 21:19:01 +01:00 
			
		
		
		
	fix(client/dialogs): include note not respecting size (closes #6947)
This commit is contained in:
		
							parent
							
								
									5f1f27a4f9
								
							
						
					
					
						commit
						2a5cb85199
					
				@ -8,7 +8,7 @@ import Button from "../react/Button";
 | 
				
			|||||||
import { Suggestion, triggerRecentNotes } from "../../services/note_autocomplete";
 | 
					import { Suggestion, triggerRecentNotes } from "../../services/note_autocomplete";
 | 
				
			||||||
import tree from "../../services/tree";
 | 
					import tree from "../../services/tree";
 | 
				
			||||||
import froca from "../../services/froca";
 | 
					import froca from "../../services/froca";
 | 
				
			||||||
import EditableTextTypeWidget from "../type_widgets/editable_text";
 | 
					import EditableTextTypeWidget, { type BoxSize } from "../type_widgets/editable_text";
 | 
				
			||||||
import { useTriliumEvent } from "../react/hooks";
 | 
					import { useTriliumEvent } from "../react/hooks";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export default function IncludeNoteDialog() {
 | 
					export default function IncludeNoteDialog() {
 | 
				
			||||||
@ -37,7 +37,7 @@ export default function IncludeNoteDialog() {
 | 
				
			|||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                setShown(false);
 | 
					                setShown(false);
 | 
				
			||||||
                includeNote(suggestion.notePath, textTypeWidget);
 | 
					                includeNote(suggestion.notePath, textTypeWidget, boxSize as BoxSize);
 | 
				
			||||||
            }}
 | 
					            }}
 | 
				
			||||||
            footer={<Button text={t("include_note.button_include")} keyboardShortcut="Enter" />}
 | 
					            footer={<Button text={t("include_note.button_include")} keyboardShortcut="Enter" />}
 | 
				
			||||||
            show={shown}
 | 
					            show={shown}
 | 
				
			||||||
@ -69,13 +69,12 @@ export default function IncludeNoteDialog() {
 | 
				
			|||||||
    )
 | 
					    )
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
async function includeNote(notePath: string, textTypeWidget: EditableTextTypeWidget) {
 | 
					async function includeNote(notePath: string, textTypeWidget: EditableTextTypeWidget, boxSize: BoxSize) {
 | 
				
			||||||
    const noteId = tree.getNoteIdFromUrl(notePath);
 | 
					    const noteId = tree.getNoteIdFromUrl(notePath);
 | 
				
			||||||
    if (!noteId) {
 | 
					    if (!noteId) {
 | 
				
			||||||
        return;
 | 
					        return;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    const note = await froca.getNote(noteId);
 | 
					    const note = await froca.getNote(noteId);
 | 
				
			||||||
    const boxSize = $("input[name='include-note-box-size']:checked").val() as string;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (["image", "canvas", "mermaid"].includes(note?.type ?? "")) {
 | 
					    if (["image", "canvas", "mermaid"].includes(note?.type ?? "")) {
 | 
				
			||||||
        // there's no benefit to use insert note functionlity for images,
 | 
					        // there's no benefit to use insert note functionlity for images,
 | 
				
			||||||
 | 
				
			|||||||
@ -14,6 +14,8 @@ import type FNote from "../../entities/fnote.js";
 | 
				
			|||||||
import { PopupEditor, ClassicEditor, EditorWatchdog, type CKTextEditor, type MentionFeed, type WatchdogConfig, EditorConfig } from "@triliumnext/ckeditor5";
 | 
					import { PopupEditor, ClassicEditor, EditorWatchdog, type CKTextEditor, type MentionFeed, type WatchdogConfig, EditorConfig } from "@triliumnext/ckeditor5";
 | 
				
			||||||
import { updateTemplateCache } from "./ckeditor/snippets.js";
 | 
					import { updateTemplateCache } from "./ckeditor/snippets.js";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export type BoxSize = "small" | "medium" | "full";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const TPL = /*html*/`
 | 
					const TPL = /*html*/`
 | 
				
			||||||
<div class="note-detail-editable-text note-detail-printable">
 | 
					<div class="note-detail-editable-text note-detail-printable">
 | 
				
			||||||
    <style>
 | 
					    <style>
 | 
				
			||||||
@ -434,7 +436,7 @@ export default class EditableTextTypeWidget extends AbstractTextTypeWidget {
 | 
				
			|||||||
        this.triggerCommand("showIncludeNoteDialog", { textTypeWidget: this });
 | 
					        this.triggerCommand("showIncludeNoteDialog", { textTypeWidget: this });
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    addIncludeNote(noteId: string, boxSize?: string) {
 | 
					    addIncludeNote(noteId: string, boxSize?: BoxSize) {
 | 
				
			||||||
        this.watchdog.editor?.model.change((writer) => {
 | 
					        this.watchdog.editor?.model.change((writer) => {
 | 
				
			||||||
            // Insert <includeNote>*</includeNote> at the current selection position
 | 
					            // Insert <includeNote>*</includeNote> at the current selection position
 | 
				
			||||||
            // in a way that will result in creating a valid model structure
 | 
					            // in a way that will result in creating a valid model structure
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user