@fiduswriter/editor 0.1.34 → 0.1.36

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 +1 @@
1
- {"version":3,"file":"jump_hidden_nodes.d.ts","sourceRoot":"","sources":["../../src/state_plugins/jump_hidden_nodes.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,MAAM,EAA2B,MAAM,mBAAmB,CAAA;AAmBlE,eAAO,MAAM,qBAAqB,GAAI,UAAU;IAAC,MAAM,EAAE,OAAO,CAAA;CAAC,gBA8C3D,CAAA"}
1
+ {"version":3,"file":"jump_hidden_nodes.d.ts","sourceRoot":"","sources":["../../src/state_plugins/jump_hidden_nodes.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,MAAM,EAA2B,MAAM,mBAAmB,CAAA;AAmBlE,eAAO,MAAM,qBAAqB,GAAI,UAAU;IAAC,MAAM,EAAE,OAAO,CAAA;CAAC,gBAmC3D,CAAA"}
@@ -16,45 +16,32 @@ const key = new PluginKey("jump-hidden-nodes");
16
16
  export const jumpHiddenNodesPlugin = (_options) => new Plugin({
17
17
  key,
18
18
  appendTransaction: (trs, oldState, state) => {
19
- if (state.selection.from !== state.selection.to) {
19
+ if (!state.selection.empty) {
20
20
  // Only applies to collapsed selection
21
21
  return;
22
22
  }
23
- const selection = state.selection;
24
- let $pos = selection.$from;
25
- if (!posHidden($pos)) {
26
- return;
27
- }
28
- let movedRight = false, movedLeft = false;
29
- const startPos = $pos.pos;
30
- while ($pos.depth > 1 && posHidden($pos)) {
31
- $pos = state.doc.resolve($pos.after());
32
- movedRight = true;
33
- }
34
- if (!movedRight) {
35
- $pos = selection.$from;
36
- while ($pos.depth > 1 && posHidden($pos)) {
37
- $pos = state.doc.resolve($pos.before());
38
- movedLeft = true;
23
+ const selectionSet = trs.find(tr => tr.selectionSet);
24
+ if (selectionSet && posHidden(state.selection.$from)) {
25
+ const dir = state.selection.from > oldState.selection.from ? 1 : -1;
26
+ let newPos = state.selection.from, hidden = true, validTextSelection = false, validGapCursor = false;
27
+ let $pos = state.selection.$from;
28
+ while (hidden || (!validGapCursor && !validTextSelection)) {
29
+ newPos += dir;
30
+ if (newPos === 0 || newPos === state.doc.nodeSize) {
31
+ // Could not find any valid position
32
+ return;
33
+ }
34
+ $pos = state.doc.resolve(newPos);
35
+ validTextSelection = $pos.parent.inlineContent;
36
+ validGapCursor = GapCursor.valid($pos);
37
+ hidden = posHidden($pos);
39
38
  }
39
+ const selection = validTextSelection
40
+ ? new TextSelection($pos)
41
+ : new GapCursor($pos);
42
+ return state.tr.setSelection(selection);
40
43
  }
41
- if (!movedRight && !movedLeft) {
42
- return;
43
- }
44
- let tr = state.tr;
45
- if ($pos.node().isTextblock &&
46
- $pos.pos >= startPos &&
47
- $pos.pos <= startPos) {
48
- // Try to set text selection
49
- tr = tr.setSelection(TextSelection.near($pos));
50
- }
51
- else if ($pos.pos !== startPos) {
52
- tr = tr.setSelection(new GapCursor($pos));
53
- }
54
- if (trs[trs.length - 1].doc.eq(tr.doc)) {
55
- return tr;
56
- }
57
- return;
44
+ return undefined;
58
45
  }
59
46
  });
60
47
  //# sourceMappingURL=jump_hidden_nodes.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"jump_hidden_nodes.js","sourceRoot":"","sources":["../../src/state_plugins/jump_hidden_nodes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,uBAAuB,CAAA;AAC/C,OAAO,EAAC,MAAM,EAAE,SAAS,EAAE,aAAa,EAAC,MAAM,mBAAmB,CAAA;AAGlE,MAAM,SAAS,GAAG,CAAC,IAAiB,EAAE,EAAE;IACpC,IAAI,MAAM,GAAG,KAAK,CAAA;IAClB,KAAK,IAAI,CAAC,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,C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QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;YAC3D,IAAI,MAAM,GAAG,KAAK,CAAC,SAAS,CAAC,IAAI,EAC7B,MAAM,GAAG,IAAI,EACb,kBAAkB,GAAG,KAAK,EAC1B,cAAc,GAAG,KAAK,CAAA;YAC1B,IAAI,IAAI,GAAgB,KAAK,CAAC,SAAS,CAAC,KAAK,CAAA;YAC7C,OAAO,MAAM,IAAI,CAAC,CAAC,cAAc,IAAI,CAAC,kBAAkB,CAAC,EAAE,CAAC;gBACxD,MAAM,IAAI,GAAG,CAAA;gBACb,IAAI,MAAM,KAAK,CAAC,IAAI,MAAM,KAAK,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;oBAChD,oCAAoC;oBACpC,OAAM;gBACV,CAAC;gBACD,IAAI,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;gBAChC,kBAAkB,GAAG,IAAI,CAAC,MAAM,CAAC,aAAa,CAAA;gBAC9C,cAAc,GAAI,SAAiB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;gBAC/C,MAAM,GAAG,SAAS,CAAC,IAAI,CAAC,CAAA;YAC5B,CAAC;YACD,MAAM,SAAS,GAAG,kBAAkB;gBAChC,CAAC,CAAC,IAAI,aAAa,CAAC,IAAI,CAAC;gBACzB,CAAC,CAAC,IAAI,SAAS,CAAC,IAAI,CAAC,CAAA;YACzB,OAAO,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,SAAS,CAAC,CAAA;QAC3C,CAAC;QACD,OAAO,SAAS,CAAA;IACpB,CAAC;CACJ,CAAC,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fiduswriter/editor",
3
- "version": "0.1.34",
3
+ "version": "0.1.36",
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
  }
@@ -22,46 +22,35 @@ export const jumpHiddenNodesPlugin = (_options: {editor: unknown}) =>
22
22
  new Plugin({
23
23
  key,
24
24
  appendTransaction: (trs, oldState, state) => {
25
- if (state.selection.from !== state.selection.to) {
25
+ if (!state.selection.empty) {
26
26
  // Only applies to collapsed selection
27
27
  return
28
28
  }
29
- const selection = state.selection
30
- let $pos = selection.$from
31
- if (!posHidden($pos)) {
32
- return
33
- }
34
- let movedRight = false,
35
- movedLeft = false
36
- const startPos = $pos.pos
37
- while ($pos.depth > 1 && posHidden($pos)) {
38
- $pos = state.doc.resolve($pos.after())
39
- movedRight = true
40
- }
41
- if (!movedRight) {
42
- $pos = selection.$from
43
- while ($pos.depth > 1 && posHidden($pos)) {
44
- $pos = state.doc.resolve($pos.before())
45
- movedLeft = true
29
+ const selectionSet = trs.find(tr => tr.selectionSet)
30
+ if (selectionSet && posHidden(state.selection.$from)) {
31
+ const dir =
32
+ state.selection.from > oldState.selection.from ? 1 : -1
33
+ let newPos = state.selection.from,
34
+ hidden = true,
35
+ validTextSelection = false,
36
+ validGapCursor = false
37
+ let $pos: ResolvedPos = state.selection.$from
38
+ while (hidden || (!validGapCursor && !validTextSelection)) {
39
+ newPos += dir
40
+ if (newPos === 0 || newPos === state.doc.nodeSize) {
41
+ // Could not find any valid position
42
+ return
43
+ }
44
+ $pos = state.doc.resolve(newPos)
45
+ validTextSelection = $pos.parent.inlineContent
46
+ validGapCursor = (GapCursor as any).valid($pos)
47
+ hidden = posHidden($pos)
46
48
  }
49
+ const selection = validTextSelection
50
+ ? new TextSelection($pos)
51
+ : new GapCursor($pos)
52
+ return state.tr.setSelection(selection)
47
53
  }
48
- if (!movedRight && !movedLeft) {
49
- return
50
- }
51
- let tr = state.tr
52
- if (
53
- $pos.node().isTextblock &&
54
- $pos.pos >= startPos &&
55
- $pos.pos <= startPos
56
- ) {
57
- // Try to set text selection
58
- tr = tr.setSelection(TextSelection.near($pos))
59
- } else if ($pos.pos !== startPos) {
60
- tr = tr.setSelection(new GapCursor($pos))
61
- }
62
- if (trs[trs.length - 1].doc.eq(tr.doc)) {
63
- return tr
64
- }
65
- return
54
+ return undefined
66
55
  }
67
56
  })