Section Editor - Prototype

@sull-vitsy

:filter[get[title]regexp<nonWhitespace>]

change to

:filter[regexp<nonWhitespace>] 

and let me know if it works!

1 Like

It works well. Awesome!

Mohammad, thanks for that reference. In fact it is the find macro that is the revelation.

Its taking a little time to digest how it works because its very compact and there are number of nice design tricks there in,

  • Calling itself (Expected for multiple hits)
  • Calling an output macro, in effect providing a named template - very nice.

There remains the issue of if a marker is loaded with additional content, which does not occur in the \define / \end but if we used the aformentions section;

<section>
content
</section>

Would work but not;

<section class="namedclass">
content
</section>

Or

\define macro() single line
\define multiline macro
one extra line
\end

would mess up?

But its almost there! Ta

@TW_Tones , then it needs to accept regex pattern! It is solved and can be found in

http://tw-regexp.tiddlyspot.com/#Extract%20Contents%20between%20Html%20Tags

2 Likes

Yes regular expressions thanks for the reference.

Actually your macro may need to be extended to support nesting which could not occur with macro definitions or headings but could with div and other html tags.

As I said I will continue this weekend. If I can i will extend the TOC with filter and position. I have always being keen to totally tame hierarchy.

Thank for the inspiration

A post was split to a new topic: Streams as a single tiddler editor - demo

See section-editor beta release as plugin: Section Editor - Prototype

This is definitely in the category of “Why didn’t anyone do this before?”

I think the first improvement I would like is to use “Cntrl-enter” to close the editing session.

If sections could fold then it would be great for long-form documents.

:+1:

3 Likes

I’ll be adding it to my stuff soon as it’s ready for prime time.

@Mohammad I hope the section element is customizable (I don’t want Hn tags or have to style them invisible/hidden).

@Mohammad I took your prototype and did the follwing;

in toggle-button added this style/class to the button
style="float: left; margin: -35px;" class="tc-btn-invisible"

in feditor
moved the following to the bottom of feditor
<$macrocall $name=toggle-button stateTiddler=<<stateTid>> onlabel="edit" offlabel="show"/>

Now it looks like this;

Not perfect but the button appears at the bottom of the content in the margin.

@TW_Tones please test the latest version! See the first post!

It uses right float! but you can set it for left float as you suggested! See styles and give a try!

1 Like

Thank you Mark,
Please open the settings, you have option to switch between text area / main editor (e.g. codemirror)
Then you have some shortcuts!

I will work on this to have keyword shortcuts working for text area too!

Absolutely! It is in todo list!

@Mark_S one question: what do you think if we add settings allow user determines the levels of sectioning? I mean: set =1 only h1 creates sections, if set=2 both h1 and h2 creates sections but not h3! If so, what regex pattern do you propose?

1 Like

@CodaCoder - sure,
If you are in rush, please see the section-editor! also see the tw-regexp (how to extract contents between elements tag). Give a try and let me know!

I tried to insert a regex pattern to create only h1 and h2 sections, but not h3.

--- Start

<$vars pattern="\n(?=^!{1,2}[^!])" nonWhitespace="[^\s]"
  src={{{[<source>get[text]]}}}  stid=<<currentTiddler>>>
<$list filter="[<src>splitregexp:m<pattern>!is[blank]first[]] :filter[regexp<nonWhitespace>] 
               [<src>splitregexp:m<pattern>!is[blank]]" counter=cnt   >
<<feditor>>
</$list>
</$vars>

I’m not sure on browser support for lookaheads, though. Does it work?

1 Like

kookma.github.io/TW-SE/

Gives a 404 error

My lookahead is almost the same as sull-vitsy

<$list filter="[all[current]has:field[se-type]]">
<$macrocall $name=section-editor source=<<currentTiddler>> pattern="\n(?=!{1,2}[^!])" />
</$list>

Then, in your main macro you don’t have to add back in the ! because you’ve used the lookahead:

<$list counter=counter variable=section
       filter="[<sourceText>splitregexp<pattern>!is[blank]first[]regexp<nonWhitespace>]
               [<sourceText>splitregexp<pattern>!is[blank]butfirst[]regexp<nonWhitespace>]">
1 Like

@Mohammad There is a little problem. Try this text

! asdf

aaaa

! asdf

aaaa

Now edit the 2nd one and save. → The 1st one will be edited.

1 Like

Corrected! I also updated the original post at top of this thread!
Section Editor is here:

2 Likes

Thank you @pmario - I confirm the bug!
While having two similar sections, is an edge case, but I surely address this bug!

Great job! I’ve been waiting for a plugin like this for a long time, thanks for the work!

I think this section editor plugin in conjunction with my CodeMirror-Enhanced plugin would greatly enhance the TiddlyWiki writing experience, just like notion does.

Also, I’d like to ask if it’s possible to make each block (e.g. a paragraph, an image, a quote, a table, etc.) editable individually like notion, instead of using headers for section editing? I think this would make editing more flexible. Thanks!