Layouts for prose (headings+paragraphs+???)
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 25/100
- Issue 类型
- 功能
- 描述清晰度
- 需要澄清
- 活跃度
- 停滞
- 技术栈
- javascript
调研方向
未指定任何文件或测试。首先跟踪 Svedit 的节点光标、prose/文本节点结构以及复制粘贴行为;先就 prose 容器模型及其边界情况达成一致。完成的标准是:针对方向、插入、删除和粘贴节点,形成一套已确定且可测试的设计。
由索引模型根据 Issue 内容生成。
描述
Trying to work out the right approach for allowing different orientations/layouts for prose. E.g. for my website I might want a group of headings and paragraphs be left-aligned, centered, or right-oriented, to make things a bit more interesting visually.
My first attempt was to just encode all that layout information in a text node's layout property. E.g. I'd have 9 layouts for headings: left-aligned h1,h2,3 centered h1,h2,h3 and right-oriented h1,h2,h3.
While this works in principle, and keeps the content structure flat, it has downsides:
- if i want to change the orientation of multiple text nodes i'd need to change them one by one, or have some badge command (but then it's hard and error-prone to match the right layouts together, e.g. paragraph I have layout: 1,2,3 (you can only choose the orientation) while for headings you haver 1,2,...9.
- Also when splitting nodes or copy and paste you'd need to look for predecessors/successor text nodes and inspect them in order to determine which layout the pasted elements should get.
After some consideration I think a better approach is to group sections of prose together to single units, which then get a layout property (the orientation). For that I'd introduce a new node type prose at top level, that can take headings and paragraphs.
Pros:
- I'd have a dedicated entity to set stuff for a body of text. e.g. orientation, but also background
- You can optimize spacing because you know which body of text belongs together.
- Copy and paste: Easy to move text nodes from one prose node to another, while it automatically inherits the right layout
Cons:
- Copy and paste special cases: Say you select a bunch of paragraphs from a prose node, and then paste them at a top-level position. In this case Svedit would need to somehow determine the right parent component (in this case a prose node) so we have a valid structure again. Definitely possible, but needs significant changes to Svedit.
- Say the node cursor is after a Hero element, and you press ENTER. Currently you would expect a new paragraph to be created and a blinking cursor. But now to be consistent with the rest of the system, it would create a prose element with a heading and two paragraphs. The good thing is that you then understand implicitly how prose nodes work, and how a finished prose section roughly looks like. However the bad side is that it may be surprising, because it doesn't behave like your traditional text editor.
- Another edge case: What should happen when you want to delete the last text block inside a prose node. Should the prose node be removed alltogether, or should just EW just reject that (current behavior)
- You might accidentally create new prose elements, instead of adding new text blocks to an existing one. This could be a source of confusion/complexity. You'd only want to create a new prose node, when you want to change the layout e.g. start with left aligned and then continue with centered text. However, typically you'd never have two prose nodes after another. Or would you? Needs testing I guess.
- Added complexity to "just add a heading": A common use case might be that you just want to add a heading, e.g. before a gallery node. To do that you press ENTER at a node cursor position, then by default a prose with placeholders for one heading + 2 paragraphs is inserted. Now you need to delete the paragraph, and the heading (level 1) remains.
Generally I think adding a prose wrapper adds a lot of flexibility, and is definitely a pattern that can be utilized in custom nodes. On the downside it's definitely getting more complex, and breaks a bit with the expectations of a rich text-editor. Maybe that's not a bad thing, but it definitely hurts a bit simplicity, and might overwhelm some people that "just want to write a blog post".
Some ideas to mitigate the problems of the prose-container-approach:
- Maybe separate nodes for Section Headlines (much spacing etc., separator lines) and Headings (inside a Prose element, that are part of a body of text).
- 主要语言
- TypeScript
- 星标
- 1.8k
- 派生
- 148
- 平均合并
- 2 小时 47 分钟
- 30 天内合并 PR
- 13
环境准备
- 提供 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 没有贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
michael/editable 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 72/100
michael/editable#181 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 52/100
维护者通常 1 天内回复
-
难度 5/5 一周以上 新手友好度 38/100
维护者通常 1 天内回复
-
难度 5/5 一周以上 新手友好度 35/100
维护者通常 1 天内回复
-
难度 5/5 一周以上 新手友好度 25/100
维护者通常 1 天内回复
相似的 Issue
-
bug data-types
难度 2/5 1-3 小时 新手友好度 88/100
ClickHouse/clickhouse-js#1293 ·
维护者通常 1 天内回复
-
area: middleware enhancement good first issue
难度 2/5 1-3 小时 新手友好度 68/100
-
agent/quality testing
难度 1/5 1 小时以内 新手友好度 95/100
维护者通常 1 天内回复
-
GitHub registry install via `gh` credentials rewrites `\u0000`–`\u001f` escapes in source files to `^@`–`^_`可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 2/5 1-3 小时 新手友好度 92/100
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
juspay/agent-distro#203 ·
维护者通常 1 天内回复