@coze-editor/react-merge 0.1.0-alpha.dac011 → 0.1.0-alpha.f1005d
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/esm/index.js +1 -6
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +2 -9
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
package/dist/esm/index.js
CHANGED
|
@@ -97,12 +97,7 @@ function MergeViewRenderer(props) {
|
|
|
97
97
|
}, [props.b.options]);
|
|
98
98
|
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", { ...domProps, ref }), children);
|
|
99
99
|
}
|
|
100
|
-
|
|
101
|
-
// src/index.ts
|
|
102
|
-
import { goToPreviousChunk, goToNextChunk } from "@codemirror/merge";
|
|
103
100
|
export {
|
|
104
|
-
MergeViewRenderer
|
|
105
|
-
goToNextChunk,
|
|
106
|
-
goToPreviousChunk
|
|
101
|
+
MergeViewRenderer
|
|
107
102
|
};
|
|
108
103
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/renderer.tsx"
|
|
1
|
+
{"version":3,"sources":["../../src/renderer.tsx"],"sourcesContent":["// Copyright (c) 2025 coze-dev\n// SPDX-License-Identifier: MIT\n\nimport React, {\n useRef,\n useEffect,\n type CSSProperties,\n type ReactNode,\n} from 'react';\n\nimport {\n // from core\n create,\n type EditorPluginSpec,\n type InferEditorAPIFromPlugins,\n type InferValues,\n // from react\n useInjector,\n} from '@coze-editor/react';\nimport { type Extension } from '@codemirror/state';\nimport { type MergeConfig, MergeView } from '@codemirror/merge';\n\ninterface SingleEditorProps<T extends EditorPluginSpec<string, any, any>[]> {\n defaultValue?: string;\n options?: Partial<InferValues<T[number]>>;\n extensions?: Extension[];\n}\ninterface InferRendererProps<T extends EditorPluginSpec<string, any, any>[]> {\n domProps?: {\n style?: CSSProperties;\n className?: string;\n };\n mergeConfig?: MergeConfig;\n a: SingleEditorProps<T>;\n b: SingleEditorProps<T>;\n didMount?: (e: {\n a: InferEditorAPIFromPlugins<T>;\n b: InferEditorAPIFromPlugins<T>;\n }) => void;\n children?: ReactNode;\n}\n\nfunction MergeViewRenderer<T extends EditorPluginSpec<string, any, any>[]>(\n props: { plugins: T } & InferRendererProps<T>,\n) {\n const {\n plugins,\n mergeConfig,\n a,\n b,\n domProps = {},\n didMount,\n children,\n } = props;\n\n const ref = useRef(null);\n const apiRef = useRef<any>(null);\n const propsRef = useRef<any>(null);\n const injector = useInjector();\n const mergeConfigRef = useRef(mergeConfig);\n const aRef = useRef(a);\n const bRef = useRef(b);\n\n aRef.current = a;\n bRef.current = b;\n propsRef.current = props;\n\n useEffect(() => {\n const a = aRef.current;\n const b = bRef.current;\n const config = mergeConfigRef.current ?? {};\n\n const { getExtensions, createAPI, createOptions, createEvents } = create({\n plugins,\n injector,\n });\n\n const aOptions = createOptions();\n const aEvents = createEvents();\n\n const bOptions = createOptions();\n const bEvents = createEvents();\n\n const mergeView = new MergeView({\n ...config,\n a: {\n doc: a.defaultValue ?? '',\n extensions: [\n ...getExtensions(a.options ?? {}, {\n options: aOptions,\n events: aEvents,\n }),\n ...(a.extensions ?? []),\n ],\n },\n b: {\n doc: b.defaultValue ?? '',\n extensions: [\n ...getExtensions(b.options ?? {}, {\n options: bOptions,\n events: bEvents,\n }),\n ...(b.extensions ?? []),\n ],\n },\n parent: ref.current!,\n });\n\n const aAPI = createAPI({\n view: mergeView.a,\n options: aOptions,\n events: aEvents,\n });\n\n const bAPI = createAPI({\n view: mergeView.b,\n options: bOptions,\n events: bEvents,\n });\n\n apiRef.current = {\n a: aAPI,\n b: bAPI,\n };\n\n if (typeof didMount === 'function') {\n didMount({ a: aAPI, b: bAPI });\n }\n\n return () => {\n aAPI.$destroy();\n bAPI.$destroy();\n mergeView.destroy();\n };\n }, []);\n\n useEffect(() => {\n apiRef.current?.a.$set(props.a.options ?? {});\n }, [props.a.options]);\n\n useEffect(() => {\n apiRef.current?.b.$set(props.b.options ?? {});\n }, [props.b.options]);\n\n return (\n <>\n <div {...domProps} ref={ref} />\n {children}\n </>\n );\n}\n\nexport { MergeViewRenderer };\n"],"mappings":";AAGA,OAAO;AAAA,EACL;AAAA,EACA;AAAA,OAGK;AAEP;AAAA,EAEE;AAAA,EAKA;AAAA,OACK;AAEP,SAA2B,iBAAiB;AAsB5C,SAAS,kBACP,OACA;AACA,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,WAAW,CAAC;AAAA,IACZ;AAAA,IACA;AAAA,EACF,IAAI;AAEJ,QAAM,MAAM,OAAO,IAAI;AACvB,QAAM,SAAS,OAAY,IAAI;AAC/B,QAAM,WAAW,OAAY,IAAI;AACjC,QAAM,WAAW,YAAY;AAC7B,QAAM,iBAAiB,OAAO,WAAW;AACzC,QAAM,OAAO,OAAO,CAAC;AACrB,QAAM,OAAO,OAAO,CAAC;AAErB,OAAK,UAAU;AACf,OAAK,UAAU;AACf,WAAS,UAAU;AAEnB,YAAU,MAAM;AACd,UAAMA,KAAI,KAAK;AACf,UAAMC,KAAI,KAAK;AACf,UAAM,SAAS,eAAe,WAAW,CAAC;AAE1C,UAAM,EAAE,eAAe,WAAW,eAAe,aAAa,IAAI,OAAO;AAAA,MACvE;AAAA,MACA;AAAA,IACF,CAAC;AAED,UAAM,WAAW,cAAc;AAC/B,UAAM,UAAU,aAAa;AAE7B,UAAM,WAAW,cAAc;AAC/B,UAAM,UAAU,aAAa;AAE7B,UAAM,YAAY,IAAI,UAAU;AAAA,MAC9B,GAAG;AAAA,MACH,GAAG;AAAA,QACD,KAAKD,GAAE,gBAAgB;AAAA,QACvB,YAAY;AAAA,UACV,GAAG,cAAcA,GAAE,WAAW,CAAC,GAAG;AAAA,YAChC,SAAS;AAAA,YACT,QAAQ;AAAA,UACV,CAAC;A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
3
|
import { EditorPluginSpec, InferValues, InferEditorAPIFromPlugins } from '@coze-editor/react';
|
|
4
4
|
import { Extension } from '@codemirror/state';
|
|
5
5
|
import { MergeConfig } from '@codemirror/merge';
|
|
6
|
-
export { goToNextChunk, goToPreviousChunk } from '@codemirror/merge';
|
|
7
6
|
|
|
8
7
|
interface SingleEditorProps<T extends EditorPluginSpec<string, any, any>[]> {
|
|
9
8
|
defaultValue?: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,6 @@ import { CSSProperties, ReactNode } from 'react';
|
|
|
3
3
|
import { EditorPluginSpec, InferValues, InferEditorAPIFromPlugins } from '@coze-editor/react';
|
|
4
4
|
import { Extension } from '@codemirror/state';
|
|
5
5
|
import { MergeConfig } from '@codemirror/merge';
|
|
6
|
-
export { goToNextChunk, goToPreviousChunk } from '@codemirror/merge';
|
|
7
6
|
|
|
8
7
|
interface SingleEditorProps<T extends EditorPluginSpec<string, any, any>[]> {
|
|
9
8
|
defaultValue?: string;
|
package/dist/index.js
CHANGED
|
@@ -29,9 +29,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
29
29
|
// src/index.ts
|
|
30
30
|
var index_exports = {};
|
|
31
31
|
__export(index_exports, {
|
|
32
|
-
MergeViewRenderer: () => MergeViewRenderer
|
|
33
|
-
goToNextChunk: () => import_merge2.goToNextChunk,
|
|
34
|
-
goToPreviousChunk: () => import_merge2.goToPreviousChunk
|
|
32
|
+
MergeViewRenderer: () => MergeViewRenderer
|
|
35
33
|
});
|
|
36
34
|
module.exports = __toCommonJS(index_exports);
|
|
37
35
|
|
|
@@ -128,13 +126,8 @@ function MergeViewRenderer(props) {
|
|
|
128
126
|
}, [props.b.options]);
|
|
129
127
|
return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement("div", { ...domProps, ref }), children);
|
|
130
128
|
}
|
|
131
|
-
|
|
132
|
-
// src/index.ts
|
|
133
|
-
var import_merge2 = require("@codemirror/merge");
|
|
134
129
|
// Annotate the CommonJS export names for ESM import in node:
|
|
135
130
|
0 && (module.exports = {
|
|
136
|
-
MergeViewRenderer
|
|
137
|
-
goToNextChunk,
|
|
138
|
-
goToPreviousChunk
|
|
131
|
+
MergeViewRenderer
|
|
139
132
|
});
|
|
140
133
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/renderer.tsx"],"sourcesContent":["// Copyright (c) 2025 coze-dev\n// SPDX-License-Identifier: MIT\n\nexport { MergeViewRenderer } from './renderer';\
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/renderer.tsx"],"sourcesContent":["// Copyright (c) 2025 coze-dev\n// SPDX-License-Identifier: MIT\n\nexport { MergeViewRenderer } from './renderer';\n","// Copyright (c) 2025 coze-dev\n// SPDX-License-Identifier: MIT\n\nimport React, {\n useRef,\n useEffect,\n type CSSProperties,\n type ReactNode,\n} from 'react';\n\nimport {\n // from core\n create,\n type EditorPluginSpec,\n type InferEditorAPIFromPlugins,\n type InferValues,\n // from react\n useInjector,\n} from '@coze-editor/react';\nimport { type Extension } from '@codemirror/state';\nimport { type MergeConfig, MergeView } from '@codemirror/merge';\n\ninterface SingleEditorProps<T extends EditorPluginSpec<string, any, any>[]> {\n defaultValue?: string;\n options?: Partial<InferValues<T[number]>>;\n extensions?: Extension[];\n}\ninterface InferRendererProps<T extends EditorPluginSpec<string, any, any>[]> {\n domProps?: {\n style?: CSSProperties;\n className?: string;\n };\n mergeConfig?: MergeConfig;\n a: SingleEditorProps<T>;\n b: SingleEditorProps<T>;\n didMount?: (e: {\n a: InferEditorAPIFromPlugins<T>;\n b: InferEditorAPIFromPlugins<T>;\n }) => void;\n children?: ReactNode;\n}\n\nfunction MergeViewRenderer<T extends EditorPluginSpec<string, any, any>[]>(\n props: { plugins: T } & InferRendererProps<T>,\n) {\n const {\n plugins,\n mergeConfig,\n a,\n b,\n domProps = {},\n didMount,\n children,\n } = props;\n\n const ref = useRef(null);\n const apiRef = useRef<any>(null);\n const propsRef = useRef<any>(null);\n const injector = useInjector();\n const mergeConfigRef = useRef(mergeConfig);\n const aRef = useRef(a);\n const bRef = useRef(b);\n\n aRef.current = a;\n bRef.current = b;\n propsRef.current = props;\n\n useEffect(() => {\n const a = aRef.current;\n const b = bRef.current;\n const config = mergeConfigRef.current ?? {};\n\n const { getExtensions, createAPI, createOptions, createEvents } = create({\n plugins,\n injector,\n });\n\n const aOptions = createOptions();\n const aEvents = createEvents();\n\n const bOptions = createOptions();\n const bEvents = createEvents();\n\n const mergeView = new MergeView({\n ...config,\n a: {\n doc: a.defaultValue ?? '',\n extensions: [\n ...getExtensions(a.options ?? {}, {\n options: aOptions,\n events: aEvents,\n }),\n ...(a.extensions ?? []),\n ],\n },\n b: {\n doc: b.defaultValue ?? '',\n extensions: [\n ...getExtensions(b.options ?? {}, {\n options: bOptions,\n events: bEvents,\n }),\n ...(b.extensions ?? []),\n ],\n },\n parent: ref.current!,\n });\n\n const aAPI = createAPI({\n view: mergeView.a,\n options: aOptions,\n events: aEvents,\n });\n\n const bAPI = createAPI({\n view: mergeView.b,\n options: bOptions,\n events: bEvents,\n });\n\n apiRef.current = {\n a: aAPI,\n b: bAPI,\n };\n\n if (typeof didMount === 'function') {\n didMount({ a: aAPI, b: bAPI });\n }\n\n return () => {\n aAPI.$destroy();\n bAPI.$destroy();\n mergeView.destroy();\n };\n }, []);\n\n useEffect(() => {\n apiRef.current?.a.$set(props.a.options ?? {});\n }, [props.a.options]);\n\n useEffect(() => {\n apiRef.current?.b.$set(props.b.options ?? {});\n }, [props.b.options]);\n\n return (\n <>\n <div {...domProps} ref={ref} />\n {children}\n </>\n );\n}\n\nexport { MergeViewRenderer };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACGA,mBAKO;AAEP,IAAAA,gBAQO;AAE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AA,MACA,QAAQ,IAAI;AAAA,IACd,CAAC;AAED,UAAM,OAAO,UAAU;AAAA,MACrB,MAAM,UAAU;AAAA,MAChB,SAAS;AAAA,MACT,QAAQ;AAAA,IACV,CAAC;AAED,UAAM,OAAO,UAAU;AAAA,MACrB,MAAM,UAAU;AAAA,MAChB,SAAS;AAAA,MACT,QAAQ;AAAA,IACV,CAAC;AAED,WAAO,UAAU;AAAA,MACf,GAAG;AAAA,MACH,GAAG;AAAA,IACL;AAEA,QAAI,OAAO,aAAa,YAAY;AAClC,eAAS,EAAE,GAAG,MAAM,GAAG,KAAK,CAAC;AAAA,IAC/B;AAEA,WAAO,MAAM;AACX,WAAK,SAAS;AACd,WAAK,SAAS;AACd,gBAAU,QAAQ;AAAA,IACpB;AAAA,EACF,GAAG,CAAC,CAAC;AAEL,8BAAU,MAAM;AAxIlB;AAyII,iBAAO,YAAP,mBAAgB,EAAE,KAAK,MAAM,EAAE,WAAW,CAAC;AAAA,EAC7C,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC;AAEpB,8BAAU,MAAM;AA5IlB;AA6II,iBAAO,YAAP,mBAAgB,EAAE,KAAK,MAAM,EAAE,WAAW,CAAC;AAAA,EAC7C,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC;AAEpB,SACE,6BAAAC,QAAA,2BAAAA,QAAA,gBACE,6BAAAA,QAAA,cAAC,SAAK,GAAG,UAAU,KAAU,GAC5B,QACH;AAEJ;","names":["import_react","a","b","React"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coze-editor/react-merge",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.f1005d",
|
|
4
4
|
"description": "react merge",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "fengzilong",
|
|
@@ -22,10 +22,9 @@
|
|
|
22
22
|
"dev": "vite --force",
|
|
23
23
|
"lint": "eslint && tsc --noEmit"
|
|
24
24
|
},
|
|
25
|
-
"dependencies": {
|
|
26
|
-
"@codemirror/merge": "^6.10.0"
|
|
27
|
-
},
|
|
25
|
+
"dependencies": {},
|
|
28
26
|
"devDependencies": {
|
|
27
|
+
"@codemirror/merge": "^6.10.0",
|
|
29
28
|
"@codemirror/state": "^6.4.1",
|
|
30
29
|
"@codemirror/view": "^6.26.1",
|
|
31
30
|
"@coze-arch/ts-config": "workspace:*",
|
|
@@ -41,11 +40,12 @@
|
|
|
41
40
|
"typescript": "^5.8.2"
|
|
42
41
|
},
|
|
43
42
|
"peerDependencies": {
|
|
43
|
+
"@codemirror/merge": "^6.10.0",
|
|
44
44
|
"@codemirror/state": "^6.4.1",
|
|
45
45
|
"@codemirror/view": "^6.26.1",
|
|
46
|
-
"@coze-editor/react": "0.1.0-alpha.
|
|
47
|
-
"react": "
|
|
48
|
-
"react-dom": "
|
|
46
|
+
"@coze-editor/react": "0.1.0-alpha.f1005d",
|
|
47
|
+
"react": ">=16.8",
|
|
48
|
+
"react-dom": ">=16.8"
|
|
49
49
|
},
|
|
50
50
|
"packageManager": "pnpm@9.15.0",
|
|
51
51
|
"publishConfig": {
|