Support hidden (#8)

* feat: Add mock and deleteText

* feat:Support Hidden

* fix: Change comment id to usize

* chore: build wasm
main
bokuweb 2019-12-14 00:47:47 +09:00 committed by GitHub
parent df5eefff20
commit 4447ab6e9d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
27 changed files with 256 additions and 76 deletions

View File

@ -3,7 +3,7 @@ use crate::xml_builder::*;
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct Comment { pub struct Comment {
pub id: String, pub id: usize,
pub author: String, pub author: String,
pub date: String, pub date: String,
pub paragraph: Paragraph, pub paragraph: Paragraph,
@ -12,7 +12,7 @@ pub struct Comment {
impl Default for Comment { impl Default for Comment {
fn default() -> Comment { fn default() -> Comment {
Comment { Comment {
id: "invalidId".to_owned(), id: 1,
author: "unnamed".to_owned(), author: "unnamed".to_owned(),
date: "1970-01-01T00:00:00Z".to_owned(), date: "1970-01-01T00:00:00Z".to_owned(),
paragraph: Paragraph::new(), paragraph: Paragraph::new(),
@ -21,9 +21,9 @@ impl Default for Comment {
} }
impl Comment { impl Comment {
pub fn new(id: impl Into<String>) -> Comment { pub fn new(id: usize) -> Comment {
Self { Self {
id: id.into(), id,
..Default::default() ..Default::default()
} }
} }
@ -43,15 +43,15 @@ impl Comment {
self self
} }
pub fn id(&self) -> String { pub fn id(&self) -> usize {
self.id.clone() self.id
} }
} }
impl BuildXML for Comment { impl BuildXML for Comment {
fn build(&self) -> Vec<u8> { fn build(&self) -> Vec<u8> {
XMLBuilder::new() XMLBuilder::new()
.open_comment(&self.id, &self.author, &self.date, "") .open_comment(&format!("{}", self.id), &self.author, &self.date, "")
.add_child(&self.paragraph) .add_child(&self.paragraph)
.close() .close()
.build() .build()
@ -68,10 +68,10 @@ mod tests {
#[test] #[test]
fn test_ins_default() { fn test_ins_default() {
let b = Comment::new("123").build(); let b = Comment::new(1).build();
assert_eq!( assert_eq!(
str::from_utf8(&b).unwrap(), str::from_utf8(&b).unwrap(),
r#"<w:comment w:id="123" w:author="unnamed" w:date="1970-01-01T00:00:00Z" w:initials=""><w:p><w:pPr><w:pStyle w:val="Normal" /><w:rPr /></w:pPr></w:p></w:comment>"# r#"<w:comment w:id="1" w:author="unnamed" w:date="1970-01-01T00:00:00Z" w:initials=""><w:p><w:pPr><w:pStyle w:val="Normal" /><w:rPr /></w:pPr></w:p></w:comment>"#
); );
} }
} }

View File

@ -3,12 +3,12 @@ use crate::xml_builder::*;
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct CommentRangeEnd { pub struct CommentRangeEnd {
id: String, id: usize,
} }
impl CommentRangeEnd { impl CommentRangeEnd {
pub fn new(id: impl Into<String>) -> CommentRangeEnd { pub fn new(id: usize) -> CommentRangeEnd {
CommentRangeEnd { id: id.into() } CommentRangeEnd { id }
} }
} }
@ -19,9 +19,9 @@ impl BuildXML for CommentRangeEnd {
.open_run_property() .open_run_property()
.close() .close()
.close() .close()
.comment_range_end(&self.id) .comment_range_end(&format!("{}", self.id))
.open_run() .open_run()
.comment_reference(&self.id) .comment_reference(&format!("{}", self.id))
.close() .close()
.build() .build()
} }
@ -37,16 +37,16 @@ mod tests {
#[test] #[test]
fn test_comment_range_end() { fn test_comment_range_end() {
let c = CommentRangeEnd::new("mockid"); let c = CommentRangeEnd::new(1);
let b = c.build(); let b = c.build();
assert_eq!( assert_eq!(
str::from_utf8(&b).unwrap(), str::from_utf8(&b).unwrap(),
r#"<w:r> r#"<w:r>
<w:rPr /> <w:rPr />
</w:r> </w:r>
<w:commentRangeEnd w:id="mockid" /> <w:commentRangeEnd w:id="1" />
<w:r> <w:r>
<w:commentReference w:id="mockid" /> <w:commentReference w:id="1" />
</w:r>"# </w:r>"#
); );
} }

View File

@ -4,7 +4,7 @@ use crate::xml_builder::*;
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct CommentRangeStart { pub struct CommentRangeStart {
id: String, id: usize,
comment: Comment, comment: Comment,
} }
@ -24,7 +24,7 @@ impl CommentRangeStart {
impl BuildXML for CommentRangeStart { impl BuildXML for CommentRangeStart {
fn build(&self) -> Vec<u8> { fn build(&self) -> Vec<u8> {
let b = XMLBuilder::new(); let b = XMLBuilder::new();
b.comment_range_start(&self.id).build() b.comment_range_start(&format!("{}", self.id)).build()
} }
} }
@ -38,11 +38,11 @@ mod tests {
#[test] #[test]
fn test_comment_range_start() { fn test_comment_range_start() {
let c = CommentRangeStart::new(Comment::new("mockid")); let c = CommentRangeStart::new(Comment::new(1));
let b = c.build(); let b = c.build();
assert_eq!( assert_eq!(
str::from_utf8(&b).unwrap(), str::from_utf8(&b).unwrap(),
r#"<w:commentRangeStart w:id="mockid" />"# r#"<w:commentRangeStart w:id="1" />"#
); );
} }
} }

View File

@ -0,0 +1,41 @@
use crate::documents::BuildXML;
use crate::xml_builder::*;
#[derive(Debug, Clone)]
pub struct DeleteText {
text: String,
preserve_space: bool,
}
impl DeleteText {
pub fn new(text: impl Into<String>) -> DeleteText {
DeleteText {
text: text.into(),
preserve_space: true,
}
}
}
impl BuildXML for DeleteText {
fn build(&self) -> Vec<u8> {
XMLBuilder::new().delete_text(&self.text, true).build()
}
}
#[cfg(test)]
mod tests {
use super::*;
#[cfg(test)]
use pretty_assertions::assert_eq;
use std::str;
#[test]
fn test_build() {
let b = DeleteText::new("Hello").build();
assert_eq!(
str::from_utf8(&b).unwrap(),
r#"<w:delText xml:space="preserve">Hello</w:delText>"#
);
}
}

View File

@ -10,6 +10,7 @@ mod comment_range_end;
mod comment_range_start; mod comment_range_start;
mod default_tab_stop; mod default_tab_stop;
mod delete; mod delete;
mod delete_text;
mod doc_defaults; mod doc_defaults;
mod font; mod font;
mod grid_span; mod grid_span;
@ -59,6 +60,7 @@ mod table_row_property;
mod table_width; mod table_width;
mod text; mod text;
mod underline; mod underline;
mod vanish;
mod vertical_merge; mod vertical_merge;
mod zoom; mod zoom;
@ -74,6 +76,7 @@ pub use comment_range_end::*;
pub use comment_range_start::*; pub use comment_range_start::*;
pub use default_tab_stop::*; pub use default_tab_stop::*;
pub use delete::*; pub use delete::*;
pub use delete_text::*;
pub use doc_defaults::*; pub use doc_defaults::*;
pub use font::*; pub use font::*;
pub use grid_span::*; pub use grid_span::*;
@ -123,5 +126,6 @@ pub use table_row_property::*;
pub use table_width::*; pub use table_width::*;
pub use text::*; pub use text::*;
pub use underline::*; pub use underline::*;
pub use vanish::*;
pub use vertical_merge::*; pub use vertical_merge::*;
pub use zoom::*; pub use zoom::*;

View File

@ -98,7 +98,7 @@ impl Paragraph {
self self
} }
pub fn add_comment_end(mut self, id: impl Into<String>) -> Paragraph { pub fn add_comment_end(mut self, id: usize) -> Paragraph {
self.children self.children
.push(ParagraphChild::CommentEnd(CommentRangeEnd::new(id))); .push(ParagraphChild::CommentEnd(CommentRangeEnd::new(id)));
self self
@ -183,18 +183,18 @@ mod tests {
#[test] #[test]
fn test_comment() { fn test_comment() {
let b = Paragraph::new() let b = Paragraph::new()
.add_comment_start(Comment::new("1234-5678")) .add_comment_start(Comment::new(1))
.add_run(Run::new().add_text("Hello")) .add_run(Run::new().add_text("Hello"))
.add_comment_end("1234-5678") .add_comment_end(1)
.build(); .build();
assert_eq!( assert_eq!(
str::from_utf8(&b).unwrap(), str::from_utf8(&b).unwrap(),
r#"<w:p><w:pPr><w:pStyle w:val="Normal" /><w:rPr /></w:pPr><w:commentRangeStart w:id="1234-5678" /><w:r><w:rPr /><w:t xml:space="preserve">Hello</w:t></w:r><w:r> r#"<w:p><w:pPr><w:pStyle w:val="Normal" /><w:rPr /></w:pPr><w:commentRangeStart w:id="1" /><w:r><w:rPr /><w:t xml:space="preserve">Hello</w:t></w:r><w:r>
<w:rPr /> <w:rPr />
</w:r> </w:r>
<w:commentRangeEnd w:id="1234-5678" /> <w:commentRangeEnd w:id="1" />
<w:r> <w:r>
<w:commentReference w:id="1234-5678" /> <w:commentReference w:id="1" />
</w:r></w:p>"# </w:r></w:p>"#
); );
} }

View File

@ -1,4 +1,4 @@
use super::{Break, RunProperty, Tab, Text}; use super::{Break, DeleteText, RunProperty, Tab, Text};
use crate::documents::BuildXML; use crate::documents::BuildXML;
use crate::types::BreakType; use crate::types::BreakType;
use crate::xml_builder::*; use crate::xml_builder::*;
@ -22,6 +22,7 @@ impl Default for Run {
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub enum RunChild { pub enum RunChild {
Text(Text), Text(Text),
DeleteText(DeleteText),
Tab(Tab), Tab(Tab),
Break(Break), Break(Break),
} }
@ -82,6 +83,11 @@ impl Run {
self.run_property = self.run_property.underline(line_type); self.run_property = self.run_property.underline(line_type);
self self
} }
pub fn vanish(mut self) -> Run {
self.run_property = self.run_property.vanish();
self
}
} }
impl BuildXML for Run { impl BuildXML for Run {
@ -91,6 +97,7 @@ impl BuildXML for Run {
for c in &self.children { for c in &self.children {
match c { match c {
RunChild::Text(t) => b = b.add_child(t), RunChild::Text(t) => b = b.add_child(t),
RunChild::DeleteText(t) => b = b.add_child(t),
RunChild::Tab(t) => b = b.add_child(t), RunChild::Tab(t) => b = b.add_child(t),
RunChild::Break(t) => b = b.add_child(t), RunChild::Break(t) => b = b.add_child(t),
} }

View File

@ -1,4 +1,4 @@
use super::{Bold, BoldCs, Color, Highlight, Italic, ItalicCs, Sz, SzCs, Underline}; use super::{Bold, BoldCs, Color, Highlight, Italic, ItalicCs, Sz, SzCs, Underline, Vanish};
use crate::documents::BuildXML; use crate::documents::BuildXML;
use crate::xml_builder::*; use crate::xml_builder::*;
@ -13,6 +13,7 @@ pub struct RunProperty {
bold_cs: Option<BoldCs>, bold_cs: Option<BoldCs>,
italic: Option<Italic>, italic: Option<Italic>,
italic_cs: Option<ItalicCs>, italic_cs: Option<ItalicCs>,
vanish: Option<Vanish>,
} }
impl RunProperty { impl RunProperty {
@ -52,6 +53,11 @@ impl RunProperty {
self.underline = Some(Underline::new(line_type)); self.underline = Some(Underline::new(line_type));
self self
} }
pub fn vanish(mut self) -> RunProperty {
self.vanish = Some(Vanish::new());
self
}
} }
impl Default for RunProperty { impl Default for RunProperty {
@ -66,6 +72,7 @@ impl Default for RunProperty {
bold_cs: None, bold_cs: None,
italic: None, italic: None,
italic_cs: None, italic_cs: None,
vanish: None,
} }
} }
} }
@ -83,6 +90,7 @@ impl BuildXML for RunProperty {
.add_optional_child(&self.italic_cs) .add_optional_child(&self.italic_cs)
.add_optional_child(&self.highlight) .add_optional_child(&self.highlight)
.add_optional_child(&self.underline) .add_optional_child(&self.underline)
.add_optional_child(&self.vanish)
.close() .close()
.build() .build()
} }
@ -135,4 +143,14 @@ mod tests {
r#"<w:rPr><w:u w:val="single" /></w:rPr>"# r#"<w:rPr><w:u w:val="single" /></w:rPr>"#
); );
} }
#[test]
fn test_vanish() {
let c = RunProperty::new().vanish();
let b = c.build();
assert_eq!(
str::from_utf8(&b).unwrap(),
r#"<w:rPr><w:vanish /></w:rPr>"#
);
}
} }

View File

@ -0,0 +1,34 @@
use crate::documents::BuildXML;
use crate::xml_builder::*;
#[derive(Debug, Clone)]
pub struct Vanish {}
impl Vanish {
pub fn new() -> Vanish {
Vanish {}
}
}
impl BuildXML for Vanish {
fn build(&self) -> Vec<u8> {
let b = XMLBuilder::new();
b.vanish().build()
}
}
#[cfg(test)]
mod tests {
use super::*;
#[cfg(test)]
use pretty_assertions::assert_eq;
use std::str;
#[test]
fn test_build() {
let c = Vanish::new();
let b = c.build();
assert_eq!(str::from_utf8(&b).unwrap(), r#"<w:vanish />"#);
}
}

View File

@ -199,6 +199,7 @@ impl XMLBuilder {
only_str_val_el!(level_text, "w:lvlText"); only_str_val_el!(level_text, "w:lvlText");
only_str_val_el!(level_justification, "w:lvlJc"); only_str_val_el!(level_justification, "w:lvlJc");
only_str_val_el!(abstract_num_id, "w:abstractNumId"); only_str_val_el!(abstract_num_id, "w:abstractNumId");
closed_el!(vanish, "w:vanish");
} }
#[cfg(test)] #[cfg(test)]

View File

@ -265,14 +265,14 @@ pub fn comments() -> Result<(), DocxError> {
.add_paragraph( .add_paragraph(
Paragraph::new() Paragraph::new()
.add_comment_start( .add_comment_start(
Comment::new("1") Comment::new(1)
.author("bokuweb") .author("bokuweb")
.date("2019-01-01T00:00:00Z") .date("2019-01-01T00:00:00Z")
.paragraph(Paragraph::new().add_run(Run::new().add_text("Hello"))), .paragraph(Paragraph::new().add_run(Run::new().add_text("Hello"))),
) )
.add_run(Run::new().add_text("Hello").highlight("cyan")) .add_run(Run::new().add_text("Hello").highlight("cyan"))
.add_run(Run::new().add_text(" World!").highlight("yellow")) .add_run(Run::new().add_text(" World!").highlight("yellow"))
.add_comment_end("1"), .add_comment_end(1),
) )
.build() .build()
.pack(file)?; .pack(file)?;
@ -287,13 +287,13 @@ pub fn comments_to_table() -> Result<(), DocxError> {
TableCell::new().add_paragraph( TableCell::new().add_paragraph(
Paragraph::new() Paragraph::new()
.add_comment_start( .add_comment_start(
Comment::new("1") Comment::new(1)
.author("bokuweb") .author("bokuweb")
.date("2019-01-01T00:00:00Z") .date("2019-01-01T00:00:00Z")
.paragraph(Paragraph::new().add_run(Run::new().add_text("Hello"))), .paragraph(Paragraph::new().add_run(Run::new().add_text("Hello"))),
) )
.add_run(Run::new().add_text("Hello")) .add_run(Run::new().add_text("Hello"))
.add_comment_end("1"), .add_comment_end(1),
), ),
TableCell::new().add_paragraph(Paragraph::new().add_run(Run::new().add_text("World"))), TableCell::new().add_paragraph(Paragraph::new().add_run(Run::new().add_text("World"))),
])]); ])]);
@ -301,13 +301,13 @@ pub fn comments_to_table() -> Result<(), DocxError> {
.add_paragraph( .add_paragraph(
Paragraph::new() Paragraph::new()
.add_comment_start( .add_comment_start(
Comment::new("ABCD-1234") Comment::new(1)
.author("bokuweb") .author("bokuweb")
.date("2019-01-01T00:00:00Z") .date("2019-01-01T00:00:00Z")
.paragraph(Paragraph::new().add_run(Run::new().add_text("Comment!!"))), .paragraph(Paragraph::new().add_run(Run::new().add_text("Comment!!"))),
) )
.add_run(Run::new().add_text("Hello").highlight("cyan")) .add_run(Run::new().add_text("Hello").highlight("cyan"))
.add_comment_end("ABCD-1234"), .add_comment_end(1),
) )
.add_table(table) .add_table(table)
.build() .build()
@ -386,3 +386,19 @@ pub fn escape() -> Result<(), DocxError> {
.pack(file)?; .pack(file)?;
Ok(()) Ok(())
} }
#[test]
pub fn vanish() -> Result<(), DocxError> {
let path = std::path::Path::new("./tests/output/vanish.docx");
let file = std::fs::File::create(&path).unwrap();
Docx::new()
.add_paragraph(
Paragraph::new()
.add_run(Run::new().add_text("Hello"))
.add_run(Run::new().add_text("Hidden").vanish())
.add_run(Run::new().add_text(" World!!")),
)
.build()
.pack(file)?;
Ok(())
}

