steven-tey / novel

Notion-style WYSIWYG editor with AI-powered autocompletion.
https://novel.sh
Apache License 2.0
11.8k stars 980 forks source link

feat: Overwrite the `simpleExtensions` especially the markdown config #369

Open saculNiot opened 3 months ago

saculNiot commented 3 months ago

Describe the feature you'd like to request

I am trying to modify the config in the markdown under the simpleExtensions. I am planning to make transformCopiedText as false. Is there any way I can do it? Thankss in advance

Describe the solution you'd like to see

It is better if we can overwrite the extensions in simpleExtensions just like the rest of extensions.

Additional information

No response

EnriqueSantos-dev commented 3 months ago

I think you can do it like this, a agree actualitythis is not the best way to do this, but it working expected for me :)

// sure you have tiptap-markdown installed in you project
import { Markdown } from "tiptap-markdown";

import { simpleExtensions as novelSimpleExtensions } from "novel/extensions";

const markdown = Markdown.configure({
  // your config
});

// remove markdown extension from simpleExtensions array
export const simpleExtensions = novelSimpleExtensions.filter(
  (ext) => ext.name !== "markdown"
);

// export your custom config of markdown extension and another extensions
export const defaultExtensions = [
   // rest of extension
   markdown,
   ...simpleExtensions 
]
saculNiot commented 3 months ago

Thanks for the solution. Yeah, this could be the workaround. Let me try it out. Thanks.

maks-ivanov commented 3 months ago

did it work for you @saculNiot ? No luck here EDIT: hacky variant below worked for me

const markdown = simpleExtensions.find((ext) => ext.name === "markdown")
markdown!.options.transformCopiedText = false;