본문 바로가기

Obsidian/Templater Tips

옵시디언 템플레이터 - 실행한 다음 에디터가 활성화(focus) 안됨. - 임시 해결

"Templater" 실행이 끝난 다음 "Editor"가 활성화(fucus) 되지 않습니다.
노트 파일에서  커서(caret)가 보이지 않습니다.
그래서 이어서 바로 글을 작성할 수 없습니다.

그렇지만 "Template"에서는 바로 이어서 글을 작성할 수 있습니다.



템플레이터 issue 사이트(https://github.com/SilentVoid13/Templater/issues)에서 검색해 보니 다음과 같은 비슷한 내용의 글을 볼 수 있었습니다.

Put writing cursor at the end of the template after insertion · Issue #4 · SilentVoid13/Templater  
https://github.com/SilentVoid13/Templater/issues/4 

 

Put writing cursor at the end of the template after insertion · Issue #4 · SilentVoid13/Templater

Right now, after inserting a template, the editing screen seems to lose focus, and you have to click on it to continue editing. Ideally, the cursor would be active (focused) on the position just af...

github.com

 

이 문제가 한참 전에 해결 되었다고 나오는 데 아직도 제게는 지금 일어나네요.

 

또 다른 이슈를 살펴보니 임시로 해결할 만한 내용이 있었습니다.

 

<% tp.file.cursor() %> doesn't work anymore in a daily note if the daily note is created through the calendar plugin (in the side pane) (Obsidian v.0.15+) · Issue #664 · SilentVoid13/Templater  
https://github.com/SilentVoid13/Templater/issues/664 

 

<% tp.file.cursor() %> doesn't work anymore in a daily note if the daily note is created through the calendar plugin (in the sid

Plugin information: OS: MacOS Big Sur 11.6.6 Templater version: 1.12.0 Obsidian version: 0.15.1 Templater settings: Template folder location: Meta/Templates Syntax Highlighting: ON Automatic jump t...

github.com

다음은 위 페이지의 일부 내용입니다.

Put this:

<%* app.workspace.activeLeaf.view.editor.focus() -%>

Or this:

<%* setTimeout(() => app.workspace.activeLeaf.view.editor.focus(), 200) -%>


In front of your tp.file.cursor() command. It will force the app to focus on the new active leaf.
Now for my test vault, I couldn't replicate your issue exactly. I did have your issue with the cursor not going to the location it was supposed to go, but at least the <% tp.file.cursor() %> command disappeared.

 

위 글 내용처럼

<%* app.workspace.activeLeaf.view.editor.focus() -%>

위 코드를 템플레이터 템플릿의 끝에 붙이니
템플레이터 실행이 끝난 다음 에디터가 활성화되어 커서(caret)가 보이네요.

어어서 바로 글을 입력할 수 있습니다.

 

<% tp.file.cursor() %> 를 쓴 곳이 있다면 그 위치로 커서가 옮겨가 있습니다.

 

 

하지만 이러한 해결 방법은 조금 이상한 느낌이 듭니다.

템플릿 적용한 다음 바로 노트 편집 위치에 커서가 위치해 있어야 하는 것은 기본인데 이러한 코드를 넣어야 하는 것이 상식적이지 않습니다.

 

 

다음의 제 글에서 이 코드를 사용했습니다. 소스 코드 중간에서 볼 수 있습니다.

 

옵시디언 템플레이터(Templater) - Callout 넣기  
https://eoureo.tistory.com/19 

 

옵시디언 템플레이터(Templater) - Callout 넣기

Callout(말풍선, 설명글?)의 모양과 색을 보면서 골라 노트에 삽입할 수 있습니다. 얼마 전에 다음 글을 보게 되었습니다. 네이버 카페 "Obsidian 옵시디언 사용자 모임" - Callout 쉽게 넣기 템플릿 kaorw,

eoureo.tistory.com