feat: add comments_json (#773)
parent
69b4c1a4a3
commit
1f9046d2ee
|
@ -652,6 +652,13 @@ impl Docx {
|
|||
serde_json::to_string_pretty(&self).unwrap()
|
||||
}
|
||||
|
||||
// Internal: for docx-wasm
|
||||
pub fn comments_json(&mut self) -> String {
|
||||
self.reset();
|
||||
self.update_dependencies();
|
||||
serde_json::to_string_pretty(&self.comments.comments).unwrap()
|
||||
}
|
||||
|
||||
fn reset(&self) {
|
||||
crate::reset_para_id();
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ import {
|
|||
PageMargin,
|
||||
PageOrientationType,
|
||||
} from "./section-property";
|
||||
import { DocGridType, DocxJSON } from "./json";
|
||||
import { CommentJSON, DocGridType, DocxJSON } from "./json";
|
||||
|
||||
import * as wasm from "./pkg";
|
||||
import { Level } from "./level";
|
||||
|
@ -626,6 +626,13 @@ export class Docx {
|
|||
return JSON.parse(json) as DocxJSON;
|
||||
}
|
||||
|
||||
commentsJson() {
|
||||
const docx = this.createDocx();
|
||||
const json = docx.comments_json();
|
||||
docx.free();
|
||||
return JSON.parse(json) as CommentJSON[];
|
||||
}
|
||||
|
||||
build() {
|
||||
const docx = this.createDocx();
|
||||
const buf = docx.build(this.hasNumberings);
|
||||
|
|
|
@ -216,4 +216,8 @@ impl Docx {
|
|||
pub fn json_with_update_comments(&mut self) -> String {
|
||||
self.0.json_with_update_comments()
|
||||
}
|
||||
|
||||
pub fn comments_json(&mut self) -> String {
|
||||
self.0.comments_json()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue