improved signature for deleted text runs, added demo 54 and added documentation for change tracking
This commit is contained in:
@ -1,72 +1,15 @@
|
||||
import { SpaceType } from "file/space-type";
|
||||
import { XmlComponent, XmlAttributeComponent } from "file/xml-components";
|
||||
import { TextRun } from "../index";
|
||||
import { XmlAttributeComponent } from "file/xml-components";
|
||||
|
||||
export interface ITrackRevisionAttributesProperties {
|
||||
export interface IChangedAttributesProperties {
|
||||
readonly id: number;
|
||||
readonly author: string;
|
||||
readonly date: string;
|
||||
}
|
||||
|
||||
export class TrackRevisionAttributes extends XmlAttributeComponent<ITrackRevisionAttributesProperties> {
|
||||
export class ChangeAttributes extends XmlAttributeComponent<IChangedAttributesProperties> {
|
||||
protected readonly xmlKeys = {
|
||||
id: "w:id",
|
||||
author: "w:author",
|
||||
date: "w:date",
|
||||
};
|
||||
}
|
||||
|
||||
export interface IInsertedTextRunOptions extends ITrackRevisionAttributesProperties {
|
||||
readonly child: TextRun;
|
||||
}
|
||||
|
||||
export interface IDeletedTextRunOptions extends ITrackRevisionAttributesProperties {
|
||||
readonly text: string;
|
||||
}
|
||||
|
||||
export class InsertedTextRun extends XmlComponent {
|
||||
constructor(options: IInsertedTextRunOptions) {
|
||||
super("w:ins");
|
||||
this.root.push(
|
||||
new TrackRevisionAttributes({
|
||||
id: options.id,
|
||||
author: options.author,
|
||||
date: options.date,
|
||||
}),
|
||||
);
|
||||
this.addChildElement(options.child);
|
||||
}
|
||||
}
|
||||
|
||||
export class DeletedTextRunWrapper extends XmlComponent {
|
||||
constructor(text: string) {
|
||||
super("w:r");
|
||||
this.root.push(new DeletedText(text));
|
||||
}
|
||||
}
|
||||
|
||||
class TextAttributes extends XmlAttributeComponent<{ readonly space: SpaceType }> {
|
||||
protected readonly xmlKeys = { space: "xml:space" };
|
||||
}
|
||||
|
||||
export class DeletedText extends XmlComponent {
|
||||
constructor(text: string) {
|
||||
super("w:delText");
|
||||
this.root.push(new TextAttributes({ space: SpaceType.PRESERVE }));
|
||||
this.root.push(text);
|
||||
}
|
||||
}
|
||||
|
||||
export class DeletedTextRun extends XmlComponent {
|
||||
constructor(options: IDeletedTextRunOptions) {
|
||||
super("w:del");
|
||||
this.root.push(
|
||||
new TrackRevisionAttributes({
|
||||
id: options.id,
|
||||
author: options.author,
|
||||
date: options.date,
|
||||
}),
|
||||
);
|
||||
this.addChildElement(new DeletedTextRunWrapper(options.text));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user