@jvs-milkdown/crepe 1.2.13 → 1.2.14
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/lib/cjs/builder.js +41 -2
- package/lib/cjs/builder.js.map +1 -1
- package/lib/cjs/feature/block-edit/index.js +9 -2
- package/lib/cjs/feature/block-edit/index.js.map +1 -1
- package/lib/cjs/feature/code-mirror/index.js +9 -2
- package/lib/cjs/feature/code-mirror/index.js.map +1 -1
- package/lib/cjs/feature/cursor/index.js +9 -2
- package/lib/cjs/feature/cursor/index.js.map +1 -1
- package/lib/cjs/feature/image-block/index.js +9 -2
- package/lib/cjs/feature/image-block/index.js.map +1 -1
- package/lib/cjs/feature/inline-diff/index.js +1298 -0
- package/lib/cjs/feature/inline-diff/index.js.map +1 -0
- package/lib/cjs/feature/latex/index.js +9 -2
- package/lib/cjs/feature/latex/index.js.map +1 -1
- package/lib/cjs/feature/link-tooltip/index.js +9 -2
- package/lib/cjs/feature/link-tooltip/index.js.map +1 -1
- package/lib/cjs/feature/list-item/index.js +9 -2
- package/lib/cjs/feature/list-item/index.js.map +1 -1
- package/lib/cjs/feature/placeholder/index.js +9 -2
- package/lib/cjs/feature/placeholder/index.js.map +1 -1
- package/lib/cjs/feature/table/index.js +9 -2
- package/lib/cjs/feature/table/index.js.map +1 -1
- package/lib/cjs/feature/toolbar/index.js +14 -6
- package/lib/cjs/feature/toolbar/index.js.map +1 -1
- package/lib/cjs/index.js +1255 -235
- package/lib/cjs/index.js.map +1 -1
- package/lib/esm/builder.js +41 -2
- package/lib/esm/builder.js.map +1 -1
- package/lib/esm/feature/block-edit/index.js +9 -2
- package/lib/esm/feature/block-edit/index.js.map +1 -1
- package/lib/esm/feature/code-mirror/index.js +9 -2
- package/lib/esm/feature/code-mirror/index.js.map +1 -1
- package/lib/esm/feature/cursor/index.js +9 -2
- package/lib/esm/feature/cursor/index.js.map +1 -1
- package/lib/esm/feature/image-block/index.js +9 -2
- package/lib/esm/feature/image-block/index.js.map +1 -1
- package/lib/esm/feature/inline-diff/index.js +1274 -0
- package/lib/esm/feature/inline-diff/index.js.map +1 -0
- package/lib/esm/feature/latex/index.js +9 -2
- package/lib/esm/feature/latex/index.js.map +1 -1
- package/lib/esm/feature/link-tooltip/index.js +9 -2
- package/lib/esm/feature/link-tooltip/index.js.map +1 -1
- package/lib/esm/feature/list-item/index.js +9 -2
- package/lib/esm/feature/list-item/index.js.map +1 -1
- package/lib/esm/feature/placeholder/index.js +9 -2
- package/lib/esm/feature/placeholder/index.js.map +1 -1
- package/lib/esm/feature/table/index.js +9 -2
- package/lib/esm/feature/table/index.js.map +1 -1
- package/lib/esm/feature/toolbar/index.js +14 -6
- package/lib/esm/feature/toolbar/index.js.map +1 -1
- package/lib/esm/index.js +1237 -236
- package/lib/esm/index.js.map +1 -1
- package/lib/theme/common/diff-block.css +41 -0
- package/lib/theme/common/inline-diff.css +142 -0
- package/lib/theme/common/style.css +2 -0
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/types/core/builder.d.ts +2 -0
- package/lib/types/core/builder.d.ts.map +1 -1
- package/lib/types/core/locale.d.ts +4 -0
- package/lib/types/core/locale.d.ts.map +1 -1
- package/lib/types/feature/diff-block/index.d.ts +10 -0
- package/lib/types/feature/diff-block/index.d.ts.map +1 -0
- package/lib/types/feature/fixed-toolbar/index.d.ts.map +1 -1
- package/lib/types/feature/fixed-toolbar/outline-panel.d.ts.map +1 -1
- package/lib/types/feature/index.d.ts +7 -1
- package/lib/types/feature/index.d.ts.map +1 -1
- package/lib/types/feature/inline-diff/change-panel.d.ts +4 -0
- package/lib/types/feature/inline-diff/change-panel.d.ts.map +1 -0
- package/lib/types/feature/inline-diff/config.d.ts +12 -0
- package/lib/types/feature/inline-diff/config.d.ts.map +1 -0
- package/lib/types/feature/inline-diff/diff-engine.d.ts +20 -0
- package/lib/types/feature/inline-diff/diff-engine.d.ts.map +1 -0
- package/lib/types/feature/inline-diff/diff-view.d.ts +2 -0
- package/lib/types/feature/inline-diff/diff-view.d.ts.map +1 -0
- package/lib/types/feature/inline-diff/doc-builder.d.ts +21 -0
- package/lib/types/feature/inline-diff/doc-builder.d.ts.map +1 -0
- package/lib/types/feature/inline-diff/index.d.ts +9 -0
- package/lib/types/feature/inline-diff/index.d.ts.map +1 -0
- package/lib/types/feature/loader.d.ts.map +1 -1
- package/lib/types/feature/toolbar/component.d.ts.map +1 -1
- package/package.json +15 -4
- package/src/core/builder.ts +19 -0
- package/src/core/locale.ts +7 -0
- package/src/feature/diff-block/index.ts +48 -0
- package/src/feature/fixed-toolbar/index.ts +58 -23
- package/src/feature/fixed-toolbar/outline-panel.tsx +3 -2
- package/src/feature/index.ts +12 -0
- package/src/feature/inline-diff/change-panel.ts +280 -0
- package/src/feature/inline-diff/config.ts +28 -0
- package/src/feature/inline-diff/diff-engine.ts +181 -0
- package/src/feature/inline-diff/diff-view.ts +2 -0
- package/src/feature/inline-diff/doc-builder.ts +139 -0
- package/src/feature/inline-diff/index.ts +514 -0
- package/src/feature/loader.ts +8 -0
- package/src/feature/toolbar/component.tsx +3 -2
- package/src/theme/common/diff-block.css +43 -0
- package/src/theme/common/inline-diff.css +148 -0
- package/src/theme/common/style.css +2 -0
|
@@ -23,6 +23,8 @@ export declare class CrepeBuilder {
|
|
|
23
23
|
get readonly(): boolean;
|
|
24
24
|
setReadonly: (value: boolean) => this;
|
|
25
25
|
getMarkdown: () => string;
|
|
26
|
+
showDiff: (oldMarkdown: string, newMarkdown: string) => this;
|
|
27
|
+
hideDiff: () => this;
|
|
26
28
|
on: (fn: (api: ListenerManager) => void) => this;
|
|
27
29
|
}
|
|
28
30
|
//# sourceMappingURL=builder.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builder.d.ts","sourceRoot":"","sources":["../../../src/core/builder.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,YAAY,EAEjB,MAAM,EAKP,MAAM,wBAAwB,CAAA;AAI/B,OAAO,EA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,MAAM,CAAC,EAAE,CAAC,GAAG,YAAY,CAAA;KACzD,CAGA;IAGD,MAAM,wBAEL;IAGD,OAAO,wBAEN;IAGD,IAAI,MAAM,IAAI,MAAM,CAEnB;IAGD,IAAI,QAAQ,YAEX;IAGD,WAAW,GAAI,OAAO,OAAO,UAW5B;IAGD,WAAW,eAEV;IAGD,QAAQ,GAAI,aAAa,MAAM,EAAE,aAAa,MAAM,UAMnD;IAGD,QAAQ,aAMP;IAGD,EAAE,GAAI,IAAI,CAAC,GAAG,EAAE,eAAe,KAAK,IAAI,UAavC;CACF"}
|
|
@@ -140,6 +140,8 @@ export declare const zhCN: {
|
|
|
140
140
|
'shortcuts.history': string;
|
|
141
141
|
'shortcuts.undo': string;
|
|
142
142
|
'shortcuts.redo': string;
|
|
143
|
+
'inlineDiff.accept': string;
|
|
144
|
+
'inlineDiff.reject': string;
|
|
143
145
|
};
|
|
144
146
|
export declare const enUS: typeof zhCN;
|
|
145
147
|
export type CrepeTranslations = typeof zhCN;
|
|
@@ -284,6 +286,8 @@ export declare const translationsCtx: import("@jvs-milkdown/ctx").SliceType<Reco
|
|
|
284
286
|
'shortcuts.history': string;
|
|
285
287
|
'shortcuts.undo': string;
|
|
286
288
|
'shortcuts.redo': string;
|
|
289
|
+
'inlineDiff.accept': string;
|
|
290
|
+
'inlineDiff.reject': string;
|
|
287
291
|
}>>, string>;
|
|
288
292
|
export declare const localeCtx: import("@jvs-milkdown/ctx").SliceType<string, "localeCtx">;
|
|
289
293
|
export declare function i18n(ctx: Ctx, key: keyof CrepeTranslations): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"locale.d.ts","sourceRoot":"","sources":["../../../src/core/locale.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAA;AAIhD,eAAO,MAAM,IAAI
|
|
1
|
+
{"version":3,"file":"locale.d.ts","sourceRoot":"","sources":["../../../src/core/locale.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAA;AAIhD,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+KhB,CAAA;AAED,eAAO,MAAM,IAAI,EAAE,OAAO,IA+JzB,CAAA;AAED,MAAM,MAAM,iBAAiB,GAAG,OAAO,IAAI,CAAA;AAE3C,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAQ3B,CAAA;AAED,eAAO,MAAM,SAAS,4DAAoC,CAAA;AAE1D,wBAAgB,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,iBAAiB,GAAG,MAAM,CASnE"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Extension } from '@codemirror/state';
|
|
2
|
+
import { type DiffBlockConfig } from '@jvs-milkdown/kit/component/diff-block';
|
|
3
|
+
import type { DefineFeature } from '../shared';
|
|
4
|
+
interface DiffBlockConfigCustom extends Omit<DiffBlockConfig, 'theme'> {
|
|
5
|
+
theme: Extension;
|
|
6
|
+
}
|
|
7
|
+
export type DiffBlockFeatureConfig = Partial<DiffBlockConfigCustom>;
|
|
8
|
+
export declare const diffBlockFeature: DefineFeature<DiffBlockFeatureConfig>;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/feature/diff-block/index.ts"],"names":[],"mappings":"AAAA,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AAG,OAAO,CAAC,kBAAkB,CAAC,CAAA;AAEnE,eAAO,MAAM,kBAAkB,0FAG9B,CAAA;AAED,eAAO,MAAM,eAAe,gBAA0C,CAAA;AAiStE,eAAO,MAAM,kBAAkB,sCAK7B,CAAA;AAEF,eAAO,MAAM,YAAY,EAAE,aAAa,CAAC,yBAAyB,CA2BjE,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"outline-panel.d.ts","sourceRoot":"","sources":["../../../../src/feature/fixed-toolbar/outline-panel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAA;AAgBhD,eAAO,MAAM,YAAY;;cAEE,MAAM,GAAG;;;;;cAAT,MAAM,GAAG;;;+
|
|
1
|
+
{"version":3,"file":"outline-panel.d.ts","sourceRoot":"","sources":["../../../../src/feature/fixed-toolbar/outline-panel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAA;AAgBhD,eAAO,MAAM,YAAY;;cAEE,MAAM,GAAG;;;;;cAAT,MAAM,GAAG;;;+GA8clC,CAAA"}
|
|
@@ -2,8 +2,10 @@ import type { AttachmentFeatureConfig } from './attachment/config';
|
|
|
2
2
|
import type { BlockEditFeatureConfig } from './block-edit';
|
|
3
3
|
import type { CodeMirrorFeatureConfig } from './code-mirror';
|
|
4
4
|
import type { CursorFeatureConfig } from './cursor';
|
|
5
|
+
import type { DiffBlockFeatureConfig } from './diff-block';
|
|
5
6
|
import type { FixedToolbarFeatureConfig } from './fixed-toolbar';
|
|
6
7
|
import type { ImageBlockFeatureConfig } from './image-block';
|
|
8
|
+
import type { InlineDiffFeatureConfig } from './inline-diff';
|
|
7
9
|
import type { LatexFeatureConfig } from './latex';
|
|
8
10
|
import type { LinkTooltipFeatureConfig } from './link-tooltip';
|
|
9
11
|
import type { ListItemFeatureConfig } from './list-item';
|
|
@@ -22,7 +24,9 @@ export declare enum CrepeFeature {
|
|
|
22
24
|
Placeholder = "placeholder",
|
|
23
25
|
Table = "table",
|
|
24
26
|
Latex = "latex",
|
|
25
|
-
Attachment = "attachment"
|
|
27
|
+
Attachment = "attachment",
|
|
28
|
+
InlineDiff = "inline-diff",
|
|
29
|
+
DiffBlock = "diff-block"
|
|
26
30
|
}
|
|
27
31
|
export interface CrepeFeatureConfig {
|
|
28
32
|
[CrepeFeature.Cursor]?: CursorFeatureConfig;
|
|
@@ -37,6 +41,8 @@ export interface CrepeFeatureConfig {
|
|
|
37
41
|
[CrepeFeature.Table]?: TableFeatureConfig;
|
|
38
42
|
[CrepeFeature.Latex]?: LatexFeatureConfig;
|
|
39
43
|
[CrepeFeature.Attachment]?: AttachmentFeatureConfig;
|
|
44
|
+
[CrepeFeature.InlineDiff]?: InlineDiffFeatureConfig;
|
|
45
|
+
[CrepeFeature.DiffBlock]?: DiffBlockFeatureConfig;
|
|
40
46
|
}
|
|
41
47
|
export declare const defaultFeatures: Record<CrepeFeature, boolean>;
|
|
42
48
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/feature/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAA;AAClE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAA;AAC1D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAA;AAC5D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAA;AACnD,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAA;AAChE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAA;AAC5D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;AACjD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAA;AAC9D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nD,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC,EAAE,uBAAuB,CAAA;IACnD,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,EAAE,sBAAsB,CAAA;CAClD;AAED,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,YAAY,EAAE,OAAO,CAezD,CAAA"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type App as VueApp } from 'vue';
|
|
2
|
+
import type { ChangeInfo } from './doc-builder';
|
|
3
|
+
export declare function mountChangePanel(container: HTMLElement, changes: ChangeInfo[], onNavigate: (from: number) => void, onClose?: () => void): VueApp;
|
|
4
|
+
//# sourceMappingURL=change-panel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"change-panel.d.ts","sourceRoot":"","sources":["../../../../src/feature/inline-diff/change-panel.ts"],"names":[],"mappings":"AAAA,OAAO,EAA+B,KAAK,GAAG,IAAI,MAAM,EAAE,MAAM,KAAK,CAAA;AAErE,OAAO,KAAK,EAAE,UAAU,EAAc,MAAM,eAAe,CAAA;AAa3D,wBAAgB,gBAAgB,CAC9B,SAAS,EAAE,WAAW,EACtB,OAAO,EAAE,UAAU,EAAE,EACrB,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,EAClC,OAAO,CAAC,EAAE,MAAM,IAAI,GACnB,MAAM,CAmQR"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface InlineDiffConfig {
|
|
2
|
+
addedClass: string;
|
|
3
|
+
deletedClass: string;
|
|
4
|
+
}
|
|
5
|
+
export interface InlineDiffApi {
|
|
6
|
+
showDiff: (oldMarkdown: string, newMarkdown?: string) => void;
|
|
7
|
+
hideDiff: () => void;
|
|
8
|
+
isShowing: () => boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare const inlineDiffConfig: import("@jvs-milkdown/utils").$Ctx<InlineDiffConfig, "inlineDiffConfigCtx">;
|
|
11
|
+
export declare const inlineDiffApiCtx: import("@jvs-milkdown/utils").$Ctx<InlineDiffApi, "inlineDiffApiCtx">;
|
|
12
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../../src/feature/inline-diff/config.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,gBAAgB;IAC/B,UAAU,EAAE,MAAM,CAAA;IAClB,YAAY,EAAE,MAAM,CAAA;CACrB;AAED,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,CAAC,WAAW,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,KAAK,IAAI,CAAA;IAC7D,QAAQ,EAAE,MAAM,IAAI,CAAA;IACpB,SAAS,EAAE,MAAM,OAAO,CAAA;CACzB;AAED,eAAO,MAAM,gBAAgB,6EAM5B,CAAA;AAQD,eAAO,MAAM,gBAAgB,uEAAoC,CAAA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Node as PMNode } from '@jvs-milkdown/kit/prose/model';
|
|
2
|
+
export type DiffType = 'unchanged' | 'added' | 'removed';
|
|
3
|
+
export interface CharPart {
|
|
4
|
+
type: 'equal' | 'insert' | 'delete';
|
|
5
|
+
value: string;
|
|
6
|
+
}
|
|
7
|
+
export interface BlockDiff {
|
|
8
|
+
type: DiffType;
|
|
9
|
+
oldNode?: PMNode;
|
|
10
|
+
newNode?: PMNode;
|
|
11
|
+
parts?: CharPart[];
|
|
12
|
+
}
|
|
13
|
+
export type ChunkStatus = 'pending' | 'accepted' | 'rejected';
|
|
14
|
+
export interface DiffChunk {
|
|
15
|
+
id: string;
|
|
16
|
+
diffs: BlockDiff[];
|
|
17
|
+
status: ChunkStatus;
|
|
18
|
+
}
|
|
19
|
+
export declare function computeDiff(oldBlocks: PMNode[], newBlocks: PMNode[]): DiffChunk[];
|
|
20
|
+
//# sourceMappingURL=diff-engine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diff-engine.d.ts","sourceRoot":"","sources":["../../../../src/feature/inline-diff/diff-engine.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,IAAI,MAAM,EAAE,MAAM,+BAA+B,CAAA;AAInE,MAAM,MAAM,QAAQ,GAAG,WAAW,GAAG,OAAO,GAAG,SAAS,CAAA;AAExD,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,OAAO,GAAG,QAAQ,GAAG,QAAQ,CAAA;IACnC,KAAK,EAAE,MAAM,CAAA;CACd;AAED,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,QAAQ,CAAA;IACd,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,KAAK,CAAC,EAAE,QAAQ,EAAE,CAAA;CACnB;AAED,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG,UAAU,GAAG,UAAU,CAAA;AAE7D,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,SAAS,EAAE,CAAA;IAClB,MAAM,EAAE,WAAW,CAAA;CACpB;AAyCD,wBAAgB,WAAW,CACzB,SAAS,EAAE,MAAM,EAAE,EACnB,SAAS,EAAE,MAAM,EAAE,GAClB,SAAS,EAAE,CAgHb"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diff-view.d.ts","sourceRoot":"","sources":["../../../../src/feature/inline-diff/diff-view.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAA"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Schema, Node as PMNode } from '@jvs-milkdown/kit/prose/model';
|
|
2
|
+
import type { DiffChunk } from './diff-engine';
|
|
3
|
+
export type ChangeType = 'added' | 'removed';
|
|
4
|
+
export interface ContentRange {
|
|
5
|
+
from: number;
|
|
6
|
+
to: number;
|
|
7
|
+
}
|
|
8
|
+
export interface ChangeInfo {
|
|
9
|
+
type: ChangeType;
|
|
10
|
+
from: number;
|
|
11
|
+
oldText: string;
|
|
12
|
+
newText: string;
|
|
13
|
+
blockRange: ContentRange;
|
|
14
|
+
inlineRanges: ContentRange[];
|
|
15
|
+
chunkId: string;
|
|
16
|
+
}
|
|
17
|
+
export declare function buildNewDoc(chunks: DiffChunk[], schema: Schema): {
|
|
18
|
+
doc: PMNode;
|
|
19
|
+
changes: ChangeInfo[];
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=doc-builder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"doc-builder.d.ts","sourceRoot":"","sources":["../../../../src/feature/inline-diff/doc-builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,IAAI,IAAI,MAAM,EAAE,MAAM,+BAA+B,CAAA;AAE3E,OAAO,KAAK,EAAE,SAAS,EAAY,MAAM,eAAe,CAAA;AAExD,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,SAAS,CAAA;AAE5C,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAA;IACZ,EAAE,EAAE,MAAM,CAAA;CACX;AAED,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,UAAU,CAAA;IAChB,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,MAAM,CAAA;IACf,UAAU,EAAE,YAAY,CAAA;IACxB,YAAY,EAAE,YAAY,EAAE,CAAA;IAC5B,OAAO,EAAE,MAAM,CAAA;CAChB;AAWD,wBAAgB,WAAW,CACzB,MAAM,EAAE,SAAS,EAAE,EACnB,MAAM,EAAE,MAAM,GACb;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,UAAU,EAAE,CAAA;CAAE,CAyGxC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { PluginKey } from '@jvs-milkdown/kit/prose/state';
|
|
2
|
+
import type { DefineFeature } from '../shared';
|
|
3
|
+
import { inlineDiffApiCtx, type InlineDiffConfig, type InlineDiffApi } from './config';
|
|
4
|
+
export type InlineDiffFeatureConfig = Partial<InlineDiffConfig>;
|
|
5
|
+
export { inlineDiffApiCtx, type InlineDiffApi };
|
|
6
|
+
export declare const inlineDiffKey: PluginKey<any>;
|
|
7
|
+
export declare const inlineDiffPlugin: import("@jvs-milkdown/utils").$Prose;
|
|
8
|
+
export declare const inlineDiff: DefineFeature<InlineDiffFeatureConfig>;
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/feature/inline-diff/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAAU,SAAS,EAAE,MAAM,+BAA+B,CAAA;AAIjE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;AAM9C,OAAO,EAEL,gBAAgB,EAChB,KAAK,gBAAgB,EACrB,KAAK,aAAa,EACnB,MAAM,UAAU,CAAA;AAIjB,MAAM,MAAM,uBAAuB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAA;AAE/D,OAAO,EAAE,gBAAgB,EAAE,KAAK,aAAa,EAAE,CAAA;AAE/C,eAAO,MAAM,aAAa,gBAAqC,CAAA;AAyc/D,eAAO,MAAM,gBAAgB,sCAQ3B,CAAA;AAEF,eAAO,MAAM,UAAU,EAAE,aAAa,CAAC,uBAAuB,CAiB7D,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../../src/feature/loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;
|
|
1
|
+
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../../src/feature/loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AASpD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAStC,wBAAgB,WAAW,CACzB,OAAO,EAAE,YAAY,EACrB,MAAM,EAAE,MAAM,EACd,MAAM,CAAC,EAAE,KAAK,QA8Cf"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../../../src/feature/toolbar/component.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAA;AAehD,OAAO,EACL,KAAK,SAAS,EAGf,MAAM,+BAA+B,CAAA;AAUtC,OAAO,EAEL,KAAK,GAAG,EACR,KAAK,UAAU,EAQhB,MAAM,KAAK,CAAA;AAEZ,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,GAAG,CAAA;AAmG7C,KAAK,YAAY,GAAG;IAClB,GAAG,EAAE,GAAG,CAAA;IACR,IAAI,EAAE,MAAM,IAAI,CAAA;IAChB,IAAI,EAAE,GAAG,CAAC,OAAO,CAAC,CAAA;IAClB,SAAS,EAAE,UAAU,CAAC,SAAS,CAAC,CAAA;IAChC,MAAM,CAAC,EAAE,oBAAoB,CAAA;IAC7B,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB,CAAA;AAeD,eAAO,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../../../src/feature/toolbar/component.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAA;AAehD,OAAO,EACL,KAAK,SAAS,EAGf,MAAM,+BAA+B,CAAA;AAUtC,OAAO,EAEL,KAAK,GAAG,EACR,KAAK,UAAU,EAQhB,MAAM,KAAK,CAAA;AAEZ,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,GAAG,CAAA;AAmG7C,KAAK,YAAY,GAAG;IAClB,GAAG,EAAE,GAAG,CAAA;IACR,IAAI,EAAE,MAAM,IAAI,CAAA;IAChB,IAAI,EAAE,GAAG,CAAC,OAAO,CAAC,CAAA;IAClB,SAAS,EAAE,UAAU,CAAC,SAAS,CAAC,CAAA;IAChC,MAAM,CAAC,EAAE,oBAAoB,CAAA;IAC7B,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB,CAAA;AAeD,eAAO,MAAM,OAAO,0WAy9ElB,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jvs-milkdown/crepe",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.14",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"crepe",
|
|
6
6
|
"editor",
|
|
@@ -81,6 +81,16 @@
|
|
|
81
81
|
"require": "./lib/cjs/feature/toolbar/index.js",
|
|
82
82
|
"types": "./lib/types/feature/toolbar/index.d.ts"
|
|
83
83
|
},
|
|
84
|
+
"./feature/inline-diff": {
|
|
85
|
+
"import": "./lib/esm/feature/inline-diff/index.js",
|
|
86
|
+
"require": "./lib/cjs/feature/inline-diff/index.js",
|
|
87
|
+
"types": "./lib/types/feature/inline-diff/index.d.ts"
|
|
88
|
+
},
|
|
89
|
+
"./feature/diff-block": {
|
|
90
|
+
"import": "./lib/esm/feature/diff-block/index.js",
|
|
91
|
+
"require": "./lib/cjs/feature/diff-block/index.js",
|
|
92
|
+
"types": "./lib/types/feature/diff-block/index.d.ts"
|
|
93
|
+
},
|
|
84
94
|
"./theme/common/*": "./lib/theme/common/*",
|
|
85
95
|
"./theme/classic.css": "./lib/theme/crepe/style.css",
|
|
86
96
|
"./theme/classic-dark.css": "./lib/theme/crepe-dark/style.css",
|
|
@@ -97,12 +107,13 @@
|
|
|
97
107
|
"@codemirror/theme-one-dark": "^6.1.2",
|
|
98
108
|
"@codemirror/view": "^6.26.0",
|
|
99
109
|
"@floating-ui/dom": "^1.7.6",
|
|
100
|
-
"@jvs-milkdown/kit": "^1.2.
|
|
101
|
-
"@jvs-milkdown/prose": "^1.2.
|
|
102
|
-
"@jvs-milkdown/utils": "^1.2.
|
|
110
|
+
"@jvs-milkdown/kit": "^1.2.14",
|
|
111
|
+
"@jvs-milkdown/prose": "^1.2.14",
|
|
112
|
+
"@jvs-milkdown/utils": "^1.2.14",
|
|
103
113
|
"@types/lodash-es": "^4.17.12",
|
|
104
114
|
"clsx": "^2.0.0",
|
|
105
115
|
"codemirror": "^6.0.1",
|
|
116
|
+
"diff": "^9.0.0",
|
|
106
117
|
"katex": "^0.16.0",
|
|
107
118
|
"lodash-es": "^4.17.21",
|
|
108
119
|
"prosemirror-virtual-cursor": "^0.4.2",
|
package/src/core/builder.ts
CHANGED
|
@@ -27,6 +27,7 @@ import type { DefineFeature } from '../feature/shared'
|
|
|
27
27
|
|
|
28
28
|
import { CrepeFeature } from '../feature'
|
|
29
29
|
import { attachmentConfig } from '../feature/attachment/config'
|
|
30
|
+
import { inlineDiffApiCtx } from '../feature/inline-diff/config'
|
|
30
31
|
import { zhCN, enUS, type CrepeTranslations } from './locale'
|
|
31
32
|
import {
|
|
32
33
|
CrepeCtx,
|
|
@@ -244,6 +245,24 @@ export class CrepeBuilder {
|
|
|
244
245
|
return this.#editor.action(getMarkdown())
|
|
245
246
|
}
|
|
246
247
|
|
|
248
|
+
/// Show inline diff between two markdown versions.
|
|
249
|
+
showDiff = (oldMarkdown: string, newMarkdown: string) => {
|
|
250
|
+
this.#editor.action((ctx) => {
|
|
251
|
+
const api = ctx.get(inlineDiffApiCtx.key)
|
|
252
|
+
api.showDiff(oldMarkdown, newMarkdown)
|
|
253
|
+
})
|
|
254
|
+
return this
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/// Hide inline diff and return to editing mode.
|
|
258
|
+
hideDiff = () => {
|
|
259
|
+
this.#editor.action((ctx) => {
|
|
260
|
+
const api = ctx.get(inlineDiffApiCtx.key)
|
|
261
|
+
api.hideDiff()
|
|
262
|
+
})
|
|
263
|
+
return this
|
|
264
|
+
}
|
|
265
|
+
|
|
247
266
|
/// Register event listeners.
|
|
248
267
|
on = (fn: (api: ListenerManager) => void) => {
|
|
249
268
|
if (this.#editor.status !== EditorStatus.Created) {
|
package/src/core/locale.ts
CHANGED
|
@@ -173,6 +173,10 @@ export const zhCN = {
|
|
|
173
173
|
'shortcuts.history': '历史记录',
|
|
174
174
|
'shortcuts.undo': '撤销',
|
|
175
175
|
'shortcuts.redo': '重做',
|
|
176
|
+
|
|
177
|
+
// inline-diff
|
|
178
|
+
'inlineDiff.accept': '接受',
|
|
179
|
+
'inlineDiff.reject': '拒绝',
|
|
176
180
|
}
|
|
177
181
|
|
|
178
182
|
export const enUS: typeof zhCN = {
|
|
@@ -331,6 +335,9 @@ export const enUS: typeof zhCN = {
|
|
|
331
335
|
'shortcuts.history': 'History',
|
|
332
336
|
'shortcuts.undo': 'Undo',
|
|
333
337
|
'shortcuts.redo': 'Redo',
|
|
338
|
+
|
|
339
|
+
'inlineDiff.accept': 'Accept',
|
|
340
|
+
'inlineDiff.reject': 'Reject',
|
|
334
341
|
}
|
|
335
342
|
|
|
336
343
|
export type CrepeTranslations = typeof zhCN
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { Extension } from '@codemirror/state'
|
|
2
|
+
|
|
3
|
+
import { oneDark } from '@codemirror/theme-one-dark'
|
|
4
|
+
import {
|
|
5
|
+
diffBlock,
|
|
6
|
+
diffBlockConfig,
|
|
7
|
+
type DiffBlockConfig,
|
|
8
|
+
} from '@jvs-milkdown/kit/component/diff-block'
|
|
9
|
+
import { basicSetup } from 'codemirror'
|
|
10
|
+
|
|
11
|
+
import type { DefineFeature } from '../shared'
|
|
12
|
+
|
|
13
|
+
import { crepeFeatureConfig } from '../../core/slice'
|
|
14
|
+
import { CrepeFeature } from '../index'
|
|
15
|
+
|
|
16
|
+
interface DiffBlockConfigCustom extends Omit<DiffBlockConfig, 'theme'> {
|
|
17
|
+
theme: Extension
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export type DiffBlockFeatureConfig = Partial<DiffBlockConfigCustom>
|
|
21
|
+
|
|
22
|
+
export const diffBlockFeature: DefineFeature<DiffBlockFeatureConfig> = (
|
|
23
|
+
editor,
|
|
24
|
+
config = {}
|
|
25
|
+
) => {
|
|
26
|
+
editor
|
|
27
|
+
.config(crepeFeatureConfig(CrepeFeature.DiffBlock))
|
|
28
|
+
.config((ctx) => {
|
|
29
|
+
const { languages = [], theme } = config
|
|
30
|
+
const extensions = [basicSetup]
|
|
31
|
+
if (theme) {
|
|
32
|
+
extensions.push(theme)
|
|
33
|
+
} else {
|
|
34
|
+
extensions.push(oneDark)
|
|
35
|
+
}
|
|
36
|
+
if (config.extensions) {
|
|
37
|
+
extensions.push(...config.extensions)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
ctx.update(diffBlockConfig.key, (defaultConfig) => ({
|
|
41
|
+
...defaultConfig,
|
|
42
|
+
extensions,
|
|
43
|
+
languages: languages.length > 0 ? languages : defaultConfig.languages,
|
|
44
|
+
renderLanguage: config.renderLanguage || defaultConfig.renderLanguage,
|
|
45
|
+
}))
|
|
46
|
+
})
|
|
47
|
+
.use(diffBlock)
|
|
48
|
+
}
|
|
@@ -68,6 +68,7 @@ class FixedToolbarView implements PluginView {
|
|
|
68
68
|
#scrollContainers: Element[] = []
|
|
69
69
|
#onDblClick: ((event: MouseEvent) => void) | undefined
|
|
70
70
|
#view: EditorView
|
|
71
|
+
#editorContainer?: HTMLElement
|
|
71
72
|
|
|
72
73
|
constructor(ctx: Ctx, view: EditorView) {
|
|
73
74
|
this.#view = view
|
|
@@ -91,16 +92,25 @@ class FixedToolbarView implements PluginView {
|
|
|
91
92
|
if (root) {
|
|
92
93
|
root.style.position = 'relative'
|
|
93
94
|
// Use internal styles for transition for smooth resizing
|
|
94
|
-
root.style.transition =
|
|
95
|
-
'padding 0.1s ease-out, background-color 0.2s ease-out'
|
|
95
|
+
root.style.transition = 'background-color 0.2s ease-out'
|
|
96
96
|
|
|
97
97
|
root.prepend(this.#content)
|
|
98
98
|
|
|
99
|
+
const editorContainer = document.createElement('div')
|
|
100
|
+
editorContainer.className = 'milkdown-editor-container'
|
|
101
|
+
editorContainer.style.transition = 'padding 0.1s ease-out'
|
|
102
|
+
editorContainer.style.display = 'flex'
|
|
103
|
+
editorContainer.style.flexDirection = 'column'
|
|
104
|
+
editorContainer.style.flexGrow = '1'
|
|
105
|
+
root.insertBefore(editorContainer, view.dom)
|
|
106
|
+
editorContainer.appendChild(view.dom)
|
|
107
|
+
this.#editorContainer = editorContainer
|
|
108
|
+
|
|
99
109
|
const headerContent = document.createElement('div')
|
|
100
110
|
this.#headerApp = createApp(DocumentHeader, { ctx, config })
|
|
101
111
|
this.#headerApp.mount(headerContent)
|
|
102
112
|
this.#headerContent = headerContent
|
|
103
|
-
|
|
113
|
+
editorContainer.insertBefore(headerContent, view.dom)
|
|
104
114
|
|
|
105
115
|
const outlineContent = document.createElement('div')
|
|
106
116
|
outlineContent.style.position = 'fixed'
|
|
@@ -189,7 +199,29 @@ class FixedToolbarView implements PluginView {
|
|
|
189
199
|
outlineContent.style.right = 'auto'
|
|
190
200
|
} else {
|
|
191
201
|
outlineContent.style.left = 'auto'
|
|
192
|
-
|
|
202
|
+
let baseOffset = window.innerWidth - rootRect.right
|
|
203
|
+
let rightOffset = baseOffset
|
|
204
|
+
let hasVScroll = false
|
|
205
|
+
if (document.documentElement.scrollHeight > window.innerHeight) {
|
|
206
|
+
hasVScroll = true
|
|
207
|
+
}
|
|
208
|
+
let parent: HTMLElement | null = root
|
|
209
|
+
while (parent && parent !== document.body) {
|
|
210
|
+
const { overflowY } = getComputedStyle(parent)
|
|
211
|
+
if (overflowY === 'auto' || overflowY === 'scroll') {
|
|
212
|
+
if (parent.scrollHeight > parent.clientHeight) {
|
|
213
|
+
hasVScroll = true
|
|
214
|
+
break
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
parent = parent.parentElement
|
|
218
|
+
}
|
|
219
|
+
if (hasVScroll) {
|
|
220
|
+
rightOffset = Math.max(rightOffset, 32)
|
|
221
|
+
} else {
|
|
222
|
+
rightOffset = Math.max(rightOffset, 0)
|
|
223
|
+
}
|
|
224
|
+
outlineContent.style.right = `${rightOffset}px`
|
|
193
225
|
}
|
|
194
226
|
}
|
|
195
227
|
}
|
|
@@ -231,26 +263,26 @@ class FixedToolbarView implements PluginView {
|
|
|
231
263
|
root.style.backgroundColor = ''
|
|
232
264
|
}
|
|
233
265
|
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
266
|
+
// Reset root and toolbar styles to default/full-width
|
|
267
|
+
root.style.paddingLeft = '0'
|
|
268
|
+
root.style.paddingRight = '0'
|
|
269
|
+
this.#content.style.width = '100%'
|
|
270
|
+
this.#content.style.marginLeft = '0'
|
|
271
|
+
this.#content.style.marginRight = '0'
|
|
272
|
+
|
|
273
|
+
if (this.#editorContainer) {
|
|
274
|
+
if (viewState.outlineVisible) {
|
|
275
|
+
if (viewState.outlinePosition === 'left') {
|
|
276
|
+
this.#editorContainer.style.paddingLeft = `${viewState.outlineWidth}px`
|
|
277
|
+
this.#editorContainer.style.paddingRight = '0'
|
|
278
|
+
} else {
|
|
279
|
+
this.#editorContainer.style.paddingLeft = '0'
|
|
280
|
+
this.#editorContainer.style.paddingRight = `${viewState.outlineWidth}px`
|
|
281
|
+
}
|
|
241
282
|
} else {
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
this.#content.style.width = `calc(100% + ${viewState.outlineWidth}px)`
|
|
245
|
-
this.#content.style.marginLeft = '0'
|
|
246
|
-
this.#content.style.marginRight = `-${viewState.outlineWidth}px`
|
|
283
|
+
this.#editorContainer.style.paddingLeft = '0'
|
|
284
|
+
this.#editorContainer.style.paddingRight = '0'
|
|
247
285
|
}
|
|
248
|
-
} else {
|
|
249
|
-
root.style.paddingLeft = '0'
|
|
250
|
-
root.style.paddingRight = '0'
|
|
251
|
-
this.#content.style.width = '100%'
|
|
252
|
-
this.#content.style.marginLeft = '0'
|
|
253
|
-
this.#content.style.marginRight = '0'
|
|
254
286
|
}
|
|
255
287
|
|
|
256
288
|
const maxWidth = (editorWidthMap as any)[viewState.editorWidth]
|
|
@@ -269,8 +301,11 @@ class FixedToolbarView implements PluginView {
|
|
|
269
301
|
}
|
|
270
302
|
|
|
271
303
|
// Compute geometry after styles and DOM (cover) are updated
|
|
272
|
-
nextTick(() => {
|
|
304
|
+
void nextTick(() => {
|
|
273
305
|
this.#updateOutlineGeometry?.()
|
|
306
|
+
setTimeout(() => {
|
|
307
|
+
this.#updateOutlineGeometry?.()
|
|
308
|
+
}, 100)
|
|
274
309
|
})
|
|
275
310
|
},
|
|
276
311
|
{ immediate: true }
|
|
@@ -283,11 +283,12 @@ export const OutlinePanel = defineComponent({
|
|
|
283
283
|
{/* Header */}
|
|
284
284
|
<div
|
|
285
285
|
style={{
|
|
286
|
-
padding: '
|
|
286
|
+
padding: '12px 16px',
|
|
287
287
|
fontWeight: 'bold',
|
|
288
288
|
fontSize: '14px',
|
|
289
289
|
color: 'var(--crepe-color-on-surface)',
|
|
290
|
-
borderBottom:
|
|
290
|
+
borderBottom:
|
|
291
|
+
'1px solid var(--crepe-color-outline-variant, color-mix(in srgb, var(--crepe-color-outline, #ddd), transparent 80%))',
|
|
291
292
|
display: 'flex',
|
|
292
293
|
justifyContent: 'space-between',
|
|
293
294
|
alignItems: 'center',
|
package/src/feature/index.ts
CHANGED
|
@@ -2,8 +2,10 @@ import type { AttachmentFeatureConfig } from './attachment/config'
|
|
|
2
2
|
import type { BlockEditFeatureConfig } from './block-edit'
|
|
3
3
|
import type { CodeMirrorFeatureConfig } from './code-mirror'
|
|
4
4
|
import type { CursorFeatureConfig } from './cursor'
|
|
5
|
+
import type { DiffBlockFeatureConfig } from './diff-block'
|
|
5
6
|
import type { FixedToolbarFeatureConfig } from './fixed-toolbar'
|
|
6
7
|
import type { ImageBlockFeatureConfig } from './image-block'
|
|
8
|
+
import type { InlineDiffFeatureConfig } from './inline-diff'
|
|
7
9
|
import type { LatexFeatureConfig } from './latex'
|
|
8
10
|
import type { LinkTooltipFeatureConfig } from './link-tooltip'
|
|
9
11
|
import type { ListItemFeatureConfig } from './list-item'
|
|
@@ -50,6 +52,12 @@ export enum CrepeFeature {
|
|
|
50
52
|
|
|
51
53
|
/// File attachment uploads
|
|
52
54
|
Attachment = 'attachment',
|
|
55
|
+
|
|
56
|
+
/// Inline diff comparison between two document versions, similar to Word track changes.
|
|
57
|
+
InlineDiff = 'inline-diff',
|
|
58
|
+
|
|
59
|
+
/// Diff comparison block for showing code differences
|
|
60
|
+
DiffBlock = 'diff-block',
|
|
53
61
|
}
|
|
54
62
|
|
|
55
63
|
export interface CrepeFeatureConfig {
|
|
@@ -65,6 +73,8 @@ export interface CrepeFeatureConfig {
|
|
|
65
73
|
[CrepeFeature.Table]?: TableFeatureConfig
|
|
66
74
|
[CrepeFeature.Latex]?: LatexFeatureConfig
|
|
67
75
|
[CrepeFeature.Attachment]?: AttachmentFeatureConfig
|
|
76
|
+
[CrepeFeature.InlineDiff]?: InlineDiffFeatureConfig
|
|
77
|
+
[CrepeFeature.DiffBlock]?: DiffBlockFeatureConfig
|
|
68
78
|
}
|
|
69
79
|
|
|
70
80
|
export const defaultFeatures: Record<CrepeFeature, boolean> = {
|
|
@@ -80,4 +90,6 @@ export const defaultFeatures: Record<CrepeFeature, boolean> = {
|
|
|
80
90
|
[CrepeFeature.Table]: true,
|
|
81
91
|
[CrepeFeature.Latex]: true,
|
|
82
92
|
[CrepeFeature.Attachment]: true,
|
|
93
|
+
[CrepeFeature.InlineDiff]: false,
|
|
94
|
+
[CrepeFeature.DiffBlock]: true,
|
|
83
95
|
}
|