@kedataindo/docflow-plugins 0.0.90 → 0.0.92
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 +122 -33
- package/dist/index.d.cts +32 -2
- package/dist/index.d.ts +32 -2
- package/dist/index.js +113 -27
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -42,6 +42,7 @@ __export(index_exports, {
|
|
|
42
42
|
DateChipNode: () => DateChipNode,
|
|
43
43
|
DropdownChipNode: () => DropdownChipNode,
|
|
44
44
|
FileChipNode: () => FileChipNode,
|
|
45
|
+
FontFamilyExtension: () => import_docflow_core15.FontFamilyExtension,
|
|
45
46
|
FontSizeExtension: () => import_docflow_core14.FontSizeExtension,
|
|
46
47
|
FootnoteNode: () => FootnoteNode,
|
|
47
48
|
LocationChipNode: () => LocationChipNode,
|
|
@@ -70,6 +71,7 @@ __export(index_exports, {
|
|
|
70
71
|
commentPlugin: () => commentPlugin,
|
|
71
72
|
createPlaceholderPlugin: () => createPlaceholderPlugin,
|
|
72
73
|
defaultPlugins: () => defaultPlugins,
|
|
74
|
+
fontFamilyPlugin: () => fontFamilyPlugin,
|
|
73
75
|
fontSizePlugin: () => fontSizePlugin,
|
|
74
76
|
footnotePlugin: () => footnotePlugin,
|
|
75
77
|
formattingPlugin: () => formattingPlugin,
|
|
@@ -92,6 +94,7 @@ __export(index_exports, {
|
|
|
92
94
|
rejectAllSuggestions: () => rejectAllSuggestions,
|
|
93
95
|
rejectSuggestion: () => rejectSuggestion,
|
|
94
96
|
sanitizeCiteprocHtml: () => sanitizeCiteprocHtml,
|
|
97
|
+
scrollEditorToPos: () => scrollEditorToPos,
|
|
95
98
|
setDocumentMode: () => setDocumentMode,
|
|
96
99
|
setSuggestionAuthor: () => setSuggestionAuthor,
|
|
97
100
|
slashMenuPlugin: () => slashMenuPlugin,
|
|
@@ -288,6 +291,7 @@ var import_extension_table = __toESM(require("@tiptap/extension-table"), 1);
|
|
|
288
291
|
var import_extension_table_row = __toESM(require("@tiptap/extension-table-row"), 1);
|
|
289
292
|
var import_extension_table_cell = __toESM(require("@tiptap/extension-table-cell"), 1);
|
|
290
293
|
var import_extension_table_header = __toESM(require("@tiptap/extension-table-header"), 1);
|
|
294
|
+
var import_state = require("@tiptap/pm/state");
|
|
291
295
|
var CustomTable = import_extension_table.default.extend({
|
|
292
296
|
addAttributes() {
|
|
293
297
|
return {
|
|
@@ -357,6 +361,31 @@ var CustomTable = import_extension_table.default.extend({
|
|
|
357
361
|
["colgroup", ...cols],
|
|
358
362
|
["tbody", 0]
|
|
359
363
|
];
|
|
364
|
+
},
|
|
365
|
+
// #139: double-clicking an EMPTY cell resolved the caret to a neighbouring
|
|
366
|
+
// cell — ProseMirror's default dblclick word-selection has no text to land on
|
|
367
|
+
// in a cell whose only content is a trailing <br>. When the resolved position
|
|
368
|
+
// is not inside the cell under the pointer, place the caret at that cell's
|
|
369
|
+
// start instead. Non-empty cells keep the default (select the word).
|
|
370
|
+
addProseMirrorPlugins() {
|
|
371
|
+
const parent = this.parent?.() ?? [];
|
|
372
|
+
return [
|
|
373
|
+
...parent,
|
|
374
|
+
new import_state.Plugin({
|
|
375
|
+
props: {
|
|
376
|
+
handleDoubleClick(view, pos, event) {
|
|
377
|
+
const cell = event.target?.closest?.("td, th") ?? null;
|
|
378
|
+
if (!cell) return false;
|
|
379
|
+
if ((cell.textContent ?? "").trim() !== "") return false;
|
|
380
|
+
void pos;
|
|
381
|
+
const cellPos = view.posAtDOM(cell, 0);
|
|
382
|
+
const selection = import_state.TextSelection.near(view.state.doc.resolve(cellPos), 1);
|
|
383
|
+
view.dispatch(view.state.tr.setSelection(selection));
|
|
384
|
+
return true;
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
})
|
|
388
|
+
];
|
|
360
389
|
}
|
|
361
390
|
});
|
|
362
391
|
var CustomTableCell = import_extension_table_cell.default.extend({
|
|
@@ -639,6 +668,44 @@ var footnotePlugin = (0, import_docflow_core12.definePlugin)({
|
|
|
639
668
|
// src/toc.ts
|
|
640
669
|
var import_core4 = require("@tiptap/core");
|
|
641
670
|
var import_docflow_core13 = require("@kedataindo/docflow-core");
|
|
671
|
+
|
|
672
|
+
// src/editorScroll.ts
|
|
673
|
+
var import_state2 = require("@tiptap/pm/state");
|
|
674
|
+
function scrollEditorToPos(editor, pos, options = {}) {
|
|
675
|
+
const { state, view } = editor;
|
|
676
|
+
const clamped = Math.min(Math.max(0, pos), state.doc.content.size);
|
|
677
|
+
let anchor = clamped;
|
|
678
|
+
if (options.focus !== false) {
|
|
679
|
+
const selection = import_state2.TextSelection.near(state.doc.resolve(clamped), 1);
|
|
680
|
+
if (!state.selection.eq(selection)) {
|
|
681
|
+
view.dispatch(state.tr.setSelection(selection));
|
|
682
|
+
}
|
|
683
|
+
editor.commands.focus();
|
|
684
|
+
anchor = view.state.selection.from;
|
|
685
|
+
}
|
|
686
|
+
const editorDom = view.dom;
|
|
687
|
+
const scrollEl = editorDom.closest?.(".docs-editor-scroll") ?? null;
|
|
688
|
+
let coords = null;
|
|
689
|
+
try {
|
|
690
|
+
coords = view.coordsAtPos(anchor);
|
|
691
|
+
} catch {
|
|
692
|
+
coords = null;
|
|
693
|
+
}
|
|
694
|
+
if (!scrollEl || !coords) {
|
|
695
|
+
editorDom.scrollIntoView?.({ block: "start" });
|
|
696
|
+
return;
|
|
697
|
+
}
|
|
698
|
+
const scrollRect = scrollEl.getBoundingClientRect();
|
|
699
|
+
const top = scrollEl.scrollTop + (coords.top - scrollRect.top) - scrollEl.clientHeight / 3;
|
|
700
|
+
const target = Math.max(0, top);
|
|
701
|
+
try {
|
|
702
|
+
scrollEl.scrollTo({ top: target, behavior: "smooth" });
|
|
703
|
+
} catch {
|
|
704
|
+
scrollEl.scrollTop = target;
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
// src/toc.ts
|
|
642
709
|
function collectHeadingsFromDoc(doc) {
|
|
643
710
|
const headings = [];
|
|
644
711
|
doc.descendants((node, pos) => {
|
|
@@ -846,8 +913,7 @@ var TocNode = import_core4.Node.create({
|
|
|
846
913
|
const entry = event.target?.closest?.("[data-toc-entry]");
|
|
847
914
|
if (!entry) return;
|
|
848
915
|
const pos = Number(entry.getAttribute("data-pos") ?? 0);
|
|
849
|
-
|
|
850
|
-
editor.chain().focus().setTextSelection(clamped).scrollIntoView().run();
|
|
916
|
+
scrollEditorToPos(editor, pos);
|
|
851
917
|
};
|
|
852
918
|
refresh.addEventListener("click", onRefresh);
|
|
853
919
|
dom.addEventListener("click", onEntryClick);
|
|
@@ -895,10 +961,29 @@ var fontSizePlugin = (0, import_docflow_core14.definePlugin)({
|
|
|
895
961
|
}
|
|
896
962
|
});
|
|
897
963
|
|
|
898
|
-
// src/
|
|
964
|
+
// src/fontFamily.ts
|
|
899
965
|
var import_docflow_core15 = require("@kedataindo/docflow-core");
|
|
966
|
+
var fontFamilyPlugin = (0, import_docflow_core15.definePlugin)({
|
|
967
|
+
id: "font-family",
|
|
968
|
+
tiptapExtensions: [import_docflow_core15.FontFamilyExtension],
|
|
969
|
+
commands: {
|
|
970
|
+
setFontFamily: (editor, ...args) => {
|
|
971
|
+
const family = args[0] || "";
|
|
972
|
+
if (family) {
|
|
973
|
+
editor.commands.setFontFamily(family);
|
|
974
|
+
} else {
|
|
975
|
+
editor.commands.unsetFontFamily();
|
|
976
|
+
}
|
|
977
|
+
editor.commands.focus();
|
|
978
|
+
return true;
|
|
979
|
+
}
|
|
980
|
+
}
|
|
981
|
+
});
|
|
982
|
+
|
|
983
|
+
// src/textColor.ts
|
|
984
|
+
var import_docflow_core16 = require("@kedataindo/docflow-core");
|
|
900
985
|
var import_extension_color = __toESM(require("@tiptap/extension-color"), 1);
|
|
901
|
-
var textColorPlugin = (0,
|
|
986
|
+
var textColorPlugin = (0, import_docflow_core16.definePlugin)({
|
|
902
987
|
id: "text-color",
|
|
903
988
|
tiptapExtensions: [import_extension_color.default],
|
|
904
989
|
toolbar: [
|
|
@@ -917,7 +1002,7 @@ var textColorPlugin = (0, import_docflow_core15.definePlugin)({
|
|
|
917
1002
|
});
|
|
918
1003
|
|
|
919
1004
|
// src/highlight.ts
|
|
920
|
-
var
|
|
1005
|
+
var import_docflow_core17 = require("@kedataindo/docflow-core");
|
|
921
1006
|
var import_extension_highlight = __toESM(require("@tiptap/extension-highlight"), 1);
|
|
922
1007
|
var import_core5 = require("@tiptap/core");
|
|
923
1008
|
var GoogleDocsHighlight = import_extension_highlight.default.extend({
|
|
@@ -947,7 +1032,7 @@ var GoogleDocsHighlight = import_extension_highlight.default.extend({
|
|
|
947
1032
|
return ["mark", (0, import_core5.mergeAttributes)(this.options.HTMLAttributes, HTMLAttributes), 0];
|
|
948
1033
|
}
|
|
949
1034
|
});
|
|
950
|
-
var highlightPlugin = (0,
|
|
1035
|
+
var highlightPlugin = (0, import_docflow_core17.definePlugin)({
|
|
951
1036
|
id: "highlight",
|
|
952
1037
|
tiptapExtensions: [
|
|
953
1038
|
GoogleDocsHighlight.configure({
|
|
@@ -973,7 +1058,7 @@ var highlightPlugin = (0, import_docflow_core16.definePlugin)({
|
|
|
973
1058
|
|
|
974
1059
|
// src/citation.ts
|
|
975
1060
|
var import_core7 = require("@tiptap/core");
|
|
976
|
-
var
|
|
1061
|
+
var import_docflow_core18 = require("@kedataindo/docflow-core");
|
|
977
1062
|
|
|
978
1063
|
// src/citeEngine.ts
|
|
979
1064
|
var import_citeproc = __toESM(require("citeproc"), 1);
|
|
@@ -2334,7 +2419,7 @@ function insertCitationWithSource(editor, engine, attrs) {
|
|
|
2334
2419
|
if (spec.type === "footnote" && !editor.schema.nodes["footnote"]) return false;
|
|
2335
2420
|
return editor.chain().focus().insertContent({ type: spec.type, attrs: spec.attrs }).run();
|
|
2336
2421
|
}
|
|
2337
|
-
var citationPlugin = (0,
|
|
2422
|
+
var citationPlugin = (0, import_docflow_core18.definePlugin)({
|
|
2338
2423
|
id: "citation",
|
|
2339
2424
|
tiptapExtensions: [CitationEngineExtension, CitationNode, BibliographyNode],
|
|
2340
2425
|
toolbar: [{ id: "insert-citation", label: "Citation", action: "insertCitation", iconComponent: "Quote" }],
|
|
@@ -2404,15 +2489,15 @@ var citationPlugin = (0, import_docflow_core17.definePlugin)({
|
|
|
2404
2489
|
|
|
2405
2490
|
// src/ai.ts
|
|
2406
2491
|
var import_core9 = require("@tiptap/core");
|
|
2407
|
-
var
|
|
2492
|
+
var import_state4 = require("@tiptap/pm/state");
|
|
2408
2493
|
var import_view = require("@tiptap/pm/view");
|
|
2409
2494
|
var import_tiptap_markdown = require("tiptap-markdown");
|
|
2410
|
-
var
|
|
2495
|
+
var import_docflow_core19 = require("@kedataindo/docflow-core");
|
|
2411
2496
|
|
|
2412
2497
|
// src/markdownInsert.ts
|
|
2413
2498
|
var import_core8 = require("@tiptap/core");
|
|
2414
2499
|
var import_model = require("@tiptap/pm/model");
|
|
2415
|
-
var
|
|
2500
|
+
var import_state3 = require("@tiptap/pm/state");
|
|
2416
2501
|
var import_transform = require("@tiptap/pm/transform");
|
|
2417
2502
|
function mdParser(editor) {
|
|
2418
2503
|
const storage = editor.storage.markdown;
|
|
@@ -2448,7 +2533,7 @@ function selectionToInsertionEnd(tr, startLen, bias) {
|
|
|
2448
2533
|
map.forEach((_from, _to, _newFrom, newTo) => {
|
|
2449
2534
|
if (end === 0) end = newTo;
|
|
2450
2535
|
});
|
|
2451
|
-
tr.setSelection(
|
|
2536
|
+
tr.setSelection(import_state3.Selection.near(tr.doc.resolve(end), bias));
|
|
2452
2537
|
}
|
|
2453
2538
|
function insertMarkdownBlock(editor, view, from, to, markdown) {
|
|
2454
2539
|
const fragment = markdownToFragment(editor, markdown, { inline: false });
|
|
@@ -2491,7 +2576,7 @@ function insertMarkdownBlock(editor, view, from, to, markdown) {
|
|
|
2491
2576
|
}
|
|
2492
2577
|
|
|
2493
2578
|
// src/ai.ts
|
|
2494
|
-
var aiPluginKey = new
|
|
2579
|
+
var aiPluginKey = new import_state4.PluginKey("docflow-ai");
|
|
2495
2580
|
var CONTEXT_CHARS = 1500;
|
|
2496
2581
|
function getAIPreview(editor) {
|
|
2497
2582
|
return editor.storage.ai ? editor.storage.ai.preview ?? null : null;
|
|
@@ -2727,7 +2812,7 @@ var AIExtension = import_core9.Extension.create({
|
|
|
2727
2812
|
};
|
|
2728
2813
|
}
|
|
2729
2814
|
return [
|
|
2730
|
-
new
|
|
2815
|
+
new import_state4.Plugin({
|
|
2731
2816
|
key: aiPluginKey,
|
|
2732
2817
|
state: {
|
|
2733
2818
|
init: () => null,
|
|
@@ -2843,7 +2928,7 @@ var AIExtension = import_core9.Extension.create({
|
|
|
2843
2928
|
storage.preview = null;
|
|
2844
2929
|
}
|
|
2845
2930
|
});
|
|
2846
|
-
var aiPlugin = (0,
|
|
2931
|
+
var aiPlugin = (0, import_docflow_core19.definePlugin)({
|
|
2847
2932
|
id: "ai",
|
|
2848
2933
|
// The `tiptap-markdown` `Markdown` extension is registered alongside AI so
|
|
2849
2934
|
// that `editor.storage.markdown.parser` is available on every editor that
|
|
@@ -2899,15 +2984,15 @@ var commentPlugin = {
|
|
|
2899
2984
|
|
|
2900
2985
|
// src/suggestChanges.ts
|
|
2901
2986
|
var import_core11 = require("@tiptap/core");
|
|
2902
|
-
var
|
|
2987
|
+
var import_state5 = require("@tiptap/pm/state");
|
|
2903
2988
|
var import_transform2 = require("@tiptap/pm/transform");
|
|
2904
|
-
var
|
|
2989
|
+
var import_docflow_core20 = require("@kedataindo/docflow-core");
|
|
2905
2990
|
var SUGGESTION_INSERT = "suggestionInsert";
|
|
2906
2991
|
var SUGGESTION_DELETE = "suggestionDelete";
|
|
2907
2992
|
var SUGGESTION_FORMAT = "suggestionFormat";
|
|
2908
2993
|
var FORMAT_MARKS = /* @__PURE__ */ new Set(["bold", "italic", "underline", "strike", "highlight"]);
|
|
2909
2994
|
var SUGGEST_APPLIED_META = "suggestChanges:applied";
|
|
2910
|
-
var suggestChangesKey = new
|
|
2995
|
+
var suggestChangesKey = new import_state5.PluginKey("suggestChanges");
|
|
2911
2996
|
var suggestionAttributes = () => ({
|
|
2912
2997
|
suggestionId: {
|
|
2913
2998
|
default: null,
|
|
@@ -3029,7 +3114,7 @@ var SuggestChanges = import_core11.Extension.create({
|
|
|
3029
3114
|
if (storage) storage.suggestions = getSuggestions(editor);
|
|
3030
3115
|
};
|
|
3031
3116
|
return [
|
|
3032
|
-
new
|
|
3117
|
+
new import_state5.Plugin({
|
|
3033
3118
|
key: suggestChangesKey,
|
|
3034
3119
|
state: {
|
|
3035
3120
|
init: () => ({ mode: "editing", author: {} }),
|
|
@@ -3117,7 +3202,7 @@ var SuggestChanges = import_core11.Extension.create({
|
|
|
3117
3202
|
const id = adjacentRunId(view.state, from, SUGGESTION_DELETE) ?? newSuggestionId();
|
|
3118
3203
|
const tr = view.state.tr.addMark(from, to, del.create(markAttrs(id, current.author)));
|
|
3119
3204
|
if (event.key === "Backspace" && selection.empty) {
|
|
3120
|
-
tr.setSelection(
|
|
3205
|
+
tr.setSelection(import_state5.TextSelection.create(tr.doc, from));
|
|
3121
3206
|
}
|
|
3122
3207
|
view.dispatch(tr);
|
|
3123
3208
|
return true;
|
|
@@ -3269,7 +3354,7 @@ var acceptSuggestion = (editor, id) => resolveSuggestions(editor, true, id);
|
|
|
3269
3354
|
var rejectSuggestion = (editor, id) => resolveSuggestions(editor, false, id);
|
|
3270
3355
|
var acceptAllSuggestions = (editor) => resolveSuggestions(editor, true);
|
|
3271
3356
|
var rejectAllSuggestions = (editor) => resolveSuggestions(editor, false);
|
|
3272
|
-
var suggestChangesPlugin = (0,
|
|
3357
|
+
var suggestChangesPlugin = (0, import_docflow_core20.definePlugin)({
|
|
3273
3358
|
id: "suggestChanges",
|
|
3274
3359
|
tiptapExtensions: [SuggestionInsertMark, SuggestionDeleteMark, SuggestionFormatMark, SuggestChanges],
|
|
3275
3360
|
commands: {
|
|
@@ -3284,7 +3369,7 @@ var suggestChangesPlugin = (0, import_docflow_core19.definePlugin)({
|
|
|
3284
3369
|
|
|
3285
3370
|
// src/smartElements.ts
|
|
3286
3371
|
var import_core12 = require("@tiptap/core");
|
|
3287
|
-
var
|
|
3372
|
+
var import_docflow_core21 = require("@kedataindo/docflow-core");
|
|
3288
3373
|
function todayISO() {
|
|
3289
3374
|
return (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
3290
3375
|
}
|
|
@@ -3654,7 +3739,7 @@ var LocationChipNode = import_core12.Node.create({
|
|
|
3654
3739
|
};
|
|
3655
3740
|
}
|
|
3656
3741
|
});
|
|
3657
|
-
var smartElementsPlugin = (0,
|
|
3742
|
+
var smartElementsPlugin = (0, import_docflow_core21.definePlugin)({
|
|
3658
3743
|
id: "smart-elements",
|
|
3659
3744
|
tiptapExtensions: [
|
|
3660
3745
|
DateChipNode,
|
|
@@ -3713,10 +3798,10 @@ var smartElementsPlugin = (0, import_docflow_core20.definePlugin)({
|
|
|
3713
3798
|
});
|
|
3714
3799
|
|
|
3715
3800
|
// src/tablePageSplit.ts
|
|
3716
|
-
var
|
|
3801
|
+
var import_docflow_core22 = require("@kedataindo/docflow-core");
|
|
3717
3802
|
var import_core13 = require("@tiptap/core");
|
|
3718
|
-
var
|
|
3719
|
-
var PLUGIN_KEY = new
|
|
3803
|
+
var import_state6 = require("@tiptap/pm/state");
|
|
3804
|
+
var PLUGIN_KEY = new import_state6.PluginKey("docflow/table-page-split");
|
|
3720
3805
|
var SPLIT_MARK = "head";
|
|
3721
3806
|
var MAX_SPLIT_DEPTH = 16;
|
|
3722
3807
|
function readPageContentHeightPx(view, editor) {
|
|
@@ -3902,7 +3987,7 @@ var TablePageSplitExtension = import_core13.Extension.create({
|
|
|
3902
3987
|
const ext = this;
|
|
3903
3988
|
const editorRef = ext.editor ?? null;
|
|
3904
3989
|
return [
|
|
3905
|
-
new
|
|
3990
|
+
new import_state6.Plugin({
|
|
3906
3991
|
key: PLUGIN_KEY,
|
|
3907
3992
|
view(_editorView) {
|
|
3908
3993
|
viewRef = _editorView;
|
|
@@ -3934,15 +4019,15 @@ var TablePageSplitExtension = import_core13.Extension.create({
|
|
|
3934
4019
|
];
|
|
3935
4020
|
}
|
|
3936
4021
|
});
|
|
3937
|
-
var tablePageSplitPlugin = (0,
|
|
4022
|
+
var tablePageSplitPlugin = (0, import_docflow_core22.definePlugin)({
|
|
3938
4023
|
id: "tablePageSplit",
|
|
3939
4024
|
tiptapExtensions: [TablePageSplitExtension]
|
|
3940
4025
|
});
|
|
3941
4026
|
|
|
3942
4027
|
// src/slashMenu.ts
|
|
3943
4028
|
var import_core14 = require("@tiptap/core");
|
|
3944
|
-
var
|
|
3945
|
-
var
|
|
4029
|
+
var import_state7 = require("@tiptap/pm/state");
|
|
4030
|
+
var import_docflow_core23 = require("@kedataindo/docflow-core");
|
|
3946
4031
|
var slashState = {
|
|
3947
4032
|
open: false,
|
|
3948
4033
|
query: "",
|
|
@@ -4000,8 +4085,8 @@ var SlashMenuExtension = import_core14.Extension.create({
|
|
|
4000
4085
|
name: "slashMenu",
|
|
4001
4086
|
addProseMirrorPlugins() {
|
|
4002
4087
|
return [
|
|
4003
|
-
new
|
|
4004
|
-
key: new
|
|
4088
|
+
new import_state7.Plugin({
|
|
4089
|
+
key: new import_state7.PluginKey("slashMenu"),
|
|
4005
4090
|
props: {
|
|
4006
4091
|
handleTextInput(view, from, _to, text) {
|
|
4007
4092
|
if (text === "/") {
|
|
@@ -4087,7 +4172,7 @@ var SlashMenuExtension = import_core14.Extension.create({
|
|
|
4087
4172
|
];
|
|
4088
4173
|
}
|
|
4089
4174
|
});
|
|
4090
|
-
var slashMenuPlugin = (0,
|
|
4175
|
+
var slashMenuPlugin = (0, import_docflow_core23.definePlugin)({
|
|
4091
4176
|
id: "slash-menu",
|
|
4092
4177
|
tiptapExtensions: [SlashMenuExtension],
|
|
4093
4178
|
hooks: {
|
|
@@ -4115,6 +4200,7 @@ var defaultPlugins = [
|
|
|
4115
4200
|
footnotePlugin,
|
|
4116
4201
|
tocPlugin,
|
|
4117
4202
|
fontSizePlugin,
|
|
4203
|
+
fontFamilyPlugin,
|
|
4118
4204
|
textColorPlugin,
|
|
4119
4205
|
highlightPlugin,
|
|
4120
4206
|
citationPlugin,
|
|
@@ -4137,6 +4223,7 @@ var defaultPlugins = [
|
|
|
4137
4223
|
DateChipNode,
|
|
4138
4224
|
DropdownChipNode,
|
|
4139
4225
|
FileChipNode,
|
|
4226
|
+
FontFamilyExtension,
|
|
4140
4227
|
FontSizeExtension,
|
|
4141
4228
|
FootnoteNode,
|
|
4142
4229
|
LocationChipNode,
|
|
@@ -4165,6 +4252,7 @@ var defaultPlugins = [
|
|
|
4165
4252
|
commentPlugin,
|
|
4166
4253
|
createPlaceholderPlugin,
|
|
4167
4254
|
defaultPlugins,
|
|
4255
|
+
fontFamilyPlugin,
|
|
4168
4256
|
fontSizePlugin,
|
|
4169
4257
|
footnotePlugin,
|
|
4170
4258
|
formattingPlugin,
|
|
@@ -4187,6 +4275,7 @@ var defaultPlugins = [
|
|
|
4187
4275
|
rejectAllSuggestions,
|
|
4188
4276
|
rejectSuggestion,
|
|
4189
4277
|
sanitizeCiteprocHtml,
|
|
4278
|
+
scrollEditorToPos,
|
|
4190
4279
|
setDocumentMode,
|
|
4191
4280
|
setSuggestionAuthor,
|
|
4192
4281
|
slashMenuPlugin,
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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, FontSizeExtension, SlashCommand, ToolbarItem } from '@kedataindo/docflow-core';
|
|
3
|
+
export { 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
6
|
export { CSL_LOCALE_EN_US, CSL_STYLES, CitationAttrs, CitationCluster, CitationMode, CiteEngineOptions, CslStyleInfo, DEFAULT_CSL_STYLE, buildCitationNodes, nextCitationId, sanitizeCiteprocHtml } from './citations.cjs';
|
|
@@ -96,6 +96,16 @@ declare const tocPlugin: _kedata_indonesia_docflow_core.DocsEditorPlugin;
|
|
|
96
96
|
*/
|
|
97
97
|
declare const fontSizePlugin: _kedata_indonesia_docflow_core.DocsEditorPlugin;
|
|
98
98
|
|
|
99
|
+
/**
|
|
100
|
+
* fontFamilyPlugin — provides the `setFontFamily` command action for toolbar
|
|
101
|
+
* use, backed by FontFamilyExtension (a `fontFamily` attribute on the TextStyle
|
|
102
|
+
* mark). Registered through the plugin system so the extension is added once.
|
|
103
|
+
*
|
|
104
|
+
* The toolbar passes a full CSS font stack (e.g. `Georgia, serif`) so the
|
|
105
|
+
* applied family is explicit and survives round-trips.
|
|
106
|
+
*/
|
|
107
|
+
declare const fontFamilyPlugin: _kedata_indonesia_docflow_core.DocsEditorPlugin;
|
|
108
|
+
|
|
99
109
|
declare const textColorPlugin: _kedata_indonesia_docflow_core.DocsEditorPlugin;
|
|
100
110
|
|
|
101
111
|
declare const highlightPlugin: _kedata_indonesia_docflow_core.DocsEditorPlugin;
|
|
@@ -216,6 +226,26 @@ declare function markdownToFragment(editor: Editor, markdown: string, opts: {
|
|
|
216
226
|
*/
|
|
217
227
|
declare function insertMarkdownBlock(editor: Editor, view: EditorView, from: number, to: number, markdown: string): void;
|
|
218
228
|
|
|
229
|
+
/**
|
|
230
|
+
* Scroll the editor so document position `pos` is visible.
|
|
231
|
+
*
|
|
232
|
+
* Works with the paginated surface: the scrollable element is the
|
|
233
|
+
* `.docs-editor-scroll` wrapper (DocsEditor), NOT the window — a plain
|
|
234
|
+
* `scrollIntoView()` on the geo-point lands on the wrong page once
|
|
235
|
+
* PaginationPlus has cloned/offset the page frames. We resolve the target from
|
|
236
|
+
* `coordsAtPos` and move the container's scrollTop instead, which is correct in
|
|
237
|
+
* both paginated and pageless mode.
|
|
238
|
+
*
|
|
239
|
+
* Falls back to the native `scrollIntoView` on the editor element when there is
|
|
240
|
+
* no scroll container (bare editor / non-DOM environments such as tests).
|
|
241
|
+
*
|
|
242
|
+
* @param options.focus move the caret to `pos` (default true). Set false when
|
|
243
|
+
* the caller has already placed the selection.
|
|
244
|
+
*/
|
|
245
|
+
declare function scrollEditorToPos(editor: Editor, pos: number, options?: {
|
|
246
|
+
focus?: boolean;
|
|
247
|
+
}): void;
|
|
248
|
+
|
|
219
249
|
/**
|
|
220
250
|
* Phase 9 P9-4 — comment plugin.
|
|
221
251
|
*
|
|
@@ -360,4 +390,4 @@ declare const slashMenuPlugin: _kedata_indonesia_docflow_core.DocsEditorPlugin;
|
|
|
360
390
|
|
|
361
391
|
declare const defaultPlugins: _kedata_indonesia_docflow_core.DocsEditorPlugin[];
|
|
362
392
|
|
|
363
|
-
export { AIExtension, type AIPreviewState, BibliographyNode, CitationEngineExtension, CitationNode, CiteEngine, type CommentMarkAttrs, CommentMark as CommentMarkExtension, DateChipNode, DropdownChipNode, FileChipNode, FootnoteNode, LocationChipNode, PageBreak, PeopleChipNode, type PlaceholderPluginOptions, SUGGESTION_DELETE, SUGGESTION_FORMAT, SUGGESTION_INSERT, SlashMenuExtension, type SuggestionAuthor, SuggestionDeleteMark, SuggestionFormatMark, SuggestionInsertMark, type SuggestionSummary, TocEntryNode, TocNode, TocPageNumNode, acceptAllSuggestions, acceptSuggestion, aiPlugin, aiPluginKey, alignmentPlugin, blockquotePlugin, citationPlugin, codeBlockPlugin, collectHeadings, commentPlugin, createPlaceholderPlugin, defaultPlugins, fontSizePlugin, footnotePlugin, formattingPlugin, getAIPreview, getCitationEngine, getSuggestions, headingsPlugin, highlightPlugin, imagePlugin, insertMarkdownBlock, linkPlugin, listsPlugin, markdownToFragment, onSlashStateChange, pageBreakPlugin, placeholderPlugin, regenerateToc, registerSlashCommands, rejectAllSuggestions, rejectSuggestion, setDocumentMode, setSuggestionAuthor, slashMenuPlugin, slashState, smartElementsPlugin, suggestChangesPlugin, tablePageSplitPlugin, tablePlugin, textColorPlugin, tocPlugin };
|
|
393
|
+
export { AIExtension, type AIPreviewState, BibliographyNode, CitationEngineExtension, CitationNode, CiteEngine, type CommentMarkAttrs, CommentMark as CommentMarkExtension, DateChipNode, DropdownChipNode, FileChipNode, FootnoteNode, LocationChipNode, PageBreak, PeopleChipNode, type PlaceholderPluginOptions, SUGGESTION_DELETE, SUGGESTION_FORMAT, SUGGESTION_INSERT, SlashMenuExtension, type SuggestionAuthor, SuggestionDeleteMark, SuggestionFormatMark, SuggestionInsertMark, type SuggestionSummary, TocEntryNode, TocNode, TocPageNumNode, acceptAllSuggestions, acceptSuggestion, aiPlugin, aiPluginKey, alignmentPlugin, blockquotePlugin, citationPlugin, codeBlockPlugin, collectHeadings, commentPlugin, createPlaceholderPlugin, defaultPlugins, fontFamilyPlugin, fontSizePlugin, footnotePlugin, formattingPlugin, getAIPreview, getCitationEngine, getSuggestions, headingsPlugin, highlightPlugin, imagePlugin, insertMarkdownBlock, linkPlugin, listsPlugin, markdownToFragment, onSlashStateChange, pageBreakPlugin, placeholderPlugin, regenerateToc, registerSlashCommands, rejectAllSuggestions, rejectSuggestion, scrollEditorToPos, setDocumentMode, setSuggestionAuthor, slashMenuPlugin, slashState, smartElementsPlugin, suggestChangesPlugin, tablePageSplitPlugin, tablePlugin, textColorPlugin, tocPlugin };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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, FontSizeExtension, SlashCommand, ToolbarItem } from '@kedataindo/docflow-core';
|
|
3
|
+
export { 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
6
|
export { CSL_LOCALE_EN_US, CSL_STYLES, CitationAttrs, CitationCluster, CitationMode, CiteEngineOptions, CslStyleInfo, DEFAULT_CSL_STYLE, buildCitationNodes, nextCitationId, sanitizeCiteprocHtml } from './citations.js';
|
|
@@ -96,6 +96,16 @@ declare const tocPlugin: _kedata_indonesia_docflow_core.DocsEditorPlugin;
|
|
|
96
96
|
*/
|
|
97
97
|
declare const fontSizePlugin: _kedata_indonesia_docflow_core.DocsEditorPlugin;
|
|
98
98
|
|
|
99
|
+
/**
|
|
100
|
+
* fontFamilyPlugin — provides the `setFontFamily` command action for toolbar
|
|
101
|
+
* use, backed by FontFamilyExtension (a `fontFamily` attribute on the TextStyle
|
|
102
|
+
* mark). Registered through the plugin system so the extension is added once.
|
|
103
|
+
*
|
|
104
|
+
* The toolbar passes a full CSS font stack (e.g. `Georgia, serif`) so the
|
|
105
|
+
* applied family is explicit and survives round-trips.
|
|
106
|
+
*/
|
|
107
|
+
declare const fontFamilyPlugin: _kedata_indonesia_docflow_core.DocsEditorPlugin;
|
|
108
|
+
|
|
99
109
|
declare const textColorPlugin: _kedata_indonesia_docflow_core.DocsEditorPlugin;
|
|
100
110
|
|
|
101
111
|
declare const highlightPlugin: _kedata_indonesia_docflow_core.DocsEditorPlugin;
|
|
@@ -216,6 +226,26 @@ declare function markdownToFragment(editor: Editor, markdown: string, opts: {
|
|
|
216
226
|
*/
|
|
217
227
|
declare function insertMarkdownBlock(editor: Editor, view: EditorView, from: number, to: number, markdown: string): void;
|
|
218
228
|
|
|
229
|
+
/**
|
|
230
|
+
* Scroll the editor so document position `pos` is visible.
|
|
231
|
+
*
|
|
232
|
+
* Works with the paginated surface: the scrollable element is the
|
|
233
|
+
* `.docs-editor-scroll` wrapper (DocsEditor), NOT the window — a plain
|
|
234
|
+
* `scrollIntoView()` on the geo-point lands on the wrong page once
|
|
235
|
+
* PaginationPlus has cloned/offset the page frames. We resolve the target from
|
|
236
|
+
* `coordsAtPos` and move the container's scrollTop instead, which is correct in
|
|
237
|
+
* both paginated and pageless mode.
|
|
238
|
+
*
|
|
239
|
+
* Falls back to the native `scrollIntoView` on the editor element when there is
|
|
240
|
+
* no scroll container (bare editor / non-DOM environments such as tests).
|
|
241
|
+
*
|
|
242
|
+
* @param options.focus move the caret to `pos` (default true). Set false when
|
|
243
|
+
* the caller has already placed the selection.
|
|
244
|
+
*/
|
|
245
|
+
declare function scrollEditorToPos(editor: Editor, pos: number, options?: {
|
|
246
|
+
focus?: boolean;
|
|
247
|
+
}): void;
|
|
248
|
+
|
|
219
249
|
/**
|
|
220
250
|
* Phase 9 P9-4 — comment plugin.
|
|
221
251
|
*
|
|
@@ -360,4 +390,4 @@ declare const slashMenuPlugin: _kedata_indonesia_docflow_core.DocsEditorPlugin;
|
|
|
360
390
|
|
|
361
391
|
declare const defaultPlugins: _kedata_indonesia_docflow_core.DocsEditorPlugin[];
|
|
362
392
|
|
|
363
|
-
export { AIExtension, type AIPreviewState, BibliographyNode, CitationEngineExtension, CitationNode, CiteEngine, type CommentMarkAttrs, CommentMark as CommentMarkExtension, DateChipNode, DropdownChipNode, FileChipNode, FootnoteNode, LocationChipNode, PageBreak, PeopleChipNode, type PlaceholderPluginOptions, SUGGESTION_DELETE, SUGGESTION_FORMAT, SUGGESTION_INSERT, SlashMenuExtension, type SuggestionAuthor, SuggestionDeleteMark, SuggestionFormatMark, SuggestionInsertMark, type SuggestionSummary, TocEntryNode, TocNode, TocPageNumNode, acceptAllSuggestions, acceptSuggestion, aiPlugin, aiPluginKey, alignmentPlugin, blockquotePlugin, citationPlugin, codeBlockPlugin, collectHeadings, commentPlugin, createPlaceholderPlugin, defaultPlugins, fontSizePlugin, footnotePlugin, formattingPlugin, getAIPreview, getCitationEngine, getSuggestions, headingsPlugin, highlightPlugin, imagePlugin, insertMarkdownBlock, linkPlugin, listsPlugin, markdownToFragment, onSlashStateChange, pageBreakPlugin, placeholderPlugin, regenerateToc, registerSlashCommands, rejectAllSuggestions, rejectSuggestion, setDocumentMode, setSuggestionAuthor, slashMenuPlugin, slashState, smartElementsPlugin, suggestChangesPlugin, tablePageSplitPlugin, tablePlugin, textColorPlugin, tocPlugin };
|
|
393
|
+
export { AIExtension, type AIPreviewState, BibliographyNode, CitationEngineExtension, CitationNode, CiteEngine, type CommentMarkAttrs, CommentMark as CommentMarkExtension, DateChipNode, DropdownChipNode, FileChipNode, FootnoteNode, LocationChipNode, PageBreak, PeopleChipNode, type PlaceholderPluginOptions, SUGGESTION_DELETE, SUGGESTION_FORMAT, SUGGESTION_INSERT, SlashMenuExtension, type SuggestionAuthor, SuggestionDeleteMark, SuggestionFormatMark, SuggestionInsertMark, type SuggestionSummary, TocEntryNode, TocNode, TocPageNumNode, acceptAllSuggestions, acceptSuggestion, aiPlugin, aiPluginKey, alignmentPlugin, blockquotePlugin, citationPlugin, codeBlockPlugin, collectHeadings, commentPlugin, createPlaceholderPlugin, defaultPlugins, fontFamilyPlugin, fontSizePlugin, footnotePlugin, formattingPlugin, getAIPreview, getCitationEngine, getSuggestions, headingsPlugin, highlightPlugin, imagePlugin, insertMarkdownBlock, linkPlugin, listsPlugin, markdownToFragment, onSlashStateChange, pageBreakPlugin, placeholderPlugin, regenerateToc, registerSlashCommands, rejectAllSuggestions, rejectSuggestion, scrollEditorToPos, setDocumentMode, setSuggestionAuthor, slashMenuPlugin, slashState, smartElementsPlugin, suggestChangesPlugin, tablePageSplitPlugin, tablePlugin, textColorPlugin, tocPlugin };
|
package/dist/index.js
CHANGED
|
@@ -181,6 +181,7 @@ import Table from "@tiptap/extension-table";
|
|
|
181
181
|
import TableRow from "@tiptap/extension-table-row";
|
|
182
182
|
import TableCell from "@tiptap/extension-table-cell";
|
|
183
183
|
import TableHeader from "@tiptap/extension-table-header";
|
|
184
|
+
import { Plugin, TextSelection } from "@tiptap/pm/state";
|
|
184
185
|
var CustomTable = Table.extend({
|
|
185
186
|
addAttributes() {
|
|
186
187
|
return {
|
|
@@ -250,6 +251,31 @@ var CustomTable = Table.extend({
|
|
|
250
251
|
["colgroup", ...cols],
|
|
251
252
|
["tbody", 0]
|
|
252
253
|
];
|
|
254
|
+
},
|
|
255
|
+
// #139: double-clicking an EMPTY cell resolved the caret to a neighbouring
|
|
256
|
+
// cell — ProseMirror's default dblclick word-selection has no text to land on
|
|
257
|
+
// in a cell whose only content is a trailing <br>. When the resolved position
|
|
258
|
+
// is not inside the cell under the pointer, place the caret at that cell's
|
|
259
|
+
// start instead. Non-empty cells keep the default (select the word).
|
|
260
|
+
addProseMirrorPlugins() {
|
|
261
|
+
const parent = this.parent?.() ?? [];
|
|
262
|
+
return [
|
|
263
|
+
...parent,
|
|
264
|
+
new Plugin({
|
|
265
|
+
props: {
|
|
266
|
+
handleDoubleClick(view, pos, event) {
|
|
267
|
+
const cell = event.target?.closest?.("td, th") ?? null;
|
|
268
|
+
if (!cell) return false;
|
|
269
|
+
if ((cell.textContent ?? "").trim() !== "") return false;
|
|
270
|
+
void pos;
|
|
271
|
+
const cellPos = view.posAtDOM(cell, 0);
|
|
272
|
+
const selection = TextSelection.near(view.state.doc.resolve(cellPos), 1);
|
|
273
|
+
view.dispatch(view.state.tr.setSelection(selection));
|
|
274
|
+
return true;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
})
|
|
278
|
+
];
|
|
253
279
|
}
|
|
254
280
|
});
|
|
255
281
|
var CustomTableCell = TableCell.extend({
|
|
@@ -532,6 +558,44 @@ var footnotePlugin = definePlugin12({
|
|
|
532
558
|
// src/toc.ts
|
|
533
559
|
import { Extension, Node as Node4, mergeAttributes as mergeAttributes4 } from "@tiptap/core";
|
|
534
560
|
import { definePlugin as definePlugin13 } from "@kedataindo/docflow-core";
|
|
561
|
+
|
|
562
|
+
// src/editorScroll.ts
|
|
563
|
+
import { TextSelection as TextSelection2 } from "@tiptap/pm/state";
|
|
564
|
+
function scrollEditorToPos(editor, pos, options = {}) {
|
|
565
|
+
const { state, view } = editor;
|
|
566
|
+
const clamped = Math.min(Math.max(0, pos), state.doc.content.size);
|
|
567
|
+
let anchor = clamped;
|
|
568
|
+
if (options.focus !== false) {
|
|
569
|
+
const selection = TextSelection2.near(state.doc.resolve(clamped), 1);
|
|
570
|
+
if (!state.selection.eq(selection)) {
|
|
571
|
+
view.dispatch(state.tr.setSelection(selection));
|
|
572
|
+
}
|
|
573
|
+
editor.commands.focus();
|
|
574
|
+
anchor = view.state.selection.from;
|
|
575
|
+
}
|
|
576
|
+
const editorDom = view.dom;
|
|
577
|
+
const scrollEl = editorDom.closest?.(".docs-editor-scroll") ?? null;
|
|
578
|
+
let coords = null;
|
|
579
|
+
try {
|
|
580
|
+
coords = view.coordsAtPos(anchor);
|
|
581
|
+
} catch {
|
|
582
|
+
coords = null;
|
|
583
|
+
}
|
|
584
|
+
if (!scrollEl || !coords) {
|
|
585
|
+
editorDom.scrollIntoView?.({ block: "start" });
|
|
586
|
+
return;
|
|
587
|
+
}
|
|
588
|
+
const scrollRect = scrollEl.getBoundingClientRect();
|
|
589
|
+
const top = scrollEl.scrollTop + (coords.top - scrollRect.top) - scrollEl.clientHeight / 3;
|
|
590
|
+
const target = Math.max(0, top);
|
|
591
|
+
try {
|
|
592
|
+
scrollEl.scrollTo({ top: target, behavior: "smooth" });
|
|
593
|
+
} catch {
|
|
594
|
+
scrollEl.scrollTop = target;
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
// src/toc.ts
|
|
535
599
|
function collectHeadingsFromDoc(doc) {
|
|
536
600
|
const headings = [];
|
|
537
601
|
doc.descendants((node, pos) => {
|
|
@@ -739,8 +803,7 @@ var TocNode = Node4.create({
|
|
|
739
803
|
const entry = event.target?.closest?.("[data-toc-entry]");
|
|
740
804
|
if (!entry) return;
|
|
741
805
|
const pos = Number(entry.getAttribute("data-pos") ?? 0);
|
|
742
|
-
|
|
743
|
-
editor.chain().focus().setTextSelection(clamped).scrollIntoView().run();
|
|
806
|
+
scrollEditorToPos(editor, pos);
|
|
744
807
|
};
|
|
745
808
|
refresh.addEventListener("click", onRefresh);
|
|
746
809
|
dom.addEventListener("click", onEntryClick);
|
|
@@ -788,10 +851,29 @@ var fontSizePlugin = definePlugin14({
|
|
|
788
851
|
}
|
|
789
852
|
});
|
|
790
853
|
|
|
854
|
+
// src/fontFamily.ts
|
|
855
|
+
import { definePlugin as definePlugin15, FontFamilyExtension } from "@kedataindo/docflow-core";
|
|
856
|
+
var fontFamilyPlugin = definePlugin15({
|
|
857
|
+
id: "font-family",
|
|
858
|
+
tiptapExtensions: [FontFamilyExtension],
|
|
859
|
+
commands: {
|
|
860
|
+
setFontFamily: (editor, ...args) => {
|
|
861
|
+
const family = args[0] || "";
|
|
862
|
+
if (family) {
|
|
863
|
+
editor.commands.setFontFamily(family);
|
|
864
|
+
} else {
|
|
865
|
+
editor.commands.unsetFontFamily();
|
|
866
|
+
}
|
|
867
|
+
editor.commands.focus();
|
|
868
|
+
return true;
|
|
869
|
+
}
|
|
870
|
+
}
|
|
871
|
+
});
|
|
872
|
+
|
|
791
873
|
// src/textColor.ts
|
|
792
|
-
import { definePlugin as
|
|
874
|
+
import { definePlugin as definePlugin16 } from "@kedataindo/docflow-core";
|
|
793
875
|
import Color from "@tiptap/extension-color";
|
|
794
|
-
var textColorPlugin =
|
|
876
|
+
var textColorPlugin = definePlugin16({
|
|
795
877
|
id: "text-color",
|
|
796
878
|
tiptapExtensions: [Color],
|
|
797
879
|
toolbar: [
|
|
@@ -810,7 +892,7 @@ var textColorPlugin = definePlugin15({
|
|
|
810
892
|
});
|
|
811
893
|
|
|
812
894
|
// src/highlight.ts
|
|
813
|
-
import { definePlugin as
|
|
895
|
+
import { definePlugin as definePlugin17 } from "@kedataindo/docflow-core";
|
|
814
896
|
import Highlight from "@tiptap/extension-highlight";
|
|
815
897
|
import { mergeAttributes as mergeAttributes5 } from "@tiptap/core";
|
|
816
898
|
var GoogleDocsHighlight = Highlight.extend({
|
|
@@ -840,7 +922,7 @@ var GoogleDocsHighlight = Highlight.extend({
|
|
|
840
922
|
return ["mark", mergeAttributes5(this.options.HTMLAttributes, HTMLAttributes), 0];
|
|
841
923
|
}
|
|
842
924
|
});
|
|
843
|
-
var highlightPlugin =
|
|
925
|
+
var highlightPlugin = definePlugin17({
|
|
844
926
|
id: "highlight",
|
|
845
927
|
tiptapExtensions: [
|
|
846
928
|
GoogleDocsHighlight.configure({
|
|
@@ -866,7 +948,7 @@ var highlightPlugin = definePlugin16({
|
|
|
866
948
|
|
|
867
949
|
// src/citation.ts
|
|
868
950
|
import { Extension as Extension2, Node as Node6, mergeAttributes as mergeAttributes7 } from "@tiptap/core";
|
|
869
|
-
import { definePlugin as
|
|
951
|
+
import { definePlugin as definePlugin18 } from "@kedataindo/docflow-core";
|
|
870
952
|
|
|
871
953
|
// src/citeEngine.ts
|
|
872
954
|
import CSL from "citeproc";
|
|
@@ -2227,7 +2309,7 @@ function insertCitationWithSource(editor, engine, attrs) {
|
|
|
2227
2309
|
if (spec.type === "footnote" && !editor.schema.nodes["footnote"]) return false;
|
|
2228
2310
|
return editor.chain().focus().insertContent({ type: spec.type, attrs: spec.attrs }).run();
|
|
2229
2311
|
}
|
|
2230
|
-
var citationPlugin =
|
|
2312
|
+
var citationPlugin = definePlugin18({
|
|
2231
2313
|
id: "citation",
|
|
2232
2314
|
tiptapExtensions: [CitationEngineExtension, CitationNode, BibliographyNode],
|
|
2233
2315
|
toolbar: [{ id: "insert-citation", label: "Citation", action: "insertCitation", iconComponent: "Quote" }],
|
|
@@ -2297,10 +2379,10 @@ var citationPlugin = definePlugin17({
|
|
|
2297
2379
|
|
|
2298
2380
|
// src/ai.ts
|
|
2299
2381
|
import { Extension as Extension3 } from "@tiptap/core";
|
|
2300
|
-
import { Plugin, PluginKey } from "@tiptap/pm/state";
|
|
2382
|
+
import { Plugin as Plugin2, PluginKey } from "@tiptap/pm/state";
|
|
2301
2383
|
import { Decoration, DecorationSet } from "@tiptap/pm/view";
|
|
2302
2384
|
import { Markdown } from "tiptap-markdown";
|
|
2303
|
-
import { definePlugin as
|
|
2385
|
+
import { definePlugin as definePlugin19 } from "@kedataindo/docflow-core";
|
|
2304
2386
|
|
|
2305
2387
|
// src/markdownInsert.ts
|
|
2306
2388
|
import { createNodeFromContent } from "@tiptap/core";
|
|
@@ -2620,7 +2702,7 @@ var AIExtension = Extension3.create({
|
|
|
2620
2702
|
};
|
|
2621
2703
|
}
|
|
2622
2704
|
return [
|
|
2623
|
-
new
|
|
2705
|
+
new Plugin2({
|
|
2624
2706
|
key: aiPluginKey,
|
|
2625
2707
|
state: {
|
|
2626
2708
|
init: () => null,
|
|
@@ -2736,7 +2818,7 @@ var AIExtension = Extension3.create({
|
|
|
2736
2818
|
storage.preview = null;
|
|
2737
2819
|
}
|
|
2738
2820
|
});
|
|
2739
|
-
var aiPlugin =
|
|
2821
|
+
var aiPlugin = definePlugin19({
|
|
2740
2822
|
id: "ai",
|
|
2741
2823
|
// The `tiptap-markdown` `Markdown` extension is registered alongside AI so
|
|
2742
2824
|
// that `editor.storage.markdown.parser` is available on every editor that
|
|
@@ -2792,9 +2874,9 @@ var commentPlugin = {
|
|
|
2792
2874
|
|
|
2793
2875
|
// src/suggestChanges.ts
|
|
2794
2876
|
import { Extension as Extension4, Mark as Mark2, mergeAttributes as mergeAttributes8 } from "@tiptap/core";
|
|
2795
|
-
import { Plugin as
|
|
2877
|
+
import { Plugin as Plugin3, PluginKey as PluginKey2, TextSelection as TextSelection3 } from "@tiptap/pm/state";
|
|
2796
2878
|
import { AddMarkStep, RemoveMarkStep } from "@tiptap/pm/transform";
|
|
2797
|
-
import { definePlugin as
|
|
2879
|
+
import { definePlugin as definePlugin20 } from "@kedataindo/docflow-core";
|
|
2798
2880
|
var SUGGESTION_INSERT = "suggestionInsert";
|
|
2799
2881
|
var SUGGESTION_DELETE = "suggestionDelete";
|
|
2800
2882
|
var SUGGESTION_FORMAT = "suggestionFormat";
|
|
@@ -2922,7 +3004,7 @@ var SuggestChanges = Extension4.create({
|
|
|
2922
3004
|
if (storage) storage.suggestions = getSuggestions(editor);
|
|
2923
3005
|
};
|
|
2924
3006
|
return [
|
|
2925
|
-
new
|
|
3007
|
+
new Plugin3({
|
|
2926
3008
|
key: suggestChangesKey,
|
|
2927
3009
|
state: {
|
|
2928
3010
|
init: () => ({ mode: "editing", author: {} }),
|
|
@@ -3010,7 +3092,7 @@ var SuggestChanges = Extension4.create({
|
|
|
3010
3092
|
const id = adjacentRunId(view.state, from, SUGGESTION_DELETE) ?? newSuggestionId();
|
|
3011
3093
|
const tr = view.state.tr.addMark(from, to, del.create(markAttrs(id, current.author)));
|
|
3012
3094
|
if (event.key === "Backspace" && selection.empty) {
|
|
3013
|
-
tr.setSelection(
|
|
3095
|
+
tr.setSelection(TextSelection3.create(tr.doc, from));
|
|
3014
3096
|
}
|
|
3015
3097
|
view.dispatch(tr);
|
|
3016
3098
|
return true;
|
|
@@ -3162,7 +3244,7 @@ var acceptSuggestion = (editor, id) => resolveSuggestions(editor, true, id);
|
|
|
3162
3244
|
var rejectSuggestion = (editor, id) => resolveSuggestions(editor, false, id);
|
|
3163
3245
|
var acceptAllSuggestions = (editor) => resolveSuggestions(editor, true);
|
|
3164
3246
|
var rejectAllSuggestions = (editor) => resolveSuggestions(editor, false);
|
|
3165
|
-
var suggestChangesPlugin =
|
|
3247
|
+
var suggestChangesPlugin = definePlugin20({
|
|
3166
3248
|
id: "suggestChanges",
|
|
3167
3249
|
tiptapExtensions: [SuggestionInsertMark, SuggestionDeleteMark, SuggestionFormatMark, SuggestChanges],
|
|
3168
3250
|
commands: {
|
|
@@ -3177,7 +3259,7 @@ var suggestChangesPlugin = definePlugin19({
|
|
|
3177
3259
|
|
|
3178
3260
|
// src/smartElements.ts
|
|
3179
3261
|
import { Node as Node7, mergeAttributes as mergeAttributes9 } from "@tiptap/core";
|
|
3180
|
-
import { definePlugin as
|
|
3262
|
+
import { definePlugin as definePlugin21 } from "@kedataindo/docflow-core";
|
|
3181
3263
|
function todayISO() {
|
|
3182
3264
|
return (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
3183
3265
|
}
|
|
@@ -3547,7 +3629,7 @@ var LocationChipNode = Node7.create({
|
|
|
3547
3629
|
};
|
|
3548
3630
|
}
|
|
3549
3631
|
});
|
|
3550
|
-
var smartElementsPlugin =
|
|
3632
|
+
var smartElementsPlugin = definePlugin21({
|
|
3551
3633
|
id: "smart-elements",
|
|
3552
3634
|
tiptapExtensions: [
|
|
3553
3635
|
DateChipNode,
|
|
@@ -3606,9 +3688,9 @@ var smartElementsPlugin = definePlugin20({
|
|
|
3606
3688
|
});
|
|
3607
3689
|
|
|
3608
3690
|
// src/tablePageSplit.ts
|
|
3609
|
-
import { definePlugin as
|
|
3691
|
+
import { definePlugin as definePlugin22 } from "@kedataindo/docflow-core";
|
|
3610
3692
|
import { Extension as Extension5 } from "@tiptap/core";
|
|
3611
|
-
import { Plugin as
|
|
3693
|
+
import { Plugin as Plugin4, PluginKey as PluginKey3 } from "@tiptap/pm/state";
|
|
3612
3694
|
var PLUGIN_KEY = new PluginKey3("docflow/table-page-split");
|
|
3613
3695
|
var SPLIT_MARK = "head";
|
|
3614
3696
|
var MAX_SPLIT_DEPTH = 16;
|
|
@@ -3795,7 +3877,7 @@ var TablePageSplitExtension = Extension5.create({
|
|
|
3795
3877
|
const ext = this;
|
|
3796
3878
|
const editorRef = ext.editor ?? null;
|
|
3797
3879
|
return [
|
|
3798
|
-
new
|
|
3880
|
+
new Plugin4({
|
|
3799
3881
|
key: PLUGIN_KEY,
|
|
3800
3882
|
view(_editorView) {
|
|
3801
3883
|
viewRef = _editorView;
|
|
@@ -3827,15 +3909,15 @@ var TablePageSplitExtension = Extension5.create({
|
|
|
3827
3909
|
];
|
|
3828
3910
|
}
|
|
3829
3911
|
});
|
|
3830
|
-
var tablePageSplitPlugin =
|
|
3912
|
+
var tablePageSplitPlugin = definePlugin22({
|
|
3831
3913
|
id: "tablePageSplit",
|
|
3832
3914
|
tiptapExtensions: [TablePageSplitExtension]
|
|
3833
3915
|
});
|
|
3834
3916
|
|
|
3835
3917
|
// src/slashMenu.ts
|
|
3836
3918
|
import { Extension as Extension6 } from "@tiptap/core";
|
|
3837
|
-
import { Plugin as
|
|
3838
|
-
import { definePlugin as
|
|
3919
|
+
import { Plugin as Plugin5, PluginKey as PluginKey4 } from "@tiptap/pm/state";
|
|
3920
|
+
import { definePlugin as definePlugin23 } from "@kedataindo/docflow-core";
|
|
3839
3921
|
var slashState = {
|
|
3840
3922
|
open: false,
|
|
3841
3923
|
query: "",
|
|
@@ -3893,7 +3975,7 @@ var SlashMenuExtension = Extension6.create({
|
|
|
3893
3975
|
name: "slashMenu",
|
|
3894
3976
|
addProseMirrorPlugins() {
|
|
3895
3977
|
return [
|
|
3896
|
-
new
|
|
3978
|
+
new Plugin5({
|
|
3897
3979
|
key: new PluginKey4("slashMenu"),
|
|
3898
3980
|
props: {
|
|
3899
3981
|
handleTextInput(view, from, _to, text) {
|
|
@@ -3980,7 +4062,7 @@ var SlashMenuExtension = Extension6.create({
|
|
|
3980
4062
|
];
|
|
3981
4063
|
}
|
|
3982
4064
|
});
|
|
3983
|
-
var slashMenuPlugin =
|
|
4065
|
+
var slashMenuPlugin = definePlugin23({
|
|
3984
4066
|
id: "slash-menu",
|
|
3985
4067
|
tiptapExtensions: [SlashMenuExtension],
|
|
3986
4068
|
hooks: {
|
|
@@ -4008,6 +4090,7 @@ var defaultPlugins = [
|
|
|
4008
4090
|
footnotePlugin,
|
|
4009
4091
|
tocPlugin,
|
|
4010
4092
|
fontSizePlugin,
|
|
4093
|
+
fontFamilyPlugin,
|
|
4011
4094
|
textColorPlugin,
|
|
4012
4095
|
highlightPlugin,
|
|
4013
4096
|
citationPlugin,
|
|
@@ -4029,6 +4112,7 @@ export {
|
|
|
4029
4112
|
DateChipNode,
|
|
4030
4113
|
DropdownChipNode,
|
|
4031
4114
|
FileChipNode,
|
|
4115
|
+
FontFamilyExtension,
|
|
4032
4116
|
FontSizeExtension,
|
|
4033
4117
|
FootnoteNode,
|
|
4034
4118
|
LocationChipNode,
|
|
@@ -4057,6 +4141,7 @@ export {
|
|
|
4057
4141
|
commentPlugin,
|
|
4058
4142
|
createPlaceholderPlugin,
|
|
4059
4143
|
defaultPlugins,
|
|
4144
|
+
fontFamilyPlugin,
|
|
4060
4145
|
fontSizePlugin,
|
|
4061
4146
|
footnotePlugin,
|
|
4062
4147
|
formattingPlugin,
|
|
@@ -4079,6 +4164,7 @@ export {
|
|
|
4079
4164
|
rejectAllSuggestions,
|
|
4080
4165
|
rejectSuggestion,
|
|
4081
4166
|
sanitizeCiteprocHtml,
|
|
4167
|
+
scrollEditorToPos,
|
|
4082
4168
|
setDocumentMode,
|
|
4083
4169
|
setSuggestionAuthor,
|
|
4084
4170
|
slashMenuPlugin,
|
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.92",
|
|
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.87"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
37
|
"@tiptap/core": "^2.11.0",
|