Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,18 @@ export class NotebookComponent extends MessageListenersManager implements OnInit

definedNote.paragraphs[paragraphIndex].focus = true;
this.cdr.markForCheck();

// Focus the editor only for a clone/insert initiated by this client (not auto-append on run or remote inserts).
// Defer a tick so the new paragraph's editor child exists, since `focus = true` alone misses it.
if (this.messageService.localAddFocusPending) {
this.messageService.localAddFocusPending = false;
const addedId = data.paragraph.id;
setTimeout(() => {
const added = this.listOfNotebookParagraphComponent?.find(e => e.paragraph.id === addedId);
added?.focusEditor();
added?.notebookParagraphCodeEditorComponent?.setRestorePosition();
});
}
}

@MessageListener(OP.SAVE_NOTE_FORMS)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,19 +94,24 @@ export class NotebookParagraphCodeEditorComponent
this.position = e.position;
});
}),
editor.onDidChangeModelContent(() => {
editor.onDidChangeModelContent(e => {
this.ngZone.run(() => {
const model = editor.getModel();
if (!model) {
throw new Error('Model content changed but model not found.');
}
this.text = model.getValue();
this.textChanged.emit(this.text);
this.setParagraphMode(true);
this.autoAdjustEditorHeight();
setTimeout(() => {
this.autoAdjustEditorHeight();
});
// A flush is a programmatic setValue (editor init, remote content update, patch), not a user edit.
// Such changes must not mark the paragraph dirty.
if (e.isFlush) {
return;
}
this.textChanged.emit(this.text);
this.setParagraphMode(true);
});
})
);
Expand Down
6 changes: 6 additions & 0 deletions zeppelin-web-angular/src/app/services/message.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ import { TicketService } from './ticket.service';
providedIn: 'root'
})
export class MessageService extends Message implements OnDestroy {
// Set by a local clone/insert so the PARAGRAPH_ADDED handler focuses the new
// paragraph's editor — not on auto-append or other clients' inserts.
localAddFocusPending = false;

constructor(
private baseUrlService: BaseUrlService,
private ticketService: TicketService,
Expand Down Expand Up @@ -167,6 +171,7 @@ export class MessageService extends Message implements OnDestroy {
}

insertParagraph(newIndex: number): void {
this.localAddFocusPending = true;
super.insertParagraph(newIndex);
}

Expand All @@ -177,6 +182,7 @@ export class MessageService extends Message implements OnDestroy {
paragraphConfig: ParagraphConfig,
paragraphParams: ParagraphParams
): void {
this.localAddFocusPending = true;
super.copyParagraph(newIndex, paragraphTitle, paragraphData, paragraphConfig, paragraphParams);
}

Expand Down
Loading