@adobe/helix-md2docx 2.2.2 → 2.2.4
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/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## [2.2.4](https://github.com/adobe/helix-md2docx/compare/v2.2.3...v2.2.4) (2025-03-11)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* add workaround for fragment issue ([#568](https://github.com/adobe/helix-md2docx/issues/568)) ([4e14e89](https://github.com/adobe/helix-md2docx/commit/4e14e89cfaff20aa0b1db04e7908500c0f0d6ca6)), closes [#567](https://github.com/adobe/helix-md2docx/issues/567)
|
|
7
|
+
|
|
8
|
+
## [2.2.3](https://github.com/adobe/helix-md2docx/compare/v2.2.2...v2.2.3) (2025-03-10)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* **deps:** update adobe fixes ([#566](https://github.com/adobe/helix-md2docx/issues/566)) ([943a9da](https://github.com/adobe/helix-md2docx/commit/943a9da81e9d192e80f2c52b8144e449be1fa138))
|
|
14
|
+
|
|
1
15
|
## [2.2.2](https://github.com/adobe/helix-md2docx/compare/v2.2.1...v2.2.2) (2025-03-06)
|
|
2
16
|
|
|
3
17
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adobe/helix-md2docx",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.4",
|
|
4
4
|
"description": "Helix Service that converts markdown to word documents",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -29,10 +29,10 @@
|
|
|
29
29
|
"homepage": "https://github.com/adobe/helix-md2docx#readme",
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@adobe/fetch": "4.2.0",
|
|
32
|
-
"@adobe/helix-docx2md": "1.6.
|
|
32
|
+
"@adobe/helix-docx2md": "1.6.24",
|
|
33
33
|
"@adobe/helix-markdown-support": "7.1.12",
|
|
34
34
|
"@adobe/helix-shared-process-queue": "3.1.2",
|
|
35
|
-
"@adobe/remark-gridtables": "3.0.
|
|
35
|
+
"@adobe/remark-gridtables": "3.0.11",
|
|
36
36
|
"docx": "9.2.0",
|
|
37
37
|
"github-slugger": "2.0.0",
|
|
38
38
|
"hast-util-is-element": "3.0.0",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@adobe/eslint-config-helix": "2.0.9",
|
|
51
|
-
"@adobe/helix-mediahandler": "2.6.
|
|
51
|
+
"@adobe/helix-mediahandler": "2.6.5",
|
|
52
52
|
"@semantic-release/changelog": "6.0.3",
|
|
53
53
|
"@semantic-release/exec": "7.0.3",
|
|
54
54
|
"@semantic-release/git": "10.0.1",
|
|
@@ -9,9 +9,10 @@
|
|
|
9
9
|
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
|
-
import { Bookmark, HeadingLevel
|
|
12
|
+
import { Bookmark, HeadingLevel } from 'docx';
|
|
13
13
|
|
|
14
14
|
import all from '../all.js';
|
|
15
|
+
import { MyParagraph } from './paragraph.js';
|
|
15
16
|
|
|
16
17
|
const DEPTHS = [
|
|
17
18
|
HeadingLevel.HEADING_1,
|
|
@@ -31,7 +32,7 @@ export default async function heading(ctx, node, parent) {
|
|
|
31
32
|
children: [],
|
|
32
33
|
}));
|
|
33
34
|
}
|
|
34
|
-
return new
|
|
35
|
+
return new MyParagraph({
|
|
35
36
|
heading: DEPTHS[node.depth - 1],
|
|
36
37
|
children,
|
|
37
38
|
alignment: parent.alignment,
|
|
@@ -9,8 +9,49 @@
|
|
|
9
9
|
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
ConcreteHyperlink, ExternalHyperlink, Paragraph, uniqueId,
|
|
14
|
+
} from 'docx';
|
|
13
15
|
import all from '../all.js';
|
|
16
|
+
import { findXMLComponent } from '../utils.js';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Custom paragraph that overwrites `prepForXml` and handles the special case for external links
|
|
20
|
+
* with fragments the same way as word does: it creates a relationship w/o the fragment and adds
|
|
21
|
+
* the fragment as `w:anchor` property to the hyperlink.
|
|
22
|
+
*
|
|
23
|
+
* @see https://github.com/dolanmiu/docx/issues/2986
|
|
24
|
+
*/
|
|
25
|
+
export class MyParagraph extends Paragraph {
|
|
26
|
+
prepForXml(context) {
|
|
27
|
+
for (const element of this.root) {
|
|
28
|
+
if (element instanceof ExternalHyperlink) {
|
|
29
|
+
let { link } = element.options;
|
|
30
|
+
let anchor;
|
|
31
|
+
const idx = link.indexOf('#');
|
|
32
|
+
if (idx > 0) {
|
|
33
|
+
anchor = link.substring(idx + 1);
|
|
34
|
+
link = link.substring(0, idx);
|
|
35
|
+
}
|
|
36
|
+
const index = this.root.indexOf(element);
|
|
37
|
+
// eslint-disable-next-line max-len
|
|
38
|
+
const concreteHyperlink = new ConcreteHyperlink(element.options.children, uniqueId());
|
|
39
|
+
context.viewWrapper.Relationships.createRelationship(
|
|
40
|
+
concreteHyperlink.linkId,
|
|
41
|
+
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink',
|
|
42
|
+
link,
|
|
43
|
+
'External',
|
|
44
|
+
);
|
|
45
|
+
if (anchor) {
|
|
46
|
+
const attrs = findXMLComponent(concreteHyperlink, '_attr');
|
|
47
|
+
attrs.root.anchor = anchor;
|
|
48
|
+
}
|
|
49
|
+
this.root[index] = concreteHyperlink;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return super.prepForXml(context);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
14
55
|
|
|
15
56
|
export default async function paragraph(ctx, node, parent) {
|
|
16
57
|
// clear style
|
|
@@ -47,5 +88,5 @@ export default async function paragraph(ctx, node, parent) {
|
|
|
47
88
|
} else if (ctx.paragraphStyle) {
|
|
48
89
|
opts.style = ctx.paragraphStyle;
|
|
49
90
|
}
|
|
50
|
-
return new
|
|
91
|
+
return new MyParagraph(opts);
|
|
51
92
|
}
|
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
} from 'docx';
|
|
15
15
|
import all from '../all.js';
|
|
16
16
|
import { removeUndefined } from '../utils.js';
|
|
17
|
+
import { MyParagraph } from './paragraph.js';
|
|
17
18
|
|
|
18
19
|
const ALIGN = {
|
|
19
20
|
left: null,
|
|
@@ -41,7 +42,7 @@ export default async function tableCell(ctx, node, parent, siblings) {
|
|
|
41
42
|
const child = children[i];
|
|
42
43
|
if ((child instanceof Paragraph) || (child instanceof Table)) {
|
|
43
44
|
if (leaves.length) {
|
|
44
|
-
content.push(new
|
|
45
|
+
content.push(new MyParagraph({ alignment: node.alignment, children: leaves }));
|
|
45
46
|
}
|
|
46
47
|
content.push(child);
|
|
47
48
|
leaves = [];
|
|
@@ -50,7 +51,7 @@ export default async function tableCell(ctx, node, parent, siblings) {
|
|
|
50
51
|
}
|
|
51
52
|
}
|
|
52
53
|
if (leaves.length) {
|
|
53
|
-
content.push(new
|
|
54
|
+
content.push(new MyParagraph({ alignment: node.alignment, children: leaves }));
|
|
54
55
|
}
|
|
55
56
|
|
|
56
57
|
const opts = removeUndefined({
|