bastianallgeier / triptrap Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
This field is likely to be used for stuff like blog posts. There, you'd want to have one <h1>
(which is the title
field) and perhaps a subtitle (which might be a subtitle
field). This is just good SEO and is how Medium works. This means that in your content, you'll mainly have <h3>
and up (again, how Medium works as well). This is also an argument for #8.
My argument is that in the editor, you'll likely be writing ###
and ####
most of the time, which can get annoying. My proposal is to be able to configure a "heading offset" that specifies the starting heading index.
For example, the default heading offset could be 0
, which means:
#
== <h1>
##
== <h2>
However, if you set headingOffset: 2
, you get:
#
== <h3>
##
== <h4>
This is useful for two reasons:
headingOffset
set to 2
and I want all <h3>
to turn into <h2>
(and all others to be adjusted accordingly), I would simply reduce headingOffset
by 1
. I wouldn't have to change the content at all.this is solved?
If I have the following content:
Sample text: (image: quote.png caption: Caption lorem ipsum dolor sit amet)
...I get the following markup:
<p>Sample text: (image: quote.png caption: Caption lorem ipsum dolor sit amet)</p>
That's expected. But when the text is parsed with kirbytext()
, the created <figure>
tag is put within the <p>
tag, which is not valid.
The obvious solution is to save it like that:
Sample text:
(image: quote.png caption: Caption lorem ipsum dolor sit amet)
...which turns into:
<p>Sample text:</p>
<p>(image: quote.png caption: Caption lorem ipsum dolor sit amet)</p>
...and you have the same problem. I don't know how this may be solved efficiently, though. I guess:
<p>
tags that surround kirbytags should be removed, which I don't think is easily possible and is actually a pretty bad idea, so it's not really a solutionThe reason this is such a problem is because the browser can't handle block elements inside a <p>
tag since the HTML spec does not allow it. Because of that, markup like:
<p>foo <div>bar</div> baz</p>
...is turned by the browser into:
<p>foo </p><div>bar</div> baz<p></p>
...which is bad. You expect one <p>
tag and you get two, one of which is empty.
You could add kirbytag support by serializing tags to XML before saving them.
(image: quote.png caption: Caption lorem ipsum dolor sit amet)
to
<kirby image="quote.png" caption="Caption lorem ipsum dolor sit amet"/>
I use that in kirby-exporter and it has worked flawlessly so far. It uses a lot of native Kirby functionality too.
Then, you could configure tiptap's toDOM()
method to parse <kriby>
tags. You'd have a custom Vue component to handle them - and that's it.
As for the UI, you could add a dropdown similar to those for headings - except it contains all possible kirbytags. Or perhaps those that are allowed in the field's blueprint.
Edit: On second thoughts, tiptap should be able to save Kirbytags as XML tags by itself, as long as you correctly define the parse rules. Then, the only problem would be to convert those tags from XML to the actual HTML output that each tag has in a template. That could be accomplished by:
Like you said on slack, parcel is including the vue runtime in the bundle. Actually, it seems like parcel has no other choice.
tiptap explicitly imports Vue here: https://github.com/scrumpy/tiptap/blob/master/packages/tiptap/src/Utils/ComponentView.js
I see 4 options and none of them is without drawbacks:
"vue"
module to any js file. That js file could be something like
export default panel.Vue;
Currently, the editor supports just <h1>
-<h3>
. You can't output the smaller tags even by writing ####
, so this is not a just problem with the UI. It should support all six tags so content can be organized more freely.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.