@kedataindo/docflow-plugins 0.0.75 → 0.0.76
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 +31 -6
- package/dist/index.d.cts +8 -3
- package/dist/index.d.ts +8 -3
- package/dist/index.js +31 -6
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -2031,6 +2031,20 @@ var BibliographyNode = import_core6.Node.create({
|
|
|
2031
2031
|
selectable: true,
|
|
2032
2032
|
draggable: true,
|
|
2033
2033
|
atom: true,
|
|
2034
|
+
addAttributes() {
|
|
2035
|
+
return {
|
|
2036
|
+
showHeading: {
|
|
2037
|
+
default: true,
|
|
2038
|
+
parseHTML: (el) => el.getAttribute("data-show-heading") !== "false",
|
|
2039
|
+
renderHTML: (attrs) => attrs.showHeading === false ? { "data-show-heading": "false" } : {}
|
|
2040
|
+
},
|
|
2041
|
+
headingText: {
|
|
2042
|
+
default: "Bibliography",
|
|
2043
|
+
parseHTML: (el) => el.getAttribute("data-heading-text") || "Bibliography",
|
|
2044
|
+
renderHTML: (attrs) => typeof attrs.headingText === "string" && attrs.headingText !== "Bibliography" ? { "data-heading-text": attrs.headingText } : {}
|
|
2045
|
+
}
|
|
2046
|
+
};
|
|
2047
|
+
},
|
|
2034
2048
|
parseHTML() {
|
|
2035
2049
|
return [{ tag: 'div[data-node-type="bibliography"]' }];
|
|
2036
2050
|
},
|
|
@@ -2052,21 +2066,27 @@ var BibliographyNode = import_core6.Node.create({
|
|
|
2052
2066
|
const dom = document.createElement("div");
|
|
2053
2067
|
dom.className = "docs-bibliography";
|
|
2054
2068
|
dom.setAttribute("data-node-type", "bibliography");
|
|
2069
|
+
let attrs = props.node?.attrs ?? {};
|
|
2055
2070
|
const render = () => {
|
|
2056
2071
|
const engine2 = getEngine(editor);
|
|
2057
2072
|
const items = engine2?.getBibliography() ?? [];
|
|
2073
|
+
const showHeading = attrs.showHeading !== false;
|
|
2074
|
+
const headingText = typeof attrs.headingText === "string" ? attrs.headingText : "Bibliography";
|
|
2058
2075
|
dom.innerHTML = "";
|
|
2059
2076
|
if (items.length === 0) {
|
|
2077
|
+
if (!showHeading) return;
|
|
2060
2078
|
const placeholder = document.createElement("p");
|
|
2061
2079
|
placeholder.className = "docs-bibliography__empty";
|
|
2062
|
-
placeholder.textContent =
|
|
2080
|
+
placeholder.textContent = headingText;
|
|
2063
2081
|
dom.appendChild(placeholder);
|
|
2064
2082
|
return;
|
|
2065
2083
|
}
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2084
|
+
if (showHeading) {
|
|
2085
|
+
const heading = document.createElement("h2");
|
|
2086
|
+
heading.className = "docs-bibliography__heading";
|
|
2087
|
+
heading.textContent = headingText;
|
|
2088
|
+
dom.appendChild(heading);
|
|
2089
|
+
}
|
|
2070
2090
|
const list = document.createElement("div");
|
|
2071
2091
|
list.className = "docs-bibliography__entries";
|
|
2072
2092
|
for (const item of items) {
|
|
@@ -2084,7 +2104,12 @@ var BibliographyNode = import_core6.Node.create({
|
|
|
2084
2104
|
dom,
|
|
2085
2105
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2086
2106
|
update(updatedNode) {
|
|
2087
|
-
|
|
2107
|
+
if (updatedNode?.type?.name !== "bibliography") return false;
|
|
2108
|
+
const next = updatedNode.attrs ?? {};
|
|
2109
|
+
const changed = next.showHeading !== attrs.showHeading || next.headingText !== attrs.headingText;
|
|
2110
|
+
attrs = next;
|
|
2111
|
+
if (changed) render();
|
|
2112
|
+
return true;
|
|
2088
2113
|
},
|
|
2089
2114
|
destroy() {
|
|
2090
2115
|
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
|
|
279
|
-
*
|
|
280
|
-
*
|
|
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
|
|
279
|
-
*
|
|
280
|
-
*
|
|
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
|
@@ -1938,6 +1938,20 @@ var BibliographyNode = Node5.create({
|
|
|
1938
1938
|
selectable: true,
|
|
1939
1939
|
draggable: true,
|
|
1940
1940
|
atom: true,
|
|
1941
|
+
addAttributes() {
|
|
1942
|
+
return {
|
|
1943
|
+
showHeading: {
|
|
1944
|
+
default: true,
|
|
1945
|
+
parseHTML: (el) => el.getAttribute("data-show-heading") !== "false",
|
|
1946
|
+
renderHTML: (attrs) => attrs.showHeading === false ? { "data-show-heading": "false" } : {}
|
|
1947
|
+
},
|
|
1948
|
+
headingText: {
|
|
1949
|
+
default: "Bibliography",
|
|
1950
|
+
parseHTML: (el) => el.getAttribute("data-heading-text") || "Bibliography",
|
|
1951
|
+
renderHTML: (attrs) => typeof attrs.headingText === "string" && attrs.headingText !== "Bibliography" ? { "data-heading-text": attrs.headingText } : {}
|
|
1952
|
+
}
|
|
1953
|
+
};
|
|
1954
|
+
},
|
|
1941
1955
|
parseHTML() {
|
|
1942
1956
|
return [{ tag: 'div[data-node-type="bibliography"]' }];
|
|
1943
1957
|
},
|
|
@@ -1959,21 +1973,27 @@ var BibliographyNode = Node5.create({
|
|
|
1959
1973
|
const dom = document.createElement("div");
|
|
1960
1974
|
dom.className = "docs-bibliography";
|
|
1961
1975
|
dom.setAttribute("data-node-type", "bibliography");
|
|
1976
|
+
let attrs = props.node?.attrs ?? {};
|
|
1962
1977
|
const render = () => {
|
|
1963
1978
|
const engine2 = getEngine(editor);
|
|
1964
1979
|
const items = engine2?.getBibliography() ?? [];
|
|
1980
|
+
const showHeading = attrs.showHeading !== false;
|
|
1981
|
+
const headingText = typeof attrs.headingText === "string" ? attrs.headingText : "Bibliography";
|
|
1965
1982
|
dom.innerHTML = "";
|
|
1966
1983
|
if (items.length === 0) {
|
|
1984
|
+
if (!showHeading) return;
|
|
1967
1985
|
const placeholder = document.createElement("p");
|
|
1968
1986
|
placeholder.className = "docs-bibliography__empty";
|
|
1969
|
-
placeholder.textContent =
|
|
1987
|
+
placeholder.textContent = headingText;
|
|
1970
1988
|
dom.appendChild(placeholder);
|
|
1971
1989
|
return;
|
|
1972
1990
|
}
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1991
|
+
if (showHeading) {
|
|
1992
|
+
const heading = document.createElement("h2");
|
|
1993
|
+
heading.className = "docs-bibliography__heading";
|
|
1994
|
+
heading.textContent = headingText;
|
|
1995
|
+
dom.appendChild(heading);
|
|
1996
|
+
}
|
|
1977
1997
|
const list = document.createElement("div");
|
|
1978
1998
|
list.className = "docs-bibliography__entries";
|
|
1979
1999
|
for (const item of items) {
|
|
@@ -1991,7 +2011,12 @@ var BibliographyNode = Node5.create({
|
|
|
1991
2011
|
dom,
|
|
1992
2012
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1993
2013
|
update(updatedNode) {
|
|
1994
|
-
|
|
2014
|
+
if (updatedNode?.type?.name !== "bibliography") return false;
|
|
2015
|
+
const next = updatedNode.attrs ?? {};
|
|
2016
|
+
const changed = next.showHeading !== attrs.showHeading || next.headingText !== attrs.headingText;
|
|
2017
|
+
attrs = next;
|
|
2018
|
+
if (changed) render();
|
|
2019
|
+
return true;
|
|
1995
2020
|
},
|
|
1996
2021
|
destroy() {
|
|
1997
2022
|
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.
|
|
4
|
+
"version": "0.0.76",
|
|
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.
|
|
34
|
+
"@kedataindo/docflow-core": "0.0.74"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
37
|
"@tiptap/core": "^2.11.0",
|