obsidian-db-folder icon indicating copy to clipboard operation
obsidian-db-folder copied to clipboard

[FR] search inline fields that do not start the line or be bold

Open galsom opened this issue 2 years ago • 3 comments

First of all I'd like to thank you for this amazing plugin! Have been playing around with it an seems really useful.

In my vault I have Person notes where each person has its own note with properties like first name, last name, birthday, etc.

Each of these properties is managed using a Dataview inline field in an unordered list, e.g:

- First Name:: John
- Last Name:: Doe
- Birthday:: 28/03/1979
image

During some of these tests, I noticed that inline fields are also rendered correctly if they contain text before, like a dash.

image

When I change the value using the plugin like the following example, the updated value is correctly saved in the note

image

The value however is not update in the inline field, but added on top of the note as a new entry

image

I'm not a developer, but when looking in the source code for the term inline, I came across the following line of code

array.push(${key}:: ${inlineFields.inline[key]});

Could this be the reason that the dash in front of the inline field is ignored?

galsom avatar Jun 12 '22 19:06 galsom

hi @galsom

I see the problem here. The plugin before add a new inline field search if it already exist, but the way it’s searched is being at start of a line

In you example the inline field is behind a - So the plugin thinks that does not exist and add a new one. I am afraid that changes thst behaviour to edit that case its not trivial but could be added to the roadmap

RafaelGB avatar Jun 12 '22 22:06 RafaelGB

While this issue is into the backlog, you can use the editing option by replacing:

  • Birthday:: x/y/z

for:

Birthday:: x/y/z

RafaelGB avatar Jun 12 '22 22:06 RafaelGB

Thank you for the tip of using it without an unordered list. The disadvantage that that has is that when you render the MarkDown, all the values are placed on one line by convention:

image

That is why I started using the unordered lists. If somebody has another idea, please do share :-).

In the mean time I look forward to all the progress you make and hopefully this can be added.

galsom avatar Jun 14 '22 20:06 galsom

New regex expression:

const inlineFieldRegex = new RegExp(`(^|(.*)(\\s))([_\\*~\`]{ 0, 2}${columnId}[_\\*~\`]{ 0, 2}[:]{2}\\s)+([\\w\\W]+?$)`, 'gm');

https://user-images.githubusercontent.com/11924043/187700499-299cc39e-24aa-44ac-8e57-62fa5e3bd4b8.mov

RafaelGB avatar Aug 31 '22 14:08 RafaelGB

works for write but dataview needs parentheses between key:: value to read it. Working on another one

Edit: To replace new values without affects the text after parentheses the plugin needs the previous value and that implies more work that I expected

RafaelGB avatar Aug 31 '22 14:08 RafaelGB

I have a solid candidate => https://regex101.com/r/22g1JC/1

RafaelGB avatar Aug 31 '22 15:08 RafaelGB