@tiptap/extension-image
Advanced tools
Comparing version 2.3.2 to 2.4.0
import { Node, mergeAttributes, nodeInputRule } from '@tiptap/core'; | ||
/** | ||
* Matches an image to a ![image](src "title") on input. | ||
*/ | ||
const inputRegex = /(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/; | ||
/** | ||
* This extension allows you to insert images. | ||
* @see https://www.tiptap.dev/api/nodes/image | ||
*/ | ||
const Image = Node.create({ | ||
@@ -5,0 +12,0 @@ name: 'image', |
@@ -7,3 +7,10 @@ (function (global, factory) { | ||
/** | ||
* Matches an image to a ![image](src "title") on input. | ||
*/ | ||
const inputRegex = /(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/; | ||
/** | ||
* This extension allows you to insert images. | ||
* @see https://www.tiptap.dev/api/nodes/image | ||
*/ | ||
const Image = core.Node.create({ | ||
@@ -10,0 +17,0 @@ name: 'image', |
import { Node } from '@tiptap/core'; | ||
export interface ImageOptions { | ||
/** | ||
* Controls if the image node should be inline or not. | ||
* @default false | ||
* @example true | ||
*/ | ||
inline: boolean; | ||
/** | ||
* Controls if base64 images are allowed. Enable this if you want to allow | ||
* base64 image urls in the `src` attribute. | ||
* @default false | ||
* @example true | ||
*/ | ||
allowBase64: boolean; | ||
/** | ||
* HTML attributes to add to the image element. | ||
* @default {} | ||
* @example { class: 'foo' } | ||
*/ | ||
HTMLAttributes: Record<string, any>; | ||
@@ -12,2 +28,7 @@ } | ||
* Add an image | ||
* @param options The image attributes | ||
* @example | ||
* editor | ||
* .commands | ||
* .setImage({ src: 'https://tiptap.dev/logo.png', alt: 'tiptap', title: 'tiptap logo' }) | ||
*/ | ||
@@ -22,3 +43,10 @@ setImage: (options: { | ||
} | ||
/** | ||
* Matches an image to a ![image](src "title") on input. | ||
*/ | ||
export declare const inputRegex: RegExp; | ||
/** | ||
* This extension allows you to insert images. | ||
* @see https://www.tiptap.dev/api/nodes/image | ||
*/ | ||
export declare const Image: Node<ImageOptions, any>; |
{ | ||
"name": "@tiptap/extension-image", | ||
"description": "image extension for tiptap", | ||
"version": "2.3.2", | ||
"version": "2.4.0", | ||
"homepage": "https://tiptap.dev", | ||
@@ -32,3 +32,3 @@ "keywords": [ | ||
"devDependencies": { | ||
"@tiptap/core": "^2.3.2" | ||
"@tiptap/core": "^2.4.0" | ||
}, | ||
@@ -35,0 +35,0 @@ "peerDependencies": { |
@@ -8,4 +8,22 @@ import { | ||
export interface ImageOptions { | ||
/** | ||
* Controls if the image node should be inline or not. | ||
* @default false | ||
* @example true | ||
*/ | ||
inline: boolean, | ||
/** | ||
* Controls if base64 images are allowed. Enable this if you want to allow | ||
* base64 image urls in the `src` attribute. | ||
* @default false | ||
* @example true | ||
*/ | ||
allowBase64: boolean, | ||
/** | ||
* HTML attributes to add to the image element. | ||
* @default {} | ||
* @example { class: 'foo' } | ||
*/ | ||
HTMLAttributes: Record<string, any>, | ||
@@ -19,2 +37,7 @@ } | ||
* Add an image | ||
* @param options The image attributes | ||
* @example | ||
* editor | ||
* .commands | ||
* .setImage({ src: 'https://tiptap.dev/logo.png', alt: 'tiptap', title: 'tiptap logo' }) | ||
*/ | ||
@@ -26,4 +49,11 @@ setImage: (options: { src: string, alt?: string, title?: string }) => ReturnType, | ||
/** | ||
* Matches an image to a ![image](src "title") on input. | ||
*/ | ||
export const inputRegex = /(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/ | ||
/** | ||
* This extension allows you to insert images. | ||
* @see https://www.tiptap.dev/api/nodes/image | ||
*/ | ||
export const Image = Node.create<ImageOptions>({ | ||
@@ -30,0 +60,0 @@ name: 'image', |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
25581
406