diff --git a/docs/api/nodes/image.md b/docs/api/nodes/image.md index 1e1726cb..0572965b 100644 --- a/docs/api/nodes/image.md +++ b/docs/api/nodes/image.md @@ -20,17 +20,6 @@ npm install @tiptap/extension-image ## Settings -### HTMLAttributes -Custom HTML attributes that should be added to the rendered HTML tag. - -```js -Image.configure({ - HTMLAttributes: { - class: 'my-custom-class', - }, -}) -``` - ### inline Renders the image node inline, for example in a paragraph tag: `

`. By default images are on the same level as paragraphs. @@ -44,6 +33,28 @@ Image.configure({ }) ``` +### allowBase64 +Allow images to be parsed as base64 strings ``. + +Default: `false` + +```js +Image.configure({ + allowBase64: true, +}) +``` + +### HTMLAttributes +Custom HTML attributes that should be added to the rendered HTML tag. + +```js +Image.configure({ + HTMLAttributes: { + class: 'my-custom-class', + }, +}) +``` + ## Commands ### setImage() diff --git a/packages/extension-image/src/image.ts b/packages/extension-image/src/image.ts index d6d8ec56..3eb5af28 100644 --- a/packages/extension-image/src/image.ts +++ b/packages/extension-image/src/image.ts @@ -6,6 +6,7 @@ import { export interface ImageOptions { inline: boolean, + allowBase64: boolean, HTMLAttributes: Record, } @@ -28,6 +29,7 @@ export const Image = Node.create({ addOptions() { return { inline: false, + allowBase64: false, HTMLAttributes: {}, } }, @@ -59,7 +61,9 @@ export const Image = Node.create({ parseHTML() { return [ { - tag: 'img[src]:not([src^="data:"])', + tag: this.options.allowBase64 + ? 'img[src]' + : 'img[src]:not([src^="data:"])', }, ] },