Repository navigation
Add Schema registry, Mark types, and declarative parent builders - #54
Open
chadwilken wants to merge 10 commits into
Open
chadwilken wants to merge 10 commits into
chadwilken wants to merge 10 commits into
Conversation
Phase 1 of a schema-centric redesign: Schema holds name→class registrations; Registry becomes a thin façade over TipTap.default_schema. Document/Node.from_json accept an optional schema: keyword while preserving existing behavior for built-ins.
Phase 2: introduce TipTap::Mark and TipTap::Marks::* for bold, italic, underline, strike, code, link, textStyle, superscript, subscript, and highlight. Schema gains register_mark/mark_for; Text renders via the node schema's mark registry. Builder API and built-in HTML/Markdown output are unchanged.
Phase 3: node classes declare parent_builder to install builder methods on allowed parents at registration time. Migrate Document, ListItem, lists, tables, and related parents off duplicated hand-written builders. Text#text / Codeblock#code remain special-cased.
Default remains MissingNodeError. Schema#unknown_node and from_json(..., unknown_node:) accept :passthrough to preserve unregistered types as TipTap::Nodes::Unknown for to_h round-trips, recursively parsing nested known and unknown children.
Expose paragraph/heading#hard_break and document#horizontal_rule as declarative leaf builders so registered types match the rest of the parent_builder migration.
id and data-toc-id from JSON/attrs are no longer overwritten. Missing values are still filled with a UUID by default; pass generate_toc_ids: false on Heading.new or Document.from_json to skip.
Replace the Document monkey-patch extension guide with type_name, parent_builder, and isolated schema examples; point to docs/schema.md for marks and related options.
Schema no longer supports dup/clone. Docs, README, and specs now build isolated schemas via TipTap::Schema.new.use(TipTap.default_schema).
Remove schema: from from_json/Text initialize. Custom nodes and marks register on the default schema via type_name= (or register). Docs and specs no longer describe Schema.new.use isolation.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Introduces a schema-centric registry while keeping the familiar
Document.from_json/ builder /to_*API.TipTap::Schema— canonical store for node and mark type names → classes;Registryis a thin façade overTipTap.default_schemaTextintoTipTap::Marksubclasses registered on the default schema; custom marks viatype_name=/register_markparent_builder— child nodes declare which parents get builder methods (no Document monkey-patches); addshard_break/horizontal_rulebuildersunknown_node: :passthroughonfrom_json(default still raises)id/data-toc-idon parse; generate only when missing; opt out withgenerate_toc_ids: falsedocs/schema.mdupdated for the default-schema extension pathEverything uses
TipTap.default_schema(no per-document / isolated schemas). Custom nodes: settype_name=+parent_builder, require the file, thenDocument.from_jsonworks as before.Reason/Reference
Evolve the gem’s internals so extending TipTap with custom node and mark types is a first-class, documented path—without monkey-patching parents or editing
Text—while preserving the public façade apps already depend on.