Comments (4)
I did some research into this, and I don't think this is feasible to implement at the moment. The current implementation uses a Codemirror transaction to set the selection. This does not work with the new properties UI because it's not part of the editor for the purpose of transactions, the properties input boxes are divs that are contenteditable
. We could maybe conditionally use browser APIs instead of Codemirror APIs, but that feels brittle.
If any Obsidian API experts have input on a way to accomplish this that isn't brittle, I would love to know about it.
Here's an example of what a browser API solution would look like, for reference.
function setCursorPosition(el, pos) {
var range = document.createRange();
var sel = window.getSelection();
range.setStart(el, pos);
range.collapse(true);
sel.removeAllRanges();
sel.addRange(range);
}
// Assuming we have figured out which property value and what position within that contenteditable div for that property value
const propertyIndex = 0;
const characterIndex = 19;
setCursorPosition(this.app.workspace.activeEditor.metadataEditor.rendered.at(propertyIndex).valueEl.childNodes.at(0).childNodes.at(0), characterIndex);
from templater.
It is not just in tags; I have the same problem in the body of a note. <% tp.file.cursor(1) %> works in preview mode if the template is at the beginning of a line. It does not work if the template is inserted in the middle of a line, the cursor is placed at the beginning of the text to be inserted instead. It works as expected in source mode.
Probably related to #1089
from templater.
tp.file.cursor()
will need to be updated to work in the properties widget. That is the reason it doesn't work.
from templater.
Adding to this because it's probably related: If I'm in editing a property and jump to the next tp.file.cursor() position, the templater tag ("<% tp.file.cursor() %>") ist removed but the cursor isn't moved but stays in properties forcing me to use the mouse to move out of Properties.
from templater.
Related Issues (20)
- main.js missing HOT 3
- Date not rendered as link HOT 1
- 2.3.2 broke my frontmatter processing template HOT 6
- Auto jump to cursor is triggered twice on new file creation HOT 4
- invalid reference date format, try specifying one with reference format HOT 4
- bug: app.workspace.getLeaf().openFile() replaces content in a note if called without "await"
- app.fileManager.processFrontMatter doesn't work HOT 1
- Templater should parse, merge and write out frontmatter gracefully HOT 6
- Applying Text Color in Obsidian Without Unwanted New Lines HOT 2
- Templater no longer works with console error "Plugin failure: templater-obsidian TypeError: c is not a constructor" HOT 2
- The recent upgrade of this plug-in has broken "Trigger Templater on new file creation" HOT 6
- {{date}} fail to work after updating to 2.3.3 HOT 1
- Target file gets overwritten by processFrontMatter() HOT 1
- Note Creation with Core Plugin "Note Composer" Breaks Templater HOT 1
- Option to add ignored files to Templater settings HOT 2
- Copy existing file with templater HOT 1
- Ability to use {{date}} in Folder Templates HOT 2
- Templater file module does not support the concurrent creation of files HOT 4
- Folder Template overwrites non-empty note HOT 2
- Daily Quote errors HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from templater.