Read sdt (#546)
* feat: Add StructuredDataTagJSON * spec: Add test * 0.0.276-rc25 * fix: changelogmain
parent
f267114d2d
commit
1018e4dd27
|
@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
|
||||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
|
## docx-wasm@0.0.276-rc26 (14. Oct, 2022)
|
||||||
|
|
||||||
|
- Support text direction (#545)
|
||||||
|
- read `<sdt>`
|
||||||
|
|
||||||
## docx-rs@0.4.5 (14. Oct, 2022)
|
## docx-rs@0.4.5 (14. Oct, 2022)
|
||||||
|
|
||||||
- Support text direction (#545)
|
- Support text direction (#545)
|
||||||
|
@ -13,6 +18,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
|
|
||||||
- Support rotate in pic
|
- Support rotate in pic
|
||||||
|
|
||||||
|
## docx-wasm@0.0.276-rc25 (21. Sep, 2022)
|
||||||
|
|
||||||
|
- [BugFix] Fixed a bug, hyperlink is broken with special characters.
|
||||||
|
|
||||||
## docx-wasm@0.0.276-rc20 (9. Sep, 2022)
|
## docx-wasm@0.0.276-rc20 (9. Sep, 2022)
|
||||||
|
|
||||||
- Support `sectionProperty` in pPr.
|
- Support `sectionProperty` in pPr.
|
||||||
|
|
|
@ -60,6 +60,12 @@ impl FromXML for Document {
|
||||||
doc = doc.default_section_property(e);
|
doc = doc.default_section_property(e);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
XMLElement::StructuredDataTag => {
|
||||||
|
if let Ok(tag) = StructuredDataTag::read(&mut parser, &attributes) {
|
||||||
|
doc = doc.add_structured_data_tag(tag);
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,7 +72,8 @@ impl ElementReader for StructuredDataTag {
|
||||||
}
|
}
|
||||||
XMLElement::Run => {
|
XMLElement::Run => {
|
||||||
if let Ok(run) = Run::read(r, attrs) {
|
if let Ok(run) = Run::read(r, attrs) {
|
||||||
sdt.children.push(StructuredDataTagChild::Run(Box::new(run)));
|
sdt.children
|
||||||
|
.push(StructuredDataTagChild::Run(Box::new(run)));
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -81,7 +82,7 @@ impl ElementReader for StructuredDataTag {
|
||||||
}
|
}
|
||||||
Ok(XmlEvent::EndElement { name, .. }) => {
|
Ok(XmlEvent::EndElement { name, .. }) => {
|
||||||
let e = XMLElement::from_str(&name.local_name).unwrap();
|
let e = XMLElement::from_str(&name.local_name).unwrap();
|
||||||
if e == XMLElement::Paragraph {
|
if e == XMLElement::StructuredDataTag {
|
||||||
return Ok(sdt);
|
return Ok(sdt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -149,6 +149,7 @@ pub enum XMLElement {
|
||||||
FooterReference,
|
FooterReference,
|
||||||
TitlePg,
|
TitlePg,
|
||||||
EvenAndOddHeaders,
|
EvenAndOddHeaders,
|
||||||
|
StructuredDataTag,
|
||||||
Unsupported,
|
Unsupported,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -372,6 +373,7 @@ impl FromStr for XMLElement {
|
||||||
"footerReference" => Ok(XMLElement::FooterReference),
|
"footerReference" => Ok(XMLElement::FooterReference),
|
||||||
"titlePg" => Ok(XMLElement::TitlePg),
|
"titlePg" => Ok(XMLElement::TitlePg),
|
||||||
"evenAndOddHeaders" => Ok(XMLElement::EvenAndOddHeaders),
|
"evenAndOddHeaders" => Ok(XMLElement::EvenAndOddHeaders),
|
||||||
|
"sdt" => Ok(XMLElement::StructuredDataTag),
|
||||||
_ => Ok(XMLElement::Unsupported),
|
_ => Ok(XMLElement::Unsupported),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ import { ParagraphJSON, BookmarkStartJSON, BookmarkEndJSON } from "./paragraph";
|
||||||
import { TableJSON } from "./table";
|
import { TableJSON } from "./table";
|
||||||
import { SectionPropertyJSON } from "./section-property";
|
import { SectionPropertyJSON } from "./section-property";
|
||||||
import { CommentRangeStartJSON, CommentRangeEndJSON } from "..";
|
import { CommentRangeStartJSON, CommentRangeEndJSON } from "..";
|
||||||
|
import { StructuredTagJSON } from "./structured-data-tag";
|
||||||
|
|
||||||
export type DocumentChildJSON =
|
export type DocumentChildJSON =
|
||||||
| ParagraphJSON
|
| ParagraphJSON
|
||||||
|
@ -9,7 +10,8 @@ export type DocumentChildJSON =
|
||||||
| CommentRangeStartJSON
|
| CommentRangeStartJSON
|
||||||
| CommentRangeEndJSON
|
| CommentRangeEndJSON
|
||||||
| BookmarkStartJSON
|
| BookmarkStartJSON
|
||||||
| BookmarkEndJSON;
|
| BookmarkEndJSON
|
||||||
|
| StructuredTagJSON;
|
||||||
|
|
||||||
export type DocumentJSON = {
|
export type DocumentJSON = {
|
||||||
children: DocumentChildJSON[];
|
children: DocumentChildJSON[];
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
import {
|
||||||
|
BookmarkEndJSON,
|
||||||
|
BookmarkStartJSON,
|
||||||
|
CommentRangeEndJSON,
|
||||||
|
CommentRangeStartJSON,
|
||||||
|
ParagraphJSON,
|
||||||
|
TableJSON,
|
||||||
|
} from "..";
|
||||||
|
|
||||||
|
export type StructuredTagJSON = {
|
||||||
|
type: "structuredDataTag";
|
||||||
|
data: {
|
||||||
|
children: StructuredDataTagChildJSON[];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export type StructuredDataTagChildJSON =
|
||||||
|
| ParagraphJSON
|
||||||
|
| TableJSON
|
||||||
|
| CommentRangeStartJSON
|
||||||
|
| CommentRangeEndJSON
|
||||||
|
| BookmarkStartJSON
|
||||||
|
| BookmarkEndJSON;
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "docx-wasm",
|
"name": "docx-wasm",
|
||||||
"version": "0.0.276-rc24",
|
"version": "0.0.276-rc26",
|
||||||
"main": "dist/node/index.js",
|
"main": "dist/node/index.js",
|
||||||
"browser": "dist/web/index.js",
|
"browser": "dist/web/index.js",
|
||||||
"author": "bokuweb <bokuweb12@gmail.com>",
|
"author": "bokuweb <bokuweb12@gmail.com>",
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Binary file not shown.
Loading…
Reference in New Issue