Skip to content

Commit 8287bb9

Browse files
committed
fix: images are missing for the document in edit mode
1 parent 1b2868d commit 8287bb9

3 files changed

Lines changed: 13 additions & 3 deletions

File tree

packages/super-editor/src/core/DocxZipper.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,10 @@ class DocxZipper {
4848
name: zipEntry.name,
4949
content,
5050
});
51-
} else if (zipEntry.name.startsWith('word/media') && zipEntry.name !== 'word/media/') {
51+
} else if (
52+
(zipEntry.name.startsWith('word/media') && zipEntry.name !== 'word/media/') ||
53+
(zipEntry.name.startsWith('media') && zipEntry.name !== 'media/')
54+
) {
5255
// If we are in node, we need to convert the buffer to base64
5356
if (isNode) {
5457
const buffer = await zipEntry.async('nodebuffer');

packages/super-editor/src/core/super-converter/v2/importer/imageImporter.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,12 @@ export function handleImageImport(node, currentFileName, params) {
116116
if (!rel) return null;
117117

118118
const { attributes: relAttributes } = rel;
119+
const targetPath = relAttributes['Target'].startsWith('/')
120+
? relAttributes['Target'].slice(1)
121+
: relAttributes['target'];
119122

120-
const path = `word/${relAttributes['Target']}`;
123+
// Some images may appear out of the word folder
124+
const path = targetPath.startsWith('word') || params.converter.media[targetPath] ? targetPath : `word/${targetPath}`;
121125

122126
return {
123127
type: 'image',

packages/super-editor/src/dev/components/DeveloperPlayground.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import '@/style.css';
33
import '@harbour-enterprises/common/styles/common-styles.css';
44
55
import { ref, shallowRef, computed, onMounted } from 'vue';
6+
import { NMessageProvider } from 'naive-ui';
67
import { SuperEditor } from '@/index.js';
78
import { getFileObject } from '@harbour-enterprises/common/helpers/get-file-object';
89
import { DOCX } from '@harbour-enterprises/common';
@@ -158,7 +159,9 @@ onMounted(async () => {
158159
</div>
159160
160161
<div class="dev-app__content" v-if="currentFile">
161-
<SuperEditor :file-source="currentFile" :options="editorOptions" />
162+
<n-message-provider>
163+
<SuperEditor :file-source="currentFile" :options="editorOptions" />
164+
</n-message-provider>
162165
</div>
163166
</div>
164167
</div>

0 commit comments

Comments
 (0)