Socket
Socket
Sign inDemoInstall

@tiptap/extension-image

Package Overview
Dependencies
Maintainers
5
Versions
160
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tiptap/extension-image - npm Package Compare versions

Comparing version 3.0.0-next.0 to 3.0.0-next.1

dist/index.d.cts

151

dist/index.js

@@ -1,77 +0,78 @@

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({
name: 'image',
addOptions() {
return {
inline: false,
allowBase64: false,
HTMLAttributes: {},
};
},
inline() {
return this.options.inline;
},
group() {
return this.options.inline ? 'inline' : 'block';
},
draggable: true,
addAttributes() {
return {
src: {
default: null,
},
alt: {
default: null,
},
title: {
default: null,
},
};
},
parseHTML() {
return [
{
tag: this.options.allowBase64
? 'img[src]'
: 'img[src]:not([src^="data:"])',
},
];
},
renderHTML({ HTMLAttributes }) {
return ['img', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes)];
},
addCommands() {
return {
setImage: options => ({ commands }) => {
return commands.insertContent({
type: this.name,
attrs: options,
});
},
};
},
addInputRules() {
return [
nodeInputRule({
find: inputRegex,
type: this.type,
getAttributes: match => {
const [, , alt, src, title] = match;
return { src, alt, title };
},
}),
];
},
// src/image.ts
import {
mergeAttributes,
Node,
nodeInputRule
} from "@tiptap/core";
var inputRegex = /(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/;
var Image = Node.create({
name: "image",
addOptions() {
return {
inline: false,
allowBase64: false,
HTMLAttributes: {}
};
},
inline() {
return this.options.inline;
},
group() {
return this.options.inline ? "inline" : "block";
},
draggable: true,
addAttributes() {
return {
src: {
default: null
},
alt: {
default: null
},
title: {
default: null
}
};
},
parseHTML() {
return [
{
tag: this.options.allowBase64 ? "img[src]" : 'img[src]:not([src^="data:"])'
}
];
},
renderHTML({ HTMLAttributes }) {
return ["img", mergeAttributes(this.options.HTMLAttributes, HTMLAttributes)];
},
addCommands() {
return {
setImage: (options) => ({ commands }) => {
return commands.insertContent({
type: this.name,
attrs: options
});
}
};
},
addInputRules() {
return [
nodeInputRule({
find: inputRegex,
type: this.type,
getAttributes: (match) => {
const [, , alt, src, title] = match;
return { src, alt, title };
}
})
];
}
});
export { Image, Image as default, inputRegex };
//# sourceMappingURL=index.js.map
// src/index.ts
var src_default = Image;
export {
Image,
src_default as default,
inputRegex
};
//# sourceMappingURL=index.js.map
{
"name": "@tiptap/extension-image",
"description": "image extension for tiptap",
"version": "3.0.0-next.0",
"version": "3.0.0-next.1",
"homepage": "https://tiptap.dev",

@@ -18,3 +18,3 @@ "keywords": [

".": {
"types": "./dist/packages/extension-image/src/index.d.ts",
"types": "./dist/index.d.ts",
"import": "./dist/index.js",

@@ -26,4 +26,3 @@ "require": "./dist/index.cjs"

"module": "dist/index.js",
"umd": "dist/index.umd.js",
"types": "dist/packages/extension-image/src/index.d.ts",
"types": "dist/index.d.ts",
"files": [

@@ -34,6 +33,6 @@ "src",

"devDependencies": {
"@tiptap/core": "^3.0.0-next.0"
"@tiptap/core": "^3.0.0-next.1"
},
"peerDependencies": {
"@tiptap/core": "^3.0.0-next.0"
"@tiptap/core": "^3.0.0-next.1"
},

@@ -46,5 +45,4 @@ "repository": {

"scripts": {
"clean": "rm -rf dist",
"build": "npm run clean && rollup -c"
"build": "tsup"
}
}

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc