@kedataindo/docflow-plugins 0.0.39 → 0.0.40

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
@@ -2005,7 +2005,7 @@ var CiteEngine = class {
2005
2005
  // src/bibliography.ts
2006
2006
  var import_core6 = require("@tiptap/core");
2007
2007
  function getEngine(editor) {
2008
- const storage = editor.storage.citation;
2008
+ const storage = editor.storage.citationEngine;
2009
2009
  return storage?.engine ?? null;
2010
2010
  }
2011
2011
  var BibliographyNode = import_core6.Node.create({
@@ -2094,10 +2094,10 @@ function buildCitationNodes(engine, attrs) {
2094
2094
 
2095
2095
  // src/citation.ts
2096
2096
  function getCitationEngine(editor) {
2097
- return editor.storage.citation ? editor.storage.citation.engine ?? null : null;
2097
+ return editor.storage.citationEngine ? editor.storage.citationEngine.engine ?? null : null;
2098
2098
  }
2099
2099
  var CitationEngineExtension = import_core7.Extension.create({
2100
- name: "citation",
2100
+ name: "citationEngine",
2101
2101
  addStorage() {
2102
2102
  return {
2103
2103
  engine: null
@@ -2161,6 +2161,30 @@ var CitationEngineExtension = import_core7.Extension.create({
2161
2161
  const port = editor.storage.editorContext;
2162
2162
  port?.citation?.onSourcesChange?.(engine.getCitedSourceIds());
2163
2163
  }
2164
+ {
2165
+ const updates = [];
2166
+ editor.state.doc.descendants((node, pos) => {
2167
+ if (node.type.name === "footnote" && node.attrs.sourceId) {
2168
+ const id = node.attrs.citationId;
2169
+ if (!id) return true;
2170
+ const text = engine.renderCluster(id);
2171
+ if (text && text !== node.attrs.content) {
2172
+ updates.push({ pos, content: text });
2173
+ }
2174
+ }
2175
+ return true;
2176
+ });
2177
+ if (updates.length > 0) {
2178
+ const tr = editor.state.tr;
2179
+ for (const { pos, content } of updates) {
2180
+ const node = editor.state.doc.nodeAt(pos);
2181
+ if (node) {
2182
+ tr.setNodeMarkup(pos, void 0, { ...node.attrs, content });
2183
+ }
2184
+ }
2185
+ editor.view.dispatch(tr);
2186
+ }
2187
+ }
2164
2188
  }
2165
2189
  });
2166
2190
  var CitationNode = import_core7.Node.create({
@@ -2324,11 +2348,11 @@ var citationPlugin = (0, import_docflow_core17.definePlugin)({
2324
2348
  if (!citation) return;
2325
2349
  const sources = typeof citation.sources === "function" ? citation.sources() : citation.sources;
2326
2350
  const engine = new CiteEngine({ sources, style: citation.style });
2327
- editor.storage.citation.engine = engine;
2351
+ editor.storage.citationEngine.engine = engine;
2328
2352
  },
2329
2353
  onDestroy(editor) {
2330
2354
  ;
2331
- editor.storage.citation.engine = null;
2355
+ editor.storage.citationEngine.engine = null;
2332
2356
  }
2333
2357
  }
2334
2358
  });
package/dist/index.js CHANGED
@@ -1913,7 +1913,7 @@ var CiteEngine = class {
1913
1913
  // src/bibliography.ts
1914
1914
  import { Node as Node5, mergeAttributes as mergeAttributes6 } from "@tiptap/core";
1915
1915
  function getEngine(editor) {
1916
- const storage = editor.storage.citation;
1916
+ const storage = editor.storage.citationEngine;
1917
1917
  return storage?.engine ?? null;
1918
1918
  }
1919
1919
  var BibliographyNode = Node5.create({
@@ -2002,10 +2002,10 @@ function buildCitationNodes(engine, attrs) {
2002
2002
 
2003
2003
  // src/citation.ts
2004
2004
  function getCitationEngine(editor) {
2005
- return editor.storage.citation ? editor.storage.citation.engine ?? null : null;
2005
+ return editor.storage.citationEngine ? editor.storage.citationEngine.engine ?? null : null;
2006
2006
  }
2007
2007
  var CitationEngineExtension = Extension2.create({
2008
- name: "citation",
2008
+ name: "citationEngine",
2009
2009
  addStorage() {
2010
2010
  return {
2011
2011
  engine: null
@@ -2069,6 +2069,30 @@ var CitationEngineExtension = Extension2.create({
2069
2069
  const port = editor.storage.editorContext;
2070
2070
  port?.citation?.onSourcesChange?.(engine.getCitedSourceIds());
2071
2071
  }
2072
+ {
2073
+ const updates = [];
2074
+ editor.state.doc.descendants((node, pos) => {
2075
+ if (node.type.name === "footnote" && node.attrs.sourceId) {
2076
+ const id = node.attrs.citationId;
2077
+ if (!id) return true;
2078
+ const text = engine.renderCluster(id);
2079
+ if (text && text !== node.attrs.content) {
2080
+ updates.push({ pos, content: text });
2081
+ }
2082
+ }
2083
+ return true;
2084
+ });
2085
+ if (updates.length > 0) {
2086
+ const tr = editor.state.tr;
2087
+ for (const { pos, content } of updates) {
2088
+ const node = editor.state.doc.nodeAt(pos);
2089
+ if (node) {
2090
+ tr.setNodeMarkup(pos, void 0, { ...node.attrs, content });
2091
+ }
2092
+ }
2093
+ editor.view.dispatch(tr);
2094
+ }
2095
+ }
2072
2096
  }
2073
2097
  });
2074
2098
  var CitationNode = Node6.create({
@@ -2232,11 +2256,11 @@ var citationPlugin = definePlugin17({
2232
2256
  if (!citation) return;
2233
2257
  const sources = typeof citation.sources === "function" ? citation.sources() : citation.sources;
2234
2258
  const engine = new CiteEngine({ sources, style: citation.style });
2235
- editor.storage.citation.engine = engine;
2259
+ editor.storage.citationEngine.engine = engine;
2236
2260
  },
2237
2261
  onDestroy(editor) {
2238
2262
  ;
2239
- editor.storage.citation.engine = null;
2263
+ editor.storage.citationEngine.engine = null;
2240
2264
  }
2241
2265
  }
2242
2266
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@kedataindo/docflow-plugins",
3
3
  "license": "UNLICENSED",
4
- "version": "0.0.39",
4
+ "version": "0.0.40",
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.37"
34
+ "@kedataindo/docflow-core": "0.0.38"
35
35
  },
36
36
  "peerDependencies": {
37
37
  "@tiptap/core": "^2.11.0",