Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wysiwyg: split node/mark addition into separate methods in extension builder #636

Open
Tracked by #584
d3m1d0v opened this issue Feb 17, 2025 · 0 comments
Open
Tracked by #584
Assignees

Comments

@d3m1d0v
Copy link
Member

d3m1d0v commented Feb 17, 2025

At the current moment ExtensionBuilder has two methods to declare new nodes and marks:

// for nodes
builder.addNode();

// for marks
builder.addMark();

In each method you should provide:

  • prosemirror schema spec
  • markdown parser spec
  • markdown serializer spec
  • custom view for entity (optional)

This is inconvenient for several reasons:

  • impossible to separate declaration for prosemirror from declaration for markdown parsing and serializing
  • sometimes it is required to parse different markdown-tokens into one prosemirror-node (for example, parse code_block and fence tokens to code_block-node in prosemirror). In this case you should add empty schema spec and empty serializer spec into builder.addNode()

Proposal

Split builder.addNode() and builder.addMark() into separate methods:

builder.addNodeSpec();
builder.addMarkSpec();
builder.addParserSpec();
builder.addSerializerSpec();
builder.addNodeView();
builder.addMarkView();

And refactor code in CodeBlockSpecs extension

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants