@jvs-milkdown/crepe 1.2.18 → 1.2.20

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.
@@ -8,5 +8,6 @@ export interface CrepeConfig extends CrepeBuilderConfig {
8
8
  export declare class Crepe extends CrepeBuilder {
9
9
  static Feature: typeof CrepeFeature;
10
10
  constructor(config?: CrepeConfig);
11
+ destroy: () => Promise<import("@jvs-milkdown/core").Editor>;
11
12
  }
12
13
  //# sourceMappingURL=crepe.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"crepe.d.ts","sourceRoot":"","sources":["../../../src/core/crepe.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAGpD,OAAO,EAAE,YAAY,EAAmB,MAAM,YAAY,CAAA;AAE1D,OAAO,EAAE,YAAY,EAAE,KAAK,kBAAkB,EAAE,MAAM,WAAW,CAAA;AAGjE,MAAM,WAAW,WAAY,SAAQ,kBAAkB;IAErD,QAAQ,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC,CAAA;IAGjD,cAAc,CAAC,EAAE,kBAAkB,CAAA;CACpC;AAGD,qBAAa,KAAM,SAAQ,YAAY;IAErC,MAAM,CAAC,OAAO,sBAAe;gBAKjB,MAAM,GAAE,WAAgB;CA2ErC"}
1
+ {"version":3,"file":"crepe.d.ts","sourceRoot":"","sources":["../../../src/core/crepe.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAGpD,OAAO,EAAE,YAAY,EAAmB,MAAM,YAAY,CAAA;AAG1D,OAAO,EAAE,YAAY,EAAE,KAAK,kBAAkB,EAAE,MAAM,WAAW,CAAA;AAGjE,MAAM,WAAW,WAAY,SAAQ,kBAAkB;IAErD,QAAQ,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC,CAAA;IAGjD,cAAc,CAAC,EAAE,kBAAkB,CAAA;CACpC;AAGD,qBAAa,KAAM,SAAQ,YAAY;IAErC,MAAM,CAAC,OAAO,sBAAe;gBAKjB,MAAM,GAAE,WAAgB;IA0G3B,OAAO,qDAGf;CACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../../../src/feature/fixed-toolbar/component.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAA;AAChD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAA;AAO9D,OAAO,EAEL,KAAK,UAAU,EACf,KAAK,GAAG,EAKT,MAAM,KAAK,CAAA;AAEZ,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,GAAG,CAAA;AAQlD,KAAK,iBAAiB,GAAG;IACvB,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,yBAAyB,CAAA;IAClC,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC,CAAA;IACrB,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC,CAAA;CACtB,CAAA;AAED,eAAO,MAAM,qBAAqB,oXA4JhC,CAAA"}
1
+ {"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../../../src/feature/fixed-toolbar/component.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAA;AAChD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAA;AAI9D,OAAO,EAEL,KAAK,UAAU,EACf,KAAK,GAAG,EAIT,MAAM,KAAK,CAAA;AAEZ,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,GAAG,CAAA;AAOlD,KAAK,iBAAiB,GAAG;IACvB,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,yBAAyB,CAAA;IAClC,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC,CAAA;IACrB,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC,CAAA;CACtB,CAAA;AAED,eAAO,MAAM,qBAAqB,oXA8JhC,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"menu-bar.d.ts","sourceRoot":"","sources":["../../../../src/feature/fixed-toolbar/menu-bar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAA;AAchD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;AAsDjD,eAAO,MAAM,OAAO;;cAEO,MAAM,GAAG;;;;cACN,MAAM,kBAAkB;;;;;cAD3B,MAAM,GAAG;;;;cACN,MAAM,kBAAkB;;;+GAkgBpD,CAAA"}
1
+ {"version":3,"file":"menu-bar.d.ts","sourceRoot":"","sources":["../../../../src/feature/fixed-toolbar/menu-bar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAA;AAahD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;AAsDjD,eAAO,MAAM,OAAO;;cAEO,MAAM,GAAG;;;;cACN,MAAM,kBAAkB;;;;;cAD3B,MAAM,GAAG;;;;cACN,MAAM,kBAAkB;;;+GAkgBpD,CAAA"}
@@ -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;AAgBhD,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,0WA++ElB,CAAA"}
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;AAgBhD,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,0WAihFlB,CAAA"}
@@ -3,5 +3,6 @@ export declare function getIsAnyPopupOpen(): boolean;
3
3
  export declare function addPopupChangeListener(fn: Listener): () => void;
4
4
  export declare function incrementPopupCount(): void;
5
5
  export declare function decrementPopupCount(): void;
6
+ export declare function resetPopupCount(): void;
6
7
  export {};
7
8
  //# sourceMappingURL=fixed-toolbar-popup-state.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"fixed-toolbar-popup-state.d.ts","sourceRoot":"","sources":["../../../src/utils/fixed-toolbar-popup-state.ts"],"names":[],"mappings":"AAAA,KAAK,QAAQ,GAAG,MAAM,IAAI,CAAA;AAI1B,wBAAgB,iBAAiB,IAAI,OAAO,CAE3C;AAED,wBAAgB,sBAAsB,CAAC,EAAE,EAAE,QAAQ,GAAG,MAAM,IAAI,CAG/D;AAED,wBAAgB,mBAAmB,IAAI,IAAI,CAM1C;AAED,wBAAgB,mBAAmB,IAAI,IAAI,CAK1C"}
1
+ {"version":3,"file":"fixed-toolbar-popup-state.d.ts","sourceRoot":"","sources":["../../../src/utils/fixed-toolbar-popup-state.ts"],"names":[],"mappings":"AAAA,KAAK,QAAQ,GAAG,MAAM,IAAI,CAAA;AAI1B,wBAAgB,iBAAiB,IAAI,OAAO,CAE3C;AAED,wBAAgB,sBAAsB,CAAC,EAAE,EAAE,QAAQ,GAAG,MAAM,IAAI,CAG/D;AAED,wBAAgB,mBAAmB,IAAI,IAAI,CAM1C;AAED,wBAAgB,mBAAmB,IAAI,IAAI,CAK1C;AAED,wBAAgB,eAAe,IAAI,IAAI,CAGtC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jvs-milkdown/crepe",
3
- "version": "1.2.18",
3
+ "version": "1.2.20",
4
4
  "keywords": [
5
5
  "crepe",
6
6
  "editor",
@@ -19,85 +19,145 @@
19
19
  ],
20
20
  "type": "module",
21
21
  "sideEffects": false,
22
- "main": "./lib/esm/index.js",
22
+ "main": "./src/index.ts",
23
23
  "exports": {
24
24
  ".": {
25
- "import": "./lib/esm/index.js",
26
- "require": "./lib/cjs/index.js",
27
- "types": "./lib/types/index.d.ts"
25
+ "import": "./src/index.ts"
28
26
  },
29
27
  "./builder": {
30
- "import": "./lib/esm/builder.js",
31
- "require": "./lib/cjs/builder.js",
32
- "types": "./lib/types/builder.d.ts"
28
+ "import": "./src/builder.ts"
33
29
  },
34
30
  "./feature/block-edit": {
35
- "import": "./lib/esm/feature/block-edit/index.js",
36
- "require": "./lib/cjs/feature/block-edit/index.js",
37
- "types": "./lib/types/feature/block-edit/index.d.ts"
31
+ "import": "./src/feature/block-edit/index.ts"
38
32
  },
39
33
  "./feature/code-mirror": {
40
- "import": "./lib/esm/feature/code-mirror/index.js",
41
- "require": "./lib/cjs/feature/code-mirror/index.js",
42
- "types": "./lib/types/feature/code-mirror/index.d.ts"
34
+ "import": "./src/feature/code-mirror/index.ts"
43
35
  },
44
36
  "./feature/cursor": {
45
- "import": "./lib/esm/feature/cursor/index.js",
46
- "require": "./lib/cjs/feature/cursor/index.js",
47
- "types": "./lib/types/feature/cursor/index.d.ts"
37
+ "import": "./src/feature/cursor/index.ts"
48
38
  },
49
39
  "./feature/image-block": {
50
- "import": "./lib/esm/feature/image-block/index.js",
51
- "require": "./lib/cjs/feature/image-block/index.js",
52
- "types": "./lib/types/feature/image-block/index.d.ts"
40
+ "import": "./src/feature/image-block/index.ts"
53
41
  },
54
42
  "./feature/latex": {
55
- "import": "./lib/esm/feature/latex/index.js",
56
- "require": "./lib/cjs/feature/latex/index.js",
57
- "types": "./lib/types/feature/latex/index.d.ts"
43
+ "import": "./src/feature/latex/index.ts"
58
44
  },
59
45
  "./feature/link-tooltip": {
60
- "import": "./lib/esm/feature/link-tooltip/index.js",
61
- "require": "./lib/cjs/feature/link-tooltip/index.js",
62
- "types": "./lib/types/feature/link-tooltip/index.d.ts"
46
+ "import": "./src/feature/link-tooltip/index.ts"
63
47
  },
64
48
  "./feature/list-item": {
65
- "import": "./lib/esm/feature/list-item/index.js",
66
- "require": "./lib/cjs/feature/list-item/index.js",
67
- "types": "./lib/types/feature/list-item/index.d.ts"
49
+ "import": "./src/feature/list-item/index.ts"
68
50
  },
69
51
  "./feature/placeholder": {
70
- "import": "./lib/esm/feature/placeholder/index.js",
71
- "require": "./lib/cjs/feature/placeholder/index.js",
72
- "types": "./lib/types/feature/placeholder/index.d.ts"
52
+ "import": "./src/feature/placeholder/index.ts"
73
53
  },
74
54
  "./feature/table": {
75
- "import": "./lib/esm/feature/table/index.js",
76
- "require": "./lib/cjs/feature/table/index.js",
77
- "types": "./lib/types/feature/table/index.d.ts"
55
+ "import": "./src/feature/table/index.ts"
78
56
  },
79
57
  "./feature/toolbar": {
80
- "import": "./lib/esm/feature/toolbar/index.js",
81
- "require": "./lib/cjs/feature/toolbar/index.js",
82
- "types": "./lib/types/feature/toolbar/index.d.ts"
58
+ "import": "./src/feature/toolbar/index.ts"
83
59
  },
84
60
  "./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"
61
+ "import": "./src/feature/inline-diff/index.ts"
88
62
  },
89
63
  "./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"
64
+ "import": "./src/feature/diff-block/index.ts"
93
65
  },
94
- "./theme/common/*": "./lib/theme/common/*",
95
- "./theme/classic.css": "./lib/theme/crepe/style.css",
96
- "./theme/classic-dark.css": "./lib/theme/crepe-dark/style.css",
97
- "./theme/nord.css": "./lib/theme/nord/style.css",
98
- "./theme/nord-dark.css": "./lib/theme/nord-dark/style.css",
99
- "./theme/frame.css": "./lib/theme/frame/style.css",
100
- "./theme/frame-dark.css": "./lib/theme/frame-dark/style.css"
66
+ "./theme/common/*": "./src/theme/common/*",
67
+ "./theme/classic.css": "./src/theme/crepe/style.css",
68
+ "./theme/classic-dark.css": "./src/theme/crepe-dark/style.css",
69
+ "./theme/nord.css": "./src/theme/nord/style.css",
70
+ "./theme/nord-dark.css": "./src/theme/nord-dark/style.css",
71
+ "./theme/frame.css": "./src/theme/frame/style.css",
72
+ "./theme/frame-dark.css": "./src/theme/frame-dark/style.css"
73
+ },
74
+ "publishConfig": {
75
+ "exports": {
76
+ ".": {
77
+ "import": "./lib/esm/index.js",
78
+ "require": "./lib/cjs/index.js",
79
+ "types": "./lib/types/index.d.ts"
80
+ },
81
+ "./builder": {
82
+ "import": "./lib/esm/builder.js",
83
+ "require": "./lib/cjs/builder.js",
84
+ "types": "./lib/types/builder.d.ts"
85
+ },
86
+ "./feature/block-edit": {
87
+ "import": "./lib/esm/feature/block-edit/index.js",
88
+ "require": "./lib/cjs/feature/block-edit/index.js",
89
+ "types": "./lib/types/feature/block-edit/index.d.ts"
90
+ },
91
+ "./feature/code-mirror": {
92
+ "import": "./lib/esm/feature/code-mirror/index.js",
93
+ "require": "./lib/cjs/feature/code-mirror/index.js",
94
+ "types": "./lib/types/feature/code-mirror/index.d.ts"
95
+ },
96
+ "./feature/cursor": {
97
+ "import": "./lib/esm/feature/cursor/index.js",
98
+ "require": "./lib/cjs/feature/cursor/index.js",
99
+ "types": "./lib/types/feature/cursor/index.d.ts"
100
+ },
101
+ "./feature/image-block": {
102
+ "import": "./lib/esm/feature/image-block/index.js",
103
+ "require": "./lib/cjs/feature/image-block/index.js",
104
+ "types": "./lib/types/feature/image-block/index.d.ts"
105
+ },
106
+ "./feature/latex": {
107
+ "import": "./lib/esm/feature/latex/index.js",
108
+ "require": "./lib/cjs/feature/latex/index.js",
109
+ "types": "./lib/types/feature/latex/index.d.ts"
110
+ },
111
+ "./feature/link-tooltip": {
112
+ "import": "./lib/esm/feature/link-tooltip/index.js",
113
+ "require": "./lib/cjs/feature/link-tooltip/index.js",
114
+ "types": "./lib/types/feature/link-tooltip/index.d.ts"
115
+ },
116
+ "./feature/list-item": {
117
+ "import": "./lib/esm/feature/list-item/index.js",
118
+ "require": "./lib/cjs/feature/list-item/index.js",
119
+ "types": "./lib/types/feature/list-item/index.d.ts"
120
+ },
121
+ "./feature/placeholder": {
122
+ "import": "./lib/esm/feature/placeholder/index.js",
123
+ "require": "./lib/cjs/feature/placeholder/index.js",
124
+ "types": "./lib/types/feature/placeholder/index.d.ts"
125
+ },
126
+ "./feature/table": {
127
+ "import": "./lib/esm/feature/table/index.js",
128
+ "require": "./lib/cjs/feature/table/index.js",
129
+ "types": "./lib/types/feature/table/index.d.ts"
130
+ },
131
+ "./feature/toolbar": {
132
+ "import": "./lib/esm/feature/toolbar/index.js",
133
+ "require": "./lib/cjs/feature/toolbar/index.js",
134
+ "types": "./lib/types/feature/toolbar/index.d.ts"
135
+ },
136
+ "./feature/inline-diff": {
137
+ "import": "./lib/esm/feature/inline-diff/index.js",
138
+ "require": "./lib/cjs/feature/inline-diff/index.js",
139
+ "types": "./lib/types/feature/inline-diff/index.d.ts"
140
+ },
141
+ "./feature/diff-block": {
142
+ "import": "./lib/esm/feature/diff-block/index.js",
143
+ "require": "./lib/cjs/feature/diff-block/index.js",
144
+ "types": "./lib/types/feature/diff-block/index.d.ts"
145
+ },
146
+ "./theme/common/*": "./lib/theme/common/*",
147
+ "./theme/classic.css": "./lib/theme/crepe/style.css",
148
+ "./theme/classic-dark.css": "./lib/theme/crepe-dark/style.css",
149
+ "./theme/nord.css": "./lib/theme/nord/style.css",
150
+ "./theme/nord-dark.css": "./lib/theme/nord-dark/style.css",
151
+ "./theme/frame.css": "./lib/theme/frame/style.css",
152
+ "./theme/frame-dark.css": "./lib/theme/frame-dark/style.css"
153
+ },
154
+ "main": "./lib/esm/index.js",
155
+ "types": "./lib/types/index.d.ts"
156
+ },
157
+ "scripts": {
158
+ "build": "pnpm run build:es && pnpm run build:theme && echo",
159
+ "build:es": "rollup -c",
160
+ "build:theme": "postcss src/theme/**/*.css --base src/theme --dir lib/theme && xcopy /E /I /Y src\\theme\\fonts lib\\theme\\fonts"
101
161
  },
102
162
  "dependencies": {
103
163
  "@codemirror/commands": "^6.3.3",
@@ -107,9 +167,9 @@
107
167
  "@codemirror/theme-one-dark": "^6.1.2",
108
168
  "@codemirror/view": "^6.26.0",
109
169
  "@floating-ui/dom": "^1.7.6",
110
- "@jvs-milkdown/kit": "^1.2.18",
111
- "@jvs-milkdown/prose": "^1.2.18",
112
- "@jvs-milkdown/utils": "^1.2.18",
170
+ "@jvs-milkdown/kit": "^1.2.20",
171
+ "@jvs-milkdown/prose": "^1.2.20",
172
+ "@jvs-milkdown/utils": "^1.2.20",
113
173
  "@types/lodash-es": "^4.17.12",
114
174
  "clsx": "^2.0.0",
115
175
  "codemirror": "^6.0.1",
@@ -127,11 +187,5 @@
127
187
  "@vue/reactivity": "^3.5.34",
128
188
  "@vue/runtime-core": "^3.5.34",
129
189
  "@vue/runtime-dom": "^3.5.34"
130
- },
131
- "scripts": {
132
- "build": "pnpm run build:es && pnpm run build:theme && echo",
133
- "build:es": "rollup -c",
134
- "build:theme": "postcss src/theme/**/*.css --base src/theme --dir lib/theme && xcopy /E /I /Y src\\theme\\fonts lib\\theme\\fonts"
135
- },
136
- "types": "./lib/types/index.d.ts"
137
- }
190
+ }
191
+ }
package/src/core/crepe.ts CHANGED
@@ -6,6 +6,7 @@ import type { CrepeFeatureConfig } from '../feature'
6
6
  import { defaultConfig } from '../default-config'