View File

@ -4,10 +4,10 @@
*/ */
export function createRun(): Run; export function createRun(): Run;
/** /**
* @param {string} id * @param {number} id
* @returns {Comment} * @returns {Comment}
*/ */
export function createComment(id: string): Comment; export function createComment(id: number): Comment;
/** /**
* @returns {TableCell} * @returns {TableCell}
*/ */
@ -136,9 +136,9 @@ export class Comment {
*/ */
paragraph(p: Paragraph): Comment; paragraph(p: Paragraph): Comment;
/** /**
* @returns {string} * @returns {number}
*/ */
id(): string; id(): number;
} }
/** /**
*/ */
@ -232,10 +232,10 @@ export class Paragraph {
*/ */
add_comment_start(comment: Comment): Paragraph; add_comment_start(comment: Comment): Paragraph;
/** /**
* @param {string} id * @param {number} id
* @returns {Paragraph} * @returns {Paragraph}
*/ */
add_comment_end(id: string): Paragraph; add_comment_end(id: number): Paragraph;
/** /**
* @param {number} alignment_type * @param {number} alignment_type
* @returns {Paragraph} * @returns {Paragraph}

View File

@ -69,11 +69,12 @@ function passStringToWasm(arg) {
return ptr; return ptr;
} }
/** /**
* @param {string} id * @param {number} id
* @returns {Comment} * @returns {Comment}
*/ */
export function createComment(id) { export function createComment(id) {
const ret = wasm.createComment(passStringToWasm(id), WASM_VECTOR_LEN); _assertNum(id);
const ret = wasm.createComment(id);
return Comment.__wrap(ret); return Comment.__wrap(ret);
} }
@ -83,22 +84,6 @@ function _assertClass(instance, klass) {
} }
return instance.ptr; return instance.ptr;
} }
let cachegetInt32Memory = null;
function getInt32Memory() {
if (cachegetInt32Memory === null || cachegetInt32Memory.buffer !== wasm.memory.buffer) {
cachegetInt32Memory = new Int32Array(wasm.memory.buffer);
}
return cachegetInt32Memory;
}
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
cachedTextDecoder.decode();
function getStringFromWasm(ptr, len) {
return cachedTextDecoder.decode(getUint8Memory().subarray(ptr, ptr + len));
}
/** /**
* @returns {TableCell} * @returns {TableCell}
*/ */
@ -123,6 +108,14 @@ export function createDocx() {
return Docx.__wrap(ret); return Docx.__wrap(ret);
} }
let cachegetInt32Memory = null;
function getInt32Memory() {
if (cachegetInt32Memory === null || cachegetInt32Memory.buffer !== wasm.memory.buffer) {
cachegetInt32Memory = new Int32Array(wasm.memory.buffer);
}
return cachegetInt32Memory;
}
function getArrayU8FromWasm(ptr, len) { function getArrayU8FromWasm(ptr, len) {
return getUint8Memory().subarray(ptr / 1, ptr / 1 + len); return getUint8Memory().subarray(ptr / 1, ptr / 1 + len);
} }
@ -200,6 +193,14 @@ export function createParagraph() {
return Paragraph.__wrap(ret); return Paragraph.__wrap(ret);
} }
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
cachedTextDecoder.decode();
function getStringFromWasm(ptr, len) {
return cachedTextDecoder.decode(getUint8Memory().subarray(ptr, ptr + len));
}
const heap = new Array(32); const heap = new Array(32);
heap.fill(undefined); heap.fill(undefined);
@ -323,18 +324,13 @@ export class Comment {
return Comment.__wrap(ret); return Comment.__wrap(ret);
} }
/** /**
* @returns {string} * @returns {number}
*/ */
id() { id() {
const retptr = 8;
if (this.ptr == 0) throw new Error('Attempt to use a moved value'); if (this.ptr == 0) throw new Error('Attempt to use a moved value');
_assertNum(retptr);
_assertNum(this.ptr); _assertNum(this.ptr);
const ret = wasm.comment_id(retptr, this.ptr); const ret = wasm.comment_id(this.ptr);
const memi32 = getInt32Memory(); return ret >>> 0;
const v0 = getStringFromWasm(memi32[retptr / 4 + 0], memi32[retptr / 4 + 1]).slice();
wasm.__wbindgen_free(memi32[retptr / 4 + 0], memi32[retptr / 4 + 1] * 1);
return v0;
} }
} }
/** /**
@ -673,7 +669,7 @@ export class Paragraph {
return Paragraph.__wrap(ret); return Paragraph.__wrap(ret);
} }
/** /**
* @param {string} id * @param {number} id
* @returns {Paragraph} * @returns {Paragraph}
*/ */
add_comment_end(id) { add_comment_end(id) {
@ -681,7 +677,8 @@ export class Paragraph {
const ptr = this.ptr; const ptr = this.ptr;
this.ptr = 0; this.ptr = 0;
_assertNum(ptr); _assertNum(ptr);
const ret = wasm.paragraph_add_comment_end(ptr, passStringToWasm(id), WASM_VECTOR_LEN); _assertNum(id);
const ret = wasm.paragraph_add_comment_end(ptr, id);
return Paragraph.__wrap(ret); return Paragraph.__wrap(ret);
} }
/** /**

View File

@ -13,11 +13,11 @@ export function run_bold(a: number): number;
export function run_italic(a: number): number; export function run_italic(a: number): number;
export function run_underline(a: number, b: number, c: number): number; export function run_underline(a: number, b: number, c: number): number;
export function __wbg_comment_free(a: number): void; export function __wbg_comment_free(a: number): void;
export function createComment(a: number, b: number): number; export function createComment(a: number): number;
export function comment_author(a: number, b: number, c: number): number; export function comment_author(a: number, b: number, c: number): number;
export function comment_date(a: number, b: number, c: number): number; export function comment_date(a: number, b: number, c: number): number;
export function comment_paragraph(a: number, b: number): number; export function comment_paragraph(a: number, b: number): number;
export function comment_id(a: number, b: number): void; export function comment_id(a: number): number;
export function __wbg_tablecell_free(a: number): void; export function __wbg_tablecell_free(a: number): void;
export function createTableCell(): number; export function createTableCell(): number;
export function tablecell_add_paragraph(a: number, b: number): number; export function tablecell_add_paragraph(a: number, b: number): number;
@ -56,7 +56,7 @@ export function paragraph_add_delete(a: number, b: number): number;
export function paragraph_add_bookmark_start(a: number, b: number, c: number, d: number, e: number): number; export function paragraph_add_bookmark_start(a: number, b: number, c: number, d: number, e: number): number;
export function paragraph_add_bookmark_end(a: number, b: number, c: number): number; export function paragraph_add_bookmark_end(a: number, b: number, c: number): number;
export function paragraph_add_comment_start(a: number, b: number): number; export function paragraph_add_comment_start(a: number, b: number): number;
export function paragraph_add_comment_end(a: number, b: number, c: number): number; export function paragraph_add_comment_end(a: number, b: number): number;
export function paragraph_align(a: number, b: number): number; export function paragraph_align(a: number, b: number): number;
export function paragraph_style(a: number, b: number, c: number): number; export function paragraph_style(a: number, b: number, c: number): number;
export function paragraph_indent(a: number, b: number, c: number, d: number, e: number): number; export function paragraph_indent(a: number, b: number, c: number, d: number, e: number): number;

Binary file not shown.

View File

@ -7,7 +7,7 @@ use wasm_bindgen::prelude::*;
pub struct Comment(docx_core::Comment); pub struct Comment(docx_core::Comment);
#[wasm_bindgen(js_name = createComment)] #[wasm_bindgen(js_name = createComment)]
pub fn create_comment(id: String) -> Comment { pub fn create_comment(id: usize) -> Comment {
Comment(docx_core::Comment::new(id)) Comment(docx_core::Comment::new(id))
} }
@ -34,7 +34,7 @@ impl Comment {
self self
} }
pub fn id(&self) -> String { pub fn id(&self) -> usize {
self.0.id.clone() self.0.id
} }
} }

View File

@ -57,7 +57,7 @@ impl Paragraph {
self self
} }
pub fn add_comment_end(mut self, id: &str) -> Paragraph { pub fn add_comment_end(mut self, id: usize) -> Paragraph {
self.0.children.push(docx_core::ParagraphChild::CommentEnd( self.0.children.push(docx_core::ParagraphChild::CommentEnd(
docx_core::CommentRangeEnd::new(id), docx_core::CommentRangeEnd::new(id),
)); ));

View File

@ -0,0 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?>
<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"><Override PartName="/_rels/.rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/><Override PartName="/docProps/app.xml" ContentType="application/vnd.openxmlformats-officedocument.extended-properties+xml"/><Override PartName="/docProps/core.xml" ContentType="application/vnd.openxmlformats-package.core-properties+xml"/><Override PartName="/word/_rels/document.xml.rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/><Override PartName="/word/settings.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml"/><Override PartName="/word/fontTable.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml"/><Override PartName="/word/document.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml"/><Override PartName="/word/styles.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml"/>
</Types>

View File

@ -0,0 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?>
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties" Target="docProps/core.xml"/><Relationship Id="rId2" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties" Target="docProps/app.xml"/><Relationship Id="rId3" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="word/document.xml"/>
</Relationships>

View File

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Properties xmlns="http://schemas.openxmlformats.org/officeDocument/2006/extended-properties" xmlns:vt="http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes"><Template></Template><TotalTime>1</TotalTime><Application>LibreOffice/6.0.7.3$Linux_X86_64 LibreOffice_project/00m0$Build-3</Application><Pages>1</Pages><Words>2</Words><Characters>10</Characters><CharactersWithSpaces>11</CharactersWithSpaces><Paragraphs>1</Paragraphs></Properties>

View File

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<cp:coreProperties xmlns:cp="http://schemas.openxmlformats.org/package/2006/metadata/core-properties" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:dcmitype="http://purl.org/dc/dcmitype/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><dcterms:created xsi:type="dcterms:W3CDTF">2019-12-14T00:03:20Z</dcterms:created><dc:creator></dc:creator><dc:description></dc:description><dc:language>ja-JP</dc:language><cp:lastModifiedBy></cp:lastModifiedBy><dcterms:modified xsi:type="dcterms:W3CDTF">2019-12-14T00:04:24Z</dcterms:modified><cp:revision>1</cp:revision><dc:subject></dc:subject><dc:title></dc:title></cp:coreProperties>

Binary file not shown.

View File

@ -0,0 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?>
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" Target="styles.xml"/><Relationship Id="rId2" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable" Target="fontTable.xml"/><Relationship Id="rId3" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings" Target="settings.xml"/>
</Relationships>

View File

@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<w:document xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"
xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"
xmlns:w10="urn:schemas-microsoft-com:office:word"
xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing"
xmlns:wps="http://schemas.microsoft.com/office/word/2010/wordprocessingShape"
xmlns:wpg="http://schemas.microsoft.com/office/word/2010/wordprocessingGroup"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:wp14="http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing"
xmlns:w14="http://schemas.microsoft.com/office/word/2010/wordml" mc:Ignorable="w14 wp14">
<w:body>
<w:p>
<w:pPr>
<w:pStyle w:val="Normal"/>
<w:rPr></w:rPr>
</w:pPr>
<w:r>
<w:rPr></w:rPr>
<w:t xml:space="preserve">Hello </w:t>
</w:r>
<w:r>
<w:rPr>
<w:vanish/>
</w:rPr>
<w:t xml:space="preserve">Hidden </w:t>
</w:r>
<w:r>
<w:rPr></w:rPr>
<w:t>World</w:t>
</w:r>
</w:p>
<w:sectPr>
<w:type w:val="nextPage"/>
<w:pgSz w:w="11906" w:h="16838"/>
<w:pgMar w:left="1134" w:right="1134" w:header="0" w:top="1134" w:footer="0" w:bottom="1134" w:gutter="0"/>
<w:pgNumType w:fmt="decimal"/>
<w:formProt w:val="false"/>
<w:textDirection w:val="lrTb"/>
</w:sectPr>
</w:body>
</w:document>

View File

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<w:fonts xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"><w:font w:name="Times New Roman"><w:charset w:val="00"/><w:family w:val="roman"/><w:pitch w:val="variable"/></w:font><w:font w:name="Symbol"><w:charset w:val="02"/><w:family w:val="roman"/><w:pitch w:val="variable"/></w:font><w:font w:name="Arial"><w:charset w:val="00"/><w:family w:val="swiss"/><w:pitch w:val="variable"/></w:font><w:font w:name="Liberation Serif"><w:altName w:val="Times New Roman"/><w:charset w:val="01"/><w:family w:val="roman"/><w:pitch w:val="variable"/></w:font><w:font w:name="Liberation Sans"><w:altName w:val="Arial"/><w:charset w:val="01"/><w:family w:val="swiss"/><w:pitch w:val="variable"/></w:font></w:fonts>

View File

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<w:settings xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"><w:zoom w:percent="100"/><w:defaultTabStop w:val="709"/><w:compat><w:doNotExpandShiftReturn/></w:compat></w:settings>

View File

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<w:styles xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:w14="http://schemas.microsoft.com/office/word/2010/wordml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="w14"><w:docDefaults><w:rPrDefault><w:rPr><w:rFonts w:ascii="Liberation Serif" w:hAnsi="Liberation Serif" w:eastAsia="Noto Sans CJK JP" w:cs="Lohit Devanagari"/><w:kern w:val="2"/><w:sz w:val="24"/><w:szCs w:val="24"/><w:lang w:val="en-US" w:eastAsia="ja-JP" w:bidi="hi-IN"/></w:rPr></w:rPrDefault><w:pPrDefault><w:pPr><w:widowControl/></w:pPr></w:pPrDefault></w:docDefaults><w:style w:type="paragraph" w:styleId="Normal"><w:name w:val="Normal"/><w:qFormat/><w:pPr><w:widowControl/></w:pPr><w:rPr><w:rFonts w:ascii="Liberation Serif" w:hAnsi="Liberation Serif" w:eastAsia="Noto Sans CJK JP" w:cs="Lohit Devanagari"/><w:color w:val="auto"/><w:kern w:val="2"/><w:sz w:val="24"/><w:szCs w:val="24"/><w:lang w:val="en-US" w:eastAsia="ja-JP" w:bidi="hi-IN"/></w:rPr></w:style><w:style w:type="paragraph" w:styleId="Style14"><w:name w:val="見出し"/><w:basedOn w:val="Normal"/><w:next w:val="Style15"/><w:qFormat/><w:pPr><w:keepNext w:val="true"/><w:spacing w:before="240" w:after="120"/></w:pPr><w:rPr><w:rFonts w:ascii="Liberation Sans" w:hAnsi="Liberation Sans" w:eastAsia="Noto Sans CJK JP" w:cs="Lohit Devanagari"/><w:sz w:val="28"/><w:szCs w:val="28"/></w:rPr></w:style><w:style w:type="paragraph" w:styleId="Style15"><w:name w:val="Body Text"/><w:basedOn w:val="Normal"/><w:pPr><w:spacing w:lineRule="auto" w:line="276" w:before="0" w:after="140"/></w:pPr><w:rPr></w:rPr></w:style><w:style w:type="paragraph" w:styleId="Style16"><w:name w:val="List"/><w:basedOn w:val="Style15"/><w:pPr></w:pPr><w:rPr><w:rFonts w:cs="Lohit Devanagari"/></w:rPr></w:style><w:style w:type="paragraph" w:styleId="Style17"><w:name w:val="Caption"/><w:basedOn w:val="Normal"/><w:qFormat/><w:pPr><w:suppressLineNumbers/><w:spacing w:before="120" w:after="120"/></w:pPr><w:rPr><w:rFonts w:cs="Lohit Devanagari"/><w:i/><w:iCs/><w:sz w:val="24"/><w:szCs w:val="24"/></w:rPr></w:style><w:style w:type="paragraph" w:styleId="Style18"><w:name w:val="索引"/><w:basedOn w:val="Normal"/><w:qFormat/><w:pPr><w:suppressLineNumbers/></w:pPr><w:rPr><w:rFonts w:cs="Lohit Devanagari"/></w:rPr></w:style></w:styles>