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

inputRules can't work for atom node #1507

Closed
zunsthy opened this issue Feb 6, 2025 · 2 comments
Closed

inputRules can't work for atom node #1507

zunsthy opened this issue Feb 6, 2025 · 2 comments

Comments

@zunsthy
Copy link

zunsthy commented Feb 6, 2025

wrappingInputRule() create InputRule for atom node, such as <hr>. it can't work due inner method findWrappingInside() always return null.

const schema = new Schema({
  marks: basicSchema.spec.marks,
  nodes: basicSchema.spec.nodes
    .append({
      hr: { parseDOM: [{ tag: 'hr' }] },
    }),
});

const rules = [
  wrappingInputRule(/^\s*---\s$/, schema.nodes.hr),
  wrappingInputRule(/^\s*>\s$/,schema.nodes.blockquote),
];

const state = EditorState.create({
  schema,
  plugins: [
    // ...
    inputRules({ rules }),
  ],
});
const view = new EditorView(container, { state });

if input > will create blockquote node, but input --- can't create hr node.

@marijnh
Copy link
Member

marijnh commented Feb 6, 2025

You cannot wrap anything in an atom node. As such, wrappingInputRule not working for such nodes is the expected behavior.

@marijnh marijnh closed this as completed Feb 6, 2025
@zunsthy
Copy link
Author

zunsthy commented Feb 17, 2025

You cannot wrap anything in an atom node. As such, wrappingInputRule not working for such nodes is the expected behavior.

wrap() method is too complex if inputrule for atom node. has some wrap method for it?

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