@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,187 @@
|
|
|
1
|
+
import {escapeText} from "../../common/index.js"
|
|
2
|
+
import {parseTracks} from "../common/index.js"
|
|
3
|
+
import {fnNodeToHtml, htmlToFnNode} from "../footnotes_convert.js"
|
|
4
|
+
|
|
5
|
+
export const randomCodeBlockId = () => {
|
|
6
|
+
return `C${Math.round(Math.random() * 10000000) + 1}`
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const contributor = {
|
|
10
|
+
inline: true,
|
|
11
|
+
draggable: true,
|
|
12
|
+
attrs: {
|
|
13
|
+
firstname: {default: false},
|
|
14
|
+
lastname: {default: false},
|
|
15
|
+
email: {default: false},
|
|
16
|
+
institution: {default: false},
|
|
17
|
+
// Only present if template defines id_types:
|
|
18
|
+
id_type: {default: false}, // Selected from template's id_types list
|
|
19
|
+
id_value: {default: false} // Validated against selected id_type's regex
|
|
20
|
+
},
|
|
21
|
+
parseDOM: [
|
|
22
|
+
{
|
|
23
|
+
tag: "span.contributor",
|
|
24
|
+
getAttrs(dom) {
|
|
25
|
+
return {
|
|
26
|
+
firstname: dom.dataset.firstname,
|
|
27
|
+
lastname: dom.dataset.lastname,
|
|
28
|
+
email: dom.dataset.email,
|
|
29
|
+
institution: dom.dataset.institution,
|
|
30
|
+
id_type: dom.dataset.id_type || false,
|
|
31
|
+
id_value: dom.dataset.id_value || false
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
],
|
|
36
|
+
toDOM(node) {
|
|
37
|
+
const dom = document.createElement("span")
|
|
38
|
+
dom.classList.add("contributor")
|
|
39
|
+
dom.dataset.firstname = node.attrs.firstname
|
|
40
|
+
dom.dataset.lastname = node.attrs.lastname
|
|
41
|
+
dom.dataset.email = node.attrs.email
|
|
42
|
+
dom.dataset.institution = node.attrs.institution
|
|
43
|
+
if (node.attrs.id_type) {
|
|
44
|
+
dom.dataset.id_type = node.attrs.id_type
|
|
45
|
+
}
|
|
46
|
+
if (node.attrs.id_value) {
|
|
47
|
+
dom.dataset.id_value = node.attrs.id_value
|
|
48
|
+
}
|
|
49
|
+
const content = []
|
|
50
|
+
if (node.attrs.firstname) {
|
|
51
|
+
content.push(escapeText(node.attrs.firstname))
|
|
52
|
+
}
|
|
53
|
+
if (node.attrs.lastname) {
|
|
54
|
+
content.push(escapeText(node.attrs.lastname))
|
|
55
|
+
}
|
|
56
|
+
if (node.attrs.email) {
|
|
57
|
+
content.push(
|
|
58
|
+
`<i>${gettext("Email")}: ${escapeText(node.attrs.email)}</i>`
|
|
59
|
+
)
|
|
60
|
+
}
|
|
61
|
+
if (node.attrs.institution) {
|
|
62
|
+
content.push(`(${escapeText(node.attrs.institution)})`)
|
|
63
|
+
}
|
|
64
|
+
if (node.attrs.id_type && node.attrs.id_value) {
|
|
65
|
+
content.push(
|
|
66
|
+
`<i>${escapeText(node.attrs.id_type)}: ${escapeText(node.attrs.id_value)}</i>`
|
|
67
|
+
)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
dom.innerHTML = content.join(" ")
|
|
71
|
+
|
|
72
|
+
return dom
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export const tag = {
|
|
77
|
+
inline: true,
|
|
78
|
+
draggable: true,
|
|
79
|
+
attrs: {
|
|
80
|
+
tag: {
|
|
81
|
+
default: ""
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
parseDOM: [
|
|
85
|
+
{
|
|
86
|
+
tag: "span.tag",
|
|
87
|
+
getAttrs(dom) {
|
|
88
|
+
return {
|
|
89
|
+
tag: dom.innerText
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
],
|
|
94
|
+
toDOM(node) {
|
|
95
|
+
return ["span", {class: "tag"}, node.attrs.tag]
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export const footnote = {
|
|
100
|
+
inline: true,
|
|
101
|
+
group: "inline",
|
|
102
|
+
attrs: {
|
|
103
|
+
footnote: {
|
|
104
|
+
default: [
|
|
105
|
+
{
|
|
106
|
+
type: "paragraph"
|
|
107
|
+
}
|
|
108
|
+
]
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
parseDOM: [
|
|
112
|
+
{
|
|
113
|
+
tag: "span.footnote-marker[data-footnote]",
|
|
114
|
+
getAttrs(dom) {
|
|
115
|
+
return {
|
|
116
|
+
footnote: htmlToFnNode(dom.dataset.footnote)
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
],
|
|
121
|
+
toDOM(node) {
|
|
122
|
+
const dom = document.createElement("span")
|
|
123
|
+
dom.classList.add("footnote-marker")
|
|
124
|
+
dom.dataset.footnote = fnNodeToHtml(node.attrs.footnote)
|
|
125
|
+
dom.innerHTML = " "
|
|
126
|
+
return dom
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export const code_block = {
|
|
131
|
+
content: "text*",
|
|
132
|
+
marks: "_",
|
|
133
|
+
group: "block",
|
|
134
|
+
code: true,
|
|
135
|
+
defining: true,
|
|
136
|
+
attrs: {
|
|
137
|
+
track: {
|
|
138
|
+
default: []
|
|
139
|
+
},
|
|
140
|
+
language: {
|
|
141
|
+
default: ""
|
|
142
|
+
},
|
|
143
|
+
category: {
|
|
144
|
+
default: ""
|
|
145
|
+
},
|
|
146
|
+
title: {
|
|
147
|
+
default: ""
|
|
148
|
+
},
|
|
149
|
+
id: {
|
|
150
|
+
default: ""
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
parseDOM: [
|
|
154
|
+
{
|
|
155
|
+
tag: "pre",
|
|
156
|
+
preserveWhitespace: "full",
|
|
157
|
+
getAttrs(dom) {
|
|
158
|
+
return {
|
|
159
|
+
track: parseTracks(dom.dataset.track),
|
|
160
|
+
language: dom.dataset.language || "",
|
|
161
|
+
category: dom.dataset.category || "",
|
|
162
|
+
title: dom.dataset.title || "",
|
|
163
|
+
id: dom.dataset.id || ""
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
],
|
|
168
|
+
toDOM(node) {
|
|
169
|
+
const attrs = {}
|
|
170
|
+
if (node.attrs.track.length) {
|
|
171
|
+
attrs["data-track"] = JSON.stringify(node.attrs.track)
|
|
172
|
+
}
|
|
173
|
+
if (node.attrs.language) {
|
|
174
|
+
attrs["data-language"] = node.attrs.language
|
|
175
|
+
}
|
|
176
|
+
if (node.attrs.category) {
|
|
177
|
+
attrs["data-category"] = node.attrs.category
|
|
178
|
+
}
|
|
179
|
+
if (node.attrs.title) {
|
|
180
|
+
attrs["data-title"] = node.attrs.title
|
|
181
|
+
}
|
|
182
|
+
if (node.attrs.id) {
|
|
183
|
+
attrs["data-id"] = node.attrs.id
|
|
184
|
+
}
|
|
185
|
+
return ["pre", attrs, ["code", 0]]
|
|
186
|
+
}
|
|
187
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import OrderedMap from "orderedmap"
|
|
2
|
+
import {Schema} from "prosemirror-model"
|
|
3
|
+
import {marks, nodes} from "prosemirror-schema-basic"
|
|
4
|
+
import {
|
|
5
|
+
anchor,
|
|
6
|
+
annotation_tag,
|
|
7
|
+
blockquote,
|
|
8
|
+
bullet_list,
|
|
9
|
+
citation,
|
|
10
|
+
code,
|
|
11
|
+
comment,
|
|
12
|
+
cross_reference,
|
|
13
|
+
deletion,
|
|
14
|
+
equation,
|
|
15
|
+
figure,
|
|
16
|
+
figure_caption,
|
|
17
|
+
figure_equation,
|
|
18
|
+
format_change,
|
|
19
|
+
heading1,
|
|
20
|
+
heading2,
|
|
21
|
+
heading3,
|
|
22
|
+
heading4,
|
|
23
|
+
heading5,
|
|
24
|
+
heading6,
|
|
25
|
+
horizontal_rule,
|
|
26
|
+
image,
|
|
27
|
+
insertion,
|
|
28
|
+
link,
|
|
29
|
+
list_item,
|
|
30
|
+
ordered_list,
|
|
31
|
+
paragraph,
|
|
32
|
+
sub,
|
|
33
|
+
sup,
|
|
34
|
+
table,
|
|
35
|
+
table_body,
|
|
36
|
+
table_caption,
|
|
37
|
+
table_cell,
|
|
38
|
+
table_header,
|
|
39
|
+
table_row,
|
|
40
|
+
underline
|
|
41
|
+
} from "../common/index.js"
|
|
42
|
+
import {code_block, contributor, footnote, tag} from "./content.js"
|
|
43
|
+
import {
|
|
44
|
+
contributors_part,
|
|
45
|
+
doc,
|
|
46
|
+
heading_part,
|
|
47
|
+
richtext_part,
|
|
48
|
+
separator_part,
|
|
49
|
+
table_of_contents,
|
|
50
|
+
table_part,
|
|
51
|
+
tags_part,
|
|
52
|
+
title
|
|
53
|
+
} from "./structure.js"
|
|
54
|
+
|
|
55
|
+
const specNodes = OrderedMap.from({
|
|
56
|
+
doc,
|
|
57
|
+
richtext_part,
|
|
58
|
+
heading_part,
|
|
59
|
+
contributors_part,
|
|
60
|
+
tags_part,
|
|
61
|
+
table_part,
|
|
62
|
+
table_of_contents,
|
|
63
|
+
separator_part,
|
|
64
|
+
title,
|
|
65
|
+
contributor,
|
|
66
|
+
tag,
|
|
67
|
+
paragraph,
|
|
68
|
+
blockquote,
|
|
69
|
+
horizontal_rule,
|
|
70
|
+
figure,
|
|
71
|
+
image,
|
|
72
|
+
figure_equation,
|
|
73
|
+
figure_caption,
|
|
74
|
+
heading1,
|
|
75
|
+
heading2,
|
|
76
|
+
heading3,
|
|
77
|
+
heading4,
|
|
78
|
+
heading5,
|
|
79
|
+
heading6,
|
|
80
|
+
code_block,
|
|
81
|
+
text: nodes.text,
|
|
82
|
+
hard_break: nodes.hard_break,
|
|
83
|
+
citation,
|
|
84
|
+
equation,
|
|
85
|
+
cross_reference,
|
|
86
|
+
footnote,
|
|
87
|
+
ordered_list,
|
|
88
|
+
bullet_list,
|
|
89
|
+
list_item,
|
|
90
|
+
table,
|
|
91
|
+
table_caption,
|
|
92
|
+
table_body,
|
|
93
|
+
table_row,
|
|
94
|
+
table_cell,
|
|
95
|
+
table_header
|
|
96
|
+
})
|
|
97
|
+
|
|
98
|
+
const spec = {
|
|
99
|
+
nodes: specNodes,
|
|
100
|
+
marks: OrderedMap.from({
|
|
101
|
+
em: marks.em,
|
|
102
|
+
strong: marks.strong,
|
|
103
|
+
link,
|
|
104
|
+
underline,
|
|
105
|
+
sup,
|
|
106
|
+
sub,
|
|
107
|
+
code,
|
|
108
|
+
comment,
|
|
109
|
+
annotation_tag,
|
|
110
|
+
anchor,
|
|
111
|
+
deletion,
|
|
112
|
+
insertion,
|
|
113
|
+
format_change
|
|
114
|
+
})
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export const docSchema = new Schema(spec)
|