@kedataindo/docflow-plugins 0.0.103 → 0.0.105
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/citations.cjs +26 -4
- package/dist/citations.d.cts +31 -11
- package/dist/citations.d.ts +31 -11
- package/dist/citations.js +25 -4
- package/dist/index.cjs +57 -34
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +44 -22
- package/package.json +23 -21
package/dist/citations.cjs
CHANGED
|
@@ -36,6 +36,7 @@ __export(citations_exports, {
|
|
|
36
36
|
DEFAULT_CSL_STYLE: () => DEFAULT_CSL_STYLE,
|
|
37
37
|
buildCitationNodes: () => buildCitationNodes,
|
|
38
38
|
nextCitationId: () => nextCitationId,
|
|
39
|
+
resolveCslStyles: () => resolveCslStyles,
|
|
39
40
|
sanitizeCiteprocHtml: () => sanitizeCiteprocHtml
|
|
40
41
|
});
|
|
41
42
|
module.exports = __toCommonJS(citations_exports);
|
|
@@ -958,6 +959,19 @@ var DEFAULT_CSL_STYLE = "chicago-notes-bibliography";
|
|
|
958
959
|
var CSL_LOCALE_EN_US = localesEnUS_default;
|
|
959
960
|
|
|
960
961
|
// src/citeEngine.ts
|
|
962
|
+
function resolveCslStyles(extra) {
|
|
963
|
+
const merged = { ...CSL_STYLES };
|
|
964
|
+
for (const style of extra ?? []) {
|
|
965
|
+
const id = typeof style?.id === "string" ? style.id.trim() : "";
|
|
966
|
+
if (!id || typeof style?.xml !== "string" || style.xml.trim() === "") {
|
|
967
|
+
throw new Error(
|
|
968
|
+
`resolveCslStyles: every style needs a non-empty id and CSL xml (got id=${JSON.stringify(style?.id)}, xml=${style?.xml === void 0 ? "undefined" : `${typeof style.xml === "string" ? style.xml.length : typeof style.xml} chars`})`
|
|
969
|
+
);
|
|
970
|
+
}
|
|
971
|
+
merged[id] = { ...style, id };
|
|
972
|
+
}
|
|
973
|
+
return merged;
|
|
974
|
+
}
|
|
961
975
|
var clusterSeq = 0;
|
|
962
976
|
function nextCitationId() {
|
|
963
977
|
clusterSeq += 1;
|
|
@@ -970,21 +984,28 @@ function sanitizeCiteprocHtml(html) {
|
|
|
970
984
|
var CiteEngine = class {
|
|
971
985
|
sources = /* @__PURE__ */ new Map();
|
|
972
986
|
style;
|
|
987
|
+
/** Bundled styles + whatever the host injected (issue #180). */
|
|
988
|
+
styles;
|
|
973
989
|
clusters = /* @__PURE__ */ new Map();
|
|
974
990
|
order = [];
|
|
975
991
|
rendered = /* @__PURE__ */ new Map();
|
|
976
992
|
bibliography = [];
|
|
977
993
|
listeners = /* @__PURE__ */ new Set();
|
|
978
994
|
constructor(options = {}) {
|
|
979
|
-
this.
|
|
995
|
+
this.styles = resolveCslStyles(options.styles);
|
|
996
|
+
this.style = options.style && this.styles[options.style] ? options.style : DEFAULT_CSL_STYLE;
|
|
980
997
|
this.updateSources(options.sources ?? [], false);
|
|
981
998
|
}
|
|
982
999
|
getStyle() {
|
|
983
1000
|
return this.style;
|
|
984
1001
|
}
|
|
1002
|
+
/** Every style this engine can render with, bundled + host-injected. */
|
|
1003
|
+
getAvailableStyles() {
|
|
1004
|
+
return Object.values(this.styles).sort((a, b) => a.id.localeCompare(b.id));
|
|
1005
|
+
}
|
|
985
1006
|
/** 'note' styles (Chicago notes-bib) cite via footnotes; 'in-text' cite inline. */
|
|
986
1007
|
isNoteStyle() {
|
|
987
|
-
return
|
|
1008
|
+
return this.styles[this.style]?.category === "note";
|
|
988
1009
|
}
|
|
989
1010
|
getSource(id) {
|
|
990
1011
|
return this.sources.get(id);
|
|
@@ -1001,7 +1022,7 @@ var CiteEngine = class {
|
|
|
1001
1022
|
}
|
|
1002
1023
|
/** Live style switch: reload the CSL, recompute everything, repaint (6A-7). */
|
|
1003
1024
|
setStyle(styleId) {
|
|
1004
|
-
if (!
|
|
1025
|
+
if (!this.styles[styleId] || styleId === this.style) return;
|
|
1005
1026
|
this.style = styleId;
|
|
1006
1027
|
this.recompute();
|
|
1007
1028
|
this.emitChange();
|
|
@@ -1054,7 +1075,7 @@ var CiteEngine = class {
|
|
|
1054
1075
|
* any edit — the same derived-view pattern used for pagination/collab.
|
|
1055
1076
|
*/
|
|
1056
1077
|
recompute() {
|
|
1057
|
-
const styleInfo =
|
|
1078
|
+
const styleInfo = this.styles[this.style];
|
|
1058
1079
|
const engine = new import_citeproc.default.Engine(
|
|
1059
1080
|
{
|
|
1060
1081
|
retrieveLocale: () => CSL_LOCALE_EN_US,
|
|
@@ -1134,5 +1155,6 @@ function buildCitationNodes(engine, attrs) {
|
|
|
1134
1155
|
DEFAULT_CSL_STYLE,
|
|
1135
1156
|
buildCitationNodes,
|
|
1136
1157
|
nextCitationId,
|
|
1158
|
+
resolveCslStyles,
|
|
1137
1159
|
sanitizeCiteprocHtml
|
|
1138
1160
|
});
|
package/dist/citations.d.cts
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
|
-
import { CslItemData } from '@kedataindo/docflow-core';
|
|
1
|
+
import { CslItemData, CslStyleInfo } from '@kedataindo/docflow-core';
|
|
2
|
+
export { CslStyleInfo } from '@kedataindo/docflow-core';
|
|
2
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Merge the bundled styles with the ones a host injected (issue #180) — the
|
|
6
|
+
* single place that decides what this engine can render with.
|
|
7
|
+
*
|
|
8
|
+
* Bundled styles stay available unless the host overrides one by id, so a host
|
|
9
|
+
* that passes nothing (or an empty array) behaves exactly as before and nothing
|
|
10
|
+
* has to be fetched at runtime for the defaults to work offline.
|
|
11
|
+
*
|
|
12
|
+
* A malformed entry fails loudly here rather than inside citeproc, where the
|
|
13
|
+
* error would arrive as an empty citation with no clue which style caused it.
|
|
14
|
+
*/
|
|
15
|
+
declare function resolveCslStyles(extra?: CslStyleInfo[]): Record<string, CslStyleInfo>;
|
|
3
16
|
type CitationMode = 'normal' | 'author-only' | 'suppress-author';
|
|
4
17
|
/**
|
|
5
18
|
* Structured citation attributes stored on citation/footnote nodes. Nodes
|
|
@@ -17,6 +30,14 @@ interface CitationAttrs {
|
|
|
17
30
|
interface CiteEngineOptions {
|
|
18
31
|
sources?: CslItemData[];
|
|
19
32
|
style?: string;
|
|
33
|
+
/**
|
|
34
|
+
* Extra CSL styles for this engine (issue #180). A style whose `id` matches a
|
|
35
|
+
* bundled one **overrides** it; every other id is added alongside the four
|
|
36
|
+
* defaults. Omitting this keeps the previous behaviour exactly (offline
|
|
37
|
+
* bundled styles), and an unknown `style` id always falls back to
|
|
38
|
+
* `DEFAULT_CSL_STYLE` instead of throwing.
|
|
39
|
+
*/
|
|
40
|
+
styles?: CslStyleInfo[];
|
|
20
41
|
}
|
|
21
42
|
interface CitationCluster {
|
|
22
43
|
citationId: string;
|
|
@@ -39,6 +60,8 @@ declare function sanitizeCiteprocHtml(html: string): string;
|
|
|
39
60
|
declare class CiteEngine {
|
|
40
61
|
private sources;
|
|
41
62
|
private style;
|
|
63
|
+
/** Bundled styles + whatever the host injected (issue #180). */
|
|
64
|
+
private styles;
|
|
42
65
|
private clusters;
|
|
43
66
|
private order;
|
|
44
67
|
private rendered;
|
|
@@ -46,6 +69,8 @@ declare class CiteEngine {
|
|
|
46
69
|
private listeners;
|
|
47
70
|
constructor(options?: CiteEngineOptions);
|
|
48
71
|
getStyle(): string;
|
|
72
|
+
/** Every style this engine can render with, bundled + host-injected. */
|
|
73
|
+
getAvailableStyles(): CslStyleInfo[];
|
|
49
74
|
/** 'note' styles (Chicago notes-bib) cite via footnotes; 'in-text' cite inline. */
|
|
50
75
|
isNoteStyle(): boolean;
|
|
51
76
|
getSource(id: string): CslItemData | undefined;
|
|
@@ -112,22 +137,17 @@ declare function buildCitationNodes(engine: CiteEngine, attrs: {
|
|
|
112
137
|
locator?: string;
|
|
113
138
|
}): CitationNodeSpec;
|
|
114
139
|
|
|
115
|
-
interface CslStyleInfo {
|
|
116
|
-
id: string;
|
|
117
|
-
name: string;
|
|
118
|
-
/** 'note' styles render citations as footnotes; 'in-text' render inline. */
|
|
119
|
-
category: 'note' | 'in-text';
|
|
120
|
-
xml: string;
|
|
121
|
-
}
|
|
122
140
|
/**
|
|
123
141
|
* CSL styles bundled with the citation engine. Bundling (instead of runtime
|
|
124
142
|
* fetch) keeps the editor standalone/offline-capable — the same guarantee the
|
|
125
|
-
* embedded source snapshot provides (see phase-6 plan §2 decision 5).
|
|
143
|
+
* embedded source snapshot provides (see phase-6 plan §2 decision 5). These are
|
|
144
|
+
* the *default* set: a host can add or override styles through
|
|
145
|
+
* `CitationPort.styles` / `CiteEngineOptions.styles` (see `resolveCslStyles`).
|
|
126
146
|
*/
|
|
127
147
|
declare const CSL_STYLES: Record<string, CslStyleInfo>;
|
|
128
148
|
declare const DEFAULT_CSL_STYLE = "chicago-notes-bibliography";
|
|
129
149
|
/** The single bundled locale. Multi-locale rendering is deferred (phase 6 §7). */
|
|
130
150
|
declare const CSL_LOCALE_EN_US: string;
|
|
131
151
|
|
|
132
|
-
export { CSL_LOCALE_EN_US, CSL_STYLES, CiteEngine, DEFAULT_CSL_STYLE, buildCitationNodes, nextCitationId, sanitizeCiteprocHtml };
|
|
133
|
-
export type { CitationAttrs, CitationCluster, CitationMode, CiteEngineOptions
|
|
152
|
+
export { CSL_LOCALE_EN_US, CSL_STYLES, CiteEngine, DEFAULT_CSL_STYLE, buildCitationNodes, nextCitationId, resolveCslStyles, sanitizeCiteprocHtml };
|
|
153
|
+
export type { CitationAttrs, CitationCluster, CitationMode, CiteEngineOptions };
|
package/dist/citations.d.ts
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
|
-
import { CslItemData } from '@kedataindo/docflow-core';
|
|
1
|
+
import { CslItemData, CslStyleInfo } from '@kedataindo/docflow-core';
|
|
2
|
+
export { CslStyleInfo } from '@kedataindo/docflow-core';
|
|
2
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Merge the bundled styles with the ones a host injected (issue #180) — the
|
|
6
|
+
* single place that decides what this engine can render with.
|
|
7
|
+
*
|
|
8
|
+
* Bundled styles stay available unless the host overrides one by id, so a host
|
|
9
|
+
* that passes nothing (or an empty array) behaves exactly as before and nothing
|
|
10
|
+
* has to be fetched at runtime for the defaults to work offline.
|
|
11
|
+
*
|
|
12
|
+
* A malformed entry fails loudly here rather than inside citeproc, where the
|
|
13
|
+
* error would arrive as an empty citation with no clue which style caused it.
|
|
14
|
+
*/
|
|
15
|
+
declare function resolveCslStyles(extra?: CslStyleInfo[]): Record<string, CslStyleInfo>;
|
|
3
16
|
type CitationMode = 'normal' | 'author-only' | 'suppress-author';
|
|
4
17
|
/**
|
|
5
18
|
* Structured citation attributes stored on citation/footnote nodes. Nodes
|
|
@@ -17,6 +30,14 @@ interface CitationAttrs {
|
|
|
17
30
|
interface CiteEngineOptions {
|
|
18
31
|
sources?: CslItemData[];
|
|
19
32
|
style?: string;
|
|
33
|
+
/**
|
|
34
|
+
* Extra CSL styles for this engine (issue #180). A style whose `id` matches a
|
|
35
|
+
* bundled one **overrides** it; every other id is added alongside the four
|
|
36
|
+
* defaults. Omitting this keeps the previous behaviour exactly (offline
|
|
37
|
+
* bundled styles), and an unknown `style` id always falls back to
|
|
38
|
+
* `DEFAULT_CSL_STYLE` instead of throwing.
|
|
39
|
+
*/
|
|
40
|
+
styles?: CslStyleInfo[];
|
|
20
41
|
}
|
|
21
42
|
interface CitationCluster {
|
|
22
43
|
citationId: string;
|
|
@@ -39,6 +60,8 @@ declare function sanitizeCiteprocHtml(html: string): string;
|
|
|
39
60
|
declare class CiteEngine {
|
|
40
61
|
private sources;
|
|
41
62
|
private style;
|
|
63
|
+
/** Bundled styles + whatever the host injected (issue #180). */
|
|
64
|
+
private styles;
|
|
42
65
|
private clusters;
|
|
43
66
|
private order;
|
|
44
67
|
private rendered;
|
|
@@ -46,6 +69,8 @@ declare class CiteEngine {
|
|
|
46
69
|
private listeners;
|
|
47
70
|
constructor(options?: CiteEngineOptions);
|
|
48
71
|
getStyle(): string;
|
|
72
|
+
/** Every style this engine can render with, bundled + host-injected. */
|
|
73
|
+
getAvailableStyles(): CslStyleInfo[];
|
|
49
74
|
/** 'note' styles (Chicago notes-bib) cite via footnotes; 'in-text' cite inline. */
|
|
50
75
|
isNoteStyle(): boolean;
|
|
51
76
|
getSource(id: string): CslItemData | undefined;
|
|
@@ -112,22 +137,17 @@ declare function buildCitationNodes(engine: CiteEngine, attrs: {
|
|
|
112
137
|
locator?: string;
|
|
113
138
|
}): CitationNodeSpec;
|
|
114
139
|
|
|
115
|
-
interface CslStyleInfo {
|
|
116
|
-
id: string;
|
|
117
|
-
name: string;
|
|
118
|
-
/** 'note' styles render citations as footnotes; 'in-text' render inline. */
|
|
119
|
-
category: 'note' | 'in-text';
|
|
120
|
-
xml: string;
|
|
121
|
-
}
|
|
122
140
|
/**
|
|
123
141
|
* CSL styles bundled with the citation engine. Bundling (instead of runtime
|
|
124
142
|
* fetch) keeps the editor standalone/offline-capable — the same guarantee the
|
|
125
|
-
* embedded source snapshot provides (see phase-6 plan §2 decision 5).
|
|
143
|
+
* embedded source snapshot provides (see phase-6 plan §2 decision 5). These are
|
|
144
|
+
* the *default* set: a host can add or override styles through
|
|
145
|
+
* `CitationPort.styles` / `CiteEngineOptions.styles` (see `resolveCslStyles`).
|
|
126
146
|
*/
|
|
127
147
|
declare const CSL_STYLES: Record<string, CslStyleInfo>;
|
|
128
148
|
declare const DEFAULT_CSL_STYLE = "chicago-notes-bibliography";
|
|
129
149
|
/** The single bundled locale. Multi-locale rendering is deferred (phase 6 §7). */
|
|
130
150
|
declare const CSL_LOCALE_EN_US: string;
|
|
131
151
|
|
|
132
|
-
export { CSL_LOCALE_EN_US, CSL_STYLES, CiteEngine, DEFAULT_CSL_STYLE, buildCitationNodes, nextCitationId, sanitizeCiteprocHtml };
|
|
133
|
-
export type { CitationAttrs, CitationCluster, CitationMode, CiteEngineOptions
|
|
152
|
+
export { CSL_LOCALE_EN_US, CSL_STYLES, CiteEngine, DEFAULT_CSL_STYLE, buildCitationNodes, nextCitationId, resolveCslStyles, sanitizeCiteprocHtml };
|
|
153
|
+
export type { CitationAttrs, CitationCluster, CitationMode, CiteEngineOptions };
|
package/dist/citations.js
CHANGED
|
@@ -916,6 +916,19 @@ var DEFAULT_CSL_STYLE = "chicago-notes-bibliography";
|
|
|
916
916
|
var CSL_LOCALE_EN_US = localesEnUS_default;
|
|
917
917
|
|
|
918
918
|
// src/citeEngine.ts
|
|
919
|
+
function resolveCslStyles(extra) {
|
|
920
|
+
const merged = { ...CSL_STYLES };
|
|
921
|
+
for (const style of extra ?? []) {
|
|
922
|
+
const id = typeof style?.id === "string" ? style.id.trim() : "";
|
|
923
|
+
if (!id || typeof style?.xml !== "string" || style.xml.trim() === "") {
|
|
924
|
+
throw new Error(
|
|
925
|
+
`resolveCslStyles: every style needs a non-empty id and CSL xml (got id=${JSON.stringify(style?.id)}, xml=${style?.xml === void 0 ? "undefined" : `${typeof style.xml === "string" ? style.xml.length : typeof style.xml} chars`})`
|
|
926
|
+
);
|
|
927
|
+
}
|
|
928
|
+
merged[id] = { ...style, id };
|
|
929
|
+
}
|
|
930
|
+
return merged;
|
|
931
|
+
}
|
|
919
932
|
var clusterSeq = 0;
|
|
920
933
|
function nextCitationId() {
|
|
921
934
|
clusterSeq += 1;
|
|
@@ -928,21 +941,28 @@ function sanitizeCiteprocHtml(html) {
|
|
|
928
941
|
var CiteEngine = class {
|
|
929
942
|
sources = /* @__PURE__ */ new Map();
|
|
930
943
|
style;
|
|
944
|
+
/** Bundled styles + whatever the host injected (issue #180). */
|
|
945
|
+
styles;
|
|
931
946
|
clusters = /* @__PURE__ */ new Map();
|
|
932
947
|
order = [];
|
|
933
948
|
rendered = /* @__PURE__ */ new Map();
|
|
934
949
|
bibliography = [];
|
|
935
950
|
listeners = /* @__PURE__ */ new Set();
|
|
936
951
|
constructor(options = {}) {
|
|
937
|
-
this.
|
|
952
|
+
this.styles = resolveCslStyles(options.styles);
|
|
953
|
+
this.style = options.style && this.styles[options.style] ? options.style : DEFAULT_CSL_STYLE;
|
|
938
954
|
this.updateSources(options.sources ?? [], false);
|
|
939
955
|
}
|
|
940
956
|
getStyle() {
|
|
941
957
|
return this.style;
|
|
942
958
|
}
|
|
959
|
+
/** Every style this engine can render with, bundled + host-injected. */
|
|
960
|
+
getAvailableStyles() {
|
|
961
|
+
return Object.values(this.styles).sort((a, b) => a.id.localeCompare(b.id));
|
|
962
|
+
}
|
|
943
963
|
/** 'note' styles (Chicago notes-bib) cite via footnotes; 'in-text' cite inline. */
|
|
944
964
|
isNoteStyle() {
|
|
945
|
-
return
|
|
965
|
+
return this.styles[this.style]?.category === "note";
|
|
946
966
|
}
|
|
947
967
|
getSource(id) {
|
|
948
968
|
return this.sources.get(id);
|
|
@@ -959,7 +979,7 @@ var CiteEngine = class {
|
|
|
959
979
|
}
|
|
960
980
|
/** Live style switch: reload the CSL, recompute everything, repaint (6A-7). */
|
|
961
981
|
setStyle(styleId) {
|
|
962
|
-
if (!
|
|
982
|
+
if (!this.styles[styleId] || styleId === this.style) return;
|
|
963
983
|
this.style = styleId;
|
|
964
984
|
this.recompute();
|
|
965
985
|
this.emitChange();
|
|
@@ -1012,7 +1032,7 @@ var CiteEngine = class {
|
|
|
1012
1032
|
* any edit — the same derived-view pattern used for pagination/collab.
|
|
1013
1033
|
*/
|
|
1014
1034
|
recompute() {
|
|
1015
|
-
const styleInfo =
|
|
1035
|
+
const styleInfo = this.styles[this.style];
|
|
1016
1036
|
const engine = new CSL.Engine(
|
|
1017
1037
|
{
|
|
1018
1038
|
retrieveLocale: () => CSL_LOCALE_EN_US,
|
|
@@ -1091,5 +1111,6 @@ export {
|
|
|
1091
1111
|
DEFAULT_CSL_STYLE,
|
|
1092
1112
|
buildCitationNodes,
|
|
1093
1113
|
nextCitationId,
|
|
1114
|
+
resolveCslStyles,
|
|
1094
1115
|
sanitizeCiteprocHtml
|
|
1095
1116
|
};
|
package/dist/index.cjs
CHANGED
|
@@ -93,6 +93,7 @@ __export(index_exports, {
|
|
|
93
93
|
registerSlashCommands: () => registerSlashCommands,
|
|
94
94
|
rejectAllSuggestions: () => rejectAllSuggestions,
|
|
95
95
|
rejectSuggestion: () => rejectSuggestion,
|
|
96
|
+
resolveCslStyles: () => resolveCslStyles,
|
|
96
97
|
sanitizeCiteprocHtml: () => sanitizeCiteprocHtml,
|
|
97
98
|
scrollEditorToPos: () => scrollEditorToPos,
|
|
98
99
|
setDocumentMode: () => setDocumentMode,
|
|
@@ -110,10 +111,10 @@ module.exports = __toCommonJS(index_exports);
|
|
|
110
111
|
|
|
111
112
|
// src/formatting.ts
|
|
112
113
|
var import_docflow_core = require("@kedataindo/docflow-core");
|
|
113
|
-
var import_extension_underline =
|
|
114
|
+
var import_extension_underline = require("@tiptap/extension-underline");
|
|
114
115
|
var formattingPlugin = (0, import_docflow_core.definePlugin)({
|
|
115
116
|
id: "formatting",
|
|
116
|
-
tiptapExtensions: [import_extension_underline.
|
|
117
|
+
tiptapExtensions: [import_extension_underline.Underline],
|
|
117
118
|
toolbar: [
|
|
118
119
|
{ id: "bold", label: "Bold", action: "toggleBold", iconComponent: "Bold" },
|
|
119
120
|
{ id: "italic", label: "Italic", action: "toggleItalic", iconComponent: "Italic" },
|
|
@@ -157,11 +158,10 @@ var headingsPlugin = (0, import_docflow_core2.definePlugin)({
|
|
|
157
158
|
|
|
158
159
|
// src/lists.ts
|
|
159
160
|
var import_docflow_core3 = require("@kedataindo/docflow-core");
|
|
160
|
-
var
|
|
161
|
-
var import_extension_task_item = __toESM(require("@tiptap/extension-task-item"), 1);
|
|
161
|
+
var import_extension_list = require("@tiptap/extension-list");
|
|
162
162
|
var listsPlugin = (0, import_docflow_core3.definePlugin)({
|
|
163
163
|
id: "lists",
|
|
164
|
-
tiptapExtensions: [
|
|
164
|
+
tiptapExtensions: [import_extension_list.TaskList, import_extension_list.TaskItem.configure({ nested: true })],
|
|
165
165
|
toolbar: [
|
|
166
166
|
{ id: "bullet-list", label: "Bullet List", action: "toggleBulletList", iconComponent: "List" },
|
|
167
167
|
{ id: "ordered-list", label: "Ordered List", action: "toggleOrderedList", iconComponent: "ListOrdered" },
|
|
@@ -176,14 +176,14 @@ var listsPlugin = (0, import_docflow_core3.definePlugin)({
|
|
|
176
176
|
|
|
177
177
|
// src/alignment.ts
|
|
178
178
|
var import_docflow_core4 = require("@kedataindo/docflow-core");
|
|
179
|
-
var import_extension_text_align =
|
|
179
|
+
var import_extension_text_align = require("@tiptap/extension-text-align");
|
|
180
180
|
function setAlign(alignment) {
|
|
181
181
|
return (editor) => editor.commands.setTextAlign(alignment);
|
|
182
182
|
}
|
|
183
183
|
var alignmentPlugin = (0, import_docflow_core4.definePlugin)({
|
|
184
184
|
id: "alignment",
|
|
185
185
|
tiptapExtensions: [
|
|
186
|
-
import_extension_text_align.
|
|
186
|
+
import_extension_text_align.TextAlign.configure({ types: ["heading", "paragraph"] })
|
|
187
187
|
],
|
|
188
188
|
toolbar: [
|
|
189
189
|
{ id: "align-left", label: "Align Left", action: "alignLeft", iconComponent: "AlignLeft" },
|
|
@@ -201,10 +201,10 @@ var alignmentPlugin = (0, import_docflow_core4.definePlugin)({
|
|
|
201
201
|
|
|
202
202
|
// src/link.ts
|
|
203
203
|
var import_docflow_core5 = require("@kedataindo/docflow-core");
|
|
204
|
-
var import_extension_link =
|
|
204
|
+
var import_extension_link = require("@tiptap/extension-link");
|
|
205
205
|
var linkPlugin = (0, import_docflow_core5.definePlugin)({
|
|
206
206
|
id: "link",
|
|
207
|
-
tiptapExtensions: [import_extension_link.
|
|
207
|
+
tiptapExtensions: [import_extension_link.Link.configure({ openOnClick: true })],
|
|
208
208
|
toolbar: [
|
|
209
209
|
{ id: "set-link", label: "Link", action: "setLink", iconComponent: "Link" }
|
|
210
210
|
],
|
|
@@ -226,7 +226,7 @@ var linkPlugin = (0, import_docflow_core5.definePlugin)({
|
|
|
226
226
|
|
|
227
227
|
// src/image.ts
|
|
228
228
|
var import_docflow_core6 = require("@kedataindo/docflow-core");
|
|
229
|
-
var import_extension_image =
|
|
229
|
+
var import_extension_image = require("@tiptap/extension-image");
|
|
230
230
|
function pickImageFile() {
|
|
231
231
|
if (typeof document === "undefined") return Promise.resolve(null);
|
|
232
232
|
return new Promise((resolve) => {
|
|
@@ -249,7 +249,7 @@ function pickImageFile() {
|
|
|
249
249
|
}
|
|
250
250
|
var imagePlugin = (0, import_docflow_core6.definePlugin)({
|
|
251
251
|
id: "image",
|
|
252
|
-
tiptapExtensions: [import_extension_image.
|
|
252
|
+
tiptapExtensions: [import_extension_image.Image],
|
|
253
253
|
toolbar: [{ id: "insert-image", label: "Image", action: "insertImage", iconComponent: "Image" }],
|
|
254
254
|
slashCommands: [{ name: "Image", command: "insertImage" }],
|
|
255
255
|
commands: {
|
|
@@ -287,12 +287,9 @@ var imagePlugin = (0, import_docflow_core6.definePlugin)({
|
|
|
287
287
|
// src/table.ts
|
|
288
288
|
var import_docflow_core7 = require("@kedataindo/docflow-core");
|
|
289
289
|
var import_core = require("@tiptap/core");
|
|
290
|
-
var import_extension_table =
|
|
291
|
-
var import_extension_table_row = __toESM(require("@tiptap/extension-table-row"), 1);
|
|
292
|
-
var import_extension_table_cell = __toESM(require("@tiptap/extension-table-cell"), 1);
|
|
293
|
-
var import_extension_table_header = __toESM(require("@tiptap/extension-table-header"), 1);
|
|
290
|
+
var import_extension_table = require("@tiptap/extension-table");
|
|
294
291
|
var import_state = require("@tiptap/pm/state");
|
|
295
|
-
var CustomTable = import_extension_table.
|
|
292
|
+
var CustomTable = import_extension_table.Table.extend({
|
|
296
293
|
addAttributes() {
|
|
297
294
|
return {
|
|
298
295
|
...this.parent?.(),
|
|
@@ -388,7 +385,7 @@ var CustomTable = import_extension_table.default.extend({
|
|
|
388
385
|
];
|
|
389
386
|
}
|
|
390
387
|
});
|
|
391
|
-
var CustomTableCell =
|
|
388
|
+
var CustomTableCell = import_extension_table.TableCell.extend({
|
|
392
389
|
addAttributes() {
|
|
393
390
|
return {
|
|
394
391
|
...this.parent?.(),
|
|
@@ -422,7 +419,7 @@ var CustomTableCell = import_extension_table_cell.default.extend({
|
|
|
422
419
|
};
|
|
423
420
|
}
|
|
424
421
|
});
|
|
425
|
-
var CustomTableHeader =
|
|
422
|
+
var CustomTableHeader = import_extension_table.TableHeader.extend({
|
|
426
423
|
addAttributes() {
|
|
427
424
|
return {
|
|
428
425
|
...this.parent?.(),
|
|
@@ -459,8 +456,14 @@ var CustomTableHeader = import_extension_table_header.default.extend({
|
|
|
459
456
|
var tablePlugin = (0, import_docflow_core7.definePlugin)({
|
|
460
457
|
id: "table",
|
|
461
458
|
tiptapExtensions: [
|
|
462
|
-
|
|
463
|
-
|
|
459
|
+
// v3 ships a `TableView` node view by default (`View: TableView`), which rebuilds
|
|
460
|
+
// the <table> element itself and drops whatever our `renderHTML` put on it —
|
|
461
|
+
// `data-tps-splittable`/`data-colwidth` disappear and the inline `!important`
|
|
462
|
+
// width is rewritten. Column resizing in docflow is handled by
|
|
463
|
+
// `ManualColumnResize`, so the node view buys nothing here; `View: null` makes
|
|
464
|
+
// v3 fall back to our `renderHTML` and keeps the rendered DOM identical to v2.
|
|
465
|
+
CustomTable.configure({ resizable: false, View: null }),
|
|
466
|
+
import_extension_table.TableRow,
|
|
464
467
|
CustomTableCell,
|
|
465
468
|
CustomTableHeader
|
|
466
469
|
],
|
|
@@ -488,12 +491,12 @@ var codeBlockPlugin = (0, import_docflow_core9.definePlugin)({
|
|
|
488
491
|
|
|
489
492
|
// src/placeholder.ts
|
|
490
493
|
var import_docflow_core10 = require("@kedataindo/docflow-core");
|
|
491
|
-
var
|
|
494
|
+
var import_extensions = require("@tiptap/extensions");
|
|
492
495
|
function createPlaceholderPlugin(options = {}) {
|
|
493
496
|
return (0, import_docflow_core10.definePlugin)({
|
|
494
497
|
id: "placeholder",
|
|
495
498
|
tiptapExtensions: [
|
|
496
|
-
|
|
499
|
+
import_extensions.Placeholder.configure({
|
|
497
500
|
placeholder: options.placeholder ?? "Start writing\u2026"
|
|
498
501
|
})
|
|
499
502
|
]
|
|
@@ -974,10 +977,10 @@ var fontFamilyPlugin = (0, import_docflow_core15.definePlugin)({
|
|
|
974
977
|
|
|
975
978
|
// src/textColor.ts
|
|
976
979
|
var import_docflow_core16 = require("@kedataindo/docflow-core");
|
|
977
|
-
var import_extension_color =
|
|
980
|
+
var import_extension_color = require("@tiptap/extension-color");
|
|
978
981
|
var textColorPlugin = (0, import_docflow_core16.definePlugin)({
|
|
979
982
|
id: "text-color",
|
|
980
|
-
tiptapExtensions: [import_extension_color.
|
|
983
|
+
tiptapExtensions: [import_extension_color.Color],
|
|
981
984
|
toolbar: [
|
|
982
985
|
{ id: "text-color", label: "Text Color", action: "setTextColor", iconComponent: "Palette" }
|
|
983
986
|
],
|
|
@@ -995,9 +998,9 @@ var textColorPlugin = (0, import_docflow_core16.definePlugin)({
|
|
|
995
998
|
|
|
996
999
|
// src/highlight.ts
|
|
997
1000
|
var import_docflow_core17 = require("@kedataindo/docflow-core");
|
|
998
|
-
var import_extension_highlight =
|
|
1001
|
+
var import_extension_highlight = require("@tiptap/extension-highlight");
|
|
999
1002
|
var import_core5 = require("@tiptap/core");
|
|
1000
|
-
var GoogleDocsHighlight = import_extension_highlight.
|
|
1003
|
+
var GoogleDocsHighlight = import_extension_highlight.Highlight.extend({
|
|
1001
1004
|
parseHTML() {
|
|
1002
1005
|
return [
|
|
1003
1006
|
// Standard <mark> tag (default TipTap behavior)
|
|
@@ -1970,6 +1973,19 @@ var DEFAULT_CSL_STYLE = "chicago-notes-bibliography";
|
|
|
1970
1973
|
var CSL_LOCALE_EN_US = localesEnUS_default;
|
|
1971
1974
|
|
|
1972
1975
|
// src/citeEngine.ts
|
|
1976
|
+
function resolveCslStyles(extra) {
|
|
1977
|
+
const merged = { ...CSL_STYLES };
|
|
1978
|
+
for (const style of extra ?? []) {
|
|
1979
|
+
const id = typeof style?.id === "string" ? style.id.trim() : "";
|
|
1980
|
+
if (!id || typeof style?.xml !== "string" || style.xml.trim() === "") {
|
|
1981
|
+
throw new Error(
|
|
1982
|
+
`resolveCslStyles: every style needs a non-empty id and CSL xml (got id=${JSON.stringify(style?.id)}, xml=${style?.xml === void 0 ? "undefined" : `${typeof style.xml === "string" ? style.xml.length : typeof style.xml} chars`})`
|
|
1983
|
+
);
|
|
1984
|
+
}
|
|
1985
|
+
merged[id] = { ...style, id };
|
|
1986
|
+
}
|
|
1987
|
+
return merged;
|
|
1988
|
+
}
|
|
1973
1989
|
var clusterSeq = 0;
|
|
1974
1990
|
function nextCitationId() {
|
|
1975
1991
|
clusterSeq += 1;
|
|
@@ -1982,21 +1998,28 @@ function sanitizeCiteprocHtml(html) {
|
|
|
1982
1998
|
var CiteEngine = class {
|
|
1983
1999
|
sources = /* @__PURE__ */ new Map();
|
|
1984
2000
|
style;
|
|
2001
|
+
/** Bundled styles + whatever the host injected (issue #180). */
|
|
2002
|
+
styles;
|
|
1985
2003
|
clusters = /* @__PURE__ */ new Map();
|
|
1986
2004
|
order = [];
|
|
1987
2005
|
rendered = /* @__PURE__ */ new Map();
|
|
1988
2006
|
bibliography = [];
|
|
1989
2007
|
listeners = /* @__PURE__ */ new Set();
|
|
1990
2008
|
constructor(options = {}) {
|
|
1991
|
-
this.
|
|
2009
|
+
this.styles = resolveCslStyles(options.styles);
|
|
2010
|
+
this.style = options.style && this.styles[options.style] ? options.style : DEFAULT_CSL_STYLE;
|
|
1992
2011
|
this.updateSources(options.sources ?? [], false);
|
|
1993
2012
|
}
|
|
1994
2013
|
getStyle() {
|
|
1995
2014
|
return this.style;
|
|
1996
2015
|
}
|
|
2016
|
+
/** Every style this engine can render with, bundled + host-injected. */
|
|
2017
|
+
getAvailableStyles() {
|
|
2018
|
+
return Object.values(this.styles).sort((a, b) => a.id.localeCompare(b.id));
|
|
2019
|
+
}
|
|
1997
2020
|
/** 'note' styles (Chicago notes-bib) cite via footnotes; 'in-text' cite inline. */
|
|
1998
2021
|
isNoteStyle() {
|
|
1999
|
-
return
|
|
2022
|
+
return this.styles[this.style]?.category === "note";
|
|
2000
2023
|
}
|
|
2001
2024
|
getSource(id) {
|
|
2002
2025
|
return this.sources.get(id);
|
|
@@ -2013,7 +2036,7 @@ var CiteEngine = class {
|
|
|
2013
2036
|
}
|
|
2014
2037
|
/** Live style switch: reload the CSL, recompute everything, repaint (6A-7). */
|
|
2015
2038
|
setStyle(styleId) {
|
|
2016
|
-
if (!
|
|
2039
|
+
if (!this.styles[styleId] || styleId === this.style) return;
|
|
2017
2040
|
this.style = styleId;
|
|
2018
2041
|
this.recompute();
|
|
2019
2042
|
this.emitChange();
|
|
@@ -2066,7 +2089,7 @@ var CiteEngine = class {
|
|
|
2066
2089
|
* any edit — the same derived-view pattern used for pagination/collab.
|
|
2067
2090
|
*/
|
|
2068
2091
|
recompute() {
|
|
2069
|
-
const styleInfo =
|
|
2092
|
+
const styleInfo = this.styles[this.style];
|
|
2070
2093
|
const engine = new import_citeproc.default.Engine(
|
|
2071
2094
|
{
|
|
2072
2095
|
retrieveLocale: () => CSL_LOCALE_EN_US,
|
|
@@ -2254,7 +2277,6 @@ var CitationEngineExtension = import_core7.Extension.create({
|
|
|
2254
2277
|
tr.setNodeMarkup(pos, void 0, { ...attrs, citationId: nextCitationId() });
|
|
2255
2278
|
}
|
|
2256
2279
|
editor.view.dispatch(tr);
|
|
2257
|
-
return;
|
|
2258
2280
|
}
|
|
2259
2281
|
}
|
|
2260
2282
|
const ordered = [];
|
|
@@ -2461,7 +2483,7 @@ var citationPlugin = (0, import_docflow_core18.definePlugin)({
|
|
|
2461
2483
|
const citation = port?.citation;
|
|
2462
2484
|
if (!citation) return;
|
|
2463
2485
|
const sources = typeof citation.sources === "function" ? citation.sources() : citation.sources;
|
|
2464
|
-
const engine = new CiteEngine({ sources, style: citation.style });
|
|
2486
|
+
const engine = new CiteEngine({ sources, style: citation.style, styles: citation.styles });
|
|
2465
2487
|
editor.storage.citationEngine.engine = engine;
|
|
2466
2488
|
},
|
|
2467
2489
|
onDestroy(editor) {
|
|
@@ -3398,7 +3420,7 @@ var DateChipNode = import_core12.Node.create({
|
|
|
3398
3420
|
addNodeView() {
|
|
3399
3421
|
return (props) => {
|
|
3400
3422
|
let currentNode = props.node;
|
|
3401
|
-
const getPos = props.getPos;
|
|
3423
|
+
const getPos = () => typeof props.getPos === "function" ? props.getPos() : void 0;
|
|
3402
3424
|
const view = props.view;
|
|
3403
3425
|
const dom = document.createElement("span");
|
|
3404
3426
|
dom.className = "docs-chip docs-chip--date";
|
|
@@ -3606,7 +3628,7 @@ var DropdownChipNode = import_core12.Node.create({
|
|
|
3606
3628
|
addNodeView() {
|
|
3607
3629
|
return (props) => {
|
|
3608
3630
|
let currentNode = props.node;
|
|
3609
|
-
const getPos = props.getPos;
|
|
3631
|
+
const getPos = () => typeof props.getPos === "function" ? props.getPos() : void 0;
|
|
3610
3632
|
const view = props.view;
|
|
3611
3633
|
const dom = document.createElement("span");
|
|
3612
3634
|
dom.className = "docs-chip docs-chip--dropdown";
|
|
@@ -4266,6 +4288,7 @@ var defaultPlugins = [
|
|
|
4266
4288
|
registerSlashCommands,
|
|
4267
4289
|
rejectAllSuggestions,
|
|
4268
4290
|
rejectSuggestion,
|
|
4291
|
+
resolveCslStyles,
|
|
4269
4292
|
sanitizeCiteprocHtml,
|
|
4270
4293
|
scrollEditorToPos,
|
|
4271
4294
|
setDocumentMode,
|
package/dist/index.d.cts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as _kedata_indonesia_docflow_core from '@kedataindo/docflow-core';
|
|
2
2
|
import { AIAction, DocsEditorPlugin, DocumentMode } from '@kedataindo/docflow-core';
|
|
3
|
-
export { DocsEditorPlugin, FontFamilyExtension, FontSizeExtension, SlashCommand, ToolbarItem } from '@kedataindo/docflow-core';
|
|
3
|
+
export { CslStyleInfo, DocsEditorPlugin, FontFamilyExtension, FontSizeExtension, SlashCommand, ToolbarItem } from '@kedataindo/docflow-core';
|
|
4
4
|
import { Node, Editor, Extension, Mark } from '@tiptap/core';
|
|
5
5
|
import { CiteEngine } from './citations.cjs';
|
|
6
|
-
export { CSL_LOCALE_EN_US, CSL_STYLES, CitationAttrs, CitationCluster, CitationMode, CiteEngineOptions,
|
|
6
|
+
export { CSL_LOCALE_EN_US, CSL_STYLES, CitationAttrs, CitationCluster, CitationMode, CiteEngineOptions, DEFAULT_CSL_STYLE, buildCitationNodes, nextCitationId, resolveCslStyles, sanitizeCiteprocHtml } from './citations.cjs';
|
|
7
7
|
import { PluginKey } from '@tiptap/pm/state';
|
|
8
8
|
import { Fragment } from '@tiptap/pm/model';
|
|
9
9
|
import { EditorView } from '@tiptap/pm/view';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as _kedata_indonesia_docflow_core from '@kedataindo/docflow-core';
|
|
2
2
|
import { AIAction, DocsEditorPlugin, DocumentMode } from '@kedataindo/docflow-core';
|
|
3
|
-
export { DocsEditorPlugin, FontFamilyExtension, FontSizeExtension, SlashCommand, ToolbarItem } from '@kedataindo/docflow-core';
|
|
3
|
+
export { CslStyleInfo, DocsEditorPlugin, FontFamilyExtension, FontSizeExtension, SlashCommand, ToolbarItem } from '@kedataindo/docflow-core';
|
|
4
4
|
import { Node, Editor, Extension, Mark } from '@tiptap/core';
|
|
5
5
|
import { CiteEngine } from './citations.js';
|
|
6
|
-
export { CSL_LOCALE_EN_US, CSL_STYLES, CitationAttrs, CitationCluster, CitationMode, CiteEngineOptions,
|
|
6
|
+
export { CSL_LOCALE_EN_US, CSL_STYLES, CitationAttrs, CitationCluster, CitationMode, CiteEngineOptions, DEFAULT_CSL_STYLE, buildCitationNodes, nextCitationId, resolveCslStyles, sanitizeCiteprocHtml } from './citations.js';
|
|
7
7
|
import { PluginKey } from '@tiptap/pm/state';
|
|
8
8
|
import { Fragment } from '@tiptap/pm/model';
|
|
9
9
|
import { EditorView } from '@tiptap/pm/view';
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// src/formatting.ts
|
|
2
2
|
import { definePlugin } from "@kedataindo/docflow-core";
|
|
3
|
-
import Underline from "@tiptap/extension-underline";
|
|
3
|
+
import { Underline } from "@tiptap/extension-underline";
|
|
4
4
|
var formattingPlugin = definePlugin({
|
|
5
5
|
id: "formatting",
|
|
6
6
|
tiptapExtensions: [Underline],
|
|
@@ -47,8 +47,7 @@ var headingsPlugin = definePlugin2({
|
|
|
47
47
|
|
|
48
48
|
// src/lists.ts
|
|
49
49
|
import { definePlugin as definePlugin3 } from "@kedataindo/docflow-core";
|
|
50
|
-
import TaskList from "@tiptap/extension-
|
|
51
|
-
import TaskItem from "@tiptap/extension-task-item";
|
|
50
|
+
import { TaskItem, TaskList } from "@tiptap/extension-list";
|
|
52
51
|
var listsPlugin = definePlugin3({
|
|
53
52
|
id: "lists",
|
|
54
53
|
tiptapExtensions: [TaskList, TaskItem.configure({ nested: true })],
|
|
@@ -66,7 +65,7 @@ var listsPlugin = definePlugin3({
|
|
|
66
65
|
|
|
67
66
|
// src/alignment.ts
|
|
68
67
|
import { definePlugin as definePlugin4 } from "@kedataindo/docflow-core";
|
|
69
|
-
import TextAlign from "@tiptap/extension-text-align";
|
|
68
|
+
import { TextAlign } from "@tiptap/extension-text-align";
|
|
70
69
|
function setAlign(alignment) {
|
|
71
70
|
return (editor) => editor.commands.setTextAlign(alignment);
|
|
72
71
|
}
|
|
@@ -91,7 +90,7 @@ var alignmentPlugin = definePlugin4({
|
|
|
91
90
|
|
|
92
91
|
// src/link.ts
|
|
93
92
|
import { definePlugin as definePlugin5 } from "@kedataindo/docflow-core";
|
|
94
|
-
import Link from "@tiptap/extension-link";
|
|
93
|
+
import { Link } from "@tiptap/extension-link";
|
|
95
94
|
var linkPlugin = definePlugin5({
|
|
96
95
|
id: "link",
|
|
97
96
|
tiptapExtensions: [Link.configure({ openOnClick: true })],
|
|
@@ -116,7 +115,7 @@ var linkPlugin = definePlugin5({
|
|
|
116
115
|
|
|
117
116
|
// src/image.ts
|
|
118
117
|
import { definePlugin as definePlugin6 } from "@kedataindo/docflow-core";
|
|
119
|
-
import Image from "@tiptap/extension-image";
|
|
118
|
+
import { Image } from "@tiptap/extension-image";
|
|
120
119
|
function pickImageFile() {
|
|
121
120
|
if (typeof document === "undefined") return Promise.resolve(null);
|
|
122
121
|
return new Promise((resolve) => {
|
|
@@ -177,10 +176,7 @@ var imagePlugin = definePlugin6({
|
|
|
177
176
|
// src/table.ts
|
|
178
177
|
import { definePlugin as definePlugin7 } from "@kedataindo/docflow-core";
|
|
179
178
|
import { mergeAttributes } from "@tiptap/core";
|
|
180
|
-
import Table from "@tiptap/extension-table";
|
|
181
|
-
import TableRow from "@tiptap/extension-table-row";
|
|
182
|
-
import TableCell from "@tiptap/extension-table-cell";
|
|
183
|
-
import TableHeader from "@tiptap/extension-table-header";
|
|
179
|
+
import { Table, TableCell, TableHeader, TableRow } from "@tiptap/extension-table";
|
|
184
180
|
import { Plugin, TextSelection } from "@tiptap/pm/state";
|
|
185
181
|
var CustomTable = Table.extend({
|
|
186
182
|
addAttributes() {
|
|
@@ -349,7 +345,13 @@ var CustomTableHeader = TableHeader.extend({
|
|
|
349
345
|
var tablePlugin = definePlugin7({
|
|
350
346
|
id: "table",
|
|
351
347
|
tiptapExtensions: [
|
|
352
|
-
|
|
348
|
+
// v3 ships a `TableView` node view by default (`View: TableView`), which rebuilds
|
|
349
|
+
// the <table> element itself and drops whatever our `renderHTML` put on it —
|
|
350
|
+
// `data-tps-splittable`/`data-colwidth` disappear and the inline `!important`
|
|
351
|
+
// width is rewritten. Column resizing in docflow is handled by
|
|
352
|
+
// `ManualColumnResize`, so the node view buys nothing here; `View: null` makes
|
|
353
|
+
// v3 fall back to our `renderHTML` and keeps the rendered DOM identical to v2.
|
|
354
|
+
CustomTable.configure({ resizable: false, View: null }),
|
|
353
355
|
TableRow,
|
|
354
356
|
CustomTableCell,
|
|
355
357
|
CustomTableHeader
|
|
@@ -378,7 +380,7 @@ var codeBlockPlugin = definePlugin9({
|
|
|
378
380
|
|
|
379
381
|
// src/placeholder.ts
|
|
380
382
|
import { definePlugin as definePlugin10 } from "@kedataindo/docflow-core";
|
|
381
|
-
import Placeholder from "@tiptap/
|
|
383
|
+
import { Placeholder } from "@tiptap/extensions";
|
|
382
384
|
function createPlaceholderPlugin(options = {}) {
|
|
383
385
|
return definePlugin10({
|
|
384
386
|
id: "placeholder",
|
|
@@ -864,7 +866,7 @@ var fontFamilyPlugin = definePlugin15({
|
|
|
864
866
|
|
|
865
867
|
// src/textColor.ts
|
|
866
868
|
import { definePlugin as definePlugin16 } from "@kedataindo/docflow-core";
|
|
867
|
-
import Color from "@tiptap/extension-color";
|
|
869
|
+
import { Color } from "@tiptap/extension-color";
|
|
868
870
|
var textColorPlugin = definePlugin16({
|
|
869
871
|
id: "text-color",
|
|
870
872
|
tiptapExtensions: [Color],
|
|
@@ -885,7 +887,7 @@ var textColorPlugin = definePlugin16({
|
|
|
885
887
|
|
|
886
888
|
// src/highlight.ts
|
|
887
889
|
import { definePlugin as definePlugin17 } from "@kedataindo/docflow-core";
|
|
888
|
-
import Highlight from "@tiptap/extension-highlight";
|
|
890
|
+
import { Highlight } from "@tiptap/extension-highlight";
|
|
889
891
|
import { mergeAttributes as mergeAttributes5 } from "@tiptap/core";
|
|
890
892
|
var GoogleDocsHighlight = Highlight.extend({
|
|
891
893
|
parseHTML() {
|
|
@@ -1860,6 +1862,19 @@ var DEFAULT_CSL_STYLE = "chicago-notes-bibliography";
|
|
|
1860
1862
|
var CSL_LOCALE_EN_US = localesEnUS_default;
|
|
1861
1863
|
|
|
1862
1864
|
// src/citeEngine.ts
|
|
1865
|
+
function resolveCslStyles(extra) {
|
|
1866
|
+
const merged = { ...CSL_STYLES };
|
|
1867
|
+
for (const style of extra ?? []) {
|
|
1868
|
+
const id = typeof style?.id === "string" ? style.id.trim() : "";
|
|
1869
|
+
if (!id || typeof style?.xml !== "string" || style.xml.trim() === "") {
|
|
1870
|
+
throw new Error(
|
|
1871
|
+
`resolveCslStyles: every style needs a non-empty id and CSL xml (got id=${JSON.stringify(style?.id)}, xml=${style?.xml === void 0 ? "undefined" : `${typeof style.xml === "string" ? style.xml.length : typeof style.xml} chars`})`
|
|
1872
|
+
);
|
|
1873
|
+
}
|
|
1874
|
+
merged[id] = { ...style, id };
|
|
1875
|
+
}
|
|
1876
|
+
return merged;
|
|
1877
|
+
}
|
|
1863
1878
|
var clusterSeq = 0;
|
|
1864
1879
|
function nextCitationId() {
|
|
1865
1880
|
clusterSeq += 1;
|
|
@@ -1872,21 +1887,28 @@ function sanitizeCiteprocHtml(html) {
|
|
|
1872
1887
|
var CiteEngine = class {
|
|
1873
1888
|
sources = /* @__PURE__ */ new Map();
|
|
1874
1889
|
style;
|
|
1890
|
+
/** Bundled styles + whatever the host injected (issue #180). */
|
|
1891
|
+
styles;
|
|
1875
1892
|
clusters = /* @__PURE__ */ new Map();
|
|
1876
1893
|
order = [];
|
|
1877
1894
|
rendered = /* @__PURE__ */ new Map();
|
|
1878
1895
|
bibliography = [];
|
|
1879
1896
|
listeners = /* @__PURE__ */ new Set();
|
|
1880
1897
|
constructor(options = {}) {
|
|
1881
|
-
this.
|
|
1898
|
+
this.styles = resolveCslStyles(options.styles);
|
|
1899
|
+
this.style = options.style && this.styles[options.style] ? options.style : DEFAULT_CSL_STYLE;
|
|
1882
1900
|
this.updateSources(options.sources ?? [], false);
|
|
1883
1901
|
}
|
|
1884
1902
|
getStyle() {
|
|
1885
1903
|
return this.style;
|
|
1886
1904
|
}
|
|
1905
|
+
/** Every style this engine can render with, bundled + host-injected. */
|
|
1906
|
+
getAvailableStyles() {
|
|
1907
|
+
return Object.values(this.styles).sort((a, b) => a.id.localeCompare(b.id));
|
|
1908
|
+
}
|
|
1887
1909
|
/** 'note' styles (Chicago notes-bib) cite via footnotes; 'in-text' cite inline. */
|
|
1888
1910
|
isNoteStyle() {
|
|
1889
|
-
return
|
|
1911
|
+
return this.styles[this.style]?.category === "note";
|
|
1890
1912
|
}
|
|
1891
1913
|
getSource(id) {
|
|
1892
1914
|
return this.sources.get(id);
|
|
@@ -1903,7 +1925,7 @@ var CiteEngine = class {
|
|
|
1903
1925
|
}
|
|
1904
1926
|
/** Live style switch: reload the CSL, recompute everything, repaint (6A-7). */
|
|
1905
1927
|
setStyle(styleId) {
|
|
1906
|
-
if (!
|
|
1928
|
+
if (!this.styles[styleId] || styleId === this.style) return;
|
|
1907
1929
|
this.style = styleId;
|
|
1908
1930
|
this.recompute();
|
|
1909
1931
|
this.emitChange();
|
|
@@ -1956,7 +1978,7 @@ var CiteEngine = class {
|
|
|
1956
1978
|
* any edit — the same derived-view pattern used for pagination/collab.
|
|
1957
1979
|
*/
|
|
1958
1980
|
recompute() {
|
|
1959
|
-
const styleInfo =
|
|
1981
|
+
const styleInfo = this.styles[this.style];
|
|
1960
1982
|
const engine = new CSL.Engine(
|
|
1961
1983
|
{
|
|
1962
1984
|
retrieveLocale: () => CSL_LOCALE_EN_US,
|
|
@@ -2144,7 +2166,6 @@ var CitationEngineExtension = Extension2.create({
|
|
|
2144
2166
|
tr.setNodeMarkup(pos, void 0, { ...attrs, citationId: nextCitationId() });
|
|
2145
2167
|
}
|
|
2146
2168
|
editor.view.dispatch(tr);
|
|
2147
|
-
return;
|
|
2148
2169
|
}
|
|
2149
2170
|
}
|
|
2150
2171
|
const ordered = [];
|
|
@@ -2351,7 +2372,7 @@ var citationPlugin = definePlugin18({
|
|
|
2351
2372
|
const citation = port?.citation;
|
|
2352
2373
|
if (!citation) return;
|
|
2353
2374
|
const sources = typeof citation.sources === "function" ? citation.sources() : citation.sources;
|
|
2354
|
-
const engine = new CiteEngine({ sources, style: citation.style });
|
|
2375
|
+
const engine = new CiteEngine({ sources, style: citation.style, styles: citation.styles });
|
|
2355
2376
|
editor.storage.citationEngine.engine = engine;
|
|
2356
2377
|
},
|
|
2357
2378
|
onDestroy(editor) {
|
|
@@ -3288,7 +3309,7 @@ var DateChipNode = Node7.create({
|
|
|
3288
3309
|
addNodeView() {
|
|
3289
3310
|
return (props) => {
|
|
3290
3311
|
let currentNode = props.node;
|
|
3291
|
-
const getPos = props.getPos;
|
|
3312
|
+
const getPos = () => typeof props.getPos === "function" ? props.getPos() : void 0;
|
|
3292
3313
|
const view = props.view;
|
|
3293
3314
|
const dom = document.createElement("span");
|
|
3294
3315
|
dom.className = "docs-chip docs-chip--date";
|
|
@@ -3496,7 +3517,7 @@ var DropdownChipNode = Node7.create({
|
|
|
3496
3517
|
addNodeView() {
|
|
3497
3518
|
return (props) => {
|
|
3498
3519
|
let currentNode = props.node;
|
|
3499
|
-
const getPos = props.getPos;
|
|
3520
|
+
const getPos = () => typeof props.getPos === "function" ? props.getPos() : void 0;
|
|
3500
3521
|
const view = props.view;
|
|
3501
3522
|
const dom = document.createElement("span");
|
|
3502
3523
|
dom.className = "docs-chip docs-chip--dropdown";
|
|
@@ -4155,6 +4176,7 @@ export {
|
|
|
4155
4176
|
registerSlashCommands,
|
|
4156
4177
|
rejectAllSuggestions,
|
|
4157
4178
|
rejectSuggestion,
|
|
4179
|
+
resolveCslStyles,
|
|
4158
4180
|
sanitizeCiteprocHtml,
|
|
4159
4181
|
scrollEditorToPos,
|
|
4160
4182
|
setDocumentMode,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kedataindo/docflow-plugins",
|
|
3
3
|
"license": "Apache-2.0",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.105",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"module": "./dist/index.js",
|
|
@@ -27,29 +27,31 @@
|
|
|
27
27
|
],
|
|
28
28
|
"sideEffects": false,
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@tiptap/extension-color": "^
|
|
31
|
-
"@tiptap/extension-highlight": "^
|
|
32
|
-
"@tiptap/
|
|
30
|
+
"@tiptap/extension-color": "^3.32.0",
|
|
31
|
+
"@tiptap/extension-highlight": "^3.32.0",
|
|
32
|
+
"@tiptap/extension-list": "^3.32.0",
|
|
33
|
+
"@tiptap/extensions": "^3.32.0",
|
|
34
|
+
"@tiptap/pm": "^3.32.0",
|
|
33
35
|
"citeproc": "^2.4.63",
|
|
34
|
-
"tiptap-markdown": "0.
|
|
35
|
-
"@kedataindo/docflow-core": "0.0.
|
|
36
|
+
"tiptap-markdown": "0.9.0",
|
|
37
|
+
"@kedataindo/docflow-core": "0.0.98"
|
|
36
38
|
},
|
|
37
39
|
"peerDependencies": {
|
|
38
|
-
"@tiptap/core": "^
|
|
39
|
-
"@tiptap/extension-color": "^
|
|
40
|
-
"@tiptap/extension-highlight": "^
|
|
41
|
-
"@tiptap/extension-image": "^
|
|
42
|
-
"@tiptap/extension-link": "^
|
|
43
|
-
"@tiptap/extension-placeholder": "^
|
|
44
|
-
"@tiptap/extension-strike": "^
|
|
45
|
-
"@tiptap/extension-table": "^
|
|
46
|
-
"@tiptap/extension-table-cell": "^
|
|
47
|
-
"@tiptap/extension-table-header": "^
|
|
48
|
-
"@tiptap/extension-table-row": "^
|
|
49
|
-
"@tiptap/extension-task-item": "^
|
|
50
|
-
"@tiptap/extension-task-list": "^
|
|
51
|
-
"@tiptap/extension-text-align": "^
|
|
52
|
-
"@tiptap/extension-underline": "^
|
|
40
|
+
"@tiptap/core": "^3.32.0",
|
|
41
|
+
"@tiptap/extension-color": "^3.32.0",
|
|
42
|
+
"@tiptap/extension-highlight": "^3.32.0",
|
|
43
|
+
"@tiptap/extension-image": "^3.32.0",
|
|
44
|
+
"@tiptap/extension-link": "^3.32.0",
|
|
45
|
+
"@tiptap/extension-placeholder": "^3.32.0",
|
|
46
|
+
"@tiptap/extension-strike": "^3.32.0",
|
|
47
|
+
"@tiptap/extension-table": "^3.32.0",
|
|
48
|
+
"@tiptap/extension-table-cell": "^3.32.0",
|
|
49
|
+
"@tiptap/extension-table-header": "^3.32.0",
|
|
50
|
+
"@tiptap/extension-table-row": "^3.32.0",
|
|
51
|
+
"@tiptap/extension-task-item": "^3.32.0",
|
|
52
|
+
"@tiptap/extension-task-list": "^3.32.0",
|
|
53
|
+
"@tiptap/extension-text-align": "^3.32.0",
|
|
54
|
+
"@tiptap/extension-underline": "^3.32.0"
|
|
53
55
|
},
|
|
54
56
|
"peerDependenciesMeta": {
|
|
55
57
|
"@tiptap/extension-image": {
|