@aicayzer/inkkit 0.0.17 → 0.1.0
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/NOTICE +4 -2
- package/README.md +12 -6
- package/dist/THIRD-PARTY-NOTICES.txt +2742 -0
- package/dist/chunks/core-vtCr4MBS.js +56503 -0
- package/dist/chunks/highlight-Daj2fv_u.js +14122 -0
- package/dist/core.d.ts +4 -0
- package/dist/core.js +2 -0
- package/dist/editor.d.ts +261 -48
- package/dist/index.d.ts +1 -7
- package/dist/index.js +5 -2
- package/dist/style.css +242 -221
- package/dist/types.d.ts +143 -18
- package/package.json +26 -15
- package/dist/autolink.d.ts +0 -1
- package/dist/autolink.js +0 -18
- package/dist/callouts.d.ts +0 -26
- package/dist/callouts.js +0 -311
- package/dist/clipboard.d.ts +0 -11
- package/dist/clipboard.js +0 -261
- package/dist/code-fences.d.ts +0 -8
- package/dist/code-fences.js +0 -166
- package/dist/comments.d.ts +0 -55
- package/dist/comments.js +0 -494
- package/dist/decorations.d.ts +0 -2
- package/dist/decorations.js +0 -67
- package/dist/dialect.d.ts +0 -9
- package/dist/dialect.js +0 -358
- package/dist/editor.js +0 -2441
- package/dist/files.d.ts +0 -40
- package/dist/files.js +0 -133
- package/dist/highlight.d.ts +0 -1
- package/dist/highlight.js +0 -136
- package/dist/image-blocks.d.ts +0 -71
- package/dist/image-blocks.js +0 -286
- package/dist/images.d.ts +0 -51
- package/dist/images.js +0 -398
- package/dist/inline-highlight.d.ts +0 -6
- package/dist/inline-highlight.js +0 -112
- package/dist/labels.d.ts +0 -36
- package/dist/labels.js +0 -34
- package/dist/linked-syntax.d.ts +0 -48
- package/dist/linked-syntax.js +0 -320
- package/dist/literals.d.ts +0 -19
- package/dist/literals.js +0 -211
- package/dist/mermaid.d.ts +0 -8
- package/dist/mermaid.js +0 -321
- package/dist/outline.d.ts +0 -22
- package/dist/outline.js +0 -79
- package/dist/paste-html.d.ts +0 -23
- package/dist/paste-html.js +0 -441
- package/dist/paste.d.ts +0 -26
- package/dist/paste.js +0 -482
- package/dist/portable-files.d.ts +0 -10
- package/dist/portable-files.js +0 -36
- package/dist/preserve.d.ts +0 -21
- package/dist/preserve.js +0 -757
- package/dist/print.d.ts +0 -7
- package/dist/print.js +0 -409
- package/dist/reference-clipboard.d.ts +0 -8
- package/dist/reference-clipboard.js +0 -201
- package/dist/references.d.ts +0 -14
- package/dist/references.js +0 -368
- package/dist/search.d.ts +0 -15
- package/dist/search.js +0 -202
- package/dist/selection.d.ts +0 -1
- package/dist/selection.js +0 -59
- package/dist/source.d.ts +0 -16
- package/dist/source.js +0 -57
- package/dist/spreadsheet.d.ts +0 -3
- package/dist/spreadsheet.js +0 -275
- package/dist/table-alignment.d.ts +0 -2
- package/dist/table-alignment.js +0 -46
- package/dist/tables.d.ts +0 -27
- package/dist/tables.js +0 -322
- package/dist/tasks.d.ts +0 -3
- package/dist/tasks.js +0 -51
- package/dist/text-ranges.d.ts +0 -29
- package/dist/text-ranges.js +0 -256
- package/dist/types.js +0 -8
- package/dist/wiki-view.d.ts +0 -21
- package/dist/wiki-view.js +0 -78
package/dist/code-fences.js
DELETED
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
import { codeBlockSchema } from '@milkdown/kit/preset/commonmark';
|
|
2
|
-
import { $remark } from '@milkdown/kit/utils';
|
|
3
|
-
import { defaultHandlers } from 'mdast-util-to-markdown';
|
|
4
|
-
import { remarkCtx } from '@milkdown/kit/core';
|
|
5
|
-
function readFence(value) {
|
|
6
|
-
if (typeof value !== 'object' || value == null)
|
|
7
|
-
return null;
|
|
8
|
-
const fence = value;
|
|
9
|
-
return typeof fence.marker === 'string' &&
|
|
10
|
-
/^(?:`{3,}|~{3,})$/.test(fence.marker) &&
|
|
11
|
-
fence.marker.length <= 30000 &&
|
|
12
|
-
typeof fence.info === 'string' &&
|
|
13
|
-
!/[\r\n]/.test(fence.info) &&
|
|
14
|
-
typeof fence.close === 'string' &&
|
|
15
|
-
(!fence.close ||
|
|
16
|
-
new RegExp(`^${fence.marker[0]}{${fence.marker.length},}$`).test(fence.close)) &&
|
|
17
|
-
typeof fence.trailing === 'string' &&
|
|
18
|
-
/^[ \t]*$/.test(fence.trailing) &&
|
|
19
|
-
['\n', '\r\n'].includes(fence.ending)
|
|
20
|
-
? fence
|
|
21
|
-
: null;
|
|
22
|
-
}
|
|
23
|
-
export const remarkCodeFences = $remark('codeFences', () => () => (tree, file) => {
|
|
24
|
-
const source = String(file.value).replace(/^\uFEFF/, '');
|
|
25
|
-
const visit = (node) => {
|
|
26
|
-
if (node.type === 'code') {
|
|
27
|
-
const raw = source.slice(node.position?.start.offset, node.position?.end.offset);
|
|
28
|
-
const opening = /^(`{3,}|~{3,})([^\r\n]*)(\r?\n)/.exec(raw);
|
|
29
|
-
if (opening) {
|
|
30
|
-
const close = /(?:^|\n)[ \t>]*(`{3,}|~{3,})([ \t]*)\r?$/.exec(raw);
|
|
31
|
-
const matching = close &&
|
|
32
|
-
close[1][0] === opening[1][0] &&
|
|
33
|
-
close[1].length >= opening[1].length;
|
|
34
|
-
node.data = {
|
|
35
|
-
...node.data,
|
|
36
|
-
inkkitFence: {
|
|
37
|
-
marker: opening[1],
|
|
38
|
-
info: opening[2],
|
|
39
|
-
close: matching ? close[1] : '',
|
|
40
|
-
trailing: matching ? close[2] : '',
|
|
41
|
-
ending: opening[3],
|
|
42
|
-
},
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
if ('children' in node)
|
|
47
|
-
node.children.forEach(visit);
|
|
48
|
-
};
|
|
49
|
-
visit(tree);
|
|
50
|
-
});
|
|
51
|
-
export const preservingCodeBlocks = codeBlockSchema.extendSchema((base) => (ctx) => {
|
|
52
|
-
const schema = base(ctx);
|
|
53
|
-
return {
|
|
54
|
-
...schema,
|
|
55
|
-
attrs: { ...schema.attrs, authoredFence: { default: null } },
|
|
56
|
-
parseDOM: [
|
|
57
|
-
{
|
|
58
|
-
tag: 'pre',
|
|
59
|
-
preserveWhitespace: 'full',
|
|
60
|
-
getAttrs: (dom) => {
|
|
61
|
-
let authoredFence = null;
|
|
62
|
-
try {
|
|
63
|
-
authoredFence = readFence(JSON.parse(dom.getAttribute('data-inkkit-fence') ?? 'null'));
|
|
64
|
-
}
|
|
65
|
-
catch {
|
|
66
|
-
/* Ordinary code stays usable without provenance. */
|
|
67
|
-
}
|
|
68
|
-
return { language: dom.dataset.language ?? '', authoredFence };
|
|
69
|
-
},
|
|
70
|
-
},
|
|
71
|
-
],
|
|
72
|
-
toDOM: (node) => [
|
|
73
|
-
'pre',
|
|
74
|
-
{
|
|
75
|
-
'data-language': node.attrs.language,
|
|
76
|
-
...(node.attrs.authoredFence
|
|
77
|
-
? { 'data-inkkit-fence': JSON.stringify(node.attrs.authoredFence) }
|
|
78
|
-
: {}),
|
|
79
|
-
},
|
|
80
|
-
['code', 0],
|
|
81
|
-
],
|
|
82
|
-
parseMarkdown: {
|
|
83
|
-
match: (node) => node.type === 'code',
|
|
84
|
-
runner: (state, node, type) => {
|
|
85
|
-
state.openNode(type, {
|
|
86
|
-
language: node.lang ?? '',
|
|
87
|
-
authoredFence: readFence(node.data?.inkkitFence),
|
|
88
|
-
});
|
|
89
|
-
if (node.value)
|
|
90
|
-
state.addText(String(node.value).replace(/\r\n?/g, '\n'));
|
|
91
|
-
state.closeNode();
|
|
92
|
-
},
|
|
93
|
-
},
|
|
94
|
-
toMarkdown: {
|
|
95
|
-
match: (node) => node.type.name === 'code_block',
|
|
96
|
-
runner: (state, node) => {
|
|
97
|
-
state.addNode('code', undefined, node.textContent, {
|
|
98
|
-
lang: node.attrs.language,
|
|
99
|
-
data: { inkkitFence: node.attrs.authoredFence },
|
|
100
|
-
});
|
|
101
|
-
},
|
|
102
|
-
},
|
|
103
|
-
};
|
|
104
|
-
});
|
|
105
|
-
export const fencedCodeHandler = (node, parent, state, info) => {
|
|
106
|
-
const fence = readFence(node.data?.inkkitFence);
|
|
107
|
-
if (!fence)
|
|
108
|
-
return defaultHandlers.code(node, parent, state, info);
|
|
109
|
-
const character = fence.marker[0];
|
|
110
|
-
let length = fence.marker.length;
|
|
111
|
-
const body = node.value.replace(/\r\n?/g, '\n');
|
|
112
|
-
for (const line of body.split('\n')) {
|
|
113
|
-
const run = new RegExp(`^ {0,3}(${character}+)[ \\t]*$`).exec(line);
|
|
114
|
-
if (run)
|
|
115
|
-
length = Math.max(length, run[1].length + 1);
|
|
116
|
-
}
|
|
117
|
-
const close = fence.close
|
|
118
|
-
? character.repeat(Math.max(length, fence.close.length)) + fence.trailing
|
|
119
|
-
: '';
|
|
120
|
-
return (character.repeat(length) +
|
|
121
|
-
fence.info +
|
|
122
|
-
fence.ending +
|
|
123
|
-
body.replaceAll('\n', fence.ending) +
|
|
124
|
-
(close ? (body ? fence.ending : '') + close : ''));
|
|
125
|
-
};
|
|
126
|
-
export function restoreCodeEndings(ctx, doc, markdown) {
|
|
127
|
-
const endings = [];
|
|
128
|
-
doc.descendants((node) => {
|
|
129
|
-
if (node.type.name === 'code_block')
|
|
130
|
-
endings.push(readFence(node.attrs.authoredFence)?.ending ?? '\n');
|
|
131
|
-
});
|
|
132
|
-
const patches = [];
|
|
133
|
-
let index = 0;
|
|
134
|
-
const visit = (node) => {
|
|
135
|
-
if (node.type === 'code') {
|
|
136
|
-
const ending = endings[index++];
|
|
137
|
-
const from = node.position?.start.offset, to = node.position?.end.offset;
|
|
138
|
-
if (ending === '\r\n' && from != null && to != null)
|
|
139
|
-
patches.push({
|
|
140
|
-
from,
|
|
141
|
-
to,
|
|
142
|
-
text: markdown
|
|
143
|
-
.slice(from, to)
|
|
144
|
-
.replace(/\r\n?/g, '\n')
|
|
145
|
-
.replaceAll('\n', ending),
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
if ('children' in node)
|
|
149
|
-
node.children.forEach(visit);
|
|
150
|
-
};
|
|
151
|
-
const processor = ctx.get(remarkCtx);
|
|
152
|
-
visit(processor.runSync(processor.parse(markdown), { value: markdown }));
|
|
153
|
-
for (const patch of patches.reverse())
|
|
154
|
-
markdown =
|
|
155
|
-
markdown.slice(0, patch.from) + patch.text + markdown.slice(patch.to);
|
|
156
|
-
return markdown;
|
|
157
|
-
}
|
|
158
|
-
export function finalCodeEnding(doc) {
|
|
159
|
-
let last = doc.lastChild;
|
|
160
|
-
while (last) {
|
|
161
|
-
if (last.type.name === 'code_block')
|
|
162
|
-
return readFence(last.attrs.authoredFence)?.ending;
|
|
163
|
-
last = last.lastChild;
|
|
164
|
-
}
|
|
165
|
-
return undefined;
|
|
166
|
-
}
|
package/dist/comments.d.ts
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { Fragment, type Node as ProseNode } from '@milkdown/kit/prose/model';
|
|
2
|
-
import type { EditorView } from '@milkdown/kit/prose/view';
|
|
3
|
-
import type { Literal } from 'mdast';
|
|
4
|
-
export type CommentSyntax = 'html' | 'obsidian';
|
|
5
|
-
interface Comment extends Literal {
|
|
6
|
-
type: 'inkkitCommentInline' | 'inkkitCommentBlock';
|
|
7
|
-
syntax: CommentSyntax;
|
|
8
|
-
block?: boolean;
|
|
9
|
-
}
|
|
10
|
-
declare module 'mdast' {
|
|
11
|
-
interface PhrasingContentMap {
|
|
12
|
-
inkkitCommentInline: Comment & {
|
|
13
|
-
type: 'inkkitCommentInline';
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
interface BlockContentMap {
|
|
17
|
-
inkkitCommentBlock: Comment & {
|
|
18
|
-
type: 'inkkitCommentBlock';
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
interface RootContentMap {
|
|
22
|
-
inkkitCommentInline: Comment & {
|
|
23
|
-
type: 'inkkitCommentInline';
|
|
24
|
-
};
|
|
25
|
-
inkkitCommentBlock: Comment & {
|
|
26
|
-
type: 'inkkitCommentBlock';
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
declare module 'micromark-util-types' {
|
|
31
|
-
interface TokenTypeMap {
|
|
32
|
-
inkkitCommentInline: 'inkkitCommentInline';
|
|
33
|
-
inkkitCommentBlock: 'inkkitCommentBlock';
|
|
34
|
-
inkkitCommentData: 'inkkitCommentData';
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
export declare function commentSource(node: ProseNode): string;
|
|
38
|
-
export interface CommentSpan {
|
|
39
|
-
start: number;
|
|
40
|
-
end: number;
|
|
41
|
-
syntax: CommentSyntax;
|
|
42
|
-
value: string;
|
|
43
|
-
block?: boolean;
|
|
44
|
-
}
|
|
45
|
-
export declare function literalCommentSpans(value: string): CommentSpan[];
|
|
46
|
-
export declare const remarkCommentsPlugin: import("@milkdown/kit/utils").$Remark<"remarkComments", unknown>;
|
|
47
|
-
export declare const commentInline: import("@milkdown/kit/utils").$Node;
|
|
48
|
-
export declare const commentBlock: import("@milkdown/kit/utils").$Node;
|
|
49
|
-
export declare const commentVisibility: import("@milkdown/kit/utils").$Prose;
|
|
50
|
-
export declare function setCommentVisibility(view: EditorView, visible: boolean): void;
|
|
51
|
-
export declare const comments: (import("@milkdown/kit/utils").$Node | import("@milkdown/kit/utils").$Prose)[];
|
|
52
|
-
export declare function isComment(node: ProseNode): boolean;
|
|
53
|
-
export declare function shareableFragment(content: Fragment): Fragment;
|
|
54
|
-
export declare function commentSelectionContent(doc: ProseNode, from: number, to: number, content: Fragment): Fragment;
|
|
55
|
-
export {};
|