@edifice.io/tiptap-extensions 2.0.0-develop-rc.13 → 2.0.0-develop-rc.15
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/README.md +8 -5
- package/dist/abbr/abbr.cjs +1 -32
- package/dist/abbr/abbr.cjs.map +1 -1
- package/dist/abbr/abbr.d.ts +13 -13
- package/dist/abbr/abbr.js +13 -17
- package/dist/abbr/abbr.js.map +1 -1
- package/dist/alert/alert.cjs +1 -32
- package/dist/alert/alert.cjs.map +1 -1
- package/dist/alert/alert.js +22 -20
- package/dist/alert/alert.js.map +1 -1
- package/dist/attachment/attachment-transformer.cjs +2 -0
- package/dist/attachment/attachment-transformer.cjs.map +1 -0
- package/dist/attachment/attachment-transformer.d.ts +12 -0
- package/dist/attachment/attachment-transformer.js +76 -0
- package/dist/attachment/attachment-transformer.js.map +1 -0
- package/dist/attachment/attachment.cjs +1 -73
- package/dist/attachment/attachment.cjs.map +1 -1
- package/dist/attachment/attachment.d.ts +7 -7
- package/dist/attachment/attachment.js +29 -40
- package/dist/attachment/attachment.js.map +1 -1
- package/dist/attachment/index.d.ts +1 -0
- package/dist/audio/audio.cjs +2 -52
- package/dist/audio/audio.cjs.map +1 -1
- package/dist/audio/audio.d.ts +14 -18
- package/dist/audio/audio.js +25 -28
- package/dist/audio/audio.js.map +1 -1
- package/dist/font-size/font-size.cjs +1 -48
- package/dist/font-size/font-size.cjs.map +1 -1
- package/dist/font-size/font-size.d.ts +14 -14
- package/dist/font-size/font-size.js +17 -29
- package/dist/font-size/font-size.js.map +1 -1
- package/dist/heading/heading.cjs +1 -61
- package/dist/heading/heading.cjs.map +1 -1
- package/dist/heading/heading.d.ts +13 -11
- package/dist/heading/heading.js +25 -39
- package/dist/heading/heading.js.map +1 -1
- package/dist/highlight/highlight.cjs +1 -25
- package/dist/highlight/highlight.cjs.map +1 -1
- package/dist/highlight/highlight.d.ts +1 -4
- package/dist/highlight/highlight.js +13 -11
- package/dist/highlight/highlight.js.map +1 -1
- package/dist/hyperlink/hyperlink.cjs +1 -47
- package/dist/hyperlink/hyperlink.cjs.map +1 -1
- package/dist/hyperlink/hyperlink.d.ts +25 -28
- package/dist/hyperlink/hyperlink.js +19 -21
- package/dist/hyperlink/hyperlink.js.map +1 -1
- package/dist/iframe/iframe.cjs +1 -69
- package/dist/iframe/iframe.cjs.map +1 -1
- package/dist/iframe/iframe.d.ts +15 -13
- package/dist/iframe/iframe.js +32 -48
- package/dist/iframe/iframe.js.map +1 -1
- package/dist/image/image.cjs +2 -0
- package/dist/image/image.cjs.map +1 -0
- package/dist/image/image.d.ts +26 -0
- package/dist/image/image.js +178 -0
- package/dist/image/image.js.map +1 -0
- package/dist/image/index.d.ts +3 -3
- package/dist/index.cjs +1 -43
- package/dist/index.js +24 -22
- package/dist/index.js.map +1 -1
- package/dist/line-height/line-height.cjs +1 -33
- package/dist/line-height/line-height.cjs.map +1 -1
- package/dist/line-height/line-height.js +15 -18
- package/dist/line-height/line-height.js.map +1 -1
- package/dist/linker/linker.cjs +1 -95
- package/dist/linker/linker.cjs.map +1 -1
- package/dist/linker/linker.d.ts +18 -18
- package/dist/linker/linker.js +49 -57
- package/dist/linker/linker.js.map +1 -1
- package/dist/mathjax/mathjax.cjs +1 -47
- package/dist/mathjax/mathjax.cjs.map +1 -1
- package/dist/mathjax/mathjax.js +20 -30
- package/dist/mathjax/mathjax.js.map +1 -1
- package/dist/paragraph/paragraph.cjs +1 -13
- package/dist/paragraph/paragraph.cjs.map +1 -1
- package/dist/paragraph/paragraph.d.ts +1 -4
- package/dist/paragraph/paragraph.js +8 -6
- package/dist/paragraph/paragraph.js.map +1 -1
- package/dist/speech-recognition/speech-recognition.cjs +1 -76
- package/dist/speech-recognition/speech-recognition.cjs.map +1 -1
- package/dist/speech-recognition/speech-recognition.d.ts +13 -13
- package/dist/speech-recognition/speech-recognition.js +36 -57
- package/dist/speech-recognition/speech-recognition.js.map +1 -1
- package/dist/speech-synthesis/speech-synthesis.cjs +1 -32
- package/dist/speech-synthesis/speech-synthesis.cjs.map +1 -1
- package/dist/speech-synthesis/speech-synthesis.d.ts +10 -10
- package/dist/speech-synthesis/speech-synthesis.js +10 -19
- package/dist/speech-synthesis/speech-synthesis.js.map +1 -1
- package/dist/table-cell/table-cell.cjs +1 -27
- package/dist/table-cell/table-cell.cjs.map +1 -1
- package/dist/table-cell/table-cell.d.ts +1 -4
- package/dist/table-cell/table-cell.js +12 -17
- package/dist/table-cell/table-cell.js.map +1 -1
- package/dist/transform/html-to-json/html-to-json.cjs +1 -4
- package/dist/transform/html-to-json/html-to-json.cjs.map +1 -1
- package/dist/transform/html-to-json/html-to-json.d.ts +1 -4
- package/dist/transform/html-to-json/html-to-json.js +4 -2
- package/dist/transform/html-to-json/html-to-json.js.map +1 -1
- package/dist/transform/json-to-html/json-to-html.cjs +1 -4
- package/dist/transform/json-to-html/json-to-html.cjs.map +1 -1
- package/dist/transform/json-to-html/json-to-html.js +4 -2
- package/dist/transform/json-to-html/json-to-html.js.map +1 -1
- package/dist/video/video.cjs +2 -111
- package/dist/video/video.cjs.map +1 -1
- package/dist/video/video.d.ts +20 -29
- package/dist/video/video.js +90 -114
- package/dist/video/video.js.map +1 -1
- package/package.json +24 -16
- package/dist/image/custom-image.cjs +0 -163
- package/dist/image/custom-image.cjs.map +0 -1
- package/dist/image/custom-image.d.ts +0 -27
- package/dist/image/custom-image.js +0 -181
- package/dist/image/custom-image.js.map +0 -1
package/dist/iframe/iframe.js
CHANGED
|
@@ -1,85 +1,69 @@
|
|
|
1
|
-
import { Node } from
|
|
1
|
+
import { Node } from "@tiptap/core";
|
|
2
2
|
const Iframe = Node.create({
|
|
3
|
-
name:
|
|
4
|
-
group:
|
|
3
|
+
name: "iframe",
|
|
4
|
+
group: "block",
|
|
5
5
|
atom: !0,
|
|
6
6
|
draggable: !0,
|
|
7
7
|
addOptions() {
|
|
8
8
|
return {
|
|
9
9
|
allowFullscreen: !0,
|
|
10
10
|
HTMLAttributes: {
|
|
11
|
-
class:
|
|
12
|
-
}
|
|
11
|
+
class: "iframe-wrapper"
|
|
12
|
+
}
|
|
13
13
|
};
|
|
14
14
|
},
|
|
15
15
|
addAttributes() {
|
|
16
16
|
return {
|
|
17
17
|
src: {
|
|
18
|
-
default: null
|
|
18
|
+
default: null
|
|
19
19
|
},
|
|
20
20
|
frameborder: {
|
|
21
|
-
default: 0
|
|
21
|
+
default: 0
|
|
22
22
|
},
|
|
23
23
|
allowfullscreen: {
|
|
24
24
|
default: this.options.allowFullscreen,
|
|
25
|
-
parseHTML: () => this.options.allowFullscreen
|
|
25
|
+
parseHTML: () => this.options.allowFullscreen
|
|
26
26
|
},
|
|
27
27
|
width: {
|
|
28
|
-
renderHTML: (attributes) =>
|
|
29
|
-
attributes.width
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
attributes.width === '100%'
|
|
33
|
-
? '100%'
|
|
34
|
-
: parseInt(attributes.width),
|
|
35
|
-
}
|
|
36
|
-
: {},
|
|
37
|
-
parseHTML: (element) => element.getAttribute('width'),
|
|
28
|
+
renderHTML: (attributes) => attributes.width ? {
|
|
29
|
+
width: attributes.width === "100%" ? "100%" : parseInt(attributes.width)
|
|
30
|
+
} : {},
|
|
31
|
+
parseHTML: (element) => element.getAttribute("width")
|
|
38
32
|
},
|
|
39
33
|
height: {
|
|
40
|
-
renderHTML: (attributes) =>
|
|
41
|
-
attributes.height
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
: {},
|
|
46
|
-
parseHTML: (element) => element.getAttribute('height'),
|
|
34
|
+
renderHTML: (attributes) => attributes.height ? {
|
|
35
|
+
height: parseInt(attributes.height)
|
|
36
|
+
} : {},
|
|
37
|
+
parseHTML: (element) => element.getAttribute("height")
|
|
47
38
|
},
|
|
48
39
|
style: {
|
|
49
|
-
renderHTML: (attributes) =>
|
|
50
|
-
attributes.style
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
: {},
|
|
55
|
-
parseHTML: (element) => element.getAttribute('style'),
|
|
56
|
-
},
|
|
40
|
+
renderHTML: (attributes) => attributes.style ? {
|
|
41
|
+
style: attributes.style
|
|
42
|
+
} : {},
|
|
43
|
+
parseHTML: (element) => element.getAttribute("style")
|
|
44
|
+
}
|
|
57
45
|
};
|
|
58
46
|
},
|
|
59
47
|
parseHTML() {
|
|
60
48
|
return [
|
|
61
49
|
{
|
|
62
|
-
tag:
|
|
63
|
-
}
|
|
50
|
+
tag: "iframe"
|
|
51
|
+
}
|
|
64
52
|
];
|
|
65
53
|
},
|
|
66
54
|
renderHTML({ HTMLAttributes }) {
|
|
67
|
-
return [
|
|
55
|
+
return ["div", this.options.HTMLAttributes, ["iframe", HTMLAttributes]];
|
|
68
56
|
},
|
|
69
57
|
addCommands() {
|
|
70
58
|
return {
|
|
71
|
-
setIframe:
|
|
72
|
-
(options)
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
node = this.type.create(options);
|
|
76
|
-
return (
|
|
77
|
-
dispatch && tr.replaceRangeWith(selection.from, selection.to, node),
|
|
78
|
-
!0
|
|
79
|
-
);
|
|
80
|
-
},
|
|
59
|
+
setIframe: (options) => ({ tr, dispatch }) => {
|
|
60
|
+
const { selection } = tr, node = this.type.create(options);
|
|
61
|
+
return dispatch && tr.replaceRangeWith(selection.from, selection.to, node), !0;
|
|
62
|
+
}
|
|
81
63
|
};
|
|
82
|
-
}
|
|
64
|
+
}
|
|
83
65
|
});
|
|
84
|
-
export {
|
|
66
|
+
export {
|
|
67
|
+
Iframe
|
|
68
|
+
};
|
|
85
69
|
//# sourceMappingURL=iframe.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"iframe.js","sources":["../../src/iframe/iframe.ts"],"sourcesContent":["import { Node } from
|
|
1
|
+
{"version":3,"file":"iframe.js","sources":["../../src/iframe/iframe.ts"],"sourcesContent":["import { Node } from \"@tiptap/core\";\n\nexport interface IframeOptions {\n allowFullscreen: boolean;\n HTMLAttributes: {\n [key: string]: any;\n };\n}\n\ndeclare module \"@tiptap/core\" {\n interface Commands<ReturnType> {\n iframe: {\n /**\n * Add an iframe\n */\n setIframe: (options: { src: string }) => ReturnType;\n };\n }\n}\n\nexport const Iframe = Node.create<IframeOptions>({\n name: \"iframe\",\n group: \"block\",\n atom: true,\n draggable: true,\n\n addOptions() {\n return {\n allowFullscreen: true,\n HTMLAttributes: {\n class: \"iframe-wrapper\",\n },\n };\n },\n\n addAttributes() {\n return {\n src: {\n default: null,\n },\n frameborder: {\n default: 0,\n },\n allowfullscreen: {\n default: this.options.allowFullscreen,\n parseHTML: () => this.options.allowFullscreen,\n },\n width: {\n renderHTML: (attributes) => {\n return attributes.width\n ? {\n width:\n attributes.width === \"100%\"\n ? \"100%\"\n : parseInt(attributes.width),\n }\n : {};\n },\n parseHTML: (element) => element.getAttribute(\"width\"),\n },\n height: {\n renderHTML: (attributes) => {\n return attributes.height\n ? {\n height: parseInt(attributes.height),\n }\n : {};\n },\n parseHTML: (element) => element.getAttribute(\"height\"),\n },\n style: {\n renderHTML: (attributes) => {\n return attributes.style\n ? {\n style: attributes.style,\n }\n : {};\n },\n parseHTML: (element) => element.getAttribute(\"style\"),\n },\n };\n },\n\n parseHTML() {\n return [\n {\n tag: \"iframe\",\n },\n ];\n },\n\n renderHTML({ HTMLAttributes }) {\n return [\"div\", this.options.HTMLAttributes, [\"iframe\", HTMLAttributes]];\n },\n\n addCommands() {\n return {\n setIframe:\n (options: { src: string }) =>\n ({ 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"],"names":[],"mappings":";AAoBa,MAAA,SAAS,KAAK,OAAsB;AAAA,EAC/C,MAAM;AAAA,EACN,OAAO;AAAA,EACP,MAAM;AAAA,EACN,WAAW;AAAA,EAEX,aAAa;AACJ,WAAA;AAAA,MACL,iBAAiB;AAAA,MACjB,gBAAgB;AAAA,Q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IAAI,GAGjD;AAAA,MAAA;AAAA,IAEb;AAAA,EAAA;AAEJ,CAAC;"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const utilities=require("@edifice.io/utilities"),core=require("@tiptap/core"),TiptapImage=require("@tiptap/extension-image"),prosemirrorState=require("prosemirror-state"),IMAGE_INPUT_REGEX=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,Image=TiptapImage.extend({name:"custom-image",draggable:!0,selectable:!0,addOptions(){var _a;return{...(_a=this.parent)==null?void 0:_a.call(this),inline:!0,content:"inline*",sizes:["small","medium","large"],HTMLAttributes:{class:"custom-image"},uploadFile:()=>Promise.resolve(null)}},addAttributes(){var _a;return{...(_a=this.parent)==null?void 0:_a.call(this),size:{default:"medium",rendered:!1},alt:{renderHTML:attributes=>({alt:attributes.alt}),parseHTML:element=>element.getAttribute("alt")},title:{renderHTML:attributes=>({title:attributes.title}),parseHTML:element=>element.getAttribute("title")},width:{default:"350",renderHTML:attributes=>attributes.width!==null&&attributes.width!==void 0&&!Number.isNaN(attributes.width)?{width:parseInt(attributes.width)}:{},parseHTML:element=>element.getAttribute("width")},height:{renderHTML:attributes=>attributes.height!==null&&attributes.height!==void 0&&!Number.isNaN(attributes.height)?{height:parseInt(attributes.height)}:{},parseHTML:element=>element.getAttribute("height")},style:{renderHTML:attributes=>attributes.style?{style:attributes.style}:{},parseHTML:element=>{const style=element.getAttribute("style");return style&&typeof style=="string"&&style.length>0?{}:null}}}},parseHTML(){return[{tag:'img[src]:not([src^="data:"])',getAttrs:el=>{var _a,_b,_c,_d,_e;const attr={src:el.getAttribute("src")};return(_a=el.parentElement)!=null&&_a.className.includes("image-container")&&(_b=el.parentElement.style)!=null&&_b.width&&(attr.width=el.parentElement.style.width),(_c=el.style)!=null&&_c.width&&(attr.width=el.style.width),["happy","proud","dreamy","love","tired","angry","worried","sick","joker","sad"].filter(smiley=>attr.src.includes(smiley+".png")).length>0&&(attr.style={width:"1.5em",height:"1.5em",fontSize:(_e=(_d=el.parentElement)==null?void 0:_d.style)==null?void 0:_e.fontSize},attr.width="null",attr.height="null"),attr}}]},renderHTML({HTMLAttributes}){return["img",core.mergeAttributes(this.options.HTMLAttributes,HTMLAttributes)]},addInputRules(){return[core.nodeInputRule({find:IMAGE_INPUT_REGEX,type:this.type,getAttributes:match=>{const[,,alt,src,title]=match;return{src,alt,title}}})]},addCommands(){return{setNewImage:attrs=>({tr,dispatch})=>{const{selection}=tr,node=this.type.create(attrs);return dispatch&&tr.replaceRangeWith(selection.from,selection.to,node),!0},setAttributes:attributes=>({tr,dispatch})=>{const{selection}=tr,options={...tr.doc.nodeAt(tr.selection.from).attrs,...attributes},node=this.type.create(options);return dispatch&&tr.replaceRangeWith(selection.from,selection.to,node),!0}}},addProseMirrorPlugins(){const uploadNode=async file=>{const resizedImage=await utilities.ImageResizer.resizeImageFile(file),image=await this.options.uploadFile(resizedImage),imageUrl=`/workspace/${image.public?"pub/":""}document/${image._id}?timestamp=${new Date().getTime()}`;return this.type.create({src:imageUrl,alt:image.alt,title:image.title})},getFilteredFiles=files=>Array.from(files).filter(file=>/image\/(png|jpeg|jpg|gif|webp|heic|avif)/.test(file.type)),handleImageInsert=async(editor,file,position)=>{const node=await uploadNode(file);if(!node)return;const transaction=position!==void 0?editor.state.tr.insert(position,node):editor.state.tr.replaceSelectionWith(node);editor.dispatch(transaction)};return[new prosemirrorState.Plugin({props:{handlePaste:(editor,e)=>{var _a;const files=getFilteredFiles((_a=e.clipboardData)==null?void 0:_a.files);if(files.length===0)return!1;for(const file of files)handleImageInsert(editor,file);return!0},handleDrop:(editor,e,_s,moved)=>{if(moved)return!1;const files=getFilteredFiles(e.dataTransfer.files);if(files.length===0)return!1;const{pos:position}=editor.posAtCoords({left:e.clientX,top:e.clientY});for(const file of files)handleImageInsert(editor,file,position);return!0}}})]}});exports.IMAGE_INPUT_REGEX=IMAGE_INPUT_REGEX;exports.Image=Image;
|
|
2
|
+
//# sourceMappingURL=image.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image.cjs","sources":["../../src/image/image.ts"],"sourcesContent":["import { WorkspaceElement } from \"@edifice.io/ts-client\";\nimport { ImageResizer } from \"@edifice.io/utilities\";\nimport { mergeAttributes, nodeInputRule } from \"@tiptap/core\";\nimport TiptapImage from \"@tiptap/extension-image\";\nimport { Plugin } from \"prosemirror-state\";\n\nexport const IMAGE_INPUT_REGEX =\n /(?:^|\\s)(!\\[(.+|:?)]\\((\\S+)(?:(?:\\s+)[\"'](\\S+)[\"'])?\\))$/;\n\nexport interface CustomImageOptions {\n HTMLAttributes: Record<string, string>;\n sizes: string[];\n uploadFile?: (file: File) => Promise<WorkspaceElement | null>;\n}\n\ninterface AttributesProps {\n width: number | string;\n height: number | string;\n size: string;\n}\n\ndeclare module \"@tiptap/core\" {\n interface Commands<ReturnType> {\n customImage: {\n setAttributes: (options: AttributesProps) => ReturnType;\n setNewImage: (options: {\n src: string;\n alt?: string;\n title?: string;\n }) => ReturnType;\n };\n }\n}\n\nexport const Image = TiptapImage.extend<CustomImageOptions>({\n name: \"custom-image\",\n draggable: true,\n selectable: true,\n\n addOptions() {\n return {\n ...this.parent?.(),\n inline: true,\n content: \"inline*\",\n sizes: [\"small\", \"medium\", \"large\"],\n HTMLAttributes: {\n class: \"custom-image\",\n },\n uploadFile: () => {\n return Promise.resolve(null);\n },\n };\n },\n\n addAttributes() {\n return {\n ...this.parent?.(),\n size: {\n default: \"medium\",\n rendered: false,\n },\n alt: {\n renderHTML: (attributes) => {\n return {\n alt: attributes.alt,\n };\n },\n parseHTML: (element) => element.getAttribute(\"alt\"),\n },\n title: {\n renderHTML: (attributes) => {\n return {\n title: attributes.title,\n };\n },\n parseHTML: (element) => element.getAttribute(\"title\"),\n },\n width: {\n default: \"350\",\n renderHTML: (attributes) => {\n if (\n attributes.width !== null &&\n attributes.width !== undefined &&\n !Number.isNaN(attributes.width)\n ) {\n return {\n width: parseInt(attributes.width),\n };\n }\n return {};\n },\n parseHTML: (element) => element.getAttribute(\"width\"),\n },\n height: {\n renderHTML: (attributes) => {\n if (\n attributes.height !== null &&\n attributes.height !== undefined &&\n !Number.isNaN(attributes.height)\n ) {\n return {\n height: parseInt(attributes.height),\n };\n }\n return {};\n },\n parseHTML: (element) => element.getAttribute(\"height\"),\n },\n style: {\n renderHTML: (attributes) => {\n return attributes.style\n ? {\n style: attributes.style,\n }\n : {};\n },\n parseHTML: (element) => {\n const style = element.getAttribute(\"style\");\n return style && typeof style === \"string\" && style.length > 0\n ? {}\n : null;\n },\n },\n };\n },\n\n parseHTML() {\n return [\n {\n tag: 'img[src]:not([src^=\"data:\"])',\n getAttrs: (el: HTMLImageElement) => {\n const attr = { src: el.getAttribute(\"src\") };\n // Check old content format and get the width from the parent element\n if (el.parentElement?.className.includes(\"image-container\")) {\n if (el.parentElement.style?.width) {\n attr[\"width\"] = el.parentElement.style.width;\n }\n }\n if (el.style?.width) {\n attr[\"width\"] = el.style.width;\n }\n\n // Check old content smiley\n const oldSmileyList = [\n \"happy\",\n \"proud\",\n \"dreamy\",\n \"love\",\n \"tired\",\n \"angry\",\n \"worried\",\n \"sick\",\n \"joker\",\n \"sad\",\n ];\n if (\n oldSmileyList.filter((smiley) => attr.src.includes(smiley + \".png\"))\n .length > 0\n ) {\n attr[\"style\"] = {\n width: \"1.5em\",\n height: \"1.5em\",\n fontSize: el.parentElement?.style?.fontSize,\n };\n attr[\"width\"] = \"null\";\n attr[\"height\"] = \"null\";\n }\n return attr;\n },\n },\n ];\n },\n\n renderHTML({ HTMLAttributes }) {\n return [\n \"img\",\n mergeAttributes(this.options.HTMLAttributes, HTMLAttributes),\n ];\n },\n\n addInputRules() {\n return [\n nodeInputRule({\n find: IMAGE_INPUT_REGEX,\n type: this.type,\n getAttributes: (match) => {\n const [, , alt, src, title] = match;\n\n return {\n src,\n alt,\n title,\n };\n },\n }),\n ];\n },\n\n addCommands() {\n return {\n setNewImage:\n (attrs) =>\n ({ tr, dispatch }) => {\n const { selection } = tr;\n const node = this.type.create(attrs);\n\n if (dispatch) {\n tr.replaceRangeWith(selection.from, selection.to, node);\n }\n\n return true;\n },\n setAttributes:\n (attributes) =>\n ({ tr, dispatch }) => {\n const { selection } = tr;\n\n const nodeAttrs = tr.doc.nodeAt(tr.selection.from);\n const options = {\n ...nodeAttrs.attrs,\n ...attributes,\n };\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 addProseMirrorPlugins() {\n const uploadNode = async (file: File) => {\n /**\n * Resize the image\n */\n const resizedImage = await ImageResizer.resizeImageFile(file);\n\n /**\n * Upload the image\n */\n const image = await this.options.uploadFile(resizedImage);\n\n /**\n * Get the image url\n */\n const imageUrl = `/workspace/${image.public ? \"pub/\" : \"\"}document/${\n image._id\n }?timestamp=${new Date().getTime()}`;\n\n /**\n * Create the image node\n */\n\n const node = this.type.create({\n src: imageUrl,\n alt: image.alt,\n title: image.title,\n });\n\n return node;\n };\n\n const getFilteredFiles = (files: FileList) => {\n return Array.from(files).filter((file) =>\n /image\\/(png|jpeg|jpg|gif|webp|heic|avif)/.test(file.type),\n );\n };\n\n const handleImageInsert = async (\n editor: any,\n file: File,\n position?: number,\n ) => {\n const node = await uploadNode(file);\n if (!node) return;\n\n const transaction =\n position !== undefined\n ? editor.state.tr.insert(position, node)\n : editor.state.tr.replaceSelectionWith(node);\n\n editor.dispatch(transaction);\n };\n\n return [\n new Plugin({\n props: {\n handlePaste: (editor, e) => {\n const files = getFilteredFiles(e.clipboardData?.files);\n if (files.length === 0) return false;\n\n for (const file of files) {\n handleImageInsert(editor, file);\n }\n\n return true;\n },\n handleDrop: (editor, e, _s, moved) => {\n if (moved) return false;\n\n const files = getFilteredFiles(e.dataTransfer.files);\n if (files.length === 0) return false;\n\n const { pos: position } = editor.posAtCoords({\n left: e.clientX,\n top: e.clientY,\n });\n\n for (const file of files) {\n handleImageInsert(editor, file, position);\n }\n return true;\n },\n },\n }),\n ];\n },\n});\n"],"names":["mergeAttributes","nodeInputRule","ImageResizer","Plugin"],"mappings":"2PAMa,kBACX,2DA2BW,MAAQ,YAAY,OAA2B,CAC1D,KAAM,eACN,UAAW,GACX,WAAY,GAEZ,YAAa,QACJ,MAAA,CACL,IAAG,QAAK,SAAL,0BACH,OAAQ,GACR,QAAS,UACT,MAAO,CAAC,QAAS,SAAU,OAAO,EAClC,eAAgB,CACd,MAAO,cACT,EACA,WAAY,IACH,QAAQ,QAAQ,IAAI,CAE/B,CACF,EAEA,eAAgB,QACP,MAAA,CACL,IAAG,QAAK,SAAL,0BACH,KAAM,CACJ,QAAS,SACT,SAAU,EACZ,EACA,IAAK,CACH,WAAa,aACJ,CACL,IAAK,WAAW,GAClB,GAEF,UAAY,SAAY,QAAQ,aAAa,KAAK,CACpD,EACA,MAAO,CACL,WAAa,aACJ,CACL,MAAO,WAAW,KACpB,GAEF,UAAY,SAAY,QAAQ,aAAa,OAAO,CACtD,EACA,MAAO,CACL,QAAS,MACT,WAAa,YAET,WAAW,QAAU,MACrB,WAAW,QAAU,QACrB,CAAC,OAAO,MAAM,WAAW,KAAK,EAEvB,CACL,MAAO,SAAS,WAAW,KAAK,CAClC,EAEK,CAAC,EAEV,UAAY,SAAY,QAAQ,aAAa,OAAO,CACtD,EACA,OAAQ,CACN,WAAa,YAET,WAAW,SAAW,MACtB,WAAW,SAAW,QACtB,CAAC,OAAO,MAAM,WAAW,MAAM,EAExB,CACL,OAAQ,SAAS,WAAW,MAAM,CACpC,EAEK,CAAC,EAEV,UAAY,SAAY,QAAQ,aAAa,QAAQ,CACvD,EACA,MAAO,CACL,WAAa,YACJ,WAAW,MACd,CACE,MAAO,WAAW,KAAA,EAEpB,CAAC,EAEP,UAAY,SAAY,CAChB,MAAA,MAAQ,QAAQ,aAAa,OAAO,EACnC,OAAA,OAAS,OAAO,OAAU,UAAY,MAAM,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,EAAE,OAAA,CACR,EAED,UAAW,QAAQ,MACC,kBAAA,OAAQ,KAAM,QAAQ,EAEnC,MAAA,EAAA,CACT,CAEH,CAAA,CACH,CAAA,CAEJ,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { WorkspaceElement } from '@edifice.io/ts-client';
|
|
2
|
+
export declare const IMAGE_INPUT_REGEX: RegExp;
|
|
3
|
+
export interface CustomImageOptions {
|
|
4
|
+
HTMLAttributes: Record<string, string>;
|
|
5
|
+
sizes: string[];
|
|
6
|
+
uploadFile?: (file: File) => Promise<WorkspaceElement | null>;
|
|
7
|
+
}
|
|
8
|
+
interface AttributesProps {
|
|
9
|
+
width: number | string;
|
|
10
|
+
height: number | string;
|
|
11
|
+
size: string;
|
|
12
|
+
}
|
|
13
|
+
declare module "@tiptap/core" {
|
|
14
|
+
interface Commands<ReturnType> {
|
|
15
|
+
customImage: {
|
|
16
|
+
setAttributes: (options: AttributesProps) => ReturnType;
|
|
17
|
+
setNewImage: (options: {
|
|
18
|
+
src: string;
|
|
19
|
+
alt?: string;
|
|
20
|
+
title?: string;
|
|
21
|
+
}) => ReturnType;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export declare const Image: import('@tiptap/core').Node<CustomImageOptions, any>;
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import { ImageResizer } from "@edifice.io/utilities";
|
|
2
|
+
import { mergeAttributes, nodeInputRule } from "@tiptap/core";
|
|
3
|
+
import TiptapImage from "@tiptap/extension-image";
|
|
4
|
+
import { Plugin } from "prosemirror-state";
|
|
5
|
+
const IMAGE_INPUT_REGEX = /(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/, Image = TiptapImage.extend({
|
|
6
|
+
name: "custom-image",
|
|
7
|
+
draggable: !0,
|
|
8
|
+
selectable: !0,
|
|
9
|
+
addOptions() {
|
|
10
|
+
var _a;
|
|
11
|
+
return {
|
|
12
|
+
...(_a = this.parent) == null ? void 0 : _a.call(this),
|
|
13
|
+
inline: !0,
|
|
14
|
+
content: "inline*",
|
|
15
|
+
sizes: ["small", "medium", "large"],
|
|
16
|
+
HTMLAttributes: {
|
|
17
|
+
class: "custom-image"
|
|
18
|
+
},
|
|
19
|
+
uploadFile: () => Promise.resolve(null)
|
|
20
|
+
};
|
|
21
|
+
},
|
|
22
|
+
addAttributes() {
|
|
23
|
+
var _a;
|
|
24
|
+
return {
|
|
25
|
+
...(_a = this.parent) == null ? void 0 : _a.call(this),
|
|
26
|
+
size: {
|
|
27
|
+
default: "medium",
|
|
28
|
+
rendered: !1
|
|
29
|
+
},
|
|
30
|
+
alt: {
|
|
31
|
+
renderHTML: (attributes) => ({
|
|
32
|
+
alt: attributes.alt
|
|
33
|
+
}),
|
|
34
|
+
parseHTML: (element) => element.getAttribute("alt")
|
|
35
|
+
},
|
|
36
|
+
title: {
|
|
37
|
+
renderHTML: (attributes) => ({
|
|
38
|
+
title: attributes.title
|
|
39
|
+
}),
|
|
40
|
+
parseHTML: (element) => element.getAttribute("title")
|
|
41
|
+
},
|
|
42
|
+
width: {
|
|
43
|
+
default: "350",
|
|
44
|
+
renderHTML: (attributes) => attributes.width !== null && attributes.width !== void 0 && !Number.isNaN(attributes.width) ? {
|
|
45
|
+
width: parseInt(attributes.width)
|
|
46
|
+
} : {},
|
|
47
|
+
parseHTML: (element) => element.getAttribute("width")
|
|
48
|
+
},
|
|
49
|
+
height: {
|
|
50
|
+
renderHTML: (attributes) => attributes.height !== null && attributes.height !== void 0 && !Number.isNaN(attributes.height) ? {
|
|
51
|
+
height: parseInt(attributes.height)
|
|
52
|
+
} : {},
|
|
53
|
+
parseHTML: (element) => element.getAttribute("height")
|
|
54
|
+
},
|
|
55
|
+
style: {
|
|
56
|
+
renderHTML: (attributes) => attributes.style ? {
|
|
57
|
+
style: attributes.style
|
|
58
|
+
} : {},
|
|
59
|
+
parseHTML: (element) => {
|
|
60
|
+
const style = element.getAttribute("style");
|
|
61
|
+
return style && typeof style == "string" && style.length > 0 ? {} : null;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
},
|
|
66
|
+
parseHTML() {
|
|
67
|
+
return [
|
|
68
|
+
{
|
|
69
|
+
tag: 'img[src]:not([src^="data:"])',
|
|
70
|
+
getAttrs: (el) => {
|
|
71
|
+
var _a, _b, _c, _d, _e;
|
|
72
|
+
const attr = { src: el.getAttribute("src") };
|
|
73
|
+
return (_a = el.parentElement) != null && _a.className.includes("image-container") && (_b = el.parentElement.style) != null && _b.width && (attr.width = el.parentElement.style.width), (_c = el.style) != null && _c.width && (attr.width = el.style.width), [
|
|
74
|
+
"happy",
|
|
75
|
+
"proud",
|
|
76
|
+
"dreamy",
|
|
77
|
+
"love",
|
|
78
|
+
"tired",
|
|
79
|
+
"angry",
|
|
80
|
+
"worried",
|
|
81
|
+
"sick",
|
|
82
|
+
"joker",
|
|
83
|
+
"sad"
|
|
84
|
+
].filter((smiley) => attr.src.includes(smiley + ".png")).length > 0 && (attr.style = {
|
|
85
|
+
width: "1.5em",
|
|
86
|
+
height: "1.5em",
|
|
87
|
+
fontSize: (_e = (_d = el.parentElement) == null ? void 0 : _d.style) == null ? void 0 : _e.fontSize
|
|
88
|
+
}, attr.width = "null", attr.height = "null"), attr;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
];
|
|
92
|
+
},
|
|
93
|
+
renderHTML({ HTMLAttributes }) {
|
|
94
|
+
return [
|
|
95
|
+
"img",
|
|
96
|
+
mergeAttributes(this.options.HTMLAttributes, HTMLAttributes)
|
|
97
|
+
];
|
|
98
|
+
},
|
|
99
|
+
addInputRules() {
|
|
100
|
+
return [
|
|
101
|
+
nodeInputRule({
|
|
102
|
+
find: IMAGE_INPUT_REGEX,
|
|
103
|
+
type: this.type,
|
|
104
|
+
getAttributes: (match) => {
|
|
105
|
+
const [, , alt, src, title] = match;
|
|
106
|
+
return {
|
|
107
|
+
src,
|
|
108
|
+
alt,
|
|
109
|
+
title
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
})
|
|
113
|
+
];
|
|
114
|
+
},
|
|
115
|
+
addCommands() {
|
|
116
|
+
return {
|
|
117
|
+
setNewImage: (attrs) => ({ tr, dispatch }) => {
|
|
118
|
+
const { selection } = tr, node = this.type.create(attrs);
|
|
119
|
+
return dispatch && tr.replaceRangeWith(selection.from, selection.to, node), !0;
|
|
120
|
+
},
|
|
121
|
+
setAttributes: (attributes) => ({ tr, dispatch }) => {
|
|
122
|
+
const { selection } = tr, options = {
|
|
123
|
+
...tr.doc.nodeAt(tr.selection.from).attrs,
|
|
124
|
+
...attributes
|
|
125
|
+
}, node = this.type.create(options);
|
|
126
|
+
return dispatch && tr.replaceRangeWith(selection.from, selection.to, node), !0;
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
},
|
|
130
|
+
addProseMirrorPlugins() {
|
|
131
|
+
const uploadNode = async (file) => {
|
|
132
|
+
const resizedImage = await ImageResizer.resizeImageFile(file), image = await this.options.uploadFile(resizedImage), imageUrl = `/workspace/${image.public ? "pub/" : ""}document/${image._id}?timestamp=${(/* @__PURE__ */ new Date()).getTime()}`;
|
|
133
|
+
return this.type.create({
|
|
134
|
+
src: imageUrl,
|
|
135
|
+
alt: image.alt,
|
|
136
|
+
title: image.title
|
|
137
|
+
});
|
|
138
|
+
}, getFilteredFiles = (files) => Array.from(files).filter(
|
|
139
|
+
(file) => /image\/(png|jpeg|jpg|gif|webp|heic|avif)/.test(file.type)
|
|
140
|
+
), handleImageInsert = async (editor, file, position) => {
|
|
141
|
+
const node = await uploadNode(file);
|
|
142
|
+
if (!node) return;
|
|
143
|
+
const transaction = position !== void 0 ? editor.state.tr.insert(position, node) : editor.state.tr.replaceSelectionWith(node);
|
|
144
|
+
editor.dispatch(transaction);
|
|
145
|
+
};
|
|
146
|
+
return [
|
|
147
|
+
new Plugin({
|
|
148
|
+
props: {
|
|
149
|
+
handlePaste: (editor, e) => {
|
|
150
|
+
var _a;
|
|
151
|
+
const files = getFilteredFiles((_a = e.clipboardData) == null ? void 0 : _a.files);
|
|
152
|
+
if (files.length === 0) return !1;
|
|
153
|
+
for (const file of files)
|
|
154
|
+
handleImageInsert(editor, file);
|
|
155
|
+
return !0;
|
|
156
|
+
},
|
|
157
|
+
handleDrop: (editor, e, _s, moved) => {
|
|
158
|
+
if (moved) return !1;
|
|
159
|
+
const files = getFilteredFiles(e.dataTransfer.files);
|
|
160
|
+
if (files.length === 0) return !1;
|
|
161
|
+
const { pos: position } = editor.posAtCoords({
|
|
162
|
+
left: e.clientX,
|
|
163
|
+
top: e.clientY
|
|
164
|
+
});
|
|
165
|
+
for (const file of files)
|
|
166
|
+
handleImageInsert(editor, file, position);
|
|
167
|
+
return !0;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
})
|
|
171
|
+
];
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
export {
|
|
175
|
+
IMAGE_INPUT_REGEX,
|
|
176
|
+
Image
|
|
177
|
+
};
|
|
178
|
+
//# sourceMappingURL=image.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image.js","sources":["../../src/image/image.ts"],"sourcesContent":["import { WorkspaceElement } from \"@edifice.io/ts-client\";\nimport { ImageResizer } from \"@edifice.io/utilities\";\nimport { mergeAttributes, nodeInputRule } from \"@tiptap/core\";\nimport TiptapImage from \"@tiptap/extension-image\";\nimport { Plugin } from \"prosemirror-state\";\n\nexport const IMAGE_INPUT_REGEX =\n /(?:^|\\s)(!\\[(.+|:?)]\\((\\S+)(?:(?:\\s+)[\"'](\\S+)[\"'])?\\))$/;\n\nexport interface CustomImageOptions {\n HTMLAttributes: Record<string, string>;\n sizes: string[];\n uploadFile?: (file: File) => Promise<WorkspaceElement | null>;\n}\n\ninterface AttributesProps {\n width: number | string;\n height: number | string;\n size: string;\n}\n\ndeclare module \"@tiptap/core\" {\n interface Commands<ReturnType> {\n customImage: {\n setAttributes: (options: AttributesProps) => ReturnType;\n setNewImage: (options: {\n src: string;\n alt?: string;\n title?: string;\n }) => ReturnType;\n };\n }\n}\n\nexport const Image = TiptapImage.extend<CustomImageOptions>({\n name: \"custom-image\",\n draggable: true,\n selectable: true,\n\n addOptions() {\n return {\n ...this.parent?.(),\n inline: true,\n content: \"inline*\",\n sizes: [\"small\", \"medium\", \"large\"],\n HTMLAttributes: {\n class: \"custom-image\",\n },\n uploadFile: () => {\n return Promise.resolve(null);\n },\n };\n },\n\n addAttributes() {\n return {\n ...this.parent?.(),\n size: {\n default: \"medium\",\n rendered: false,\n },\n alt: {\n renderHTML: (attributes) => {\n return {\n alt: attributes.alt,\n };\n },\n parseHTML: (element) => element.getAttribute(\"alt\"),\n },\n title: {\n renderHTML: (attributes) => {\n return {\n title: attributes.title,\n };\n },\n parseHTML: (element) => element.getAttribute(\"title\"),\n },\n width: {\n default: \"350\",\n renderHTML: (attributes) => {\n if (\n attributes.width !== null &&\n attributes.width !== undefined &&\n !Number.isNaN(attributes.width)\n ) {\n return {\n width: parseInt(attributes.width),\n };\n }\n return {};\n },\n parseHTML: (element) => element.getAttribute(\"width\"),\n },\n height: {\n renderHTML: (attributes) => {\n if (\n attributes.height !== null &&\n attributes.height !== undefined &&\n !Number.isNaN(attributes.height)\n ) {\n return {\n height: parseInt(attributes.height),\n };\n }\n return {};\n },\n parseHTML: (element) => element.getAttribute(\"height\"),\n },\n style: {\n renderHTML: (attributes) => {\n return attributes.style\n ? {\n style: attributes.style,\n }\n : {};\n },\n parseHTML: (element) => {\n const style = element.getAttribute(\"style\");\n return style && typeof style === \"string\" && style.length > 0\n ? {}\n : null;\n },\n },\n };\n },\n\n parseHTML() {\n return [\n {\n tag: 'img[src]:not([src^=\"data:\"])',\n getAttrs: (el: HTMLImageElement) => {\n const attr = { src: el.getAttribute(\"src\") };\n // Check old content format and get the width from the parent element\n if (el.parentElement?.className.includes(\"image-container\")) {\n if (el.parentElement.style?.width) {\n attr[\"width\"] = el.parentElement.style.width;\n }\n }\n if (el.style?.width) {\n attr[\"width\"] = el.style.width;\n }\n\n // Check old content smiley\n const oldSmileyList = [\n \"happy\",\n \"proud\",\n \"dreamy\",\n \"love\",\n \"tired\",\n \"angry\",\n \"worried\",\n \"sick\",\n \"joker\",\n \"sad\",\n ];\n if (\n oldSmileyList.filter((smiley) => attr.src.includes(smiley + \".png\"))\n .length > 0\n ) {\n attr[\"style\"] = {\n width: \"1.5em\",\n height: \"1.5em\",\n fontSize: el.parentElement?.style?.fontSize,\n };\n attr[\"width\"] = \"null\";\n attr[\"height\"] = \"null\";\n }\n return attr;\n },\n },\n ];\n },\n\n renderHTML({ HTMLAttributes }) {\n return [\n \"img\",\n mergeAttributes(this.options.HTMLAttributes, HTMLAttributes),\n ];\n },\n\n addInputRules() {\n return [\n nodeInputRule({\n find: IMAGE_INPUT_REGEX,\n type: this.type,\n getAttributes: (match) => {\n const [, , alt, src, title] = match;\n\n return {\n src,\n alt,\n title,\n };\n },\n }),\n ];\n },\n\n addCommands() {\n return {\n setNewImage:\n (attrs) =>\n ({ tr, dispatch }) => {\n const { selection } = tr;\n const node = this.type.create(attrs);\n\n if (dispatch) {\n tr.replaceRangeWith(selection.from, selection.to, node);\n }\n\n return true;\n },\n setAttributes:\n (attributes) =>\n ({ tr, dispatch }) => {\n const { selection } = tr;\n\n const nodeAttrs = tr.doc.nodeAt(tr.selection.from);\n const options = {\n ...nodeAttrs.attrs,\n ...attributes,\n };\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 addProseMirrorPlugins() {\n const uploadNode = async (file: File) => {\n /**\n * Resize the image\n */\n const resizedImage = await ImageResizer.resizeImageFile(file);\n\n /**\n * Upload the image\n */\n const image = await this.options.uploadFile(resizedImage);\n\n /**\n * Get the image url\n */\n const imageUrl = `/workspace/${image.public ? \"pub/\" : \"\"}document/${\n image._id\n }?timestamp=${new Date().getTime()}`;\n\n /**\n * Create the image node\n */\n\n const node = this.type.create({\n src: imageUrl,\n alt: image.alt,\n title: image.title,\n });\n\n return node;\n };\n\n const getFilteredFiles = (files: FileList) => {\n return Array.from(files).filter((file) =>\n /image\\/(png|jpeg|jpg|gif|webp|heic|avif)/.test(file.type),\n );\n };\n\n const handleImageInsert = async (\n editor: any,\n file: File,\n position?: number,\n ) => {\n const node = await uploadNode(file);\n if (!node) return;\n\n const transaction =\n position !== undefined\n ? editor.state.tr.insert(position, node)\n : editor.state.tr.replaceSelectionWith(node);\n\n editor.dispatch(transaction);\n };\n\n return [\n new Plugin({\n props: {\n handlePaste: (editor, e) => {\n const files = getFilteredFiles(e.clipboardData?.files);\n if (files.length === 0) return false;\n\n for (const file of files) {\n handleImageInsert(editor, file);\n }\n\n return true;\n },\n handleDrop: (editor, e, _s, moved) => {\n if (moved) return false;\n\n const files = getFilteredFiles(e.dataTransfer.files);\n if (files.length === 0) return false;\n\n const { pos: position } = editor.posAtCoords({\n left: e.clientX,\n top: e.clientY,\n });\n\n for (const file of files) {\n handleImageInsert(editor, file, position);\n }\n return true;\n },\n },\n }),\n ];\n },\n});\n"],"names":[],"mappings":";;;;AAMO,MAAM,oBACX,4DA2BW,QAAQ,YAAY,OAA2B;AAAA,EAC1D,MAAM;AAAA,EACN,WAAW;AAAA,EACX,YAAY;AAAA,EAEZ,aAAa;;AACJ,WAAA;AAAA,MACL,IAAG,UAAK,WAAL;AAAA,MACH,QAAQ;AAAA,MACR,SAAS;AAAA,MACT,OAAO,CAAC,SAAS,UAAU,OAAO;AAAA,MAClC,gBAAgB;AAAA,QACd,OAAO;AAAA,MACT;AAAA,MACA,YAAY,MACH,QAAQ,QAAQ,IAAI;AAAA,IAE/B;AAAA,EACF;AAAA,EAEA,gBAAgB;;AACP,WAAA;AAAA,MACL,IAAG,UAAK,WAAL;AAAA,MACH,MAAM;AAAA,QACJ,SAAS;AAAA,QACT,UAAU;AAAA,MACZ;AAAA,MACA,KAAK;AAA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Q,GAAG,IAAI,UAAU;AACpC,gBAAI,MAAc,QAAA;AAElB,kBAAM,QAAQ,iBAAiB,EAAE,aAAa,KAAK;AAC/C,gBAAA,MAAM,WAAW,EAAU,QAAA;AAE/B,kBAAM,EAAE,KAAK,aAAa,OAAO,YAAY;AAAA,cAC3C,MAAM,EAAE;AAAA,cACR,KAAK,EAAE;AAAA,YAAA,CACR;AAED,uBAAW,QAAQ;AACC,gCAAA,QAAQ,MAAM,QAAQ;AAEnC,mBAAA;AAAA,UAAA;AAAA,QACT;AAAA,MAEH,CAAA;AAAA,IACH;AAAA,EAAA;AAEJ,CAAC;"}
|
package/dist/image/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export * from './
|
|
3
|
-
export default
|
|
1
|
+
import { Image } from './image';
|
|
2
|
+
export * from './image';
|
|
3
|
+
export default Image;
|
package/dist/index.cjs
CHANGED
|
@@ -1,44 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
3
|
-
const abbr = require('./abbr/abbr.cjs'),
|
|
4
|
-
alert = require('./alert/alert.cjs'),
|
|
5
|
-
attachment = require('./attachment/attachment.cjs'),
|
|
6
|
-
audio = require('./audio/audio.cjs'),
|
|
7
|
-
fontSize = require('./font-size/font-size.cjs'),
|
|
8
|
-
heading = require('./heading/heading.cjs'),
|
|
9
|
-
highlight = require('./highlight/highlight.cjs'),
|
|
10
|
-
hyperlink = require('./hyperlink/hyperlink.cjs'),
|
|
11
|
-
iframe = require('./iframe/iframe.cjs'),
|
|
12
|
-
customImage = require('./image/custom-image.cjs'),
|
|
13
|
-
lineHeight = require('./line-height/line-height.cjs'),
|
|
14
|
-
linker = require('./linker/linker.cjs'),
|
|
15
|
-
mathjax = require('./mathjax/mathjax.cjs'),
|
|
16
|
-
paragraph = require('./paragraph/paragraph.cjs'),
|
|
17
|
-
speechRecognition = require('./speech-recognition/speech-recognition.cjs'),
|
|
18
|
-
speechSynthesis = require('./speech-synthesis/speech-synthesis.cjs'),
|
|
19
|
-
tableCell = require('./table-cell/table-cell.cjs'),
|
|
20
|
-
htmlToJson = require('./transform/html-to-json/html-to-json.cjs'),
|
|
21
|
-
jsonToHtml = require('./transform/json-to-html/json-to-html.cjs'),
|
|
22
|
-
video = require('./video/video.cjs');
|
|
23
|
-
exports.Abbr = abbr.Abbr;
|
|
24
|
-
exports.Alert = alert.Alert;
|
|
25
|
-
exports.Attachment = attachment.Attachment;
|
|
26
|
-
exports.Audio = audio.Audio;
|
|
27
|
-
exports.FontSize = fontSize.FontSize;
|
|
28
|
-
exports.CustomHeading = heading.CustomHeading;
|
|
29
|
-
exports.CustomHighlight = highlight.CustomHighlight;
|
|
30
|
-
exports.Hyperlink = hyperlink.Hyperlink;
|
|
31
|
-
exports.Iframe = iframe.Iframe;
|
|
32
|
-
exports.CustomImage = customImage.CustomImage;
|
|
33
|
-
exports.IMAGE_INPUT_REGEX = customImage.IMAGE_INPUT_REGEX;
|
|
34
|
-
exports.LineHeight = lineHeight.LineHeight;
|
|
35
|
-
exports.Linker = linker.Linker;
|
|
36
|
-
exports.MathJax = mathjax.MathJax;
|
|
37
|
-
exports.Paragraph = paragraph.Paragraph;
|
|
38
|
-
exports.SpeechRecognition = speechRecognition.SpeechRecognition;
|
|
39
|
-
exports.SpeechSynthesis = speechSynthesis.SpeechSynthesis;
|
|
40
|
-
exports.TableCell = tableCell.TableCell;
|
|
41
|
-
exports.htmlToJson = htmlToJson;
|
|
42
|
-
exports.jsonToHtml = jsonToHtml;
|
|
43
|
-
exports.Video = video.Video;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const abbr=require("./abbr/abbr.cjs"),alert=require("./alert/alert.cjs"),attachmentTransformer=require("./attachment/attachment-transformer.cjs"),attachment=require("./attachment/attachment.cjs"),audio=require("./audio/audio.cjs"),fontSize=require("./font-size/font-size.cjs"),heading=require("./heading/heading.cjs"),highlight=require("./highlight/highlight.cjs"),hyperlink=require("./hyperlink/hyperlink.cjs"),iframe=require("./iframe/iframe.cjs"),image=require("./image/image.cjs"),lineHeight=require("./line-height/line-height.cjs"),linker=require("./linker/linker.cjs"),mathjax=require("./mathjax/mathjax.cjs"),paragraph=require("./paragraph/paragraph.cjs"),speechRecognition=require("./speech-recognition/speech-recognition.cjs"),speechSynthesis=require("./speech-synthesis/speech-synthesis.cjs"),tableCell=require("./table-cell/table-cell.cjs"),htmlToJson=require("./transform/html-to-json/html-to-json.cjs"),jsonToHtml=require("./transform/json-to-html/json-to-html.cjs"),video=require("./video/video.cjs");exports.Abbr=abbr.Abbr;exports.Alert=alert.Alert;exports.AttachmentTransformer=attachmentTransformer.AttachmentTransformer;exports.Attachment=attachment.Attachment;exports.Audio=audio.Audio;exports.FontSize=fontSize.FontSize;exports.CustomHeading=heading.CustomHeading;exports.CustomHighlight=highlight.CustomHighlight;exports.Hyperlink=hyperlink.Hyperlink;exports.Iframe=iframe.Iframe;exports.IMAGE_INPUT_REGEX=image.IMAGE_INPUT_REGEX;exports.Image=image.Image;exports.LineHeight=lineHeight.LineHeight;exports.Linker=linker.Linker;exports.MathJax=mathjax.MathJax;exports.Paragraph=paragraph.Paragraph;exports.SpeechRecognition=speechRecognition.SpeechRecognition;exports.SpeechSynthesis=speechSynthesis.SpeechSynthesis;exports.TableCell=tableCell.TableCell;exports.htmlToJson=htmlToJson;exports.jsonToHtml=jsonToHtml;exports.Video=video.Video;
|
|
44
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.js
CHANGED
|
@@ -1,35 +1,37 @@
|
|
|
1
|
-
import { Abbr } from
|
|
2
|
-
import { Alert } from
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import { default as
|
|
20
|
-
import {
|
|
1
|
+
import { Abbr } from "./abbr/abbr.js";
|
|
2
|
+
import { Alert } from "./alert/alert.js";
|
|
3
|
+
import { AttachmentTransformer } from "./attachment/attachment-transformer.js";
|
|
4
|
+
import { Attachment } from "./attachment/attachment.js";
|
|
5
|
+
import { Audio } from "./audio/audio.js";
|
|
6
|
+
import { FontSize } from "./font-size/font-size.js";
|
|
7
|
+
import { CustomHeading } from "./heading/heading.js";
|
|
8
|
+
import { CustomHighlight } from "./highlight/highlight.js";
|
|
9
|
+
import { Hyperlink } from "./hyperlink/hyperlink.js";
|
|
10
|
+
import { Iframe } from "./iframe/iframe.js";
|
|
11
|
+
import { IMAGE_INPUT_REGEX, Image } from "./image/image.js";
|
|
12
|
+
import { LineHeight } from "./line-height/line-height.js";
|
|
13
|
+
import { Linker } from "./linker/linker.js";
|
|
14
|
+
import { MathJax } from "./mathjax/mathjax.js";
|
|
15
|
+
import { Paragraph } from "./paragraph/paragraph.js";
|
|
16
|
+
import { SpeechRecognition } from "./speech-recognition/speech-recognition.js";
|
|
17
|
+
import { SpeechSynthesis } from "./speech-synthesis/speech-synthesis.js";
|
|
18
|
+
import { TableCell } from "./table-cell/table-cell.js";
|
|
19
|
+
import { default as default2 } from "./transform/html-to-json/html-to-json.js";
|
|
20
|
+
import { default as default3 } from "./transform/json-to-html/json-to-html.js";
|
|
21
|
+
import { Video } from "./video/video.js";
|
|
21
22
|
export {
|
|
22
23
|
Abbr,
|
|
23
24
|
Alert,
|
|
24
25
|
Attachment,
|
|
26
|
+
AttachmentTransformer,
|
|
25
27
|
Audio,
|
|
26
28
|
CustomHeading,
|
|
27
29
|
CustomHighlight,
|
|
28
|
-
CustomImage,
|
|
29
30
|
FontSize,
|
|
30
31
|
Hyperlink,
|
|
31
32
|
IMAGE_INPUT_REGEX,
|
|
32
33
|
Iframe,
|
|
34
|
+
Image,
|
|
33
35
|
LineHeight,
|
|
34
36
|
Linker,
|
|
35
37
|
MathJax,
|
|
@@ -39,6 +41,6 @@ export {
|
|
|
39
41
|
TableCell,
|
|
40
42
|
Video,
|
|
41
43
|
default2 as htmlToJson,
|
|
42
|
-
default3 as jsonToHtml
|
|
44
|
+
default3 as jsonToHtml
|
|
43
45
|
};
|
|
44
46
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,34 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
3
|
-
require('@tiptap/extension-text-style');
|
|
4
|
-
const core = require('@tiptap/core'),
|
|
5
|
-
LineHeight = core.Extension.create({
|
|
6
|
-
name: 'lineHeight',
|
|
7
|
-
addOptions() {
|
|
8
|
-
return { types: ['textStyle'] };
|
|
9
|
-
},
|
|
10
|
-
addGlobalAttributes() {
|
|
11
|
-
return [
|
|
12
|
-
{
|
|
13
|
-
types: this.options.types,
|
|
14
|
-
attributes: {
|
|
15
|
-
lineHeight: {
|
|
16
|
-
default: null,
|
|
17
|
-
parseHTML: (element) => {
|
|
18
|
-
var _a;
|
|
19
|
-
return (_a = element.style.lineHeight) == null
|
|
20
|
-
? void 0
|
|
21
|
-
: _a.replace(/['"]+/g, '');
|
|
22
|
-
},
|
|
23
|
-
renderHTML: (attributes) =>
|
|
24
|
-
attributes.lineHeight
|
|
25
|
-
? { style: `line-height: ${attributes.lineHeight}` }
|
|
26
|
-
: {},
|
|
27
|
-
},
|
|
28
|
-
},
|
|
29
|
-
},
|
|
30
|
-
];
|
|
31
|
-
},
|
|
32
|
-
});
|
|
33
|
-
exports.LineHeight = LineHeight;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("@tiptap/extension-text-style");const core=require("@tiptap/core"),LineHeight=core.Extension.create({name:"lineHeight",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{lineHeight:{default:null,parseHTML:element=>{var _a;return(_a=element.style.lineHeight)==null?void 0:_a.replace(/['"]+/g,"")},renderHTML:attributes=>attributes.lineHeight?{style:`line-height: ${attributes.lineHeight}`}:{}}}}]}});exports.LineHeight=LineHeight;
|
|
34
2
|
//# sourceMappingURL=line-height.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"line-height.cjs","sources":["../../src/line-height/line-height.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"line-height.cjs","sources":["../../src/line-height/line-height.ts"],"sourcesContent":["import \"@tiptap/extension-text-style\";\n\nimport { Extension } from \"@tiptap/core\";\n\nexport const LineHeight = Extension.create({\n name: \"lineHeight\",\n\n addOptions() {\n return {\n types: [\"textStyle\"],\n };\n },\n\n addGlobalAttributes() {\n return [\n {\n types: this.options.types,\n attributes: {\n lineHeight: {\n default: null,\n parseHTML: (element) =>\n element.style.lineHeight?.replace(/['\"]+/g, \"\"),\n renderHTML: (attributes) => {\n if (!attributes.lineHeight) {\n return {};\n }\n\n return {\n style: `line-height: ${attributes.lineHeight}`,\n };\n },\n },\n },\n },\n ];\n },\n});\n"],"names":["Extension"],"mappings":"2JAIa,WAAaA,eAAU,OAAO,CACzC,KAAM,aAEN,YAAa,CACJ,MAAA,CACL,MAAO,CAAC,WAAW,CACrB,CACF,EAEA,qBAAsB,CACb,MAAA,CACL,CACE,MAAO,KAAK,QAAQ,MACpB,WAAY,CACV,WAAY,CACV,QAAS,KACT,UAAY,SACV,QAAA,kBAAQ,MAAM,aAAd,eAA0B,QAAQ,SAAU,KAC9C,WAAa,YACN,WAAW,WAIT,CACL,MAAO,gBAAgB,WAAW,UAAU,EAC9C,EALS,CAAC,CAMZ,CACF,CACF,CAEJ,CAAA,CAEJ,CAAC"}
|