@aicayzer/inkkit 0.0.10 → 0.0.11
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/README.md +4 -2
- package/dist/editor.d.ts +5 -0
- package/dist/editor.js +42 -15
- package/dist/mermaid.js +1 -1
- package/dist/style.css +2 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -39,12 +39,14 @@ editor.loadDocument({
|
|
|
39
39
|
const snapshot = editor.snapshot(1)
|
|
40
40
|
```
|
|
41
41
|
|
|
42
|
-
InkKit runs on the web and in offline web views. Hosts use its public TypeScript facade and own toolbars, menus, persistence, clipboard bridges, Print/PDF actions and image storage. Images require an adapter; private references stay opaque. TXT stays literal. RTF
|
|
42
|
+
InkKit runs on the web and in offline web views. Hosts use its public TypeScript facade and own toolbars, menus, persistence, clipboard bridges, Print/PDF actions and image storage. Images require an adapter; private references stay opaque. TXT stays literal. RTF document editing is outside current support.
|
|
43
43
|
|
|
44
44
|
Start with the [feature guide](docs/supported-syntax.md) and [simple and rich integration examples](docs/integration.md). The [documentation index](docs/README.md) links to precise API, preservation, playground, verification and publication guidance.
|
|
45
45
|
|
|
46
|
-
Scope and release status live in the [InkKit Project](https://github.com/users/aicayzer/projects/3) and [version milestones](https://github.com/aicayzer/inkkit/milestones).
|
|
46
|
+
Scope and release status live in the [InkKit Project](https://github.com/users/aicayzer/projects/3) and [version milestones](https://github.com/aicayzer/inkkit/milestones). Only documented, released features form the supported package contract.
|
|
47
47
|
|
|
48
48
|
MIT licensed. InkKit builds on the public PadPad and Memos editors; see [NOTICE](NOTICE).
|
|
49
49
|
|
|
50
50
|
Optional wiki links and a host-owned asynchronous file adapter support named/path images, audio, video, PDFs and file cards. Authored source and sizing are preserved; portable copy/print uses validated images or documented descriptive fallbacks. See [linked syntax](docs/supported-syntax.md#linked-syntax) and [adapter contracts](docs/api.md#optional-wiki-links-and-files).
|
|
51
|
+
|
|
52
|
+
From 0.0.11, minimal hosts can mount with `rendering: { codeHighlighting: false, diagramPreview: false }` to skip optional presentation work. Source, shared history and explicit portable exports retain their contracts. Mermaid loads on first actual render. Single-file offline bundles still contain the rendering code; see [performance measurements](docs/performance.md).
|
package/dist/editor.d.ts
CHANGED
|
@@ -40,6 +40,10 @@ export interface EditorOptions {
|
|
|
40
40
|
textInput?: TextInputPreferences;
|
|
41
41
|
labels?: Partial<EditorLabels>;
|
|
42
42
|
keymap?: Keymap;
|
|
43
|
+
rendering?: {
|
|
44
|
+
codeHighlighting?: boolean;
|
|
45
|
+
diagramPreview?: boolean;
|
|
46
|
+
};
|
|
43
47
|
}
|
|
44
48
|
export interface CommandState {
|
|
45
49
|
documentId: string;
|
|
@@ -98,6 +102,7 @@ export declare class InkKitEditor {
|
|
|
98
102
|
private beforePlainInput?;
|
|
99
103
|
private mode;
|
|
100
104
|
private sourcePreservations;
|
|
105
|
+
private sourceTexts;
|
|
101
106
|
private outlineEpoch;
|
|
102
107
|
private ready;
|
|
103
108
|
private destroyed;
|
package/dist/editor.js
CHANGED
|
@@ -26,7 +26,6 @@ import { withFileSignal } from './files.js';
|
|
|
26
26
|
import { tablePlugins, tableCommand, tableCommands, tableAvailability, tableContext, configureTableMovement, } from './tables.js';
|
|
27
27
|
import { InkKitError, } from './types.js';
|
|
28
28
|
import { readableProjection, projectionPosition, projectionOffset, validateOffsets, formattedRects, literalRects, literalVisibleRanges, intersectsViewport, textRect, } from './text-ranges.js';
|
|
29
|
-
import { highlightPlugin } from './highlight.js';
|
|
30
29
|
import { highlightKeymap, toggleHighlightCommand } from './inline-highlight.js';
|
|
31
30
|
import { commentSelectionContent, setCommentVisibility } from './comments.js';
|
|
32
31
|
import { PasteController } from './paste.js';
|
|
@@ -260,6 +259,7 @@ export class InkKitEditor {
|
|
|
260
259
|
beforePlainInput;
|
|
261
260
|
mode = 'formatted';
|
|
262
261
|
sourcePreservations = new WeakMap();
|
|
262
|
+
sourceTexts = new WeakMap();
|
|
263
263
|
outlineEpoch = 0;
|
|
264
264
|
ready = false;
|
|
265
265
|
destroyed = false;
|
|
@@ -602,6 +602,9 @@ export class InkKitEditor {
|
|
|
602
602
|
return this.literalSurface ? 'source' : 'formatted';
|
|
603
603
|
}
|
|
604
604
|
currentText(doc = this.editor.ctx.get(editorViewCtx).state.doc) {
|
|
605
|
+
const cached = this.sourceTexts.get(doc);
|
|
606
|
+
if (cached !== undefined)
|
|
607
|
+
return cached;
|
|
605
608
|
const provenance = doc.attrs[sourceAttribute];
|
|
606
609
|
if (this.formatType === 'txt')
|
|
607
610
|
return provenance?.text ?? this.originalSource;
|
|
@@ -613,7 +616,9 @@ export class InkKitEditor {
|
|
|
613
616
|
this.sourcePreservations.set(provenance, preservation);
|
|
614
617
|
}
|
|
615
618
|
}
|
|
616
|
-
|
|
619
|
+
const text = preservation.serialize(cleanSourceDoc(doc));
|
|
620
|
+
this.sourceTexts.set(doc, text);
|
|
621
|
+
return text;
|
|
617
622
|
}
|
|
618
623
|
setEditingMode(mode, expectedGeneration) {
|
|
619
624
|
this.assertCurrent(expectedGeneration);
|
|
@@ -899,28 +904,41 @@ export class InkKitEditor {
|
|
|
899
904
|
}
|
|
900
905
|
else {
|
|
901
906
|
const { schema } = view.state;
|
|
907
|
+
const marks = view.state.storedMarks ??
|
|
908
|
+
(view.state.selection.empty
|
|
909
|
+
? view.state.selection.$from.marks()
|
|
910
|
+
: view.state.selection.$from.marksAcross(view.state.selection.$to)) ??
|
|
911
|
+
[];
|
|
902
912
|
const children = [];
|
|
903
|
-
text
|
|
904
|
-
|
|
905
|
-
.
|
|
906
|
-
.forEach((line, index) => {
|
|
913
|
+
const lines = text.replace(/\r\n?/g, '\n').split('\n');
|
|
914
|
+
lines.forEach((line, index) => {
|
|
915
|
+
const finalBreak = index === lines.length - 1 && line === '';
|
|
907
916
|
if (index)
|
|
908
917
|
children.push(schema.nodes.hardbreak.create({
|
|
909
|
-
isHTML:
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
918
|
+
isHTML: finalBreak,
|
|
919
|
+
}, null,
|
|
920
|
+
// A terminal HTML spacer must remain outside emphasis to reopen as a break.
|
|
921
|
+
finalBreak ? [] : marks));
|
|
913
922
|
if (line)
|
|
914
|
-
children.push(schema.text(line));
|
|
923
|
+
children.push(schema.text(line, marks));
|
|
915
924
|
});
|
|
916
925
|
if (!children.length) {
|
|
917
926
|
view.dispatch(view.state.tr.deleteSelection());
|
|
918
927
|
return;
|
|
919
928
|
}
|
|
920
929
|
const paragraph = schema.nodes.paragraph.create(null, children);
|
|
921
|
-
view.
|
|
930
|
+
const transaction = view.state.tr
|
|
922
931
|
.replaceSelection(new Slice(Fragment.from(paragraph), 1, 1))
|
|
923
|
-
.scrollIntoView()
|
|
932
|
+
.scrollIntoView();
|
|
933
|
+
try {
|
|
934
|
+
this.currentText(transaction.doc);
|
|
935
|
+
}
|
|
936
|
+
catch (error) {
|
|
937
|
+
throw new InkKitError('preservation', error instanceof Error
|
|
938
|
+
? error.message
|
|
939
|
+
: 'Cannot preserve inserted text');
|
|
940
|
+
}
|
|
941
|
+
view.dispatch(transaction);
|
|
924
942
|
}
|
|
925
943
|
}
|
|
926
944
|
}
|
|
@@ -1096,8 +1114,12 @@ export class InkKitEditor {
|
|
|
1096
1114
|
.use(dropControlCharacters)
|
|
1097
1115
|
.use(codeCopyPlugin((text) => events.copy(text)))
|
|
1098
1116
|
.use(placeholderPlugin)
|
|
1099
|
-
.use(
|
|
1100
|
-
|
|
1117
|
+
.use(options.rendering?.codeHighlighting === false
|
|
1118
|
+
? []
|
|
1119
|
+
: (await import('./highlight')).highlightPlugin)
|
|
1120
|
+
.use(options.rendering?.diagramPreview === false
|
|
1121
|
+
? []
|
|
1122
|
+
: mermaidPreview((error) => events.error?.(error)))
|
|
1101
1123
|
.use(selectionPlugin)
|
|
1102
1124
|
.use($prose(() => search()))
|
|
1103
1125
|
.use(instance.policyPlugin)
|
|
@@ -1362,6 +1384,7 @@ export class InkKitEditor {
|
|
|
1362
1384
|
this.documentEpoch += 1;
|
|
1363
1385
|
this.outlineEpoch += 1;
|
|
1364
1386
|
this.sourcePreservations = new WeakMap();
|
|
1387
|
+
this.sourceTexts = new WeakMap();
|
|
1365
1388
|
this.mode = 'formatted';
|
|
1366
1389
|
this.plainComposing = false;
|
|
1367
1390
|
this.beforePlainInput = undefined;
|
|
@@ -1878,6 +1901,10 @@ export class InkKitEditor {
|
|
|
1878
1901
|
this.replaceLiteralSelection(text, false);
|
|
1879
1902
|
return true;
|
|
1880
1903
|
}
|
|
1904
|
+
if (/[\r\n]/.test(text)) {
|
|
1905
|
+
this.pasteAsPlainText(text);
|
|
1906
|
+
return true;
|
|
1907
|
+
}
|
|
1881
1908
|
const view = this.editor.ctx.get(editorViewCtx);
|
|
1882
1909
|
if (view.composing)
|
|
1883
1910
|
return false;
|
package/dist/mermaid.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { editorLabels } from './labels.js';
|
|
2
|
-
import mermaid from 'mermaid';
|
|
3
2
|
import DOMPurify from 'dompurify';
|
|
4
3
|
import { Plugin, PluginKey } from '@milkdown/kit/prose/state';
|
|
5
4
|
import { Decoration, DecorationSet } from '@milkdown/kit/prose/view';
|
|
@@ -56,6 +55,7 @@ export function renderDiagram(source) {
|
|
|
56
55
|
if (previous)
|
|
57
56
|
return previous;
|
|
58
57
|
const rendered = queue.then(async () => {
|
|
58
|
+
const { default: mermaid } = await import('mermaid');
|
|
59
59
|
mermaid.initialize({
|
|
60
60
|
startOnLoad: false,
|
|
61
61
|
securityLevel: 'strict',
|
package/dist/style.css
CHANGED
|
@@ -719,7 +719,7 @@
|
|
|
719
719
|
display: none;
|
|
720
720
|
}
|
|
721
721
|
|
|
722
|
-
.inkkit-root[data-inkkit-comments-visible='true'] .inkkit-comment {
|
|
722
|
+
.inkkit-root [data-inkkit-comments-visible='true'] .inkkit-comment {
|
|
723
723
|
display: inline;
|
|
724
724
|
white-space: pre-wrap;
|
|
725
725
|
font-family: var(--_inkkit-mono);
|
|
@@ -727,7 +727,7 @@
|
|
|
727
727
|
background: var(--_inkkit-code-bg);
|
|
728
728
|
}
|
|
729
729
|
|
|
730
|
-
.inkkit-root[data-inkkit-comments-visible='true'] .inkkit-comment-block {
|
|
730
|
+
.inkkit-root [data-inkkit-comments-visible='true'] .inkkit-comment-block {
|
|
731
731
|
display: block;
|
|
732
732
|
padding: calc(var(--inkkit-font-size, 15px) * 0.5);
|
|
733
733
|
}
|
|
@@ -746,7 +746,6 @@
|
|
|
746
746
|
}
|
|
747
747
|
|
|
748
748
|
.inkkit-root .inkkit-comment,
|
|
749
|
-
.inkkit-root[data-inkkit-comments-visible='true'] .inkkit-comment,
|
|
750
749
|
.inkkit-root [data-inkkit-callout-toggle],
|
|
751
750
|
.inkkit-root .ProseMirror pre .copy,
|
|
752
751
|
.inkkit-root .milkdown-table-block .handle,
|