@tiptap/extension-image 2.0.0-beta.2 → 2.0.0-beta.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE.md CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2020, überdosis GbR
3
+ Copyright (c) 2021, überdosis GbR
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -7,8 +7,8 @@
7
7
  ## Introduction
8
8
  tiptap is a headless wrapper around [ProseMirror](https://ProseMirror.net) – a toolkit for building rich text WYSIWYG editors, which is already in use at many well-known companies such as *New York Times*, *The Guardian* or *Atlassian*.
9
9
 
10
- ## Offical Documentation
10
+ ## Official Documentation
11
11
  Documentation can be found on the [tiptap website](https://tiptap.dev).
12
12
 
13
13
  ## License
14
- tiptap is open sourced software licensed under the [MIT license](https://github.com/ueberdosis/tiptap-next/blob/main/LICENSE.md).
14
+ tiptap is open sourced software licensed under the [MIT license](https://github.com/ueberdosis/tiptap/blob/main/LICENSE.md).
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tiptap/extension-image",
3
3
  "description": "image extension for tiptap",
4
- "version": "2.0.0-beta.2",
4
+ "version": "2.0.0-beta.23",
5
5
  "homepage": "https://tiptap.dev",
6
6
  "keywords": [
7
7
  "tiptap",
@@ -15,7 +15,6 @@
15
15
  "main": "dist/tiptap-extension-image.cjs.js",
16
16
  "umd": "dist/tiptap-extension-image.umd.js",
17
17
  "module": "dist/tiptap-extension-image.esm.js",
18
- "unpkg": "dist/tiptap-extension-image.bundle.umd.min.js",
19
18
  "types": "dist/packages/extension-image/src/index.d.ts",
20
19
  "files": [
21
20
  "src",
@@ -24,5 +23,10 @@
24
23
  "peerDependencies": {
25
24
  "@tiptap/core": "^2.0.0-beta.1"
26
25
  },
27
- "gitHead": "634c1ae4931a8a268c7251f702b2a7d5121f02d2"
26
+ "repository": {
27
+ "type": "git",
28
+ "url": "https://github.com/ueberdosis/tiptap",
29
+ "directory": "packages/extension-image"
30
+ },
31
+ "gitHead": "fce16e805824972834d5a8ce8d60e3ff41d63c7e"
28
32
  }
package/src/image.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import {
2
- Command,
3
2
  Node,
4
3
  nodeInputRule,
5
4
  mergeAttributes,
@@ -7,30 +6,30 @@ import {
7
6
 
8
7
  export interface ImageOptions {
9
8
  inline: boolean,
10
- HTMLAttributes: {
11
- [key: string]: any
12
- },
9
+ HTMLAttributes: Record<string, any>,
13
10
  }
14
11
 
15
12
  declare module '@tiptap/core' {
16
- interface Commands {
13
+ interface Commands<ReturnType> {
17
14
  image: {
18
15
  /**
19
16
  * Add an image
20
17
  */
21
- setImage: (options: { src: string, alt?: string, title?: string }) => Command,
18
+ setImage: (options: { src: string, alt?: string, title?: string }) => ReturnType,
22
19
  }
23
20
  }
24
21
  }
25
22
 
26
- export const inputRegex = /!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\)/
23
+ export const inputRegex = /(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))/
27
24
 
28
25
  export const Image = Node.create<ImageOptions>({
29
26
  name: 'image',
30
27
 
31
- defaultOptions: {
32
- inline: false,
33
- HTMLAttributes: {},
28
+ addOptions() {
29
+ return {
30
+ inline: false,
31
+ HTMLAttributes: {},
32
+ }
34
33
  },
35
34
 
36
35
  inline() {
@@ -71,25 +70,25 @@ export const Image = Node.create<ImageOptions>({
71
70
 
72
71
  addCommands() {
73
72
  return {
74
- setImage: options => ({ tr, dispatch }) => {
75
- const { selection } = tr
76
- const node = this.type.create(options)
77
-
78
- if (dispatch) {
79
- tr.replaceRangeWith(selection.from, selection.to, node)
80
- }
81
-
82
- return true
73
+ setImage: options => ({ commands }) => {
74
+ return commands.insertContent({
75
+ type: this.name,
76
+ attrs: options,
77
+ })
83
78
  },
84
79
  }
85
80
  },
86
81
 
87
82
  addInputRules() {
88
83
  return [
89
- nodeInputRule(inputRegex, this.type, match => {
90
- const [, alt, src, title] = match
91
-
92
- return { src, alt, title }
84
+ nodeInputRule({
85
+ find: inputRegex,
86
+ type: this.type,
87
+ getAttributes: match => {
88
+ const [,, alt, src, title] = match
89
+
90
+ return { src, alt, title }
91
+ },
93
92
  }),
94
93
  ]
95
94
  },
package/CHANGELOG.md DELETED
@@ -1,123 +0,0 @@
1
- # Change Log
2
-
3
- All notable changes to this project will be documented in this file.
4
- See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
-
6
- # [2.0.0-beta.2](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-image@2.0.0-beta.1...@tiptap/extension-image@2.0.0-beta.2) (2021-04-15)
7
-
8
- **Note:** Version bump only for package @tiptap/extension-image
9
-
10
-
11
-
12
-
13
-
14
- # [2.0.0-beta.1](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-image@2.0.0-alpha.11...@tiptap/extension-image@2.0.0-beta.1) (2021-03-05)
15
-
16
- **Note:** Version bump only for package @tiptap/extension-image
17
-
18
-
19
-
20
-
21
-
22
- # [2.0.0-alpha.11](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-image@2.0.0-alpha.10...@tiptap/extension-image@2.0.0-alpha.11) (2021-02-16)
23
-
24
- **Note:** Version bump only for package @tiptap/extension-image
25
-
26
-
27
-
28
-
29
-
30
- # [2.0.0-alpha.10](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-image@2.0.0-alpha.9...@tiptap/extension-image@2.0.0-alpha.10) (2021-02-07)
31
-
32
- **Note:** Version bump only for package @tiptap/extension-image
33
-
34
-
35
-
36
-
37
-
38
- # [2.0.0-alpha.9](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-image@2.0.0-alpha.8...@tiptap/extension-image@2.0.0-alpha.9) (2021-02-05)
39
-
40
- **Note:** Version bump only for package @tiptap/extension-image
41
-
42
-
43
-
44
-
45
-
46
- # [2.0.0-alpha.8](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-image@2.0.0-alpha.7...@tiptap/extension-image@2.0.0-alpha.8) (2021-01-29)
47
-
48
- **Note:** Version bump only for package @tiptap/extension-image
49
-
50
-
51
-
52
-
53
-
54
- # [2.0.0-alpha.7](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-image@2.0.0-alpha.6...@tiptap/extension-image@2.0.0-alpha.7) (2021-01-29)
55
-
56
- **Note:** Version bump only for package @tiptap/extension-image
57
-
58
-
59
-
60
-
61
-
62
- # [2.0.0-alpha.6](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-image@2.0.0-alpha.5...@tiptap/extension-image@2.0.0-alpha.6) (2021-01-28)
63
-
64
- **Note:** Version bump only for package @tiptap/extension-image
65
-
66
-
67
-
68
-
69
-
70
- # [2.0.0-alpha.5](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-image@2.0.0-alpha.4...@tiptap/extension-image@2.0.0-alpha.5) (2020-12-18)
71
-
72
- **Note:** Version bump only for package @tiptap/extension-image
73
-
74
-
75
-
76
-
77
-
78
- # [2.0.0-alpha.4](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-image@2.0.0-alpha.3...@tiptap/extension-image@2.0.0-alpha.4) (2020-12-02)
79
-
80
- **Note:** Version bump only for package @tiptap/extension-image
81
-
82
-
83
-
84
-
85
-
86
- # [2.0.0-alpha.3](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-image@2.0.0-alpha.2...@tiptap/extension-image@2.0.0-alpha.3) (2020-11-19)
87
-
88
- **Note:** Version bump only for package @tiptap/extension-image
89
-
90
-
91
-
92
-
93
-
94
- # [2.0.0-alpha.2](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-image@2.0.0-alpha.1...@tiptap/extension-image@2.0.0-alpha.2) (2020-11-19)
95
-
96
- **Note:** Version bump only for package @tiptap/extension-image
97
-
98
-
99
-
100
-
101
-
102
- # [2.0.0-alpha.1](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-image@1.0.0-alpha.2...@tiptap/extension-image@2.0.0-alpha.1) (2020-11-18)
103
-
104
- **Note:** Version bump only for package @tiptap/extension-image
105
-
106
-
107
-
108
-
109
-
110
- # [1.0.0-alpha.2](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-image@1.0.0-alpha.1...@tiptap/extension-image@1.0.0-alpha.2) (2020-11-16)
111
-
112
- **Note:** Version bump only for package @tiptap/extension-image
113
-
114
-
115
-
116
-
117
-
118
- # 1.0.0-alpha.1 (2020-11-16)
119
-
120
-
121
- ### Reverts
122
-
123
- * Revert "use global namespace" ([0c9ce26](https://github.com/ueberdosis/tiptap-next/commit/0c9ce26c02c07d88a757c01b0a9d7f9e2b0b7502))
@@ -1,23 +0,0 @@
1
- import { Command, Node } from '@tiptap/core';
2
- export interface ImageOptions {
3
- inline: boolean;
4
- HTMLAttributes: {
5
- [key: string]: any;
6
- };
7
- }
8
- declare module '@tiptap/core' {
9
- interface Commands {
10
- image: {
11
- /**
12
- * Add an image
13
- */
14
- setImage: (options: {
15
- src: string;
16
- alt?: string;
17
- title?: string;
18
- }) => Command;
19
- };
20
- }
21
- }
22
- export declare const inputRegex: RegExp;
23
- export declare const Image: Node<ImageOptions>;
@@ -1,3 +0,0 @@
1
- import { Image } from './image';
2
- export * from './image';
3
- export default Image;
@@ -1,2 +0,0 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@tiptap/core")):"function"==typeof define&&define.amd?define(["exports","@tiptap/core"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["@tiptap/extension-image"]={},e["@tiptap/core"])}(this,(function(e,t){"use strict";const i=/!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\)/,n=t.Node.create({name:"image",defaultOptions:{inline:!1,HTMLAttributes:{}},inline(){return this.options.inline},group(){return this.options.inline?"inline":"block"},draggable:!0,addAttributes:()=>({src:{default:null},alt:{default:null},title:{default:null}}),parseHTML:()=>[{tag:"img[src]"}],renderHTML({HTMLAttributes:e}){return["img",t.mergeAttributes(this.options.HTMLAttributes,e)]},addCommands(){return{setImage:e=>({tr:t,dispatch:i})=>{const{selection:n}=t,r=this.type.create(e);return i&&t.replaceRangeWith(n.from,n.to,r),!0}}},addInputRules(){return[t.nodeInputRule(i,this.type,(e=>{const[,t,i,n]=e;return{src:i,alt:t,title:n}}))]}});e.Image=n,e.default=n,e.inputRegex=i,Object.defineProperty(e,"__esModule",{value:!0})}));
2
- //# sourceMappingURL=tiptap-extension-image.bundle.umd.min.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tiptap-extension-image.bundle.umd.min.js","sources":["../src/image.ts"],"sourcesContent":["import {\n Command,\n Node,\n nodeInputRule,\n mergeAttributes,\n} from '@tiptap/core'\n\nexport interface ImageOptions {\n inline: boolean,\n HTMLAttributes: {\n [key: string]: any\n },\n}\n\ndeclare module '@tiptap/core' {\n interface Commands {\n image: {\n /**\n * Add an image\n */\n setImage: (options: { src: string, alt?: string, title?: string }) => Command,\n }\n }\n}\n\nexport const inputRegex = /!\\[(.+|:?)]\\((\\S+)(?:(?:\\s+)[\"'](\\S+)[\"'])?\\)/\n\nexport const Image = Node.create<ImageOptions>({\n name: 'image',\n\n defaultOptions: {\n inline: false,\n HTMLAttributes: {},\n },\n\n inline() {\n return this.options.inline\n },\n\n group() {\n return this.options.inline ? 'inline' : 'block'\n },\n\n draggable: true,\n\n addAttributes() {\n return {\n src: {\n default: null,\n },\n alt: {\n default: null,\n },\n title: {\n default: null,\n },\n }\n },\n\n parseHTML() {\n return [\n {\n tag: 'img[src]',\n },\n ]\n },\n\n renderHTML({ HTMLAttributes }) {\n return ['img', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes)]\n },\n\n addCommands() {\n return {\n setImage: options => ({ tr, dispatch }) => {\n const { selection } = tr\n const node = this.type.create(options)\n\n if (dispatch) {\n tr.replaceRangeWith(selection.from, selection.to, node)\n }\n\n return true\n },\n }\n },\n\n addInputRules() {\n return [\n nodeInputRule(inputRegex, this.type, match => {\n const [, alt, src, title] = match\n\n return { src, alt, title }\n }),\n ]\n },\n})\n"],"names":["inputRegex","Image","Node","create","name","defaultOptions","inline","HTMLAttributes","[object Object]","this","options","draggable","addAttributes","src","default","alt","title","parseHTML","tag","mergeAttributes","setImage","tr","dispatch","selection","node","type","replaceRangeWith","from","to","nodeInputRule","match"],"mappings":"mUAyBaA,EAAa,gDAEbC,EAAQC,OAAKC,OAAqB,CAC7CC,KAAM,QAENC,eAAgB,CACdC,QAAQ,EACRC,eAAgB,IAGlBC,SACE,OAAOC,KAAKC,QAAQJ,QAGtBE,QACE,OAAOC,KAAKC,QAAQJ,OAAS,SAAW,SAG1CK,WAAW,EAEXC,cAAa,KACJ,CACLC,IAAK,CACHC,QAAS,MAEXC,IAAK,CACHD,QAAS,MAEXE,MAAO,CACLF,QAAS,QAKfG,UAAS,IACA,CACL,CACEC,IAAK,aAKXV,YAAWD,eAAEA,IACX,MAAO,CAAC,MAAOY,kBAAgBV,KAAKC,QAAQH,eAAgBA,KAG9DC,cACE,MAAO,CACLY,SAAUV,GAAW,EAAGW,GAAAA,EAAIC,SAAAA,MAC1B,MAAMC,UAAEA,GAAcF,EAChBG,EAAOf,KAAKgB,KAAKtB,OAAOO,GAM9B,OAJIY,GACFD,EAAGK,iBAAiBH,EAAUI,KAAMJ,EAAUK,GAAIJ,IAG7C,KAKbhB,gBACE,MAAO,CACLqB,gBAAc7B,EAAYS,KAAKgB,MAAMK,IACnC,OAASf,EAAKF,EAAKG,GAASc,EAE5B,MAAO,CAAEjB,IAAAA,EAAKE,IAAAA,EAAKC,MAAAA"}
@@ -1,69 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var core = require('@tiptap/core');
6
-
7
- const inputRegex = /!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\)/;
8
- const Image = core.Node.create({
9
- name: 'image',
10
- defaultOptions: {
11
- inline: false,
12
- HTMLAttributes: {},
13
- },
14
- inline() {
15
- return this.options.inline;
16
- },
17
- group() {
18
- return this.options.inline ? 'inline' : 'block';
19
- },
20
- draggable: true,
21
- addAttributes() {
22
- return {
23
- src: {
24
- default: null,
25
- },
26
- alt: {
27
- default: null,
28
- },
29
- title: {
30
- default: null,
31
- },
32
- };
33
- },
34
- parseHTML() {
35
- return [
36
- {
37
- tag: 'img[src]',
38
- },
39
- ];
40
- },
41
- renderHTML({ HTMLAttributes }) {
42
- return ['img', core.mergeAttributes(this.options.HTMLAttributes, HTMLAttributes)];
43
- },
44
- addCommands() {
45
- return {
46
- setImage: options => ({ tr, dispatch }) => {
47
- const { selection } = tr;
48
- const node = this.type.create(options);
49
- if (dispatch) {
50
- tr.replaceRangeWith(selection.from, selection.to, node);
51
- }
52
- return true;
53
- },
54
- };
55
- },
56
- addInputRules() {
57
- return [
58
- core.nodeInputRule(inputRegex, this.type, match => {
59
- const [, alt, src, title] = match;
60
- return { src, alt, title };
61
- }),
62
- ];
63
- },
64
- });
65
-
66
- exports.Image = Image;
67
- exports.default = Image;
68
- exports.inputRegex = inputRegex;
69
- //# sourceMappingURL=tiptap-extension-image.cjs.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tiptap-extension-image.cjs.js","sources":["../src/image.ts"],"sourcesContent":["import {\n Command,\n Node,\n nodeInputRule,\n mergeAttributes,\n} from '@tiptap/core'\n\nexport interface ImageOptions {\n inline: boolean,\n HTMLAttributes: {\n [key: string]: any\n },\n}\n\ndeclare module '@tiptap/core' {\n interface Commands {\n image: {\n /**\n * Add an image\n */\n setImage: (options: { src: string, alt?: string, title?: string }) => Command,\n }\n }\n}\n\nexport const inputRegex = /!\\[(.+|:?)]\\((\\S+)(?:(?:\\s+)[\"'](\\S+)[\"'])?\\)/\n\nexport const Image = Node.create<ImageOptions>({\n name: 'image',\n\n defaultOptions: {\n inline: false,\n HTMLAttributes: {},\n },\n\n inline() {\n return this.options.inline\n },\n\n group() {\n return this.options.inline ? 'inline' : 'block'\n },\n\n draggable: true,\n\n addAttributes() {\n return {\n src: {\n default: null,\n },\n alt: {\n default: null,\n },\n title: {\n default: null,\n },\n }\n },\n\n parseHTML() {\n return [\n {\n tag: 'img[src]',\n },\n ]\n },\n\n renderHTML({ HTMLAttributes }) {\n return ['img', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes)]\n },\n\n addCommands() {\n return {\n setImage: options => ({ tr, dispatch }) => {\n const { selection } = tr\n const node = this.type.create(options)\n\n if (dispatch) {\n tr.replaceRangeWith(selection.from, selection.to, node)\n }\n\n return true\n },\n }\n },\n\n addInputRules() {\n return [\n nodeInputRule(inputRegex, this.type, match => {\n const [, alt, src, title] = match\n\n return { src, alt, title }\n }),\n ]\n },\n})\n"],"names":["Node","mergeAttributes","nodeInputRule"],"mappings":";;;;;;MAyBa,UAAU,GAAG,gDAA+C;MAE5D,KAAK,GAAGA,SAAI,CAAC,MAAM,CAAe;IAC7C,IAAI,EAAE,OAAO;IAEb,cAAc,EAAE;QACd,MAAM,EAAE,KAAK;QACb,cAAc,EAAE,EAAE;KACnB;IAED,MAAM;QACJ,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAA;KAC3B;IAED,KAAK;QACH,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAA;KAChD;IAED,SAAS,EAAE,IAAI;IAEf,aAAa;QACX,OAAO;YACL,GAAG,EAAE;gBACH,OAAO,EAAE,IAAI;aACd;YACD,GAAG,EAAE;gBACH,OAAO,EAAE,IAAI;aACd;YACD,KAAK,EAAE;gBACL,OAAO,EAAE,IAAI;aACd;SACF,CAAA;KACF;IAED,SAAS;QACP,OAAO;YACL;gBACE,GAAG,EAAE,UAAU;aAChB;SACF,CAAA;KACF;IAED,UAAU,CAAC,EAAE,cAAc,EAAE;QAC3B,OAAO,CAAC,KAAK,EAAEC,oBAAe,CAAC,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE,cAAc,CAAC,CAAC,CAAA;KAC7E;IAED,WAAW;QACT,OAAO;YACL,QAAQ,EAAE,OAAO,IAAI,CAAC,EAAE,EAAE,EAAE,QAAQ,EAAE;gBACpC,MAAM,EAAE,SAAS,EAAE,GAAG,EAAE,CAAA;gBACxB,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;gBAEtC,IAAI,QAAQ,EAAE;oBACZ,EAAE,CAAC,gBAAgB,CAAC,SAAS,CAAC,IAAI,EAAE,SAAS,CAAC,EAAE,EAAE,IAAI,CAAC,CAAA;iBACxD;gBAED,OAAO,IAAI,CAAA;aACZ;SACF,CAAA;KACF;IAED,aAAa;QACX,OAAO;YACLC,kBAAa,CAAC,UAAU,EAAE,IAAI,CAAC,IAAI,EAAE,KAAK;gBACxC,MAAM,GAAG,GAAG,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,KAAK,CAAA;gBAEjC,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,CAAA;aAC3B,CAAC;SACH,CAAA;KACF;CACF;;;;;;"}
@@ -1,64 +0,0 @@
1
- import { Node, mergeAttributes, nodeInputRule } from '@tiptap/core';
2
-
3
- const inputRegex = /!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\)/;
4
- const Image = Node.create({
5
- name: 'image',
6
- defaultOptions: {
7
- inline: false,
8
- HTMLAttributes: {},
9
- },
10
- inline() {
11
- return this.options.inline;
12
- },
13
- group() {
14
- return this.options.inline ? 'inline' : 'block';
15
- },
16
- draggable: true,
17
- addAttributes() {
18
- return {
19
- src: {
20
- default: null,
21
- },
22
- alt: {
23
- default: null,
24
- },
25
- title: {
26
- default: null,
27
- },
28
- };
29
- },
30
- parseHTML() {
31
- return [
32
- {
33
- tag: 'img[src]',
34
- },
35
- ];
36
- },
37
- renderHTML({ HTMLAttributes }) {
38
- return ['img', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes)];
39
- },
40
- addCommands() {
41
- return {
42
- setImage: options => ({ tr, dispatch }) => {
43
- const { selection } = tr;
44
- const node = this.type.create(options);
45
- if (dispatch) {
46
- tr.replaceRangeWith(selection.from, selection.to, node);
47
- }
48
- return true;
49
- },
50
- };
51
- },
52
- addInputRules() {
53
- return [
54
- nodeInputRule(inputRegex, this.type, match => {
55
- const [, alt, src, title] = match;
56
- return { src, alt, title };
57
- }),
58
- ];
59
- },
60
- });
61
-
62
- export default Image;
63
- export { Image, inputRegex };
64
- //# sourceMappingURL=tiptap-extension-image.esm.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tiptap-extension-image.esm.js","sources":["../src/image.ts"],"sourcesContent":["import {\n Command,\n Node,\n nodeInputRule,\n mergeAttributes,\n} from '@tiptap/core'\n\nexport interface ImageOptions {\n inline: boolean,\n HTMLAttributes: {\n [key: string]: any\n },\n}\n\ndeclare module '@tiptap/core' {\n interface Commands {\n image: {\n /**\n * Add an image\n */\n setImage: (options: { src: string, alt?: string, title?: string }) => Command,\n }\n }\n}\n\nexport const inputRegex = /!\\[(.+|:?)]\\((\\S+)(?:(?:\\s+)[\"'](\\S+)[\"'])?\\)/\n\nexport const Image = Node.create<ImageOptions>({\n name: 'image',\n\n defaultOptions: {\n inline: false,\n HTMLAttributes: {},\n },\n\n inline() {\n return this.options.inline\n },\n\n group() {\n return this.options.inline ? 'inline' : 'block'\n },\n\n draggable: true,\n\n addAttributes() {\n return {\n src: {\n default: null,\n },\n alt: {\n default: null,\n },\n title: {\n default: null,\n },\n }\n },\n\n parseHTML() {\n return [\n {\n tag: 'img[src]',\n },\n ]\n },\n\n renderHTML({ HTMLAttributes }) {\n return ['img', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes)]\n },\n\n addCommands() {\n return {\n setImage: options => ({ tr, dispatch }) => {\n const { selection } = tr\n const node = this.type.create(options)\n\n if (dispatch) {\n tr.replaceRangeWith(selection.from, selection.to, node)\n }\n\n return true\n },\n }\n },\n\n addInputRules() {\n return [\n nodeInputRule(inputRegex, this.type, match => {\n const [, alt, src, title] = match\n\n return { src, alt, title }\n }),\n ]\n },\n})\n"],"names":[],"mappings":";;MAyBa,UAAU,GAAG,gDAA+C;MAE5D,KAAK,GAAG,IAAI,CAAC,MAAM,CAAe;IAC7C,IAAI,EAAE,OAAO;IAEb,cAAc,EAAE;QACd,MAAM,EAAE,KAAK;QACb,cAAc,EAAE,EAAE;KACnB;IAED,MAAM;QACJ,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAA;KAC3B;IAED,KAAK;QACH,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAA;KAChD;IAED,SAAS,EAAE,IAAI;IAEf,aAAa;QACX,OAAO;YACL,GAAG,EAAE;gBACH,OAAO,EAAE,IAAI;aACd;YACD,GAAG,EAAE;gBACH,OAAO,EAAE,IAAI;aACd;YACD,KAAK,EAAE;gBACL,OAAO,EAAE,IAAI;aACd;SACF,CAAA;KACF;IAED,SAAS;QACP,OAAO;YACL;gBACE,GAAG,EAAE,UAAU;aAChB;SACF,CAAA;KACF;IAED,UAAU,CAAC,EAAE,cAAc,EAAE;QAC3B,OAAO,CAAC,KAAK,EAAE,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE,cAAc,CAAC,CAAC,CAAA;KAC7E;IAED,WAAW;QACT,OAAO;YACL,QAAQ,EAAE,OAAO,IAAI,CAAC,EAAE,EAAE,EAAE,QAAQ,EAAE;gBACpC,MAAM,EAAE,SAAS,EAAE,GAAG,EAAE,CAAA;gBACxB,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;gBAEtC,IAAI,QAAQ,EAAE;oBACZ,EAAE,CAAC,gBAAgB,CAAC,SAAS,CAAC,IAAI,EAAE,SAAS,CAAC,EAAE,EAAE,IAAI,CAAC,CAAA;iBACxD;gBAED,OAAO,IAAI,CAAA;aACZ;SACF,CAAA;KACF;IAED,aAAa;QACX,OAAO;YACL,aAAa,CAAC,UAAU,EAAE,IAAI,CAAC,IAAI,EAAE,KAAK;gBACxC,MAAM,GAAG,GAAG,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,KAAK,CAAA;gBAEjC,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,CAAA;aAC3B,CAAC;SACH,CAAA;KACF;CACF;;;;;"}
@@ -1,73 +0,0 @@
1
- (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@tiptap/core')) :
3
- typeof define === 'function' && define.amd ? define(['exports', '@tiptap/core'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global['@tiptap/extension-image'] = {}, global.core));
5
- }(this, (function (exports, core) { 'use strict';
6
-
7
- const inputRegex = /!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\)/;
8
- const Image = core.Node.create({
9
- name: 'image',
10
- defaultOptions: {
11
- inline: false,
12
- HTMLAttributes: {},
13
- },
14
- inline() {
15
- return this.options.inline;
16
- },
17
- group() {
18
- return this.options.inline ? 'inline' : 'block';
19
- },
20
- draggable: true,
21
- addAttributes() {
22
- return {
23
- src: {
24
- default: null,
25
- },
26
- alt: {
27
- default: null,
28
- },
29
- title: {
30
- default: null,
31
- },
32
- };
33
- },
34
- parseHTML() {
35
- return [
36
- {
37
- tag: 'img[src]',
38
- },
39
- ];
40
- },
41
- renderHTML({ HTMLAttributes }) {
42
- return ['img', core.mergeAttributes(this.options.HTMLAttributes, HTMLAttributes)];
43
- },
44
- addCommands() {
45
- return {
46
- setImage: options => ({ tr, dispatch }) => {
47
- const { selection } = tr;
48
- const node = this.type.create(options);
49
- if (dispatch) {
50
- tr.replaceRangeWith(selection.from, selection.to, node);
51
- }
52
- return true;
53
- },
54
- };
55
- },
56
- addInputRules() {
57
- return [
58
- core.nodeInputRule(inputRegex, this.type, match => {
59
- const [, alt, src, title] = match;
60
- return { src, alt, title };
61
- }),
62
- ];
63
- },
64
- });
65
-
66
- exports.Image = Image;
67
- exports.default = Image;
68
- exports.inputRegex = inputRegex;
69
-
70
- Object.defineProperty(exports, '__esModule', { value: true });
71
-
72
- })));
73
- //# sourceMappingURL=tiptap-extension-image.umd.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tiptap-extension-image.umd.js","sources":["../src/image.ts"],"sourcesContent":["import {\n Command,\n Node,\n nodeInputRule,\n mergeAttributes,\n} from '@tiptap/core'\n\nexport interface ImageOptions {\n inline: boolean,\n HTMLAttributes: {\n [key: string]: any\n },\n}\n\ndeclare module '@tiptap/core' {\n interface Commands {\n image: {\n /**\n * Add an image\n */\n setImage: (options: { src: string, alt?: string, title?: string }) => Command,\n }\n }\n}\n\nexport const inputRegex = /!\\[(.+|:?)]\\((\\S+)(?:(?:\\s+)[\"'](\\S+)[\"'])?\\)/\n\nexport const Image = Node.create<ImageOptions>({\n name: 'image',\n\n defaultOptions: {\n inline: false,\n HTMLAttributes: {},\n },\n\n inline() {\n return this.options.inline\n },\n\n group() {\n return this.options.inline ? 'inline' : 'block'\n },\n\n draggable: true,\n\n addAttributes() {\n return {\n src: {\n default: null,\n },\n alt: {\n default: null,\n },\n title: {\n default: null,\n },\n }\n },\n\n parseHTML() {\n return [\n {\n tag: 'img[src]',\n },\n ]\n },\n\n renderHTML({ HTMLAttributes }) {\n return ['img', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes)]\n },\n\n addCommands() {\n return {\n setImage: options => ({ tr, dispatch }) => {\n const { selection } = tr\n const node = this.type.create(options)\n\n if (dispatch) {\n tr.replaceRangeWith(selection.from, selection.to, node)\n }\n\n return true\n },\n }\n },\n\n addInputRules() {\n return [\n nodeInputRule(inputRegex, this.type, match => {\n const [, alt, src, title] = match\n\n return { src, alt, title }\n }),\n ]\n },\n})\n"],"names":["Node","mergeAttributes","nodeInputRule"],"mappings":";;;;;;QAyBa,UAAU,GAAG,gDAA+C;QAE5D,KAAK,GAAGA,SAAI,CAAC,MAAM,CAAe;MAC7C,IAAI,EAAE,OAAO;MAEb,cAAc,EAAE;UACd,MAAM,EAAE,KAAK;UACb,cAAc,EAAE,EAAE;OACnB;MAED,MAAM;UACJ,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAA;OAC3B;MAED,KAAK;UACH,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAA;OAChD;MAED,SAAS,EAAE,IAAI;MAEf,aAAa;UACX,OAAO;cACL,GAAG,EAAE;kBACH,OAAO,EAAE,IAAI;eACd;cACD,GAAG,EAAE;kBACH,OAAO,EAAE,IAAI;eACd;cACD,KAAK,EAAE;kBACL,OAAO,EAAE,IAAI;eACd;WACF,CAAA;OACF;MAED,SAAS;UACP,OAAO;cACL;kBACE,GAAG,EAAE,UAAU;eAChB;WACF,CAAA;OACF;MAED,UAAU,CAAC,EAAE,cAAc,EAAE;UAC3B,OAAO,CAAC,KAAK,EAAEC,oBAAe,CAAC,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE,cAAc,CAAC,CAAC,CAAA;OAC7E;MAED,WAAW;UACT,OAAO;cACL,QAAQ,EAAE,OAAO,IAAI,CAAC,EAAE,EAAE,EAAE,QAAQ,EAAE;kBACpC,MAAM,EAAE,SAAS,EAAE,GAAG,EAAE,CAAA;kBACxB,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;kBAEtC,IAAI,QAAQ,EAAE;sBACZ,EAAE,CAAC,gBAAgB,CAAC,SAAS,CAAC,IAAI,EAAE,SAAS,CAAC,EAAE,EAAE,IAAI,CAAC,CAAA;mBACxD;kBAED,OAAO,IAAI,CAAA;eACZ;WACF,CAAA;OACF;MAED,aAAa;UACX,OAAO;cACLC,kBAAa,CAAC,UAAU,EAAE,IAAI,CAAC,IAAI,EAAE,KAAK;kBACxC,MAAM,GAAG,GAAG,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,KAAK,CAAA;kBAEjC,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,CAAA;eAC3B,CAAC;WACH,CAAA;OACF;GACF;;;;;;;;;;;;"}