@fiduswriter/document 0.1.0-alpha.1
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/LICENSE +661 -0
- package/README.md +16 -0
- package/jest.config.js +23 -0
- package/package.json +59 -0
- package/schema.json +1 -0
- package/scripts/export-schema.js +16 -0
- package/src/bibliography/common.js +92 -0
- package/src/bibliography/csl_bib.js +139 -0
- package/src/citations/citeproc_sys.js +42 -0
- package/src/citations/format.js +194 -0
- package/src/common/blob.js +10 -0
- package/src/common/file.js +25 -0
- package/src/common/index.js +12 -0
- package/src/common/network.js +79 -0
- package/src/common/text.js +44 -0
- package/src/editor/e2ee/encryptor.js +228 -0
- package/src/exporter/docx/citations.js +177 -0
- package/src/exporter/docx/comments.js +165 -0
- package/src/exporter/docx/footnotes.js +240 -0
- package/src/exporter/docx/images.js +101 -0
- package/src/exporter/docx/index.js +185 -0
- package/src/exporter/docx/lists.js +260 -0
- package/src/exporter/docx/math.js +46 -0
- package/src/exporter/docx/metadata.js +289 -0
- package/src/exporter/docx/rels.js +193 -0
- package/src/exporter/docx/render.js +941 -0
- package/src/exporter/docx/richtext.js +1182 -0
- package/src/exporter/docx/tables.js +112 -0
- package/src/exporter/docx/tools.js +50 -0
- package/src/exporter/epub/index.js +142 -0
- package/src/exporter/epub/templates.js +140 -0
- package/src/exporter/epub/tools.js +96 -0
- package/src/exporter/html/citations.js +121 -0
- package/src/exporter/html/convert.js +813 -0
- package/src/exporter/html/index.js +192 -0
- package/src/exporter/html/templates.js +34 -0
- package/src/exporter/html/tools.js +50 -0
- package/src/exporter/jats/bibliography.js +183 -0
- package/src/exporter/jats/citations.js +109 -0
- package/src/exporter/jats/convert.js +871 -0
- package/src/exporter/jats/index.js +92 -0
- package/src/exporter/jats/templates.js +35 -0
- package/src/exporter/jats/text.js +72 -0
- package/src/exporter/latex/convert.js +934 -0
- package/src/exporter/latex/escape_latex.js +21 -0
- package/src/exporter/latex/index.js +74 -0
- package/src/exporter/latex/readme.js +22 -0
- package/src/exporter/native/shrink.js +132 -0
- package/src/exporter/odt/citations.js +101 -0
- package/src/exporter/odt/footnotes.js +147 -0
- package/src/exporter/odt/images.js +115 -0
- package/src/exporter/odt/index.js +156 -0
- package/src/exporter/odt/math.js +57 -0
- package/src/exporter/odt/metadata.js +251 -0
- package/src/exporter/odt/render.js +806 -0
- package/src/exporter/odt/richtext.js +865 -0
- package/src/exporter/odt/styles.js +387 -0
- package/src/exporter/odt/track.js +68 -0
- package/src/exporter/pandoc/citations.js +98 -0
- package/src/exporter/pandoc/convert.js +1017 -0
- package/src/exporter/pandoc/index.js +92 -0
- package/src/exporter/pandoc/readme.js +8 -0
- package/src/exporter/pandoc/tools.js +51 -0
- package/src/exporter/print/index.js +177 -0
- package/src/exporter/tools/doc_content.js +144 -0
- package/src/exporter/tools/file.js +9 -0
- package/src/exporter/tools/json.js +73 -0
- package/src/exporter/tools/svg.js +29 -0
- package/src/exporter/tools/xml.js +531 -0
- package/src/exporter/tools/xml_zip.js +95 -0
- package/src/exporter/tools/zip.js +90 -0
- package/src/exporter/tools/zotero_csl.js +93 -0
- package/src/importer/citations.js +129 -0
- package/src/importer/docx/citations.js +123 -0
- package/src/importer/docx/convert.js +1427 -0
- package/src/importer/docx/helpers.js +9 -0
- package/src/importer/docx/omml2mathml.js +1448 -0
- package/src/importer/docx/parse.js +735 -0
- package/src/importer/native/get_images.js +76 -0
- package/src/importer/native/update.js +29 -0
- package/src/importer/odt/citations.js +87 -0
- package/src/importer/odt/convert.js +1855 -0
- package/src/importer/pandoc/convert.js +884 -0
- package/src/importer/pandoc/helpers.js +84 -0
- package/src/importer/zip_analyzer.js +102 -0
- package/src/index.js +1 -0
- package/src/mathlive/opf_includes.js +24 -0
- package/src/schema/common/annotate.js +76 -0
- package/src/schema/common/base.js +118 -0
- package/src/schema/common/citation.js +62 -0
- package/src/schema/common/equation.js +31 -0
- package/src/schema/common/figure.js +190 -0
- package/src/schema/common/heading.js +43 -0
- package/src/schema/common/index.js +40 -0
- package/src/schema/common/list.js +95 -0
- package/src/schema/common/reference.js +100 -0
- package/src/schema/common/table.js +103 -0
- package/src/schema/common/track.js +190 -0
- package/src/schema/const.js +58 -0
- package/src/schema/convert.js +1272 -0
- package/src/schema/document/content.js +187 -0
- package/src/schema/document/index.js +117 -0
- package/src/schema/document/structure.js +452 -0
- package/src/schema/export.js +21 -0
- package/src/schema/footnotes.js +126 -0
- package/src/schema/footnotes_convert.js +31 -0
- package/src/schema/i18n.js +595 -0
- package/src/schema/index.js +5 -0
- package/src/schema/mini_json.js +61 -0
- package/src/schema/text.js +22 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import {get} from "../../common/index.js"
|
|
2
|
+
|
|
3
|
+
export class GetImages {
|
|
4
|
+
constructor(images, entries) {
|
|
5
|
+
this.images = images
|
|
6
|
+
this.imageEntries = Object.values(this.images)
|
|
7
|
+
this.entries = entries
|
|
8
|
+
this.counter = 0
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
init() {
|
|
12
|
+
if (this.entries.length > 0) {
|
|
13
|
+
if (this.entries[0].hasOwnProperty("url")) {
|
|
14
|
+
return this.getImageUrlEntry()
|
|
15
|
+
} else {
|
|
16
|
+
return this.getImageZipEntry()
|
|
17
|
+
}
|
|
18
|
+
} else {
|
|
19
|
+
return Promise.resolve()
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
getImageZipEntry() {
|
|
24
|
+
if (this.counter < this.imageEntries.length) {
|
|
25
|
+
return new Promise(resolve => {
|
|
26
|
+
const f = this.entries.find(
|
|
27
|
+
entry =>
|
|
28
|
+
entry.filename === this.imageEntries[this.counter].image
|
|
29
|
+
)
|
|
30
|
+
if (!f) {
|
|
31
|
+
console.warn(
|
|
32
|
+
`Image ${this.imageEntries[this.counter].image} not found`,
|
|
33
|
+
this.imageEntries,
|
|
34
|
+
this.entries
|
|
35
|
+
)
|
|
36
|
+
this.counter++
|
|
37
|
+
return this.getImageZipEntry().then(() => {
|
|
38
|
+
resolve()
|
|
39
|
+
})
|
|
40
|
+
}
|
|
41
|
+
const fc = f.content
|
|
42
|
+
this.imageEntries[this.counter]["file"] = new window.Blob(
|
|
43
|
+
[fc],
|
|
44
|
+
{
|
|
45
|
+
type: this.imageEntries[this.counter].file_type
|
|
46
|
+
}
|
|
47
|
+
)
|
|
48
|
+
this.counter++
|
|
49
|
+
this.getImageZipEntry().then(() => {
|
|
50
|
+
resolve()
|
|
51
|
+
})
|
|
52
|
+
})
|
|
53
|
+
} else {
|
|
54
|
+
return Promise.resolve()
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
getImageUrlEntry() {
|
|
59
|
+
if (this.counter < this.imageEntries.length) {
|
|
60
|
+
const getUrl = this.entries.find(
|
|
61
|
+
entry =>
|
|
62
|
+
entry.filename ===
|
|
63
|
+
`images/${this.imageEntries[this.counter].image.split("/").pop()}`
|
|
64
|
+
).url
|
|
65
|
+
return get(getUrl)
|
|
66
|
+
.then(response => response.blob())
|
|
67
|
+
.then(blob => {
|
|
68
|
+
this.imageEntries[this.counter]["file"] = blob
|
|
69
|
+
this.counter++
|
|
70
|
+
return this.getImageUrlEntry()
|
|
71
|
+
})
|
|
72
|
+
} else {
|
|
73
|
+
return Promise.resolve()
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import {updateDoc} from "../../schema/convert.js"
|
|
2
|
+
|
|
3
|
+
export function updateFile(doc, filetypeVersion, bibliography, images) {
|
|
4
|
+
// update bibliography -- currently not needed
|
|
5
|
+
// bibliography = updateBib(bibliography)
|
|
6
|
+
if (filetypeVersion < 3.2) {
|
|
7
|
+
Object.values(images).forEach(
|
|
8
|
+
image =>
|
|
9
|
+
(image.copyright = {
|
|
10
|
+
holder: false,
|
|
11
|
+
year: false,
|
|
12
|
+
freeToRead: true,
|
|
13
|
+
licenses: []
|
|
14
|
+
})
|
|
15
|
+
)
|
|
16
|
+
}
|
|
17
|
+
if (filetypeVersion < 3.3) {
|
|
18
|
+
doc.content = doc.contents
|
|
19
|
+
delete doc.contents
|
|
20
|
+
}
|
|
21
|
+
if (filetypeVersion < 2.0) {
|
|
22
|
+
// Before 2.0, version numbers of the doc and of the file differed.
|
|
23
|
+
doc = updateDoc(doc, doc.settings["doc_version"], bibliography)
|
|
24
|
+
} else {
|
|
25
|
+
doc = updateDoc(doc, filetypeVersion, bibliography)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return {doc, bibliography, images}
|
|
29
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import {OdtCitationsParser} from "biblatex-csl-converter"
|
|
2
|
+
import {citationResultToNode} from "../citations.js"
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Check whether an ODT reference mark name belongs to a bibliography region
|
|
6
|
+
* (Zotero ZOTERO_BIBL, Mendeley CSL_BIBLIOGRAPHY).
|
|
7
|
+
* Uses OdtCitationsParser.referenceMarkBibliography().
|
|
8
|
+
*
|
|
9
|
+
* @param {string} markName - text:name attribute value
|
|
10
|
+
* @returns {boolean}
|
|
11
|
+
*/
|
|
12
|
+
export function isOdtBibliographyReferenceMark(markName) {
|
|
13
|
+
if (!markName) {
|
|
14
|
+
return false
|
|
15
|
+
}
|
|
16
|
+
return OdtCitationsParser.referenceMarkBibliography(markName).isBibliography
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Check whether a text:section name belongs to a bibliography region
|
|
21
|
+
* (Zotero, JabRef).
|
|
22
|
+
* Uses OdtCitationsParser.sectionBibliography().
|
|
23
|
+
*
|
|
24
|
+
* @param {string} sectionName - text:name attribute value
|
|
25
|
+
* @returns {boolean}
|
|
26
|
+
*/
|
|
27
|
+
export function isOdtBibliographySection(sectionName) {
|
|
28
|
+
if (!sectionName) {
|
|
29
|
+
return false
|
|
30
|
+
}
|
|
31
|
+
return OdtCitationsParser.sectionBibliography(sectionName).isBibliography
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Check whether an ODT reference mark name belongs to a citation.
|
|
36
|
+
* Uses OdtCitationsParser.referenceMarkCitation() with retrieve=false.
|
|
37
|
+
*
|
|
38
|
+
* @param {string} markName - text:name attribute value
|
|
39
|
+
* @returns {boolean}
|
|
40
|
+
*/
|
|
41
|
+
export function isOdtCitationMark(markName) {
|
|
42
|
+
if (!markName) {
|
|
43
|
+
return false
|
|
44
|
+
}
|
|
45
|
+
return OdtCitationsParser.referenceMarkCitation(markName, false).isCitation
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Parse a citation from an ODT reference mark name and add any new
|
|
50
|
+
* bibliography entries into `bibliography`.
|
|
51
|
+
*
|
|
52
|
+
* Handles Zotero, Mendeley Desktop (legacy), and JabRef reference marks.
|
|
53
|
+
*
|
|
54
|
+
* @param {string} markName - text:name attribute of the reference-mark-start
|
|
55
|
+
* @param {Object} bibliography - Fidus Writer bibliography (mutated in place)
|
|
56
|
+
* @returns {Object|null} ProseMirror citation node or null
|
|
57
|
+
*/
|
|
58
|
+
export function parseOdtReferenceMark(markName, bibliography, bibDB) {
|
|
59
|
+
if (!markName) {
|
|
60
|
+
return null
|
|
61
|
+
}
|
|
62
|
+
const result = OdtCitationsParser.referenceMarkCitation(
|
|
63
|
+
markName,
|
|
64
|
+
true, // retrieve
|
|
65
|
+
true // retrieveMetadata
|
|
66
|
+
)
|
|
67
|
+
return citationResultToNode(result, bibliography, bibDB)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Parse a citation from a LibreOffice native <text:bibliography-mark> element
|
|
72
|
+
* and add any new bibliography entries into `bibliography`.
|
|
73
|
+
*
|
|
74
|
+
* @param {Object} bibMarkNode - The parsed text:bibliography-mark XMLElement
|
|
75
|
+
* @param {Object} bibliography - Fidus Writer bibliography (mutated in place)
|
|
76
|
+
* @returns {Object|null} ProseMirror citation node or null
|
|
77
|
+
*/
|
|
78
|
+
export function parseOdtBibliographyMark(bibMarkNode, bibliography) {
|
|
79
|
+
if (!bibMarkNode) {
|
|
80
|
+
return null
|
|
81
|
+
}
|
|
82
|
+
const result = OdtCitationsParser.bibliographyMarkCitation(
|
|
83
|
+
bibMarkNode.outerXML,
|
|
84
|
+
true // retrieve
|
|
85
|
+
)
|
|
86
|
+
return citationResultToNode(result, bibliography)
|
|
87
|
+
}
|