@kedataindo/docflow-plugins 0.0.76 → 0.0.78

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/dist/index.cjs CHANGED
@@ -2025,6 +2025,12 @@ function getEngine(editor) {
2025
2025
  const storage = editor.storage.citationEngine;
2026
2026
  return storage?.engine ?? null;
2027
2027
  }
2028
+ function isHeadingHidden(value) {
2029
+ return value === false || value === "false";
2030
+ }
2031
+ function headingLabel(value) {
2032
+ return typeof value === "string" && value !== "" ? value : "Bibliography";
2033
+ }
2028
2034
  var BibliographyNode = import_core6.Node.create({
2029
2035
  name: "bibliography",
2030
2036
  group: "block",
@@ -2035,12 +2041,12 @@ var BibliographyNode = import_core6.Node.create({
2035
2041
  return {
2036
2042
  showHeading: {
2037
2043
  default: true,
2038
- parseHTML: (el) => el.getAttribute("data-show-heading") !== "false",
2039
- renderHTML: (attrs) => attrs.showHeading === false ? { "data-show-heading": "false" } : {}
2044
+ parseHTML: (el) => !isHeadingHidden(el.getAttribute("data-show-heading")),
2045
+ renderHTML: (attrs) => isHeadingHidden(attrs.showHeading) ? { "data-show-heading": "false" } : {}
2040
2046
  },
2041
2047
  headingText: {
2042
2048
  default: "Bibliography",
2043
- parseHTML: (el) => el.getAttribute("data-heading-text") || "Bibliography",
2049
+ parseHTML: (el) => headingLabel(el.getAttribute("data-heading-text")),
2044
2050
  renderHTML: (attrs) => typeof attrs.headingText === "string" && attrs.headingText !== "Bibliography" ? { "data-heading-text": attrs.headingText } : {}
2045
2051
  }
2046
2052
  };
@@ -2070,8 +2076,8 @@ var BibliographyNode = import_core6.Node.create({
2070
2076
  const render = () => {
2071
2077
  const engine2 = getEngine(editor);
2072
2078
  const items = engine2?.getBibliography() ?? [];
2073
- const showHeading = attrs.showHeading !== false;
2074
- const headingText = typeof attrs.headingText === "string" ? attrs.headingText : "Bibliography";
2079
+ const showHeading = !isHeadingHidden(attrs.showHeading);
2080
+ const headingText = headingLabel(attrs.headingText);
2075
2081
  dom.innerHTML = "";
2076
2082
  if (items.length === 0) {
2077
2083
  if (!showHeading) return;
@@ -2106,7 +2112,7 @@ var BibliographyNode = import_core6.Node.create({
2106
2112
  update(updatedNode) {
2107
2113
  if (updatedNode?.type?.name !== "bibliography") return false;
2108
2114
  const next = updatedNode.attrs ?? {};
2109
- const changed = next.showHeading !== attrs.showHeading || next.headingText !== attrs.headingText;
2115
+ const changed = isHeadingHidden(next.showHeading) !== isHeadingHidden(attrs.showHeading) || headingLabel(next.headingText) !== headingLabel(attrs.headingText);
2110
2116
  attrs = next;
2111
2117
  if (changed) render();
2112
2118
  return true;
package/dist/index.js CHANGED
@@ -1932,6 +1932,12 @@ function getEngine(editor) {
1932
1932
  const storage = editor.storage.citationEngine;
1933
1933
  return storage?.engine ?? null;
1934
1934
  }
1935
+ function isHeadingHidden(value) {
1936
+ return value === false || value === "false";
1937
+ }
1938
+ function headingLabel(value) {
1939
+ return typeof value === "string" && value !== "" ? value : "Bibliography";
1940
+ }
1935
1941
  var BibliographyNode = Node5.create({
1936
1942
  name: "bibliography",
1937
1943
  group: "block",
@@ -1942,12 +1948,12 @@ var BibliographyNode = Node5.create({
1942
1948
  return {
1943
1949
  showHeading: {
1944
1950
  default: true,
1945
- parseHTML: (el) => el.getAttribute("data-show-heading") !== "false",
1946
- renderHTML: (attrs) => attrs.showHeading === false ? { "data-show-heading": "false" } : {}
1951
+ parseHTML: (el) => !isHeadingHidden(el.getAttribute("data-show-heading")),
1952
+ renderHTML: (attrs) => isHeadingHidden(attrs.showHeading) ? { "data-show-heading": "false" } : {}
1947
1953
  },
1948
1954
  headingText: {
1949
1955
  default: "Bibliography",
1950
- parseHTML: (el) => el.getAttribute("data-heading-text") || "Bibliography",
1956
+ parseHTML: (el) => headingLabel(el.getAttribute("data-heading-text")),
1951
1957
  renderHTML: (attrs) => typeof attrs.headingText === "string" && attrs.headingText !== "Bibliography" ? { "data-heading-text": attrs.headingText } : {}
1952
1958
  }
1953
1959
  };
@@ -1977,8 +1983,8 @@ var BibliographyNode = Node5.create({
1977
1983
  const render = () => {
1978
1984
  const engine2 = getEngine(editor);
1979
1985
  const items = engine2?.getBibliography() ?? [];
1980
- const showHeading = attrs.showHeading !== false;
1981
- const headingText = typeof attrs.headingText === "string" ? attrs.headingText : "Bibliography";
1986
+ const showHeading = !isHeadingHidden(attrs.showHeading);
1987
+ const headingText = headingLabel(attrs.headingText);
1982
1988
  dom.innerHTML = "";
1983
1989
  if (items.length === 0) {
1984
1990
  if (!showHeading) return;
@@ -2013,7 +2019,7 @@ var BibliographyNode = Node5.create({
2013
2019
  update(updatedNode) {
2014
2020
  if (updatedNode?.type?.name !== "bibliography") return false;
2015
2021
  const next = updatedNode.attrs ?? {};
2016
- const changed = next.showHeading !== attrs.showHeading || next.headingText !== attrs.headingText;
2022
+ const changed = isHeadingHidden(next.showHeading) !== isHeadingHidden(attrs.showHeading) || headingLabel(next.headingText) !== headingLabel(attrs.headingText);
2017
2023
  attrs = next;
2018
2024
  if (changed) render();
2019
2025
  return true;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@kedataindo/docflow-plugins",
3
3
  "license": "UNLICENSED",
4
- "version": "0.0.76",
4
+ "version": "0.0.78",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "module": "./dist/index.js",
@@ -31,7 +31,7 @@
31
31
  "@tiptap/pm": "^2.11.0",
32
32
  "citeproc": "^2.4.63",
33
33
  "tiptap-markdown": "0.8.10",
34
- "@kedataindo/docflow-core": "0.0.74"
34
+ "@kedataindo/docflow-core": "0.0.76"
35
35
  },
36
36
  "peerDependencies": {
37
37
  "@tiptap/core": "^2.11.0",