Skip to content

Commit f04bccf

Browse files
author
clarencepalmer
committed
Merge remote-tracking branch 'origin/main' into chore/spike/new-loader-mark
2 parents d74e5b1 + 34ea284 commit f04bccf

6 files changed

Lines changed: 52 additions & 89 deletions

File tree

examples/vue-fields-example/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"preview": "vite preview"
1010
},
1111
"dependencies": {
12-
"@harbour-enterprises/superdoc": "^0.11.8",
12+
"@harbour-enterprises/superdoc": "^0.11.11",
1313
"vue": "^3.5.13"
1414
},
1515
"devDependencies": {

examples/vue-fields-example/src/App.vue

Lines changed: 45 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ const init = (fileToLoad) => {
2121
// Enable pagination
2222
pagination: true,
2323
24+
// Enable annotation import
25+
annotations: true,
26+
2427
document: fileToLoad ? { data: fileToLoad } : sampleDocument,
2528
2629
// Initialize the toolbar
@@ -64,10 +67,12 @@ const restoreSnapshot = () => {
6467
}
6568
}
6669
67-
const SAMPLE_FIELD_ID = '123';
70+
const SAMPLE_HTML_FIELD_ID = '123';
71+
const SAMPLE_TEXT_FIELD_ID = '456';
72+
6873
const replaceField = () => {
6974
const field = fieldAnnotationHelpers.findFieldAnnotationsByFieldId(
70-
SAMPLE_FIELD_ID,
75+
SAMPLE_HTML_FIELD_ID,
7176
editor.value.state,
7277
);
7378
@@ -89,20 +94,46 @@ const setViewing = () => {
8994
const getHTMLField = () => {
9095
return {
9196
displayLabel: 'My placeholder field',
92-
fieldId: SAMPLE_FIELD_ID,
97+
fieldId: SAMPLE_HTML_FIELD_ID,
9398
type: 'html',
9499
fieldType: 'HTMLINPUT',
95100
fieldColor: '#000099',
96101
};
97102
};
98103
104+
const getTextField = () => {
105+
return {
106+
displayLabel: 'My text field',
107+
fieldId: SAMPLE_TEXT_FIELD_ID,
108+
type: 'text',
109+
fieldType: 'TEXTINPUT',
110+
fieldColor: '#990000',
111+
};
112+
};
113+
99114
const addField = (field) => {
100115
if (!field) field = getHTMLField();
101116
editor.value.commands.addFieldAnnotationAtSelection(field);
102117
}
103118
119+
const exportDocx = () => {
120+
superdoc.value?.export();
121+
};
122+
104123
const onDragStart = (event) => {
105-
const field = getHTMLField();
124+
125+
const getField = (id) => {
126+
switch (id) {
127+
case 'html-field':
128+
return getHTMLField();
129+
case 'text-field':
130+
return getTextField();
131+
default:
132+
return null;
133+
}
134+
}
135+
136+
const field = getField(event.target.id);
106137
event.dataTransfer.setData('fieldAnnotation', JSON.stringify({ sourceField: field }));
107138
};
108139
@@ -117,32 +148,37 @@ onMounted(() => init());
117148
118149
<div id="toolbar" class="my-custom-toolbar"></div>
119150
<div class="editor-and-button">
120-
<div class="editor-buttons" style="margin-right: 10px;">
121-
<div class="draggable-field" draggable="true" @dragstart="onDragStart">HTML field</div>
151+
<div class="editor-buttons fields" style="margin-right: 10px;">
152+
<div class="draggable-field" draggable="true" @dragstart="onDragStart" id="html-field">HTML field</div>
153+
<div class="draggable-field" draggable="true" @dragstart="onDragStart" id="text-field">TEXT field</div>
122154
</div>
123155
<div id="editor" class="main-editor"></div>
124156
<div class="editor-buttons">
125157
<UploadFile :update-file="handleFileUpdate" />
126-
<button class="custom-button" @click="addField">Insert '123' field</button>
127-
128158
<button class="custom-button" @click="saveSnapshot">Save state</button>
129159
<button class="custom-button" @click="restoreSnapshot" :disabled="!snapshot">Restore state</button>
130-
<button class="custom-button" @click="replaceField">Replace '123' field</button>
160+
<button class="custom-button" @click="replaceField">Update HTML field content</button>
131161
<textarea
132162
id="custom-html"
133163
class="custom-textarea"
134164
placeholder="Type some HTML to replace custom nodes with"
135165
value="<p>Custom <b>Node</b> Content</p>"
136166
></textarea>
137167
168+
<br />
138169
<button class="custom-button" @click="setEditable">Set editable</button>
139170
<button class="custom-button" @click="setViewing">Set viewing</button>
171+
<br />
172+
<button class="custom-button" @click="exportDocx">Export docx</button>
140173
</div>
141174
</div>
142175
</div>
143176
</template>
144177
145178
<style>
179+
.fields > div {
180+
margin-bottom: 10px;
181+
}
146182
textarea {
147183
margin-left: 10px;
148184
}

examples/vue-fields-example/src/custom-node.js

Lines changed: 0 additions & 77 deletions
This file was deleted.

packages/super-editor/src/core/super-converter/exporter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1735,7 +1735,7 @@ function prepareHtmlAnnotation(params) {
17351735
} = params;
17361736

17371737
const parser = new window.DOMParser();
1738-
const paragraphHtml = parser.parseFromString(attrs.rawHtml, 'text/html');
1738+
const paragraphHtml = parser.parseFromString(attrs.rawHtml || attrs.displayLabel, 'text/html');
17391739

17401740
const state = EditorState.create({
17411741
doc: PMDOMParser.fromSchema(params.editorSchema).parse(paragraphHtml),

packages/superdoc/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## [0.11.12](https://github.com/Harbour-Enterprises/SuperDoc/compare/v0.11.11...v0.11.12) (2025-05-14)
4+
5+
## [0.11.11](https://github.com/Harbour-Enterprises/SuperDoc/compare/v0.11.10...v0.11.11) (2025-05-14)
6+
37
## [0.11.10](https://github.com/Harbour-Enterprises/SuperDoc/compare/v0.11.9...v0.11.10) (2025-05-13)
48

59
## [0.11.9](https://github.com/Harbour-Enterprises/SuperDoc/compare/v0.11.8...v0.11.9) (2025-05-13)

packages/superdoc/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@harbour-enterprises/superdoc",
33
"type": "module",
4-
"version": "0.11.10",
4+
"version": "0.11.12",
55
"license": "AGPL-3.0",
66
"readme": "../../README.md",
77
"files": [

0 commit comments

Comments
 (0)