Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/EditorFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,17 @@ const createRichEditor = ({
connection,
relativePath,
isEmbedded = false,
noLazyImages = false,
} = {}) => {
return new Editor({
editorProps,
extensions: [
RichText.configure({ connection, relativePath, isEmbedded }),
RichText.configure({
connection,
relativePath,
isEmbedded,
noLazyImages,
}),
FocusTrap,
...extensions,
],
Expand Down
5 changes: 5 additions & 0 deletions src/components/Editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,10 @@ export default defineComponent({
type: Boolean,
default: false,
},
noLazyImages: {
type: Boolean,
default: false,
},
},

setup(props) {
Expand Down Expand Up @@ -249,6 +253,7 @@ export default defineComponent({
relativePath: props.relativePath,
extensions,
isEmbedded: props.isEmbedded,
noLazyImages: props.noLazyImages,
})
: createPlainEditor({ language, extensions })
provideEditor(editor)
Expand Down
5 changes: 5 additions & 0 deletions src/components/Editor/MarkdownContentEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,18 @@ export default {
type: Boolean,
default: false,
},
noLazyImages: {
type: Boolean,
default: false,
},
},
emits: ['update:content'],

setup(props) {
const extensions = [
RichText.configure({
extensions: [History],
noLazyImages: props.noLazyImages,
}),
FocusTrap,
]
Expand Down
1 change: 1 addition & 0 deletions src/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ window.OCA.Text.createEditor = async function ({
props: null,
},
menubarLinkCustomAction = undefined,
noLazyImages = false,

onCreate = ({ markdown }) => {},
onLoaded = () => {},
Expand Down
4 changes: 2 additions & 2 deletions src/extensions/RichText.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ export default Extension.create({
isEmbedded: this.options.isEmbedded,
}),
Underline,
Image,
ImageInline,
Image.configure({ noLazyImages: this.options.noLazyImages }),
ImageInline.configure({ noLazyImages: this.options.noLazyImages }),
Dropcursor.configure({
color: 'var(--color-primary-element)',
width: 2,
Expand Down
1 change: 1 addition & 0 deletions src/nodes/Image.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const Image = TiptapImage.extend({
addOptions() {
return {
...this.parent?.(),
noLazyImages: false,
}
},

Expand Down
1 change: 1 addition & 0 deletions src/nodes/ImageInline.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const ImageInline = TiptapImage.extend({
addOptions() {
return {
...this.parent?.(),
noLazyImages: false,
inline: true,
}
},
Expand Down
6 changes: 6 additions & 0 deletions src/nodes/ImageView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,12 @@ export default {
this.loadAttachmentMetadata()
this.setupResizeObserver()

// Load image directly if lazy loading is disabled
if (this.extension?.options?.noLazyImages === true) {
this.loadPreview().catch(this.onImageLoadFailure)
return
}

this.$nextTick(() => {
// nextTick is necessary, intersection detection is slightly unreliable without it
const options = {
Expand Down
Loading