@fiduswriter/editor 0.1.32 → 0.1.35

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.
@@ -6,8 +6,8 @@ export const linkDialogTemplate = ({ defaultLink, internalTargets, linkType, tit
6
6
  <label class="cross-reference-label">${gettext("Cross reference")}</label>
7
7
  </div>
8
8
  <div class="fw-select-container">
9
- <select class="cross-reference-selector fw-button fw-light fw-large" required="/>
10
- <option class="fw-placeholder" selected="" disabled="" value="/>
9
+ <select class="cross-reference-selector fw-button fw-light fw-large" required="">
10
+ <option class="fw-placeholder" selected="" disabled="" value="">
11
11
  ${gettext("Select Target")}
12
12
  </option>
13
13
  ${internalTargets
@@ -24,8 +24,8 @@ export const linkDialogTemplate = ({ defaultLink, internalTargets, linkType, tit
24
24
  <label class="link-internal-label">${gettext("Internal")}</label>
25
25
  </div>
26
26
  <div class="fw-select-container">
27
- <select class="internal-link-selector fw-button fw-light fw-large" required="/>
28
- <option class="fw-placeholder" selected="" disabled="" value="/>
27
+ <select class="internal-link-selector fw-button fw-light fw-large" required="">
28
+ <option class="fw-placeholder" selected="" disabled="" value="">
29
29
  ${gettext("Select Target")}
30
30
  </option>
31
31
  ${internalTargets
@@ -257,7 +257,7 @@ export const configureCitationTemplate = ({ citedItemsHTML, citeFormat }) => `<d
257
257
  <div id="cited-items" class="fw-ar-container">
258
258
  <h3 class="fw-green-title">${gettext("Citation format")}</h3>
259
259
  <div class="fw-select-container">
260
- <select id="citation-style-selector" class="fw-button fw-light fw-large" required="/>
260
+ <select id="citation-style-selector" class="fw-button fw-light fw-large" required="">
261
261
  <option value="autocite" ${citeFormat === "autocite" ? "selected" : ""}>${gettext("(Author, 1998)")}</option>
262
262
  <option value="textcite" ${citeFormat === "textcite" ? "selected" : ""}>${gettext("Author (1998)")}</option>
263
263
  </select>
@@ -339,7 +339,7 @@ export const contributorTemplate = ({ contributor, idTypes = [] }) => {
339
339
  }
340
340
  else {
341
341
  idTypeField = `<select name="id_type">
342
- <option value="/>${gettext("Select ID Type")}</option>
342
+ <option value="">${gettext("Select ID Type")}</option>
343
343
  ${idTypes.map(t => `<option value="${escapeText(t.label)}" ${contributor.id_type === t.label ? "selected" : ""}>${escapeText(t.label)}</option>`).join("")}
344
344
  </select>`;
345
345
  }
@@ -1,6 +1,6 @@
1
1
  import { Plugin } from "prosemirror-state";
2
2
  interface CitationRenderState {
3
- action: boolean;
3
+ action: string | false;
4
4
  }
5
5
  export declare const citationRenderPlugin: (_options: {
6
6
  editor: unknown;
@@ -1 +1 @@
1
- {"version":3,"file":"citation_render.d.ts","sourceRoot":"","sources":["../../src/state_plugins/citation_render.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAY,MAAM,mBAAmB,CAAA;AAKnD,UAAU,mBAAmB;IACzB,MAAM,EAAE,OAAO,CAAA;CAClB;AAED,eAAO,MAAM,oBAAoB,GAAI,UAAU;IAAC,MAAM,EAAE,OAAO,CAAA;CAAC,gCAqD1D,CAAA"}
1
+ {"version":3,"file":"citation_render.d.ts","sourceRoot":"","sources":["../../src/state_plugins/citation_render.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAY,MAAM,mBAAmB,CAAA;AAMnD,UAAU,mBAAmB;IACzB,MAAM,EAAE,MAAM,GAAG,KAAK,CAAA;CACzB;AAED,eAAO,MAAM,oBAAoB,GAAI,UAAU;IAAC,MAAM,EAAE,OAAO,CAAA;CAAC,gCA+D1D,CAAA"}
@@ -14,7 +14,11 @@ export const citationRenderPlugin = (_options) => new Plugin({
14
14
  // of previous values
15
15
  return meta;
16
16
  }
17
- let { action } = key.getState(oldState);
17
+ const oldPluginState = key.getState(oldState);
18
+ if (!oldPluginState) {
19
+ return { action: false };
20
+ }
21
+ let { action } = oldPluginState;
18
22
  if (action || tr.getMeta("settings")) {
19
23
  return { action }; // We already need to reset the bibliography or another setting is used. Don't bother checking for more reasons to do so.
20
24
  }
@@ -22,19 +26,27 @@ export const citationRenderPlugin = (_options) => new Plugin({
22
26
  if (step instanceof ReplaceStep ||
23
27
  step instanceof ReplaceAroundStep) {
24
28
  if (step.from !== step.to) {
25
- const map = tr.mapping.maps[index];
26
- map.forEach((_oldStart, _oldEnd, newStart, newEnd) => {
27
- tr.doc.nodesBetween(newStart, newEnd, node => {
28
- if (node.type.name === "citation") {
29
- action = true;
30
- }
31
- });
29
+ ;
30
+ tr.docs[index].nodesBetween(step.from, step.to, node => {
31
+ if (node.type.name === "citation") {
32
+ // A citation was replaced. We need to reset
33
+ action = "reset";
34
+ }
35
+ else if (!action &&
36
+ node.type.name === "footnote") {
37
+ action = "numbers";
38
+ }
32
39
  });
33
40
  }
34
- else {
35
- tr.doc.nodesBetween(step.from, step.to, node => {
41
+ if (step.slice?.content) {
42
+ step.slice.content.descendants(node => {
36
43
  if (node.type.name === "citation") {
37
- action = true;
44
+ // A citation was added. We need to reset
45
+ action = "reset";
46
+ }
47
+ else if (!action &&
48
+ node.type.name === "footnote") {
49
+ action = "numbers";
38
50
  }
39
51
  });
40
52
  }
@@ -1 +1 @@
1
- {"version":3,"file":"citation_render.js","sourceRoot":"","sources":["../../src/state_plugins/citation_render.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAE,SAAS,EAAC,MAAM,mBAAmB,CAAA;AACnD,OAAO,EAAC,iBAAiB,EAAE,WAAW,EAAC,MAAM,uBAAuB,CAAA;AAEpE,MAAM,GAAG,GAAG,IAAI,SAAS,CAAC,gBAAgB,CAAC,CAAA;AAM3C,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,QAA2B,EAAE,EAAE,CAChE,IAAI,MAAM,CAAsB;IAC5B,GAAG;IACH,KAAK,EAAE;QACH,IAAI;YACA,OAAO,EAAC,MAAM,EAAE,KAAK,EAAC,CAAA;QAC1B,CAAC;QACD,KAAK,CAAC,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM;YAC7B,MAAM,IAAI,GAAG,EAAE,CAAC,OAAO,CAAC,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,EAAE;gBAC7B,IACI,IAAI,YAAY,WAAW;oBAC3B,IAAI,YAAY,iBAAiB,EACnC,CAAC;oBACC,IAAI,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,EAAE,EAAE,CAAC;wBACxB,CAAC;wBAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAU,CAAC,YAAY,CAClC,IAAI,CAAC,IAAI,EACT,IAAI,CAAC,EAAE,EACP,IAAI,CAAC,EAAE;4BACH,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;gCAChC,4CAA4C;gCAC5C,MAAM,GAAG,OAAO,CAAA;4BACpB,CAAC;iCAAM,IACH,CAAC,MAAM;gCACP,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,UAAU,EAC/B,CAAC;gCACC,MAAM,GAAG,SAAS,CAAA;4BACtB,CAAC;wBACL,CAAC,CACJ,CAAA;oBACL,CAAC;oBACD,IAAI,IAAI,CAAC,KAAK,EAAE,OAAO,EAAE,CAAC;wBACtB,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE;4BAClC,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;gCAChC,yCAAyC;gCACzC,MAAM,GAAG,OAAO,CAAA;4BACpB,CAAC;iCAAM,IACH,CAAC,MAAM;gCACP,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,UAAU,EAC/B,CAAC;gCACC,MAAM,GAAG,SAAS,CAAA;4BACtB,CAAC;wBACL,CAAC,CAAC,CAAA;oBACN,CAAC;gBACL,CAAC;YACL,CAAC,CAAC,CAAA;YACF,OAAO,EAAC,MAAM,EAAC,CAAA;QACnB,CAAC;KACJ;CACJ,CAAC,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fiduswriter/editor",
3
- "version": "0.1.32",
3
+ "version": "0.1.35",
4
4
  "description": "Fidus Writer browser editor",
5
5
  "repository": {
6
6
  "type": "git",
@@ -35,8 +35,8 @@ export const linkDialogTemplate = ({
35
35
  <label class="cross-reference-label">${gettext("Cross reference")}</label>
36
36
  </div>
37
37
  <div class="fw-select-container">
38
- <select class="cross-reference-selector fw-button fw-light fw-large" required="/>
39
- <option class="fw-placeholder" selected="" disabled="" value="/>
38
+ <select class="cross-reference-selector fw-button fw-light fw-large" required="">
39
+ <option class="fw-placeholder" selected="" disabled="" value="">
40
40
  ${gettext("Select Target")}
41
41
  </option>
42
42
  ${internalTargets
@@ -58,8 +58,8 @@ export const linkDialogTemplate = ({
58
58
  <label class="link-internal-label">${gettext("Internal")}</label>
59
59
  </div>
60
60
  <div class="fw-select-container">
61
- <select class="internal-link-selector fw-button fw-light fw-large" required="/>
62
- <option class="fw-placeholder" selected="" disabled="" value="/>
61
+ <select class="internal-link-selector fw-button fw-light fw-large" required="">
62
+ <option class="fw-placeholder" selected="" disabled="" value="">
63
63
  ${gettext("Select Target")}
64
64
  </option>
65
65
  ${internalTargets
@@ -347,7 +347,7 @@ export const configureCitationTemplate = ({
347
347
  <div id="cited-items" class="fw-ar-container">
348
348
  <h3 class="fw-green-title">${gettext("Citation format")}</h3>
349
349
  <div class="fw-select-container">
350
- <select id="citation-style-selector" class="fw-button fw-light fw-large" required="/>
350
+ <select id="citation-style-selector" class="fw-button fw-light fw-large" required="">
351
351
  <option value="autocite" ${citeFormat === "autocite" ? "selected" : ""}>${gettext("(Author, 1998)")}</option>
352
352
  <option value="textcite" ${citeFormat === "textcite" ? "selected" : ""}>${gettext("Author (1998)")}</option>
353
353
  </select>
@@ -466,7 +466,7 @@ export const contributorTemplate = ({
466
466
  idTypeField = `<span class="id-type-label">${escapeText(type.label)}:</span><input type="hidden" name="id_type" value="${escapeText(type.label)}">`
467
467
  } else {
468
468
  idTypeField = `<select name="id_type">
469
- <option value="/>${gettext("Select ID Type")}</option>
469
+ <option value="">${gettext("Select ID Type")}</option>
470
470
  ${idTypes.map(t => `<option value="${escapeText(t.label)}" ${contributor.id_type === t.label ? "selected" : ""}>${escapeText(t.label)}</option>`).join("")}
471
471
  </select>`
472
472
  }
@@ -1,10 +1,11 @@
1
1
  import {Plugin, PluginKey} from "prosemirror-state"
2
2
  import {ReplaceAroundStep, ReplaceStep} from "prosemirror-transform"
3
+ import type {Node} from "prosemirror-model"
3
4
 
4
5
  const key = new PluginKey("citationRender")
5
6
 
6
7
  interface CitationRenderState {
7
- action: boolean
8
+ action: string | false
8
9
  }
9
10
 
10
11
  export const citationRenderPlugin = (_options: {editor: unknown}) =>
@@ -21,7 +22,11 @@ export const citationRenderPlugin = (_options: {editor: unknown}) =>
21
22
  // of previous values
22
23
  return meta as CitationRenderState
23
24
  }
24
- let {action} = key.getState(oldState) as CitationRenderState
25
+ const oldPluginState = key.getState(oldState) as CitationRenderState | undefined
26
+ if (!oldPluginState) {
27
+ return {action: false}
28
+ }
29
+ let {action} = oldPluginState
25
30
 
26
31
  if (action || tr.getMeta("settings")) {
27
32
  return {action} // We already need to reset the bibliography or another setting is used. Don't bother checking for more reasons to do so.
@@ -32,29 +37,35 @@ export const citationRenderPlugin = (_options: {editor: unknown}) =>
32
37
  step instanceof ReplaceAroundStep
33
38
  ) {
34
39
  if (step.from !== step.to) {
35
- const map = tr.mapping.maps[index]
36
- map.forEach((_oldStart, _oldEnd, newStart, newEnd) => {
37
- tr.doc.nodesBetween(
38
- newStart,
39
- newEnd,
40
- node => {
41
- if (node.type.name === "citation") {
42
- action = true
43
- }
44
- }
45
- )
46
- })
47
- } else {
48
- tr.doc.nodesBetween(
40
+ ;(tr.docs[index] as Node).nodesBetween(
49
41
  step.from,
50
42
  step.to,
51
43
  node => {
52
44
  if (node.type.name === "citation") {
53
- action = true
45
+ // A citation was replaced. We need to reset
46
+ action = "reset"
47
+ } else if (
48
+ !action &&
49
+ node.type.name === "footnote"
50
+ ) {
51
+ action = "numbers"
54
52
  }
55
53
  }
56
54
  )
57
55
  }
56
+ if (step.slice?.content) {
57
+ step.slice.content.descendants(node => {
58
+ if (node.type.name === "citation") {
59
+ // A citation was added. We need to reset
60
+ action = "reset"
61
+ } else if (
62
+ !action &&
63
+ node.type.name === "footnote"
64
+ ) {
65
+ action = "numbers"
66
+ }
67
+ })
68
+ }
58
69
  }
59
70
  })
60
71
  return {action}