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

Support highlight syntax #75

Open
henrymcl opened this issue Aug 15, 2024 · 1 comment
Open

Support highlight syntax #75

henrymcl opened this issue Aug 15, 2024 · 1 comment

Comments

@henrymcl
Copy link

Is your feature request related to a problem? Please describe.
Describe the solution you'd like
Support the extended syntax for highlights

Describe alternatives you've considered
Allowing HTML is too dangerous

Additional context
None

@calumk
Copy link

calumk commented Jan 3, 2025

This works, you have to add it manually, as i havent submitted as a pull request yet.

import { Mark } from "@tiptap/core";


const Highlight = Mark.create({
    name: 'highlight',
});

export default Highlight.extend({
    /**
     * @return {{markdown: MarkdownMarkSpec}}
     */
    addStorage() {
        return {
            markdown: {
                serialize: {open: '==', close: '==', expelEnclosingWhitespace: true},
                parse: {
                    updateDOM(element) {
                        element.innerHTML = element.innerHTML.replace(/\=\=(.*?)\=\=/g, '<mark>$1</mark>')
                    },
                },
            },
        }
    }
});

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