feat: creates and uses an extension of Image that allows more attributes
This commit is contained in:
25
src/Umbraco.Web.UI.Client/src/external/tiptap/extensions/tiptap-umb-image.extension.ts
vendored
Normal file
25
src/Umbraco.Web.UI.Client/src/external/tiptap/extensions/tiptap-umb-image.extension.ts
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
import { nodeInputRule } from '@tiptap/core';
|
||||
import Image, { inputRegex } from '@tiptap/extension-image';
|
||||
|
||||
export const UmbImage = Image.extend({
|
||||
addAttributes() {
|
||||
return {
|
||||
...this.parent?.(),
|
||||
width: {
|
||||
default: '100%',
|
||||
},
|
||||
height: {
|
||||
default: null,
|
||||
},
|
||||
loading: {
|
||||
default: null,
|
||||
},
|
||||
srcset: {
|
||||
default: null,
|
||||
},
|
||||
sizes: {
|
||||
default: null,
|
||||
},
|
||||
};
|
||||
},
|
||||
});
|
||||
@@ -23,3 +23,5 @@ export { Strike } from '@tiptap/extension-strike';
|
||||
export { TextAlign } from '@tiptap/extension-text-align';
|
||||
export { Underline } from '@tiptap/extension-underline';
|
||||
export { Image } from '@tiptap/extension-image';
|
||||
// CUSTOM EXTENSIONS
|
||||
export * from './extensions/tiptap-umb-image.extension.js';
|
||||
|
||||
@@ -15,7 +15,7 @@ import {
|
||||
HardBreak,
|
||||
History,
|
||||
HorizontalRule,
|
||||
Image,
|
||||
UmbImage,
|
||||
Italic,
|
||||
Link,
|
||||
ListItem,
|
||||
@@ -94,7 +94,7 @@ export class UmbInputTiptapElement extends UmbFormControlMixin(UmbLitElement, ''
|
||||
Code,
|
||||
CodeBlock,
|
||||
HorizontalRule,
|
||||
Image.configure({ inline: true }),
|
||||
UmbImage.configure({ inline: true }),
|
||||
Italic,
|
||||
Link.configure({ openOnClick: false }),
|
||||
ListItem, // This is needed for BulletList and OrderedList. When moving to an umbraco-extension, how should we handle shared extensions?
|
||||
|
||||
Reference in New Issue
Block a user