@kedataindo/docflow-plugins 0.0.75 → 0.0.77

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,12 +2025,32 @@ 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",
2031
2037
  selectable: true,
2032
2038
  draggable: true,
2033
2039
  atom: true,
2040
+ addAttributes() {
2041
+ return {
2042
+ showHeading: {
2043
+ default: true,
2044
+ parseHTML: (el) => !isHeadingHidden(el.getAttribute("data-show-heading")),
2045
+ renderHTML: (attrs) => isHeadingHidden(attrs.showHeading) ? { "data-show-heading": "false" } : {}
2046
+ },
2047
+ headingText: {
2048
+ default: "Bibliography",
2049
+ parseHTML: (el) => headingLabel(el.getAttribute("data-heading-text")),
2050
+ renderHTML: (attrs) => typeof attrs.headingText === "string" && attrs.headingText !== "Bibliography" ? { "data-heading-text": attrs.headingText } : {}
2051
+ }
2052
+ };
2053
+ },
2034
2054
  parseHTML() {
2035
2055
  return [{ tag: 'div[data-node-type="bibliography"]' }];
2036
2056
  },
@@ -2052,21 +2072,27 @@ var BibliographyNode = import_core6.Node.create({
2052
2072
  const dom = document.createElement("div");
2053
2073
  dom.className = "docs-bibliography";
2054
2074
  dom.setAttribute("data-node-type", "bibliography");
2075
+ let attrs = props.node?.attrs ?? {};
2055
2076
  const render = () => {
2056
2077
  const engine2 = getEngine(editor);
2057
2078
  const items = engine2?.getBibliography() ?? [];
2079
+ const showHeading = !isHeadingHidden(attrs.showHeading);
2080
+ const headingText = headingLabel(attrs.headingText);
2058
2081
  dom.innerHTML = "";
2059
2082
  if (items.length === 0) {
2083
+ if (!showHeading) return;
2060
2084
  const placeholder = document.createElement("p");
2061
2085
  placeholder.className = "docs-bibliography__empty";
2062
- placeholder.textContent = "Bibliography";
2086
+ placeholder.textContent = headingText;
2063
2087
  dom.appendChild(placeholder);
2064
2088
  return;
2065
2089
  }
2066
- const heading = document.createElement("h2");
2067
- heading.className = "docs-bibliography__heading";
2068
- heading.textContent = "Bibliography";
2069
- dom.appendChild(heading);
2090
+ if (showHeading) {
2091
+ const heading = document.createElement("h2");
2092
+ heading.className = "docs-bibliography__heading";
2093
+ heading.textContent = headingText;
2094
+ dom.appendChild(heading);
2095
+ }
2070
2096
  const list = document.createElement("div");
2071
2097
  list.className = "docs-bibliography__entries";
2072
2098
  for (const item of items) {
@@ -2084,7 +2110,12 @@ var BibliographyNode = import_core6.Node.create({
2084
2110
  dom,
2085
2111
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
2086
2112
  update(updatedNode) {
2087
- return updatedNode?.type?.name === "bibliography";
2113
+ if (updatedNode?.type?.name !== "bibliography") return false;
2114
+ const next = updatedNode.attrs ?? {};
2115
+ const changed = isHeadingHidden(next.showHeading) !== isHeadingHidden(attrs.showHeading) || headingLabel(next.headingText) !== headingLabel(attrs.headingText);
2116
+ attrs = next;
2117
+ if (changed) render();
2118
+ return true;
2088
2119
  },
2089
2120
  destroy() {
2090
2121
  unsubscribe?.();
package/dist/index.d.cts CHANGED
@@ -275,9 +275,14 @@ declare const LocationChipNode: Node<any, any>;
275
275
  declare const smartElementsPlugin: _kedata_indonesia_docflow_core.DocsEditorPlugin;
276
276
 
277
277
  /**
278
- * Bibliography — a fully derived block. It stores NOTHING (no attrs): the
279
- * node view renders the engine's citeproc-sorted entries and repaints on
280
- * every engine change (source edit, style switch, citation add/remove).
278
+ * Bibliography — a fully derived block. It stores no entries: the node view
279
+ * renders the engine's citeproc-sorted bibliography and repaints on every
280
+ * engine change (source edit, style switch, citation add/remove).
281
+ *
282
+ * The two attrs are presentation-only, so the host can place the block under
283
+ * an existing section heading (e.g. an NA's "Daftar Pustaka"): `showHeading`
284
+ * suppresses the built-in heading, `headingText` relabels it. Both default to
285
+ * the previous behaviour, so existing documents render unchanged.
281
286
  */
282
287
  declare const BibliographyNode: Node<any, any>;
283
288
 
package/dist/index.d.ts CHANGED
@@ -275,9 +275,14 @@ declare const LocationChipNode: Node<any, any>;
275
275
  declare const smartElementsPlugin: _kedata_indonesia_docflow_core.DocsEditorPlugin;
276
276
 
277
277
  /**
278
- * Bibliography — a fully derived block. It stores NOTHING (no attrs): the
279
- * node view renders the engine's citeproc-sorted entries and repaints on
280
- * every engine change (source edit, style switch, citation add/remove).
278
+ * Bibliography — a fully derived block. It stores no entries: the node view
279
+ * renders the engine's citeproc-sorted bibliography and repaints on every
280
+ * engine change (source edit, style switch, citation add/remove).
281
+ *
282
+ * The two attrs are presentation-only, so the host can place the block under
283
+ * an existing section heading (e.g. an NA's "Daftar Pustaka"): `showHeading`
284
+ * suppresses the built-in heading, `headingText` relabels it. Both default to
285
+ * the previous behaviour, so existing documents render unchanged.
281
286
  */
282
287
  declare const BibliographyNode: Node<any, any>;
283
288
 
package/dist/index.js CHANGED
@@ -1932,12 +1932,32 @@ 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",
1938
1944
  selectable: true,
1939
1945
  draggable: true,
1940
1946
  atom: true,
1947
+ addAttributes() {
1948
+ return {
1949
+ showHeading: {
1950
+ default: true,
1951
+ parseHTML: (el) => !isHeadingHidden(el.getAttribute("data-show-heading")),
1952
+ renderHTML: (attrs) => isHeadingHidden(attrs.showHeading) ? { "data-show-heading": "false" } : {}
1953
+ },
1954
+ headingText: {
1955
+ default: "Bibliography",
1956
+ parseHTML: (el) => headingLabel(el.getAttribute("data-heading-text")),
1957
+ renderHTML: (attrs) => typeof attrs.headingText === "string" && attrs.headingText !== "Bibliography" ? { "data-heading-text": attrs.headingText } : {}
1958
+ }
1959
+ };
1960
+ },
1941
1961
  parseHTML() {
1942
1962
  return [{ tag: 'div[data-node-type="bibliography"]' }];
1943
1963
  },
@@ -1959,21 +1979,27 @@ var BibliographyNode = Node5.create({
1959
1979
  const dom = document.createElement("div");
1960
1980
  dom.className = "docs-bibliography";
1961
1981
  dom.setAttribute("data-node-type", "bibliography");
1982
+ let attrs = props.node?.attrs ?? {};
1962
1983
  const render = () => {
1963
1984
  const engine2 = getEngine(editor);
1964
1985
  const items = engine2?.getBibliography() ?? [];
1986
+ const showHeading = !isHeadingHidden(attrs.showHeading);
1987
+ const headingText = headingLabel(attrs.headingText);
1965
1988
  dom.innerHTML = "";
1966
1989
  if (items.length === 0) {
1990
+ if (!showHeading) return;
1967
1991
  const placeholder = document.createElement("p");
1968
1992
  placeholder.className = "docs-bibliography__empty";
1969
- placeholder.textContent = "Bibliography";
1993
+ placeholder.textContent = headingText;
1970
1994
  dom.appendChild(placeholder);
1971
1995
  return;
1972
1996
  }
1973
- const heading = document.createElement("h2");
1974
- heading.className = "docs-bibliography__heading";
1975
- heading.textContent = "Bibliography";
1976
- dom.appendChild(heading);
1997
+ if (showHeading) {
1998
+ const heading = document.createElement("h2");
1999
+ heading.className = "docs-bibliography__heading";
2000
+ heading.textContent = headingText;
2001
+ dom.appendChild(heading);
2002
+ }
1977
2003
  const list = document.createElement("div");
1978
2004
  list.className = "docs-bibliography__entries";
1979
2005
  for (const item of items) {
@@ -1991,7 +2017,12 @@ var BibliographyNode = Node5.create({
1991
2017
  dom,
1992
2018
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
1993
2019
  update(updatedNode) {
1994
- return updatedNode?.type?.name === "bibliography";
2020
+ if (updatedNode?.type?.name !== "bibliography") return false;
2021
+ const next = updatedNode.attrs ?? {};
2022
+ const changed = isHeadingHidden(next.showHeading) !== isHeadingHidden(attrs.showHeading) || headingLabel(next.headingText) !== headingLabel(attrs.headingText);
2023
+ attrs = next;
2024
+ if (changed) render();
2025
+ return true;
1995
2026
  },
1996
2027
  destroy() {
1997
2028
  unsubscribe?.();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@kedataindo/docflow-plugins",
3
3
  "license": "UNLICENSED",
4
- "version": "0.0.75",
4
+ "version": "0.0.77",
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.73"
34
+ "@kedataindo/docflow-core": "0.0.75"
35
35
  },
36
36
  "peerDependencies": {
37
37
  "@tiptap/core": "^2.11.0",