@fiduswriter/bibliography-manager 0.1.0

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.
Files changed (105) hide show
  1. package/LICENSE +661 -0
  2. package/README.md +20 -0
  3. package/dist/database/index.js +172 -0
  4. package/dist/database/index.js.map +1 -0
  5. package/dist/database/server_connector.js +47 -0
  6. package/dist/database/server_connector.js.map +1 -0
  7. package/dist/export/index.js +23 -0
  8. package/dist/export/index.js.map +1 -0
  9. package/dist/form/cats.js +22 -0
  10. package/dist/form/cats.js.map +1 -0
  11. package/dist/form/fields/date.js +28 -0
  12. package/dist/form/fields/date.js.map +1 -0
  13. package/dist/form/fields/key.js +100 -0
  14. package/dist/form/fields/key.js.map +1 -0
  15. package/dist/form/fields/key_list.js +37 -0
  16. package/dist/form/fields/key_list.js.map +1 -0
  17. package/dist/form/fields/literal.js +43 -0
  18. package/dist/form/fields/literal.js.map +1 -0
  19. package/dist/form/fields/literal_list.js +36 -0
  20. package/dist/form/fields/literal_list.js.map +1 -0
  21. package/dist/form/fields/literal_long.js +42 -0
  22. package/dist/form/fields/literal_long.js.map +1 -0
  23. package/dist/form/fields/name.js +121 -0
  24. package/dist/form/fields/name.js.map +1 -0
  25. package/dist/form/fields/name_list.js +36 -0
  26. package/dist/form/fields/name_list.js.map +1 -0
  27. package/dist/form/fields/range.js +89 -0
  28. package/dist/form/fields/range.js.map +1 -0
  29. package/dist/form/fields/range_list.js +36 -0
  30. package/dist/form/fields/range_list.js.map +1 -0
  31. package/dist/form/fields/tag_list.js +30 -0
  32. package/dist/form/fields/tag_list.js.map +1 -0
  33. package/dist/form/fields/title.js +46 -0
  34. package/dist/form/fields/title.js.map +1 -0
  35. package/dist/form/fields/uri.js +40 -0
  36. package/dist/form/fields/uri.js.map +1 -0
  37. package/dist/form/fields/verbatim.js +19 -0
  38. package/dist/form/fields/verbatim.js.map +1 -0
  39. package/dist/form/index.js +344 -0
  40. package/dist/form/index.js.map +1 -0
  41. package/dist/form/strings.js +89 -0
  42. package/dist/form/strings.js.map +1 -0
  43. package/dist/form/templates.js +59 -0
  44. package/dist/form/templates.js.map +1 -0
  45. package/dist/import/bibliography_import.js +83 -0
  46. package/dist/import/bibliography_import.js.map +1 -0
  47. package/dist/import/dialog.js +71 -0
  48. package/dist/import/dialog.js.map +1 -0
  49. package/dist/import/index.js +3 -0
  50. package/dist/import/index.js.map +1 -0
  51. package/dist/import/templates.js +12 -0
  52. package/dist/import/templates.js.map +1 -0
  53. package/dist/index.js +6 -0
  54. package/dist/index.js.map +1 -0
  55. package/dist/overview/index.js +453 -0
  56. package/dist/overview/index.js.map +1 -0
  57. package/dist/overview/menu.js +91 -0
  58. package/dist/overview/menu.js.map +1 -0
  59. package/dist/overview/templates.js +24 -0
  60. package/dist/overview/templates.js.map +1 -0
  61. package/dist/plugins/bibliography_overview/index.js +2 -0
  62. package/dist/plugins/bibliography_overview/index.js.map +1 -0
  63. package/dist/schema/literal.js +24 -0
  64. package/dist/schema/literal.js.map +1 -0
  65. package/dist/schema/literal_long.js +40 -0
  66. package/dist/schema/literal_long.js.map +1 -0
  67. package/dist/schema/title.js +31 -0
  68. package/dist/schema/title.js.map +1 -0
  69. package/dist/tools.js +53 -0
  70. package/dist/tools.js.map +1 -0
  71. package/package.json +55 -0
  72. package/src/database/index.js +234 -0
  73. package/src/database/server_connector.js +57 -0
  74. package/src/export/index.js +27 -0
  75. package/src/form/cats.js +24 -0
  76. package/src/form/fields/date.js +31 -0
  77. package/src/form/fields/key.js +113 -0
  78. package/src/form/fields/key_list.js +45 -0
  79. package/src/form/fields/literal.js +48 -0
  80. package/src/form/fields/literal_list.js +42 -0
  81. package/src/form/fields/literal_long.js +47 -0
  82. package/src/form/fields/name.js +152 -0
  83. package/src/form/fields/name_list.js +42 -0
  84. package/src/form/fields/range.js +104 -0
  85. package/src/form/fields/range_list.js +42 -0
  86. package/src/form/fields/tag_list.js +33 -0
  87. package/src/form/fields/title.js +51 -0
  88. package/src/form/fields/uri.js +43 -0
  89. package/src/form/fields/verbatim.js +21 -0
  90. package/src/form/index.js +424 -0
  91. package/src/form/strings.js +122 -0
  92. package/src/form/templates.js +70 -0
  93. package/src/import/bibliography_import.js +104 -0
  94. package/src/import/dialog.js +95 -0
  95. package/src/import/index.js +2 -0
  96. package/src/import/templates.js +12 -0
  97. package/src/index.js +5 -0
  98. package/src/overview/index.js +548 -0
  99. package/src/overview/menu.js +106 -0
  100. package/src/overview/templates.js +30 -0
  101. package/src/plugins/bibliography_overview/index.js +1 -0
  102. package/src/schema/literal.js +34 -0
  103. package/src/schema/literal_long.js +50 -0
  104. package/src/schema/title.js +42 -0
  105. package/src/tools.js +58 -0
