@edifice.io/tiptap-extensions 2.6.13 → 2.6.14-develop.20261117114501
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 +104 -13
- package/dist/_virtual/_rolldown/runtime.cjs +1 -0
- package/dist/abbr/abbr.cjs +2 -2
- package/dist/abbr/abbr.cjs.map +1 -1
- package/dist/abbr/abbr.js +2 -33
- package/dist/abbr/abbr.js.map +1 -1
- package/dist/abbr/abbr.spec.d.ts +1 -0
- package/dist/alert/alert.cjs +2 -2
- package/dist/alert/alert.cjs.map +1 -1
- package/dist/alert/alert.js +2 -45
- package/dist/alert/alert.js.map +1 -1
- package/dist/alert/alert.spec.d.ts +1 -0
- package/dist/attachment/attachment-transformer.cjs +2 -2
- package/dist/attachment/attachment-transformer.cjs.map +1 -1
- package/dist/attachment/attachment-transformer.js +2 -76
- package/dist/attachment/attachment-transformer.js.map +1 -1
- package/dist/attachment/attachment.cjs +2 -2
- package/dist/attachment/attachment.cjs.map +1 -1
- package/dist/attachment/attachment.js +2 -98
- package/dist/attachment/attachment.js.map +1 -1
- package/dist/attachment/attachment.spec.d.ts +1 -0
- package/dist/audio/audio.cjs +2 -2
- package/dist/audio/audio.cjs.map +1 -1
- package/dist/audio/audio.js +3 -52
- package/dist/audio/audio.js.map +1 -1
- package/dist/audio/audio.spec.d.ts +1 -0
- package/dist/conversation-history/conversation-history.cjs +2 -2
- package/dist/conversation-history/conversation-history.cjs.map +1 -1
- package/dist/conversation-history/conversation-history.js +2 -63
- package/dist/conversation-history/conversation-history.js.map +1 -1
- package/dist/conversation-history/conversation-history.spec.d.ts +1 -0
- package/dist/conversation-history-body/conversation-history-body.cjs +2 -2
- package/dist/conversation-history-body/conversation-history-body.cjs.map +1 -1
- package/dist/conversation-history-body/conversation-history-body.js +2 -24
- package/dist/conversation-history-body/conversation-history-body.js.map +1 -1
- package/dist/conversation-history-body/conversation-history-body.spec.d.ts +1 -0
- package/dist/font-size/font-size.cjs +2 -2
- package/dist/font-size/font-size.cjs.map +1 -1
- package/dist/font-size/font-size.js +2 -39
- package/dist/font-size/font-size.js.map +1 -1
- package/dist/font-size/font-size.spec.d.ts +1 -0
- package/dist/heading/heading.cjs +2 -2
- package/dist/heading/heading.cjs.map +1 -1
- package/dist/heading/heading.js +2 -46
- package/dist/heading/heading.js.map +1 -1
- package/dist/heading/heading.spec.d.ts +1 -0
- package/dist/highlight/highlight.cjs +2 -2
- package/dist/highlight/highlight.cjs.map +1 -1
- package/dist/highlight/highlight.js +2 -28
- package/dist/highlight/highlight.js.map +1 -1
- package/dist/highlight/highlight.spec.d.ts +1 -0
- package/dist/hyperlink/hyperlink.cjs +2 -2
- package/dist/hyperlink/hyperlink.cjs.map +1 -1
- package/dist/hyperlink/hyperlink.js +2 -53
- package/dist/hyperlink/hyperlink.js.map +1 -1
- package/dist/hyperlink/hyperlink.spec.d.ts +1 -0
- package/dist/iframe/iframe.cjs +2 -2
- package/dist/iframe/iframe.cjs.map +1 -1
- package/dist/iframe/iframe.js +2 -70
- package/dist/iframe/iframe.js.map +1 -1
- package/dist/iframe/iframe.spec.d.ts +1 -0
- package/dist/iframe/transformers/index.cjs +2 -2
- package/dist/iframe/transformers/index.cjs.map +1 -1
- package/dist/iframe/transformers/index.js +2 -22
- package/dist/iframe/transformers/index.js.map +1 -1
- package/dist/iframe/transformers/pad-transformer.cjs +2 -2
- package/dist/iframe/transformers/pad-transformer.cjs.map +1 -1
- package/dist/iframe/transformers/pad-transformer.js +2 -24
- package/dist/iframe/transformers/pad-transformer.js.map +1 -1
- package/dist/image/image.cjs +2 -2
- package/dist/image/image.cjs.map +1 -1
- package/dist/image/image.d.ts +0 -7
- package/dist/image/image.js +2 -175
- package/dist/image/image.js.map +1 -1
- package/dist/image/image.spec.d.ts +1 -0
- package/dist/index.cjs +1 -2
- package/dist/index.js +1 -52
- package/dist/information-pane/information-pane.cjs +2 -2
- package/dist/information-pane/information-pane.cjs.map +1 -1
- package/dist/information-pane/information-pane.js +2 -57
- package/dist/information-pane/information-pane.js.map +1 -1
- package/dist/information-pane/information-pane.spec.d.ts +1 -0
- package/dist/line-height/line-height.cjs +2 -2
- package/dist/line-height/line-height.cjs.map +1 -1
- package/dist/line-height/line-height.js +2 -33
- package/dist/line-height/line-height.js.map +1 -1
- package/dist/line-height/line-height.spec.d.ts +1 -0
- package/dist/linker/linker.cjs +2 -2
- package/dist/linker/linker.cjs.map +1 -1
- package/dist/linker/linker.js +2 -96
- package/dist/linker/linker.js.map +1 -1
- package/dist/linker/linker.spec.d.ts +1 -0
- package/dist/mathjax/mathjax.cjs +2 -2
- package/dist/mathjax/mathjax.cjs.map +1 -1
- package/dist/mathjax/mathjax.js +2 -40
- package/dist/mathjax/mathjax.js.map +1 -1
- package/dist/mathjax/mathjax.spec.d.ts +1 -0
- package/dist/paragraph/paragraph.cjs +2 -2
- package/dist/paragraph/paragraph.cjs.map +1 -1
- package/dist/paragraph/paragraph.js +2 -16
- package/dist/paragraph/paragraph.js.map +1 -1
- package/dist/paragraph/paragraph.spec.d.ts +1 -0
- package/dist/speech-recognition/speech-recognition.cjs +2 -2
- package/dist/speech-recognition/speech-recognition.cjs.map +1 -1
- package/dist/speech-recognition/speech-recognition.js +2 -56
- package/dist/speech-recognition/speech-recognition.js.map +1 -1
- package/dist/speech-synthesis/speech-synthesis.cjs +2 -2
- package/dist/speech-synthesis/speech-synthesis.cjs.map +1 -1
- package/dist/speech-synthesis/speech-synthesis.js +2 -25
- package/dist/speech-synthesis/speech-synthesis.js.map +1 -1
- package/dist/table-cell/table-cell.cjs +2 -2
- package/dist/table-cell/table-cell.cjs.map +1 -1
- package/dist/table-cell/table-cell.d.ts +1 -1
- package/dist/table-cell/table-cell.js +2 -23
- package/dist/table-cell/table-cell.js.map +1 -1
- package/dist/table-cell/table-cell.spec.d.ts +1 -0
- package/dist/transform/html-to-json/html-to-json.cjs +2 -2
- package/dist/transform/html-to-json/html-to-json.cjs.map +1 -1
- package/dist/transform/html-to-json/html-to-json.js +2 -6
- package/dist/transform/html-to-json/html-to-json.js.map +1 -1
- package/dist/transform/json-to-html/json-to-html.cjs +2 -2
- package/dist/transform/json-to-html/json-to-html.cjs.map +1 -1
- package/dist/transform/json-to-html/json-to-html.js +2 -6
- package/dist/transform/json-to-html/json-to-html.js.map +1 -1
- package/dist/video/video.cjs +3 -3
- package/dist/video/video.cjs.map +1 -1
- package/dist/video/video.js +3 -92
- package/dist/video/video.js.map +1 -1
- package/dist/video/video.spec.d.ts +1 -0
- package/package.json +55 -34
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
package/dist/image/image.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image.cjs","sources":["../../src/image/image.ts"],"sourcesContent":["import { WorkspaceElement } from '@edifice.io/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: () => {\n return 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: '16px',\n };\n attr['width'] = 'null';\n attr['height'] = 'null';\n }\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,QACX,MAAO,CACL,IAAG,QAAK,SAAL,0BACH,OAAQ,GACR,QAAS,UACT,MAAO,CAAC,QAAS,SAAU,OAAO,EAClC,eAAgB,CACd,MAAO,cAAA,EAET,WAAY,IACH,QAAQ,QAAQ,IAAI,CAC7B,CAEJ,EAEA,eAAgB,QACd,MAAO,CACL,IAAG,QAAK,SAAL,0BACH,KAAM,CACJ,QAAS,SACT,SAAU,EAAA,EAEZ,IAAK,CACH,WAAa,aACJ,CACL,IAAK,WAAW,GAAA,GAGpB,UAAY,SAAY,QAAQ,aAAa,KAAK,CAAA,EAEpD,MAAO,CACL,WAAa,aACJ,CACL,MAAO,WAAW,KAAA,GAGtB,UAAY,SAAY,QAAQ,aAAa,OAAO,CAAA,EAEtD,MAAO,CACL,QAAS,MACT,WAAa,YAET,WAAW,QAAU,MACrB,WAAW,QAAU,QACrB,CAAC,OAAO,MAAM,WAAW,KAAK,EAEvB,CACL,MAAO,SAAS,WAAW,KAAK,CAAA,EAG7B,CAAA,EAET,UAAY,SAAY,QAAQ,aAAa,OAAO,CAAA,EAEtD,OAAQ,CACN,WAAa,YAET,WAAW,SAAW,MACtB,WAAW,SAAW,QACtB,CAAC,OAAO,MAAM,WAAW,MAAM,EAExB,CACL,OAAQ,SAAS,WAAW,MAAM,CAAA,EAG/B,CAAA,EAET,UAAY,SAAY,QAAQ,aAA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CAAE,IAAK,UAAa,OAAO,YAAY,CAC3C,KAAM,EAAE,QACR,IAAK,EAAE,OAAA,CACR,EAED,UAAW,QAAQ,MACjB,kBAAkB,OAAQ,KAAM,QAAQ,EAE1C,MAAO,EACT,CAAA,CACF,CACD,CAAA,CAEL,CACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"image.cjs","names":[],"sources":["../../src/image/image.ts"],"sourcesContent":["import { WorkspaceElement } from '@edifice.io/client';\nimport { ImageResizer } from '@edifice.io/utilities';\nimport { mergeAttributes, nodeInputRule } from '@tiptap/core';\nimport TiptapImage from '@tiptap/extension-image';\nimport { Plugin } from '@tiptap/pm/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\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n customImage: {\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: () => {\n return 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: '16px',\n };\n attr['width'] = 'null';\n attr['height'] = 'null';\n }\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 // Inherit TiptapImage's own setImage (scoped to `this.name`, i.e.\n // 'custom-image') - same bug class as heading.ts: without this spread,\n // addCommands() replaces rather than extends the parent's commands.\n ...this.parent?.(),\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 };\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"],"mappings":"sVAMA,IAAa,kBACX,2DAoBW,MAAQ,wBAAA,QAAY,OAA2B,CAC1D,KAAM,eACN,UAAW,GACX,WAAY,GAEZ,YAAa,CACX,MAAO,CACL,GAAG,KAAK,S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AAC,KAAM,OAEX,IAAM,YACJ,WAAa,IAAA,GAET,OAAO,MAAM,GAAG,qBAAqB,IAAI,EADzC,OAAO,MAAM,GAAG,OAAO,SAAU,IAAI,EAG3C,OAAO,SAAS,WAAW,CAC7B,EAEA,MAAO,CACL,IAAI,iBAAA,OAAO,CACT,MAAO,CACL,aAAc,OAAQ,IAAM,CAC1B,IAAM,MAAQ,iBAAiB,EAAE,eAAe,KAAK,EACrD,GAAI,MAAM,SAAW,EAAG,MAAO,GAE/B,IAAK,IAAM,QAAQ,MACjB,kBAAkB,OAAQ,IAAI,EAGhC,MAAO,EACT,EACA,YAAa,OAAQ,EAAG,GAAI,QAAU,CACpC,GAAI,MAAO,MAAO,GAElB,IAAM,MAAQ,iBAAiB,EAAE,aAAa,KAAK,EACnD,GAAI,MAAM,SAAW,EAAG,MAAO,GAE/B,GAAM,CAAE,IAAK,UAAa,OAAO,YAAY,CAC3C,KAAM,EAAE,QACR,IAAK,EAAE,OACT,CAAC,EAED,IAAK,IAAM,QAAQ,MACjB,kBAAkB,OAAQ,KAAM,QAAQ,EAE1C,MAAO,EACT,CACF,CACF,CAAC,CACH,CACF,CACF,CAAC"}
|
package/dist/image/image.d.ts
CHANGED
|
@@ -5,15 +5,9 @@ export interface CustomImageOptions {
|
|
|
5
5
|
sizes: string[];
|
|
6
6
|
uploadFile?: (file: File) => Promise<WorkspaceElement | null>;
|
|
7
7
|
}
|
|
8
|
-
interface AttributesProps {
|
|
9
|
-
width: number | string;
|
|
10
|
-
height: number | string;
|
|
11
|
-
size: string;
|
|
12
|
-
}
|
|
13
8
|
declare module '@tiptap/core' {
|
|
14
9
|
interface Commands<ReturnType> {
|
|
15
10
|
customImage: {
|
|
16
|
-
setAttributes: (options: AttributesProps) => ReturnType;
|
|
17
11
|
setNewImage: (options: {
|
|
18
12
|
src: string;
|
|
19
13
|
alt?: string;
|
|
@@ -23,4 +17,3 @@ declare module '@tiptap/core' {
|
|
|
23
17
|
}
|
|
24
18
|
}
|
|
25
19
|
export declare const Image: import('@tiptap/core').Node<CustomImageOptions, any>;
|
|
26
|
-
export {};
|
package/dist/image/image.js
CHANGED
|
@@ -1,175 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
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: () => null
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
},
|
|
63
|
-
parseHTML() {
|
|
64
|
-
return [
|
|
65
|
-
{
|
|
66
|
-
tag: 'img[src]:not([src^="data:"])',
|
|
67
|
-
getAttrs: (el) => {
|
|
68
|
-
var _a, _b, _c;
|
|
69
|
-
const attr = { src: el.getAttribute("src") };
|
|
70
|
-
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), [
|
|
71
|
-
"happy",
|
|
72
|
-
"proud",
|
|
73
|
-
"dreamy",
|
|
74
|
-
"love",
|
|
75
|
-
"tired",
|
|
76
|
-
"angry",
|
|
77
|
-
"worried",
|
|
78
|
-
"sick",
|
|
79
|
-
"joker",
|
|
80
|
-
"sad"
|
|
81
|
-
].filter((smiley) => attr.src.includes(smiley + ".png")).length > 0 && (attr.style = {
|
|
82
|
-
width: "1.5em",
|
|
83
|
-
height: "1.5em",
|
|
84
|
-
fontSize: "16px"
|
|
85
|
-
}, attr.width = "null", attr.height = "null"), attr;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
];
|
|
89
|
-
},
|
|
90
|
-
renderHTML({ HTMLAttributes }) {
|
|
91
|
-
return [
|
|
92
|
-
"img",
|
|
93
|
-
mergeAttributes(this.options.HTMLAttributes, HTMLAttributes)
|
|
94
|
-
];
|
|
95
|
-
},
|
|
96
|
-
addInputRules() {
|
|
97
|
-
return [
|
|
98
|
-
nodeInputRule({
|
|
99
|
-
find: IMAGE_INPUT_REGEX,
|
|
100
|
-
type: this.type,
|
|
101
|
-
getAttributes: (match) => {
|
|
102
|
-
const [, , alt, src, title] = match;
|
|
103
|
-
return {
|
|
104
|
-
src,
|
|
105
|
-
alt,
|
|
106
|
-
title
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
})
|
|
110
|
-
];
|
|
111
|
-
},
|
|
112
|
-
addCommands() {
|
|
113
|
-
return {
|
|
114
|
-
setNewImage: (attrs) => ({ tr, dispatch }) => {
|
|
115
|
-
const { selection } = tr, node = this.type.create(attrs);
|
|
116
|
-
return dispatch && tr.replaceRangeWith(selection.from, selection.to, node), !0;
|
|
117
|
-
},
|
|
118
|
-
setAttributes: (attributes) => ({ tr, dispatch }) => {
|
|
119
|
-
const { selection } = tr, options = {
|
|
120
|
-
...tr.doc.nodeAt(tr.selection.from).attrs,
|
|
121
|
-
...attributes
|
|
122
|
-
}, node = this.type.create(options);
|
|
123
|
-
return dispatch && tr.replaceRangeWith(selection.from, selection.to, node), !0;
|
|
124
|
-
}
|
|
125
|
-
};
|
|
126
|
-
},
|
|
127
|
-
addProseMirrorPlugins() {
|
|
128
|
-
const uploadNode = async (file) => {
|
|
129
|
-
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()}`;
|
|
130
|
-
return this.type.create({
|
|
131
|
-
src: imageUrl,
|
|
132
|
-
alt: image.alt,
|
|
133
|
-
title: image.title
|
|
134
|
-
});
|
|
135
|
-
}, getFilteredFiles = (files) => Array.from(files).filter(
|
|
136
|
-
(file) => /image\/(png|jpeg|jpg|gif|webp|heic|avif)/.test(file.type)
|
|
137
|
-
), handleImageInsert = async (editor, file, position) => {
|
|
138
|
-
const node = await uploadNode(file);
|
|
139
|
-
if (!node) return;
|
|
140
|
-
const transaction = position !== void 0 ? editor.state.tr.insert(position, node) : editor.state.tr.replaceSelectionWith(node);
|
|
141
|
-
editor.dispatch(transaction);
|
|
142
|
-
};
|
|
143
|
-
return [
|
|
144
|
-
new Plugin({
|
|
145
|
-
props: {
|
|
146
|
-
handlePaste: (editor, e) => {
|
|
147
|
-
var _a;
|
|
148
|
-
const files = getFilteredFiles((_a = e.clipboardData) == null ? void 0 : _a.files);
|
|
149
|
-
if (files.length === 0) return !1;
|
|
150
|
-
for (const file of files)
|
|
151
|
-
handleImageInsert(editor, file);
|
|
152
|
-
return !0;
|
|
153
|
-
},
|
|
154
|
-
handleDrop: (editor, e, _s, moved) => {
|
|
155
|
-
if (moved) return !1;
|
|
156
|
-
const files = getFilteredFiles(e.dataTransfer.files);
|
|
157
|
-
if (files.length === 0) return !1;
|
|
158
|
-
const { pos: position } = editor.posAtCoords({
|
|
159
|
-
left: e.clientX,
|
|
160
|
-
top: e.clientY
|
|
161
|
-
});
|
|
162
|
-
for (const file of files)
|
|
163
|
-
handleImageInsert(editor, file, position);
|
|
164
|
-
return !0;
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
})
|
|
168
|
-
];
|
|
169
|
-
}
|
|
170
|
-
});
|
|
171
|
-
export {
|
|
172
|
-
IMAGE_INPUT_REGEX,
|
|
173
|
-
Image
|
|
174
|
-
};
|
|
175
|
-
//# sourceMappingURL=image.js.map
|
|
1
|
+
import{mergeAttributes,nodeInputRule}from"@tiptap/core";import{Plugin}from"@tiptap/pm/state";import{ImageResizer}from"@edifice.io/utilities";import TiptapImage from"@tiptap/extension-image";var IMAGE_INPUT_REGEX=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,Image=TiptapImage.extend({name:`custom-image`,draggable:!0,selectable:!0,addOptions(){return{...this.parent?.(),inline:!0,content:`inline*`,sizes:[`small`,`medium`,`large`],HTMLAttributes:{class:`custom-image`},uploadFile:()=>Promise.resolve(null)}},addAttributes(){return{...this.parent?.(),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:()=>null}}},parseHTML(){return[{tag:`img[src]:not([src^="data:"])`,getAttrs:el=>{let attr={src:el.getAttribute(`src`)};return el.parentElement?.className.includes(`image-container`)&&el.parentElement.style?.width&&(attr.width=el.parentElement.style.width),el.style?.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:`16px`},attr.width=`null`,attr.height=`null`),attr}}]},renderHTML({HTMLAttributes}){return[`img`,mergeAttributes(this.options.HTMLAttributes,HTMLAttributes)]},addInputRules(){return[nodeInputRule({find:IMAGE_INPUT_REGEX,type:this.type,getAttributes:match=>{let[,,alt,src,title]=match;return{src,alt,title}}})]},addCommands(){return{...this.parent?.(),setNewImage:attrs=>({tr,dispatch})=>{let{selection}=tr,node=this.type.create(attrs);return dispatch&&tr.replaceRangeWith(selection.from,selection.to,node),!0}}},addProseMirrorPlugins(){let uploadNode=async file=>{let resizedImage=await 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)=>{let node=await uploadNode(file);if(!node)return;let transaction=position===void 0?editor.state.tr.replaceSelectionWith(node):editor.state.tr.insert(position,node);editor.dispatch(transaction)};return[new Plugin({props:{handlePaste:(editor,e)=>{let files=getFilteredFiles(e.clipboardData?.files);if(files.length===0)return!1;for(let file of files)handleImageInsert(editor,file);return!0},handleDrop:(editor,e,_s,moved)=>{if(moved)return!1;let files=getFilteredFiles(e.dataTransfer.files);if(files.length===0)return!1;let{pos:position}=editor.posAtCoords({left:e.clientX,top:e.clientY});for(let file of files)handleImageInsert(editor,file,position);return!0}}})]}});export{IMAGE_INPUT_REGEX,Image};
|
|
2
|
+
//# sourceMappingURL=image.js.map
|
package/dist/image/image.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image.js","sources":["../../src/image/image.ts"],"sourcesContent":["import { WorkspaceElement } from '@edifice.io/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: () => {\n return 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: '16px',\n };\n attr['width'] = 'null';\n attr['height'] = 'null';\n }\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;;AACX,WAAO;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,MAAA;AAAA,MAET,YAAY,MACH,QAAQ,QAAQ,IAAI;AAAA,IAC7B;AAAA,EAEJ;AAAA,EAEA,gBAAgB;;AACd,WAAO;AAAA,MACL,IAAG,UAAK,WAAL;AAAA,MACH,MAAM;AAAA,QACJ,SAAS;AAAA,QACT,UAAU;AAAA,MAAA;AAAA,MAEZ,KAAK;AAAA,QACH,YAAY,CAAC,gBACJ;AAAA,UACL,KAAK,WAAW;AAAA,QAAA;AAAA,QAGpB,WAAW,CAAC,YAAY,QAAQ,aAAa,KAAK;AAAA,MAAA;AAAA,MAEpD,OAAO;AAAA,QACL,YAAY,CAAC,gBACJ;AAAA,UACL,OAAO,WAAW;AAAA,QAAA;AAAA,QAGtB,WAAW,C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A,EAEL;AACF,CAAC;"}
|
|
1
|
+
{"version":3,"file":"image.js","names":[],"sources":["../../src/image/image.ts"],"sourcesContent":["import { WorkspaceElement } from '@edifice.io/client';\nimport { ImageResizer } from '@edifice.io/utilities';\nimport { mergeAttributes, nodeInputRule } from '@tiptap/core';\nimport TiptapImage from '@tiptap/extension-image';\nimport { Plugin } from '@tiptap/pm/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\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n customImage: {\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: () => {\n return 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: '16px',\n };\n attr['width'] = 'null';\n attr['height'] = 'null';\n }\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 // Inherit TiptapImage's own setImage (scoped to `this.name`, i.e.\n // 'custom-image') - same bug class as heading.ts: without this spread,\n // addCommands() replaces rather than extends the parent's commands.\n ...this.parent?.(),\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 };\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"],"mappings":"8LAMA,IAAa,kBACX,2DAoBW,MAAQ,YAAY,OAA2B,CAC1D,KAAM,eACN,UAAW,GACX,WAAY,GAEZ,YAAa,CACX,MAAO,CACL,GAAG,KAAK,SAAS,EACjB,OAAQ,GACR,QAAS,UACT,MAAO,CAAC,QAAS,SAAU,OAAO,EAClC,eAAgB,CACd,MAAO,cACT,EACA,eACS,QAAQ,QAAQ,IAAI,CAE/B,CACF,EAEA,eAAgB,CACd,MAAO,CACL,GAAG,KAAK,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Q,IAAM,CAC1B,IAAM,MAAQ,iBAAiB,EAAE,eAAe,KAAK,EACrD,GAAI,MAAM,SAAW,EAAG,MAAO,GAE/B,IAAK,IAAM,QAAQ,MACjB,kBAAkB,OAAQ,IAAI,EAGhC,MAAO,EACT,EACA,YAAa,OAAQ,EAAG,GAAI,QAAU,CACpC,GAAI,MAAO,MAAO,GAElB,IAAM,MAAQ,iBAAiB,EAAE,aAAa,KAAK,EACnD,GAAI,MAAM,SAAW,EAAG,MAAO,GAE/B,GAAM,CAAE,IAAK,UAAa,OAAO,YAAY,CAC3C,KAAM,EAAE,QACR,IAAK,EAAE,OACT,CAAC,EAED,IAAK,IAAM,QAAQ,MACjB,kBAAkB,OAAQ,KAAM,QAAQ,EAE1C,MAAO,EACT,CACF,CACF,CAAC,CACH,CACF,CACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
//# sourceMappingURL=index.cjs.map
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const require_abbr=require("./abbr/abbr.cjs"),require_alert=require("./alert/alert.cjs"),require_attachment=require("./attachment/attachment.cjs"),require_attachment_transformer=require("./attachment/attachment-transformer.cjs"),require_audio=require("./audio/audio.cjs"),require_conversation_history=require("./conversation-history/conversation-history.cjs"),require_conversation_history_body=require("./conversation-history-body/conversation-history-body.cjs"),require_font_size=require("./font-size/font-size.cjs"),require_heading=require("./heading/heading.cjs"),require_highlight=require("./highlight/highlight.cjs"),require_hyperlink=require("./hyperlink/hyperlink.cjs"),require_iframe=require("./iframe/iframe.cjs"),require_image=require("./image/image.cjs"),require_information_pane=require("./information-pane/information-pane.cjs"),require_line_height=require("./line-height/line-height.cjs"),require_linker=require("./linker/linker.cjs"),require_mathjax=require("./mathjax/mathjax.cjs"),require_paragraph=require("./paragraph/paragraph.cjs"),require_speech_recognition=require("./speech-recognition/speech-recognition.cjs"),require_speech_synthesis=require("./speech-synthesis/speech-synthesis.cjs"),require_table_cell=require("./table-cell/table-cell.cjs"),require_html_to_json=require("./transform/html-to-json/html-to-json.cjs"),require_json_to_html=require("./transform/json-to-html/json-to-html.cjs"),require_video=require("./video/video.cjs");exports.Abbr=require_abbr.Abbr,exports.Alert=require_alert.Alert,exports.Attachment=require_attachment.Attachment,exports.AttachmentTransformer=require_attachment_transformer.AttachmentTransformer,exports.Audio=require_audio.Audio,exports.ConversationHistory=require_conversation_history.ConversationHistory,exports.ConversationHistoryBody=require_conversation_history_body.ConversationHistoryBody,exports.CustomHeading=require_heading.CustomHeading,exports.CustomHighlight=require_highlight.CustomHighlight,exports.FontSize=require_font_size.FontSize,exports.Hyperlink=require_hyperlink.Hyperlink,exports.IMAGE_INPUT_REGEX=require_image.IMAGE_INPUT_REGEX,exports.Iframe=require_iframe.Iframe,exports.Image=require_image.Image,exports.InformationPane=require_information_pane.InformationPane,exports.LineHeight=require_line_height.LineHeight,exports.Linker=require_linker.Linker,exports.MathJax=require_mathjax.MathJax,exports.Paragraph=require_paragraph.Paragraph,exports.SpeechRecognition=require_speech_recognition.SpeechRecognition,exports.SpeechSynthesis=require_speech_synthesis.SpeechSynthesis,exports.TableCell=require_table_cell.TableCell,exports.Video=require_video.Video,exports.htmlToJson=require_html_to_json,exports.jsonToHtml=require_json_to_html;
|
package/dist/index.js
CHANGED
|
@@ -1,52 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Alert } from "./alert/alert.js";
|
|
3
|
-
import { Attachment } from "./attachment/attachment.js";
|
|
4
|
-
import { AttachmentTransformer } from "./attachment/attachment-transformer.js";
|
|
5
|
-
import { Audio } from "./audio/audio.js";
|
|
6
|
-
import { ConversationHistory } from "./conversation-history/conversation-history.js";
|
|
7
|
-
import { ConversationHistoryBody } from "./conversation-history-body/conversation-history-body.js";
|
|
8
|
-
import { CustomHeading } from "./heading/heading.js";
|
|
9
|
-
import { CustomHighlight } from "./highlight/highlight.js";
|
|
10
|
-
import { FontSize } from "./font-size/font-size.js";
|
|
11
|
-
import { Hyperlink } from "./hyperlink/hyperlink.js";
|
|
12
|
-
import { IMAGE_INPUT_REGEX, Image } from "./image/image.js";
|
|
13
|
-
import { Iframe } from "./iframe/iframe.js";
|
|
14
|
-
import { InformationPane } from "./information-pane/information-pane.js";
|
|
15
|
-
import { LineHeight } from "./line-height/line-height.js";
|
|
16
|
-
import { Linker } from "./linker/linker.js";
|
|
17
|
-
import { MathJax } from "./mathjax/mathjax.js";
|
|
18
|
-
import { Paragraph } from "./paragraph/paragraph.js";
|
|
19
|
-
import { SpeechRecognition } from "./speech-recognition/speech-recognition.js";
|
|
20
|
-
import { SpeechSynthesis } from "./speech-synthesis/speech-synthesis.js";
|
|
21
|
-
import { TableCell } from "./table-cell/table-cell.js";
|
|
22
|
-
import { Video } from "./video/video.js";
|
|
23
|
-
import { default as default2 } from "./transform/html-to-json/html-to-json.js";
|
|
24
|
-
import { default as default3 } from "./transform/json-to-html/json-to-html.js";
|
|
25
|
-
export {
|
|
26
|
-
Abbr,
|
|
27
|
-
Alert,
|
|
28
|
-
Attachment,
|
|
29
|
-
AttachmentTransformer,
|
|
30
|
-
Audio,
|
|
31
|
-
ConversationHistory,
|
|
32
|
-
ConversationHistoryBody,
|
|
33
|
-
CustomHeading,
|
|
34
|
-
CustomHighlight,
|
|
35
|
-
FontSize,
|
|
36
|
-
Hyperlink,
|
|
37
|
-
IMAGE_INPUT_REGEX,
|
|
38
|
-
Iframe,
|
|
39
|
-
Image,
|
|
40
|
-
InformationPane,
|
|
41
|
-
LineHeight,
|
|
42
|
-
Linker,
|
|
43
|
-
MathJax,
|
|
44
|
-
Paragraph,
|
|
45
|
-
SpeechRecognition,
|
|
46
|
-
SpeechSynthesis,
|
|
47
|
-
TableCell,
|
|
48
|
-
Video,
|
|
49
|
-
default2 as htmlToJson,
|
|
50
|
-
default3 as jsonToHtml
|
|
51
|
-
};
|
|
52
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
import{Abbr}from"./abbr/abbr.js";import{Alert}from"./alert/alert.js";import{Attachment}from"./attachment/attachment.js";import{AttachmentTransformer}from"./attachment/attachment-transformer.js";import{Audio}from"./audio/audio.js";import{ConversationHistory}from"./conversation-history/conversation-history.js";import{ConversationHistoryBody}from"./conversation-history-body/conversation-history-body.js";import{FontSize}from"./font-size/font-size.js";import{CustomHeading}from"./heading/heading.js";import{CustomHighlight}from"./highlight/highlight.js";import{Hyperlink}from"./hyperlink/hyperlink.js";import{Iframe}from"./iframe/iframe.js";import{IMAGE_INPUT_REGEX,Image}from"./image/image.js";import{InformationPane}from"./information-pane/information-pane.js";import{LineHeight}from"./line-height/line-height.js";import{Linker}from"./linker/linker.js";import{MathJax}from"./mathjax/mathjax.js";import{Paragraph}from"./paragraph/paragraph.js";import{SpeechRecognition}from"./speech-recognition/speech-recognition.js";import{SpeechSynthesis}from"./speech-synthesis/speech-synthesis.js";import{TableCell}from"./table-cell/table-cell.js";import html_to_json_default from"./transform/html-to-json/html-to-json.js";import json_to_html_default from"./transform/json-to-html/json-to-html.js";import{Video}from"./video/video.js";export{Abbr,Alert,Attachment,AttachmentTransformer,Audio,ConversationHistory,ConversationHistoryBody,CustomHeading,CustomHighlight,FontSize,Hyperlink,IMAGE_INPUT_REGEX,Iframe,Image,InformationPane,LineHeight,Linker,MathJax,Paragraph,SpeechRecognition,SpeechSynthesis,TableCell,Video,html_to_json_default as htmlToJson,json_to_html_default as jsonToHtml};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
//# sourceMappingURL=information-pane.cjs.map
|
|
1
|
+
let _tiptap_core=require("@tiptap/core");var InformationPane=_tiptap_core.Node.create({name:`information-pane`,group:`block`,content:`block+`,defining:!0,marks:``,addAttributes(){return{type:{default:`info`,parseHTML:element=>element.getAttribute(`data-type`)||`info`,renderHTML:attributes=>({"data-type":attributes.type})}}},parseHTML(){return[{tag:`div[data-information-pane]`}]},renderHTML({node,HTMLAttributes}){let type=node.attrs.type;return[`div`,(0,_tiptap_core.mergeAttributes)(HTMLAttributes,{"data-information-pane":``,class:`information-pane information-pane-${type}`}),0]},addCommands(){return{setInformationPane:(type=`info`)=>({commands})=>commands.insertContent([{type:this.name,attrs:{type},content:[{type:`paragraph`}]}])}}});exports.InformationPane=InformationPane;
|
|
2
|
+
//# sourceMappingURL=information-pane.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"information-pane.cjs","sources":["../../src/information-pane/information-pane.ts"],"sourcesContent":["import { Node, mergeAttributes } from '@tiptap/core';\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n informationPane: {\n /**\n * Set a informationPane node\n * @param type The type of the informationPane\n */\n setInformationPane: (type?: string) => ReturnType;\n };\n }\n}\n\nexport const InformationPane = Node.create({\n name: 'information-pane',\n\n group: 'block',\n content: 'block+',\n defining: true,\n marks: '',\n\n addAttributes() {\n return {\n type: {\n default: 'info', // type par défaut\n parseHTML: (element) => element.getAttribute('data-type') || 'info',\n renderHTML: (attributes) => {\n return {\n 'data-type': attributes.type,\n };\n },\n },\n };\n },\n\n parseHTML() {\n return [\n {\n tag: 'div[data-information-pane]',\n },\n ];\n },\n\n renderHTML({ node, HTMLAttributes }) {\n const type = node.attrs.type;\n return [\n 'div',\n mergeAttributes(HTMLAttributes, {\n 'data-information-pane': '',\n 'class': `information-pane information-pane-${type}`,\n }),\n 0,\n ];\n },\n\n addCommands() {\n return {\n setInformationPane:\n (type = 'info') =>\n ({ commands }) => {\n return commands.insertContent([\n {\n type: this.name,\n attrs: { type },\n content: [\n {\n type: 'paragraph',\n },\n ],\n },\n ]);\n },\n };\n },\n});\n"],"
|
|
1
|
+
{"version":3,"file":"information-pane.cjs","names":[],"sources":["../../src/information-pane/information-pane.ts"],"sourcesContent":["import { Node, mergeAttributes } from '@tiptap/core';\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n informationPane: {\n /**\n * Set a informationPane node\n * @param type The type of the informationPane\n */\n setInformationPane: (type?: string) => ReturnType;\n };\n }\n}\n\nexport const InformationPane = Node.create({\n name: 'information-pane',\n\n group: 'block',\n content: 'block+',\n defining: true,\n marks: '',\n\n addAttributes() {\n return {\n type: {\n default: 'info', // type par défaut\n parseHTML: (element) => element.getAttribute('data-type') || 'info',\n renderHTML: (attributes) => {\n return {\n 'data-type': attributes.type,\n };\n },\n },\n };\n },\n\n parseHTML() {\n return [\n {\n tag: 'div[data-information-pane]',\n },\n ];\n },\n\n renderHTML({ node, HTMLAttributes }) {\n const type = node.attrs.type;\n return [\n 'div',\n mergeAttributes(HTMLAttributes, {\n 'data-information-pane': '',\n 'class': `information-pane information-pane-${type}`,\n }),\n 0,\n ];\n },\n\n addCommands() {\n return {\n setInformationPane:\n (type = 'info') =>\n ({ commands }) => {\n return commands.insertContent([\n {\n type: this.name,\n attrs: { type },\n content: [\n {\n type: 'paragraph',\n },\n ],\n },\n ]);\n },\n };\n },\n});\n"],"mappings":"yCAcA,IAAa,gBAAkB,aAAA,KAAK,OAAO,CACzC,KAAM,mBAEN,MAAO,QACP,QAAS,SACT,SAAU,GACV,MAAO,GAEP,eAAgB,CACd,MAAO,CACL,KAAM,CACJ,QAAS,OACT,UAAY,SAAY,QAAQ,aAAa,WAAW,GAAK,OAC7D,WAAa,aACJ,CACL,YAAa,WAAW,IAC1B,EAEJ,CACF,CACF,EAEA,WAAY,CACV,MAAO,CACL,CACE,IAAK,4BACP,CACF,CACF,EAEA,WAAW,CAAE,KAAM,gBAAkB,CACnC,IAAM,KAAO,KAAK,MAAM,KACxB,MAAO,CACL,uCACgB,eAAgB,CAC9B,wBAAyB,GACzB,MAAS,qCAAqC,MAChD,CAAC,EACD,CACF,CACF,EAEA,aAAc,CACZ,MAAO,CACL,oBACG,KAAO,UACP,CAAE,YACM,SAAS,cAAc,CAC5B,CACE,KAAM,KAAK,KACX,MAAO,CAAE,IAAK,EACd,QAAS,CACP,CACE,KAAM,WACR,CACF,CACF,CACF,CAAC,CAEP,CACF,CACF,CAAC"}
|
|
@@ -1,57 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
name: "information-pane",
|
|
4
|
-
group: "block",
|
|
5
|
-
content: "block+",
|
|
6
|
-
defining: !0,
|
|
7
|
-
marks: "",
|
|
8
|
-
addAttributes() {
|
|
9
|
-
return {
|
|
10
|
-
type: {
|
|
11
|
-
default: "info",
|
|
12
|
-
// type par défaut
|
|
13
|
-
parseHTML: (element) => element.getAttribute("data-type") || "info",
|
|
14
|
-
renderHTML: (attributes) => ({
|
|
15
|
-
"data-type": attributes.type
|
|
16
|
-
})
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
},
|
|
20
|
-
parseHTML() {
|
|
21
|
-
return [
|
|
22
|
-
{
|
|
23
|
-
tag: "div[data-information-pane]"
|
|
24
|
-
}
|
|
25
|
-
];
|
|
26
|
-
},
|
|
27
|
-
renderHTML({ node, HTMLAttributes }) {
|
|
28
|
-
const type = node.attrs.type;
|
|
29
|
-
return [
|
|
30
|
-
"div",
|
|
31
|
-
mergeAttributes(HTMLAttributes, {
|
|
32
|
-
"data-information-pane": "",
|
|
33
|
-
class: `information-pane information-pane-${type}`
|
|
34
|
-
}),
|
|
35
|
-
0
|
|
36
|
-
];
|
|
37
|
-
},
|
|
38
|
-
addCommands() {
|
|
39
|
-
return {
|
|
40
|
-
setInformationPane: (type = "info") => ({ commands }) => commands.insertContent([
|
|
41
|
-
{
|
|
42
|
-
type: this.name,
|
|
43
|
-
attrs: { type },
|
|
44
|
-
content: [
|
|
45
|
-
{
|
|
46
|
-
type: "paragraph"
|
|
47
|
-
}
|
|
48
|
-
]
|
|
49
|
-
}
|
|
50
|
-
])
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
export {
|
|
55
|
-
InformationPane
|
|
56
|
-
};
|
|
57
|
-
//# sourceMappingURL=information-pane.js.map
|
|
1
|
+
import{Node,mergeAttributes}from"@tiptap/core";var InformationPane=Node.create({name:`information-pane`,group:`block`,content:`block+`,defining:!0,marks:``,addAttributes(){return{type:{default:`info`,parseHTML:element=>element.getAttribute(`data-type`)||`info`,renderHTML:attributes=>({"data-type":attributes.type})}}},parseHTML(){return[{tag:`div[data-information-pane]`}]},renderHTML({node,HTMLAttributes}){let type=node.attrs.type;return[`div`,mergeAttributes(HTMLAttributes,{"data-information-pane":``,class:`information-pane information-pane-${type}`}),0]},addCommands(){return{setInformationPane:(type=`info`)=>({commands})=>commands.insertContent([{type:this.name,attrs:{type},content:[{type:`paragraph`}]}])}}});export{InformationPane};
|
|
2
|
+
//# sourceMappingURL=information-pane.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"information-pane.js","sources":["../../src/information-pane/information-pane.ts"],"sourcesContent":["import { Node, mergeAttributes } from '@tiptap/core';\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n informationPane: {\n /**\n * Set a informationPane node\n * @param type The type of the informationPane\n */\n setInformationPane: (type?: string) => ReturnType;\n };\n }\n}\n\nexport const InformationPane = Node.create({\n name: 'information-pane',\n\n group: 'block',\n content: 'block+',\n defining: true,\n marks: '',\n\n addAttributes() {\n return {\n type: {\n default: 'info', // type par défaut\n parseHTML: (element) => element.getAttribute('data-type') || 'info',\n renderHTML: (attributes) => {\n return {\n 'data-type': attributes.type,\n };\n },\n },\n };\n },\n\n parseHTML() {\n return [\n {\n tag: 'div[data-information-pane]',\n },\n ];\n },\n\n renderHTML({ node, HTMLAttributes }) {\n const type = node.attrs.type;\n return [\n 'div',\n mergeAttributes(HTMLAttributes, {\n 'data-information-pane': '',\n 'class': `information-pane information-pane-${type}`,\n }),\n 0,\n ];\n },\n\n addCommands() {\n return {\n setInformationPane:\n (type = 'info') =>\n ({ commands }) => {\n return commands.insertContent([\n {\n type: this.name,\n attrs: { type },\n content: [\n {\n type: 'paragraph',\n },\n ],\n },\n ]);\n },\n };\n },\n});\n"],"
|
|
1
|
+
{"version":3,"file":"information-pane.js","names":[],"sources":["../../src/information-pane/information-pane.ts"],"sourcesContent":["import { Node, mergeAttributes } from '@tiptap/core';\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n informationPane: {\n /**\n * Set a informationPane node\n * @param type The type of the informationPane\n */\n setInformationPane: (type?: string) => ReturnType;\n };\n }\n}\n\nexport const InformationPane = Node.create({\n name: 'information-pane',\n\n group: 'block',\n content: 'block+',\n defining: true,\n marks: '',\n\n addAttributes() {\n return {\n type: {\n default: 'info', // type par défaut\n parseHTML: (element) => element.getAttribute('data-type') || 'info',\n renderHTML: (attributes) => {\n return {\n 'data-type': attributes.type,\n };\n },\n },\n };\n },\n\n parseHTML() {\n return [\n {\n tag: 'div[data-information-pane]',\n },\n ];\n },\n\n renderHTML({ node, HTMLAttributes }) {\n const type = node.attrs.type;\n return [\n 'div',\n mergeAttributes(HTMLAttributes, {\n 'data-information-pane': '',\n 'class': `information-pane information-pane-${type}`,\n }),\n 0,\n ];\n },\n\n addCommands() {\n return {\n setInformationPane:\n (type = 'info') =>\n ({ commands }) => {\n return commands.insertContent([\n {\n type: this.name,\n attrs: { type },\n content: [\n {\n type: 'paragraph',\n },\n ],\n },\n ]);\n },\n };\n },\n});\n"],"mappings":"+CAcA,IAAa,gBAAkB,KAAK,OAAO,CACzC,KAAM,mBAEN,MAAO,QACP,QAAS,SACT,SAAU,GACV,MAAO,GAEP,eAAgB,CACd,MAAO,CACL,KAAM,CACJ,QAAS,OACT,UAAY,SAAY,QAAQ,aAAa,WAAW,GAAK,OAC7D,WAAa,aACJ,CACL,YAAa,WAAW,IAC1B,EAEJ,CACF,CACF,EAEA,WAAY,CACV,MAAO,CACL,CACE,IAAK,4BACP,CACF,CACF,EAEA,WAAW,CAAE,KAAM,gBAAkB,CACnC,IAAM,KAAO,KAAK,MAAM,KACxB,MAAO,CACL,MACA,gBAAgB,eAAgB,CAC9B,wBAAyB,GACzB,MAAS,qCAAqC,MAChD,CAAC,EACD,CACF,CACF,EAEA,aAAc,CACZ,MAAO,CACL,oBACG,KAAO,UACP,CAAE,YACM,SAAS,cAAc,CAC5B,CACE,KAAM,KAAK,KACX,MAAO,CAAE,IAAK,EACd,QAAS,CACP,CACE,KAAM,WACR,CACF,CACF,CACF,CAAC,CAEP,CACF,CACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
//# sourceMappingURL=line-height.cjs.map
|
|
1
|
+
let _tiptap_core=require("@tiptap/core");require("@tiptap/extension-text-style");var LineHeight=_tiptap_core.Extension.create({name:`lineHeight`,addOptions(){return{types:[`textStyle`]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{lineHeight:{default:null,parseHTML:element=>element.style.lineHeight?.replace(/['"]+/g,``),renderHTML:attributes=>attributes.lineHeight?{style:`line-height: ${attributes.lineHeight}`}:{}}}}]}});exports.LineHeight=LineHeight;
|
|
2
|
+
//# sourceMappingURL=line-height.cjs.map
|
|
@@ -1 +1 @@
|
|
|
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"],"
|
|
1
|
+
{"version":3,"file":"line-height.cjs","names":[],"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"],"mappings":"iFAIA,IAAa,WAAa,aAAA,UAAU,OAAO,CACzC,KAAM,aAEN,YAAa,CACX,MAAO,CACL,MAAO,CAAC,WAAW,CACrB,CACF,EAEA,qBAAsB,CACpB,MAAO,CACL,CACE,MAAO,KAAK,QAAQ,MACpB,WAAY,CACV,WAAY,CACV,QAAS,KACT,UAAY,SACV,QAAQ,MAAM,YAAY,QAAQ,SAAU,EAAE,EAChD,WAAa,YACN,WAAW,WAIT,CACL,MAAO,gBAAgB,WAAW,YACpC,EALS,CAAC,CAOd,CACF,CACF,CACF,CACF,CACF,CAAC"}
|
|
@@ -1,33 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
const LineHeight = Extension.create({
|
|
4
|
-
name: "lineHeight",
|
|
5
|
-
addOptions() {
|
|
6
|
-
return {
|
|
7
|
-
types: ["textStyle"]
|
|
8
|
-
};
|
|
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 ? void 0 : _a.replace(/['"]+/g, "");
|
|
20
|
-
},
|
|
21
|
-
renderHTML: (attributes) => attributes.lineHeight ? {
|
|
22
|
-
style: `line-height: ${attributes.lineHeight}`
|
|
23
|
-
} : {}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
];
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
export {
|
|
31
|
-
LineHeight
|
|
32
|
-
};
|
|
33
|
-
//# sourceMappingURL=line-height.js.map
|
|
1
|
+
import{Extension}from"@tiptap/core";import"@tiptap/extension-text-style";var LineHeight=Extension.create({name:`lineHeight`,addOptions(){return{types:[`textStyle`]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{lineHeight:{default:null,parseHTML:element=>element.style.lineHeight?.replace(/['"]+/g,``),renderHTML:attributes=>attributes.lineHeight?{style:`line-height: ${attributes.lineHeight}`}:{}}}}]}});export{LineHeight};
|
|
2
|
+
//# sourceMappingURL=line-height.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"line-height.js","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"],"
|
|
1
|
+
{"version":3,"file":"line-height.js","names":[],"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"],"mappings":"yEAIA,IAAa,WAAa,UAAU,OAAO,CACzC,KAAM,aAEN,YAAa,CACX,MAAO,CACL,MAAO,CAAC,WAAW,CACrB,CACF,EAEA,qBAAsB,CACpB,MAAO,CACL,CACE,MAAO,KAAK,QAAQ,MACpB,WAAY,CACV,WAAY,CACV,QAAS,KACT,UAAY,SACV,QAAQ,MAAM,YAAY,QAAQ,SAAU,EAAE,EAChD,WAAa,YACN,WAAW,WAIT,CACL,MAAO,gBAAgB,WAAW,YACpC,EALS,CAAC,CAOd,CACF,CACF,CACF,CACF,CACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/linker/linker.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
//# sourceMappingURL=linker.cjs.map
|
|
1
|
+
let _tiptap_core=require("@tiptap/core");var Linker=_tiptap_core.Node.create({name:`linker`,content:`text*`,marks:``,group:`inline`,inline:!0,selectable:!0,atom:!0,draggable:!0,isolating:!0,allowGapCursor:!1,priority:1100,addOptions(){return{openOnClick:!0,HTMLAttributes:{target:null,title:null,class:null,"data-id":null,"data-app-prefix":null},validate:void 0}},addAttributes(){return{href:{default:null},class:{default:this.options.HTMLAttributes.class},target:{default:this.options.HTMLAttributes.target,parseHTML:element=>element.getAttribute(`target`)===`_blank`?`_blank`:null},title:{default:this.options.HTMLAttributes.title},"data-id":{default:this.options.HTMLAttributes[`data-id`]},"data-app-prefix":{default:this.options.HTMLAttributes[`data-app-prefix`]}}},parseHTML(){return[{tag:`a[href]:not([href *= "javascript:" i])[data-id][data-app-prefix]`}]},renderHTML({HTMLAttributes}){return HTMLAttributes.href?.startsWith(`javascript:`)?[`a`,(0,_tiptap_core.mergeAttributes)(this.options.HTMLAttributes,{...HTMLAttributes,href:``}),0]:[`a`,(0,_tiptap_core.mergeAttributes)(this.options.HTMLAttributes,HTMLAttributes),0]},addCommands(){return{setLinker:attrs=>({commands})=>(commands.insertContent({type:this.name,attrs,content:[{type:`text`,text:attrs.title}]}),!0),unsetLinker:()=>({state,tr})=>{let{node,from,to}=state.selection;return node?.type.name===`linker`&&tr.delete(from,to).scrollIntoView(),!0}}}});exports.Linker=Linker;
|
|
2
|
+
//# sourceMappingURL=linker.cjs.map
|