getkirby / getkirby.com

Source code and content for the Kirby website
https://getkirby.com
130 stars 264 forks source link

Writer docs: paragraph node undocumented #1397

Open adamkiss opened 3 years ago

adamkiss commented 3 years ago

Today, as I was implementing Writer, I've looked up docs, specifically regarding limiting content;

This is what the docs state:

Sets the allowed nodes. Available nodes: bulletList, orderedList, heading, horizontalRule, listItem. Activate/deactivate them all by passing true/false. Default nodes are heading, bulletList, orderedList.

Looking at the panel source code, I also see following:

Some of those seem obvious (text = inline: true write fields?), but some of those (specifically paragraph, in my case) are probably missing in the docs.

Additionally, I was able to limit my nodes to paragraphs only by setting the field option to:

        nodes:
          - paragraph

which is consistent with other kirby panel options, but not mentioned in the docs.

texnixe commented 3 years ago

This needs to be fixed in the source code inline docs

texnixe commented 3 years ago

Should we move this to the kirby repo?

lukasbestle commented 3 years ago

I wonder if the docs are really incorrect. I don't fully understand the internal writer setup, but as far as I can tell, these are all the supported node types:

https://github.com/getkirby/kirby/blob/79bce56a34a188ceaafb0a5179215fb55dca8bc5/panel/src/components/Writer/Writer.vue#L227-L231

texnixe commented 3 years ago

But here 6 are imported: https://github.com/getkirby/kirby/blob/79bce56a34a188ceaafb0a5179215fb55dca8bc5/panel/src/components/Writer/Writer.vue#L46

And here it mentions the paragraph node: https://github.com/getkirby/kirby/blob/79bce56a34a188ceaafb0a5179215fb55dca8bc5/panel/src/components/Writer/Writer.vue#L153

And to me it makes sense to be able to limit the writer field to paragraphs only.

lukasbestle commented 3 years ago

But if we filter the nodes prop to the five (+ HardBreak, which is always forced to be contained in the list), I don't think it's possible to configure other node types.

@distantnative @bastianallgeier?

texnixe commented 3 years ago

You are probably right. Setting nodes: false always leaves you with the paragraph "node", even though it doesn't seem to count as node.

If that's the case, we should however mention that somehow in the docs as it's obviously confusing.

distantnative commented 4 months ago

The paragraph node is a tricky and confusing one. So ideally we would not mention it to users. How could we phrase it clearer that one should use nodes: false if only paragraph if the intention?