@@ -0,0 +1,34 @@
1
+ import {
2
+ url,
3
+ enquote,
4
+ literal,
5
+ smallcaps,
6
+ sub,
7
+ sup,
8
+ text,
9
+ variable
10
+ } from "@fiduswriter/document/bibliography/common"
11
+ import {Schema} from "prosemirror-model"
12
+ import {marks} from "prosemirror-schema-basic"
13
+
14
+ const doc = {
15
+ content: "literal"
16
+ }
17
+
18
+ export const litSchema = new Schema({
19
+ nodes: {
20
+ doc,
21
+ literal,
22
+ text,
23
+ variable
24
+ },
25
+ marks: {
26
+ em: marks.em,
27
+ enquote,
28
+ smallcaps,
29
+ strong: marks.strong,
30
+ sup,
31
+ sub,
32
+ url
33
+ }
34
+ })
@@ -0,0 +1,50 @@
1
+ import {
2
+ url,
3
+ enquote,
4
+ smallcaps,
5
+ sub,
6
+ sup,
7
+ text,
8
+ variable
9
+ } from "@fiduswriter/document/bibliography/common"
10
+ import {Schema} from "prosemirror-model"
11
+ import {marks} from "prosemirror-schema-basic"
12
+
13
+ const longliteral = {
14
+ content: "inline*",
15
+ marks: "_",
16
+ code: true,
17
+ defining: true,
18
+ parseDOM: [{tag: "pre.long-literal"}],
19
+ toDOM(_node) {
20
+ return [
21
+ "pre",
22
+ {
23
+ class: "long-literal"
24
+ },
25
+ 0
26
+ ]
27
+ }
28
+ }
29
+
30
+ const doc = {
31
+ content: "longliteral"
32
+ }
33
+
34
+ export const longLitSchema = new Schema({
35
+ nodes: {
36
+ doc,
37
+ longliteral,
38
+ text,
39
+ variable
40
+ },
41
+ marks: {
42
+ em: marks.em,
43
+ enquote,
44
+ smallcaps,
45
+ strong: marks.strong,
46
+ sup,
47
+ sub,
48
+ url
49
+ }
50
+ })
@@ -0,0 +1,42 @@
1
+ import {
2
+ url,
3
+ enquote,
4
+ literal,
5
+ smallcaps,
6
+ sub,
7
+ sup,
8
+ text,
9
+ variable
10
+ } from "@fiduswriter/document/bibliography/common"
11
+ import {Schema} from "prosemirror-model"
12
+ import {marks} from "prosemirror-schema-basic"
13
+
14
+ const nocase = {
15
+ parseDOM: [{tag: "span.nocase"}],
16
+ toDOM() {
17
+ return ["span", {class: "nocase"}]
18
+ }
19
+ }
20
+
21
+ const doc = {
22
+ content: "literal"
23
+ }
24
+
25
+ export const titleSchema = new Schema({
26
+ nodes: {
27
+ doc,
28
+ literal,
29
+ text,
30
+ variable
31
+ },
32
+ marks: {
33
+ em: marks.em,
34
+ enquote,
35
+ nocase,
36
+ smallcaps,
37
+ strong: marks.strong,
38
+ sup,
39
+ sub,
40
+ url
41
+ }
42
+ })
package/src/tools.js ADDED
@@ -0,0 +1,58 @@
1
+ // Extract a display year from an EDTF date string.
2
+ // Handles simple years, ranges (2023/2024), uncertainty (?, *, u), and open-ended dates.
3
+ export function dateToYear(dateStr) {
4
+ if (!dateStr) {
5
+ return ""
6
+ }
7
+ // Take the first date component (before "/" for ranges or open-ended dates)
8
+ const firstPart = dateStr.split("/")[0]
9
+ // Strip uncertainty/wildcard characters to get a clean year
10
+ return firstPart.replace(/[?*u~]/g, "")
11
+ }
12
+
13
+ // Takes any richtext text field as used in bibliography and returns the text contents
14
+ export function litToText(litStringArray) {
15
+ let outText = ""
16
+ litStringArray.forEach(litString => {
17
+ if (litString.type === "text") {
18
+ outText += litString.text
19
+ }
20
+ })
21
+ return outText
22
+ }
23
+
24
+ function nameListItemToString(nameListItem) {
25
+ let nameString = ""
26
+ if (nameListItem["family"]) {
27
+ nameString += litToText(nameListItem["family"])
28
+ if (nameListItem["given"]) {
29
+ nameString += `, ${litToText(nameListItem["given"])}`
30
+ }
31
+ } else if (nameListItem["literal"]) {
32
+ nameString += litToText(nameListItem["literal"])
33
+ }
34
+ return nameString
35
+ }
36
+
37
+ export function nameToText(nameList) {
38
+ let nameString
39
+ switch (nameList.length) {
40
+ case 0:
41
+ nameString = ""
42
+ break
43
+ case 1:
44
+ nameString = nameListItemToString(nameList[0])
45
+ break
46
+ case 2:
47
+ nameString = `${nameListItemToString(nameList[0])} ${gettext(
48
+ "and"
49
+ )} ${nameListItemToString(nameList[1])}`
50
+ break
51
+ default:
52
+ nameString = `${nameListItemToString(nameList[0])} ${gettext(
53
+ "and others"
54
+ )}`
55
+ break
56
+ }
57
+ return nameString
58
+ }