7
7
  import { CrepeFeature, defaultFeatures } from '../feature'
8
8
  import { loadFeature } from '../feature/loader'
9
+ import { resetPopupCount } from '../utils/fixed-toolbar-popup-state'
9
10
  import { CrepeBuilder, type CrepeBuilderConfig } from './builder'
10
11
 
11
12
  /// The crepe editor configuration.
@@ -26,6 +27,7 @@ export class Crepe extends CrepeBuilder {
26
27
  /// You can pass configs to the editor to configure the editor.
27
28
  /// Calling the constructor will not create the editor, you need to call `create` to create the editor.
28
29
  constructor(config: CrepeConfig = {}) {
30
+ resetPopupCount()
29
31
  const { features = {}, featureConfigs = {}, ...crepeBuilderConfig } = config
30
32
  const finalConfigs = defaultsDeep(featureConfigs, defaultConfig)
31
33
  const fixedToolbarConfig = finalConfigs[CrepeFeature.FixedToolbar]
@@ -67,31 +69,60 @@ export class Crepe extends CrepeBuilder {
67
69
  this.on((listener) => {
68
70
  listener.markdownUpdated((_, markdown) => {
69
71
  try {
70
- const stored = localStorage.getItem('jvs-milkdown-data')
71
- let parsed: any = {}
72
- if (stored) {
73
- parsed = JSON.parse(stored)
74
- }
75
- if (!parsed.content) {
76
- parsed.content = {}
77
- }
78
72
  const html = this.editor.action(getHTML())
79
73
  const docId = fixedToolbarConfig.id || 'default'
80
74
 
81
- const currentEntry = parsed.content[docId]
82
- const hasChanged =
83
- !currentEntry ||
84
- (typeof currentEntry === 'string' && currentEntry !== markdown) ||
85
- (typeof currentEntry === 'object' &&
86
- (currentEntry.markdown !== markdown ||
87
- currentEntry.html !== html))
88
-
89
- if (hasChanged) {
90
- parsed.content[docId] = {
91
- markdown,
92
- html,
75
+ const saveToLocalStorage = (mdVal: string, htmlVal: string) => {
76
+ try {
77
+ const stored = localStorage.getItem('jvs-milkdown-data')
78
+ let parsed: any = {}
79
+ if (stored) {
80
+ parsed = JSON.parse(stored)
81
+ }
82
+ if (!parsed.content) {
83
+ parsed.content = {}
84
+ }
85
+ const currentEntry = parsed.content[docId]
86
+ const hasChanged =
87
+ !currentEntry ||
88
+ (typeof currentEntry === 'string' &&
89
+ currentEntry !== mdVal) ||
90
+ (typeof currentEntry === 'object' &&
91
+ (currentEntry.markdown !== mdVal ||
92
+ currentEntry.html !== htmlVal))
93
+
94
+ if (hasChanged) {
95
+ parsed.content[docId] = {
96
+ markdown: mdVal,
97
+ html: htmlVal,
98
+ }
99
+ localStorage.setItem(
100
+ 'jvs-milkdown-data',
101
+ JSON.stringify(parsed)
102
+ )
103
+ }
104
+ } catch (e) {
105
+ console.error('Error saving content to localStorage:', e)
93
106
  }
94
- localStorage.setItem('jvs-milkdown-data', JSON.stringify(parsed))
107
+ }
108
+
109
+ const hasBlobUrl =
110
+ /blob:https?:\/\//.test(markdown) || /blob:https?:\/\//.test(html)
111
+
112
+ if (hasBlobUrl) {
113
+ Promise.all([
114
+ replaceBlobUrlsWithBase64(markdown),
115
+ replaceBlobUrlsWithBase64(html),
116
+ ])
117
+ .then(([base64Markdown, base64Html]) => {
118
+ saveToLocalStorage(base64Markdown, base64Html)
119
+ })
120
+ .catch((e) => {
121
+ console.error('Error converting blob URLs:', e)
122
+ saveToLocalStorage(markdown, html)
123
+ })
124
+ } else {
125
+ saveToLocalStorage(markdown, html)
95
126
  }
96
127
  } catch (e) {
97
128
  console.error('Error saving content to localStorage:', e)
@@ -100,4 +131,35 @@ export class Crepe extends CrepeBuilder {
100
131
  })
101
132
  }
102
133
  }
134
+
135
+ override destroy = () => {
136
+ resetPopupCount()
137
+ return this.editor.destroy()
138
+ }
139
+ }
140
+
141
+ async function replaceBlobUrlsWithBase64(content: string): Promise<string> {
142
+ const blobRegex = /blob:https?:\/\/[^\s'")>]+/g
143
+ const matches = content.match(blobRegex)
144
+ if (!matches) return content
145
+
146
+ let result = content
147
+ const uniqueBlobs = Array.from(new Set(matches))
148
+
149
+ for (const blobUrl of uniqueBlobs) {
150
+ try {
151
+ const response = await fetch(blobUrl)
152
+ const blob = await response.blob()
153
+ const base64 = await new Promise<string>((resolve, reject) => {
154
+ const reader = new FileReader()
155
+ reader.onloadend = () => resolve(reader.result as string)
156
+ reader.onerror = reject
157
+ reader.readAsDataURL(blob)
158
+ })
159
+ result = result.replaceAll(blobUrl, base64)
160
+ } catch (e) {
161
+ console.error('Failed to convert blob URL to base64:', blobUrl, e)
162
+ }
163
+ }
164
+ return result
103
165
  }
@@ -1,24 +1,19 @@
1
1
  import type { Ctx } from '@jvs-milkdown/kit/ctx'
2
2
  import type { Selection } from '@jvs-milkdown/kit/prose/state'
3
3
 
4
- import { Icon } from '@jvs-milkdown/kit/component'
5
- import { commandsCtx, editorViewCtx } from '@jvs-milkdown/kit/core'
6
- import { getMarkdown } from '@jvs-milkdown/kit/utils'
7
- import { replaceAll } from '@jvs-milkdown/utils'
4
+ import { commandsCtx } from '@jvs-milkdown/kit/core'
8
5
  // @ts-ignore
9
6
  import {
10
7
  defineComponent,
11
8
  type ShallowRef,
12
9
  type Ref,
13
10
  ref,
14
- h,
15
11
  onMounted,
16
12
  onUnmounted,
17
13
  } from 'vue'
18
14
 
19
15
  import type { FixedToolbarFeatureConfig } from '.'
20
16
 
21
- import { i18n } from '../../core/locale'
22
17
  import { undoIcon, redoIcon } from '../../icons'
23
18
  import { Toolbar } from '../toolbar/component'
24
19
  import { MenuBar } from './menu-bar'
@@ -82,6 +77,8 @@ export const FixedToolbarComponent = defineComponent<FixedToolbarProps>({
82
77
  justifyContent: 'center',
83
78
  width: '100%',
84
79
  gap: '0px',
80
+ minWidth: '0',
81
+ overflow: 'hidden',
85
82
  }}
86
83
  >
87
84
  {props.config?.showMenuBar !== false && [
@@ -3,7 +3,7 @@ import type { PluginView, Selection } from '@jvs-milkdown/kit/prose/state'
3
3
  import type { EditorView } from '@jvs-milkdown/kit/prose/view'
4
4
 
5
5
  import { Plugin, PluginKey, TextSelection } from '@jvs-milkdown/kit/prose/state'
6
- import { $ctx, $prose, getMarkdown } from '@jvs-milkdown/kit/utils'
6
+ import { $ctx, $prose } from '@jvs-milkdown/kit/utils'
7
7
  import { undo, redo } from '@jvs-milkdown/prose/history'
8
8
  // @ts-ignore
9
9
  import {
@@ -8,7 +8,6 @@ import {
8
8
  onUnmounted,
9
9
  computed,
10
10
  onMounted,
11
- h,
12
11
  watch,
13
12
  } from 'vue'
14
13