@cozeloop/prompt-components 0.0.2 → 0.0.4
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/es/basic-editor/custom-facet.js +9 -0
- package/dist/es/basic-editor/diff.js +138 -0
- package/dist/{go-syntax-067c4f5d.mjs → es/basic-editor/extensions/go-syntax.js} +9 -16
- package/dist/es/basic-editor/extensions/go-template.js +16 -0
- package/dist/{go-theme-062a6df6.mjs → es/basic-editor/extensions/go-theme.js} +4 -3
- package/dist/es/basic-editor/extensions/jinja.js +80 -0
- package/dist/es/basic-editor/extensions/keymap.js +442 -0
- package/dist/es/basic-editor/extensions/language-support.js +12 -0
- package/dist/es/basic-editor/extensions/markdown.js +58 -0
- package/dist/es/basic-editor/extensions/search/dom/icon.js +250 -0
- package/dist/es/basic-editor/extensions/search/dom/match-count.js +33 -0
- package/dist/es/basic-editor/extensions/search/index.js +18 -0
- package/dist/es/basic-editor/extensions/search/panel.js +418 -0
- package/dist/es/basic-editor/extensions/search/theme.js +184 -0
- package/dist/es/basic-editor/extensions/validation.js +84 -0
- package/dist/es/basic-editor/extensions/validation.module.js +5 -0
- package/dist/es/basic-editor/extensions/validation_module.css +7 -0
- package/dist/es/basic-editor/extensions/variable.js +178 -0
- package/dist/es/basic-editor/index.js +171 -0
- package/dist/es/code-editor/code-editor.js +83 -0
- package/dist/es/code-editor/index.js +12 -0
- package/dist/es/code-editor/json-editor.js +157 -0
- package/dist/es/code-editor/raw-text-editor.js +46 -0
- package/dist/es/code-editor/text-editor.js +41 -0
- package/dist/es/code-editor/themes/coze-dark.js +112 -0
- package/dist/es/code-editor/themes/coze-light.js +118 -0
- package/dist/es/consts/index.js +12 -0
- package/dist/es/dev-layout/index.js +35 -0
- package/dist/es/idls/fornax_ml_flow2/index.js +2293 -0
- package/dist/es/idls/fornax_ml_flow2/namespaces/ai_annotate.js +41 -0
- package/dist/es/idls/fornax_ml_flow2/namespaces/aidpcallback.js +108 -0
- package/dist/es/idls/fornax_ml_flow2/namespaces/annotation_job.js +52 -0
- package/dist/es/idls/fornax_ml_flow2/namespaces/base.js +0 -0
- package/dist/es/idls/fornax_ml_flow2/namespaces/batch_infer.js +72 -0
- package/dist/es/idls/fornax_ml_flow2/namespaces/dataprocess.js +10 -0
- package/dist/es/idls/fornax_ml_flow2/namespaces/dataset.js +36 -0
- package/dist/es/idls/fornax_ml_flow2/namespaces/datasetv2.js +139 -0
- package/dist/es/idls/fornax_ml_flow2/namespaces/datasetv2job.js +40 -0
- package/dist/es/idls/fornax_ml_flow2/namespaces/datasetv2similarity.js +12 -0
- package/dist/es/idls/fornax_ml_flow2/namespaces/filter.js +0 -0
- package/dist/es/idls/fornax_ml_flow2/namespaces/flow_devops_evaluation_callback_common.js +36 -0
- package/dist/es/idls/fornax_ml_flow2/namespaces/flow_devops_prompt_common.js +318 -0
- package/dist/es/idls/fornax_ml_flow2/namespaces/fornax_domain_model.js +326 -0
- package/dist/es/idls/fornax_ml_flow2/namespaces/ml_flow_domain_model.js +327 -0
- package/dist/es/idls/fornax_ml_flow2/namespaces/openapi.js +0 -0
- package/dist/es/idls/fornax_ml_flow2/namespaces/stone_fornax_ml_flow_annotateservice.js +0 -0
- package/dist/es/idls/fornax_ml_flow2/namespaces/stone_fornax_ml_flow_annotationjobservice.js +0 -0
- package/dist/es/idls/fornax_ml_flow2/namespaces/stone_fornax_ml_flow_batchinferservice.js +0 -0
- package/dist/es/idls/fornax_ml_flow2/namespaces/stone_fornax_ml_flow_crowdsourcingannotationjobservice.js +0 -0
- package/dist/es/idls/fornax_ml_flow2/namespaces/stone_fornax_ml_flow_dataprocessservice.js +0 -0
- package/dist/es/idls/fornax_ml_flow2/namespaces/stone_fornax_ml_flow_datasetservice.js +0 -0
- package/dist/es/idls/fornax_ml_flow2/namespaces/stone_fornax_ml_flow_datasetservicev2.js +0 -0
- package/dist/es/idls/fornax_ml_flow2/namespaces/stone_fornax_ml_flow_modelservice.js +0 -0
- package/dist/es/idls/fornax_ml_flow2/namespaces/stone_fornax_ml_flow_openapi_annotationjobservice.js +0 -0
- package/dist/es/idls/fornax_ml_flow2/namespaces/stone_fornax_ml_flow_openapi_batchinferservice.js +0 -0
- package/dist/es/idls/fornax_ml_flow2/namespaces/stone_fornax_ml_flow_openapi_datasetservicev2.js +0 -0
- package/dist/es/idls/fornax_ml_flow2/namespaces/stone_fornax_ml_flow_tagservice.js +0 -0
- package/dist/es/idls/fornax_ml_flow2/namespaces/tag.js +33 -0
- package/dist/es/idls/prompt_api2/index.js +1995 -0
- package/dist/es/idls/prompt_api2/namespaces/base.js +0 -0
- package/dist/es/idls/prompt_api2/namespaces/flow_devops_prompt_callback.js +35 -0
- package/dist/es/idls/prompt_api2/namespaces/flow_devops_prompt_commercial_openapi.js +0 -0
- package/dist/es/idls/prompt_api2/namespaces/flow_devops_prompt_common.js +318 -0
- package/dist/es/idls/prompt_api2/namespaces/flow_devops_prompt_debug.js +0 -0
- package/dist/es/idls/prompt_api2/namespaces/flow_devops_prompt_manage.js +23 -0
- package/dist/es/idls/prompt_api2/namespaces/flow_devops_prompt_mcp.js +0 -0
- package/dist/es/idls/prompt_api2/namespaces/flow_devops_prompt_optimize.js +0 -0
- package/dist/es/idls/prompt_api2/namespaces/flow_devops_prompt_paas.js +43 -0
- package/dist/es/idls/prompt_api2/namespaces/flow_devops_prompt_platform.js +0 -0
- package/dist/es/idls/prompt_api2/namespaces/mcp.js +9 -0
- package/dist/es/idls/prompt_api2/namespaces/model.js +320 -0
- package/dist/es/idls/prompt_api2/namespaces/permission.js +47 -0
- package/dist/es/idls/prompt_api2/namespaces/release.js +25 -0
- package/dist/es/index.js +66 -0
- package/dist/es/mermaid-diagram/index.js +148 -0
- package/dist/es/mermaid-diagram/index.module.js +5 -0
- package/dist/es/mermaid-diagram/index_module.css +4 -0
- package/dist/es/mermaid-diagram/use-svg-pan-zoom.js +49 -0
- package/dist/es/mermaid-diagram/utils.js +74 -0
- package/dist/es/model-config-editor/basic-type.js +71 -0
- package/dist/es/model-config-editor/index.module.js +5 -0
- package/dist/es/model-config-editor/index_module.css +8 -0
- package/dist/es/model-config-editor/model-config-form.js +132 -0
- package/dist/es/model-config-editor/popover-type.js +118 -0
- package/dist/es/model-select/index.js +136 -0
- package/dist/es/model-select/index.module.js +5 -0
- package/dist/es/model-select/index_module.css +14 -0
- package/dist/es/model-select/model-option/index.js +161 -0
- package/dist/es/model-select/model-option/index.module.js +5 -0
- package/dist/es/model-select/model-option/index_module.css +23 -0
- package/dist/es/model-select/model-option-group/index.js +44 -0
- package/dist/es/prompt-editor/index.js +188 -0
- package/dist/es/prompt-editor/index.module.js +5 -0
- package/dist/es/prompt-editor/index_module.css +71 -0
- package/dist/es/prompt-editor/message-type-select.js +74 -0
- package/dist/es/schema-editor/index.js +43 -0
- package/dist/es/utils/base.js +53 -0
- package/dist/es/utils/model-config.js +32 -0
- package/dist/lib/basic-editor/custom-facet.js +33 -0
- package/dist/lib/basic-editor/diff.js +167 -0
- package/dist/lib/basic-editor/extensions/go-syntax.js +146 -0
- package/dist/lib/basic-editor/extensions/go-template.js +50 -0
- package/dist/lib/basic-editor/extensions/go-theme.js +1091 -0
- package/dist/lib/basic-editor/extensions/jinja.js +100 -0
- package/dist/lib/basic-editor/extensions/keymap.js +465 -0
- package/dist/lib/basic-editor/extensions/language-support.js +32 -0
- package/dist/lib/basic-editor/extensions/markdown.js +78 -0
- package/dist/lib/basic-editor/extensions/search/dom/icon.js +291 -0
- package/dist/lib/basic-editor/extensions/search/dom/match-count.js +67 -0
- package/dist/lib/basic-editor/extensions/search/index.js +38 -0
- package/dist/lib/basic-editor/extensions/search/panel.js +429 -0
- package/dist/lib/basic-editor/extensions/search/theme.js +208 -0
- package/dist/lib/basic-editor/extensions/validation.js +118 -0
- package/dist/lib/basic-editor/extensions/validation.module.js +25 -0
- package/dist/lib/basic-editor/extensions/validation_module.css +7 -0
- package/dist/lib/basic-editor/extensions/variable.js +190 -0
- package/dist/lib/basic-editor/index.js +193 -0
- package/dist/lib/code-editor/code-editor.js +117 -0
- package/dist/lib/code-editor/index.js +40 -0
- package/dist/lib/code-editor/json-editor.js +184 -0
- package/dist/lib/code-editor/raw-text-editor.js +70 -0
- package/dist/lib/code-editor/text-editor.js +75 -0
- package/dist/lib/code-editor/themes/coze-dark.js +136 -0
- package/dist/lib/code-editor/themes/coze-light.js +142 -0
- package/dist/lib/consts/index.js +38 -0
- package/dist/lib/dev-layout/index.js +69 -0
- package/dist/lib/idls/fornax_ml_flow2/index.js +2355 -0
- package/dist/lib/idls/fornax_ml_flow2/namespaces/ai_annotate.js +69 -0
- package/dist/lib/idls/fornax_ml_flow2/namespaces/aidpcallback.js +140 -0
- package/dist/lib/idls/fornax_ml_flow2/namespaces/annotation_job.js +82 -0
- package/dist/lib/idls/fornax_ml_flow2/namespaces/base.js +16 -0
- package/dist/lib/idls/fornax_ml_flow2/namespaces/batch_infer.js +105 -0
- package/dist/lib/idls/fornax_ml_flow2/namespaces/dataprocess.js +34 -0
- package/dist/lib/idls/fornax_ml_flow2/namespaces/dataset.js +63 -0
- package/dist/lib/idls/fornax_ml_flow2/namespaces/datasetv2.js +177 -0
- package/dist/lib/idls/fornax_ml_flow2/namespaces/datasetv2job.js +68 -0
- package/dist/lib/idls/fornax_ml_flow2/namespaces/datasetv2similarity.js +37 -0
- package/dist/lib/idls/fornax_ml_flow2/namespaces/filter.js +16 -0
- package/dist/lib/idls/fornax_ml_flow2/namespaces/flow_devops_evaluation_callback_common.js +62 -0
- package/dist/lib/idls/fornax_ml_flow2/namespaces/flow_devops_prompt_common.js +378 -0
- package/dist/lib/idls/fornax_ml_flow2/namespaces/fornax_domain_model.js +384 -0
- package/dist/lib/idls/fornax_ml_flow2/namespaces/ml_flow_domain_model.js +385 -0
- package/dist/lib/idls/fornax_ml_flow2/namespaces/openapi.js +16 -0
- package/dist/lib/idls/fornax_ml_flow2/namespaces/stone_fornax_ml_flow_annotateservice.js +16 -0
- package/dist/lib/idls/fornax_ml_flow2/namespaces/stone_fornax_ml_flow_annotationjobservice.js +16 -0
- package/dist/lib/idls/fornax_ml_flow2/namespaces/stone_fornax_ml_flow_batchinferservice.js +16 -0
- package/dist/lib/idls/fornax_ml_flow2/namespaces/stone_fornax_ml_flow_crowdsourcingannotationjobservice.js +16 -0
- package/dist/lib/idls/fornax_ml_flow2/namespaces/stone_fornax_ml_flow_dataprocessservice.js +16 -0
- package/dist/lib/idls/fornax_ml_flow2/namespaces/stone_fornax_ml_flow_datasetservice.js +16 -0
- package/dist/lib/idls/fornax_ml_flow2/namespaces/stone_fornax_ml_flow_datasetservicev2.js +16 -0
- package/dist/lib/idls/fornax_ml_flow2/namespaces/stone_fornax_ml_flow_modelservice.js +16 -0
- package/dist/lib/idls/fornax_ml_flow2/namespaces/stone_fornax_ml_flow_openapi_annotationjobservice.js +16 -0
- package/dist/lib/idls/fornax_ml_flow2/namespaces/stone_fornax_ml_flow_openapi_batchinferservice.js +16 -0
- package/dist/lib/idls/fornax_ml_flow2/namespaces/stone_fornax_ml_flow_openapi_datasetservicev2.js +16 -0
- package/dist/lib/idls/fornax_ml_flow2/namespaces/stone_fornax_ml_flow_tagservice.js +16 -0
- package/dist/lib/idls/fornax_ml_flow2/namespaces/tag.js +60 -0
- package/dist/lib/idls/prompt_api2/index.js +2042 -0
- package/dist/lib/idls/prompt_api2/namespaces/base.js +16 -0
- package/dist/lib/idls/prompt_api2/namespaces/flow_devops_prompt_callback.js +62 -0
- package/dist/lib/idls/prompt_api2/namespaces/flow_devops_prompt_commercial_openapi.js +16 -0
- package/dist/lib/idls/prompt_api2/namespaces/flow_devops_prompt_common.js +378 -0
- package/dist/lib/idls/prompt_api2/namespaces/flow_devops_prompt_debug.js +16 -0
- package/dist/lib/idls/prompt_api2/namespaces/flow_devops_prompt_manage.js +49 -0
- package/dist/lib/idls/prompt_api2/namespaces/flow_devops_prompt_mcp.js +16 -0
- package/dist/lib/idls/prompt_api2/namespaces/flow_devops_prompt_optimize.js +16 -0
- package/dist/lib/idls/prompt_api2/namespaces/flow_devops_prompt_paas.js +72 -0
- package/dist/lib/idls/prompt_api2/namespaces/flow_devops_prompt_platform.js +16 -0
- package/dist/lib/idls/prompt_api2/namespaces/mcp.js +33 -0
- package/dist/lib/idls/prompt_api2/namespaces/model.js +377 -0
- package/dist/lib/idls/prompt_api2/namespaces/permission.js +72 -0
- package/dist/lib/idls/prompt_api2/namespaces/release.js +50 -0
- package/dist/lib/index.js +110 -0
- package/dist/lib/mermaid-diagram/index.js +174 -0
- package/dist/lib/mermaid-diagram/index.module.js +25 -0
- package/dist/lib/mermaid-diagram/index_module.css +4 -0
- package/dist/lib/mermaid-diagram/use-svg-pan-zoom.js +83 -0
- package/dist/lib/mermaid-diagram/utils.js +98 -0
- package/dist/lib/model-config-editor/basic-type.js +103 -0
- package/dist/lib/model-config-editor/index.module.js +25 -0
- package/dist/lib/model-config-editor/index_module.css +8 -0
- package/dist/lib/model-config-editor/model-config-form.js +151 -0
- package/dist/lib/model-config-editor/popover-type.js +145 -0
- package/dist/lib/model-select/index.js +170 -0
- package/dist/lib/model-select/index.module.js +25 -0
- package/dist/lib/model-select/index_module.css +14 -0
- package/dist/lib/model-select/model-option/index.js +188 -0
- package/dist/lib/model-select/model-option/index.module.js +25 -0
- package/dist/lib/model-select/model-option/index_module.css +23 -0
- package/dist/lib/model-select/model-option-group/index.js +75 -0
- package/dist/lib/prompt-editor/index.js +218 -0
- package/dist/lib/prompt-editor/index.module.js +25 -0
- package/dist/lib/prompt-editor/index_module.css +71 -0
- package/dist/lib/prompt-editor/message-type-select.js +108 -0
- package/dist/lib/schema-editor/index.js +77 -0
- package/dist/lib/utils/base.js +82 -0
- package/dist/lib/utils/model-config.js +57 -0
- package/dist/{src → types}/basic-editor/custom-facet.d.ts +1 -2
- package/dist/types/basic-editor/diff.d.ts +15 -0
- package/dist/types/basic-editor/extensions/go-syntax.d.ts +71 -0
- package/dist/types/basic-editor/extensions/go-template.d.ts +1 -0
- package/dist/{src → types}/basic-editor/extensions/go-theme.d.ts +1 -1
- package/dist/types/basic-editor/extensions/jinja.d.ts +6 -0
- package/dist/{src → types}/basic-editor/extensions/keymap.d.ts +2 -3
- package/dist/types/basic-editor/extensions/language-support.d.ts +2 -0
- package/dist/types/basic-editor/extensions/markdown.d.ts +2 -0
- package/dist/types/basic-editor/extensions/search/dom/icon.d.ts +59 -0
- package/dist/types/basic-editor/extensions/search/dom/match-count.d.ts +14 -0
- package/dist/types/basic-editor/extensions/search/index.d.ts +1 -0
- package/dist/types/basic-editor/extensions/search/panel.d.ts +32 -0
- package/dist/types/basic-editor/extensions/search/theme.d.ts +1 -0
- package/dist/types/basic-editor/extensions/validation.d.ts +10 -0
- package/dist/types/basic-editor/extensions/variable.d.ts +14 -0
- package/dist/types/basic-editor/index.d.ts +28 -0
- package/dist/types/code-editor/code-editor.d.ts +23 -0
- package/dist/{src → types}/code-editor/index.d.ts +1 -1
- package/dist/types/code-editor/json-editor.d.ts +17 -0
- package/dist/types/code-editor/raw-text-editor.d.ts +11 -0
- package/dist/types/code-editor/text-editor.d.ts +23 -0
- package/dist/types/code-editor/themes/coze-dark.d.ts +1 -0
- package/dist/types/code-editor/themes/coze-light.d.ts +1 -0
- package/dist/{src → types}/consts/index.d.ts +1 -1
- package/dist/types/dev-layout/index.d.ts +13 -0
- package/dist/types/idls/fornax_ml_flow2/index.d.ts +750 -0
- package/dist/types/idls/fornax_ml_flow2/namespaces/ai_annotate.d.ts +102 -0
- package/dist/types/idls/fornax_ml_flow2/namespaces/aidpcallback.d.ts +227 -0
- package/dist/types/idls/fornax_ml_flow2/namespaces/annotation_job.d.ts +402 -0
- package/dist/types/idls/fornax_ml_flow2/namespaces/base.d.ts +18 -0
- package/dist/types/idls/fornax_ml_flow2/namespaces/batch_infer.d.ts +331 -0
- package/dist/types/idls/fornax_ml_flow2/namespaces/dataprocess.d.ts +16 -0
- package/dist/types/idls/fornax_ml_flow2/namespaces/dataset.d.ts +88 -0
- package/dist/types/idls/fornax_ml_flow2/namespaces/datasetv2.d.ts +462 -0
- package/dist/types/idls/fornax_ml_flow2/namespaces/datasetv2job.d.ts +180 -0
- package/dist/types/idls/fornax_ml_flow2/namespaces/datasetv2similarity.d.ts +8 -0
- package/dist/types/idls/fornax_ml_flow2/namespaces/filter.d.ts +39 -0
- package/dist/types/idls/fornax_ml_flow2/namespaces/flow_devops_evaluation_callback_common.d.ts +88 -0
- package/dist/types/idls/fornax_ml_flow2/namespaces/flow_devops_prompt_common.d.ts +370 -0
- package/dist/types/idls/fornax_ml_flow2/namespaces/fornax_domain_model.d.ts +320 -0
- package/dist/types/idls/fornax_ml_flow2/namespaces/ml_flow_domain_model.d.ts +510 -0
- package/dist/types/idls/fornax_ml_flow2/namespaces/openapi.d.ts +6 -0
- package/dist/types/idls/fornax_ml_flow2/namespaces/stone_fornax_ml_flow_annotateservice.d.ts +106 -0
- package/dist/types/idls/fornax_ml_flow2/namespaces/stone_fornax_ml_flow_annotationjobservice.d.ts +256 -0
- package/dist/types/idls/fornax_ml_flow2/namespaces/stone_fornax_ml_flow_batchinferservice.d.ts +73 -0
- package/dist/types/idls/fornax_ml_flow2/namespaces/stone_fornax_ml_flow_crowdsourcingannotationjobservice.d.ts +94 -0
- package/dist/types/idls/fornax_ml_flow2/namespaces/stone_fornax_ml_flow_dataprocessservice.d.ts +11 -0
- package/dist/types/idls/fornax_ml_flow2/namespaces/stone_fornax_ml_flow_datasetservice.d.ts +24 -0
- package/dist/types/idls/fornax_ml_flow2/namespaces/stone_fornax_ml_flow_datasetservicev2.d.ts +653 -0
- package/dist/types/idls/fornax_ml_flow2/namespaces/stone_fornax_ml_flow_modelservice.d.ts +83 -0
- package/dist/types/idls/fornax_ml_flow2/namespaces/stone_fornax_ml_flow_openapi_annotationjobservice.d.ts +81 -0
- package/dist/types/idls/fornax_ml_flow2/namespaces/stone_fornax_ml_flow_openapi_batchinferservice.d.ts +24 -0
- package/dist/types/idls/fornax_ml_flow2/namespaces/stone_fornax_ml_flow_openapi_datasetservicev2.d.ts +260 -0
- package/dist/types/idls/fornax_ml_flow2/namespaces/stone_fornax_ml_flow_tagservice.d.ts +111 -0
- package/dist/types/idls/fornax_ml_flow2/namespaces/tag.d.ts +109 -0
- package/dist/types/idls/prompt_api2/index.d.ts +653 -0
- package/dist/types/idls/prompt_api2/namespaces/base.d.ts +18 -0
- package/dist/types/idls/prompt_api2/namespaces/flow_devops_prompt_callback.d.ts +102 -0
- package/dist/types/idls/prompt_api2/namespaces/flow_devops_prompt_commercial_openapi.d.ts +81 -0
- package/dist/types/idls/prompt_api2/namespaces/flow_devops_prompt_common.d.ts +1270 -0
- package/dist/types/idls/prompt_api2/namespaces/flow_devops_prompt_debug.d.ts +197 -0
- package/dist/types/idls/prompt_api2/namespaces/flow_devops_prompt_manage.d.ts +769 -0
- package/dist/types/idls/prompt_api2/namespaces/flow_devops_prompt_mcp.d.ts +301 -0
- package/dist/types/idls/prompt_api2/namespaces/flow_devops_prompt_optimize.d.ts +155 -0
- package/dist/types/idls/prompt_api2/namespaces/flow_devops_prompt_paas.d.ts +198 -0
- package/dist/types/idls/prompt_api2/namespaces/flow_devops_prompt_platform.d.ts +230 -0
- package/dist/types/idls/prompt_api2/namespaces/mcp.d.ts +95 -0
- package/dist/types/idls/prompt_api2/namespaces/model.d.ts +315 -0
- package/dist/types/idls/prompt_api2/namespaces/permission.d.ts +52 -0
- package/dist/types/idls/prompt_api2/namespaces/release.d.ts +62 -0
- package/dist/{src → types}/index.d.ts +7 -7
- package/dist/types/mermaid-diagram/index.d.ts +12 -0
- package/dist/types/mermaid-diagram/use-svg-pan-zoom.d.ts +17 -0
- package/dist/{src → types}/mermaid-diagram/utils.d.ts +1 -1
- package/dist/types/model-config-editor/basic-type.d.ts +19 -0
- package/dist/types/model-config-editor/model-config-form.d.ts +14 -0
- package/dist/types/model-config-editor/popover-type.d.ts +25 -0
- package/dist/types/model-select/index.d.ts +38 -0
- package/dist/types/model-select/model-option/index.d.ts +30 -0
- package/dist/types/model-select/model-option-group/index.d.ts +15 -0
- package/dist/types/prompt-editor/index.d.ts +30 -0
- package/dist/types/prompt-editor/message-type-select.d.ts +16 -0
- package/dist/types/schema-editor/index.d.ts +18 -0
- package/dist/{src → types}/utils/base.d.ts +4 -5
- package/dist/types/utils/model-config.d.ts +4 -0
- package/package.json +9 -13
- package/dist/edenx.config.d.ts +0 -2
- package/dist/go-syntax-4deb0289.js +0 -8
- package/dist/go-theme-fbd8a4fa.js +0 -1
- package/dist/index.cjs +0 -61
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -2788
- package/dist/src/basic-editor/diff.d.ts +0 -16
- package/dist/src/basic-editor/extensions/go-syntax.d.ts +0 -71
- package/dist/src/basic-editor/extensions/go-template.d.ts +0 -1
- package/dist/src/basic-editor/extensions/jinja.d.ts +0 -4
- package/dist/src/basic-editor/extensions/language-support.d.ts +0 -2
- package/dist/src/basic-editor/extensions/markdown.d.ts +0 -2
- package/dist/src/basic-editor/extensions/search/dom/icon.d.ts +0 -59
- package/dist/src/basic-editor/extensions/search/dom/match-count.d.ts +0 -14
- package/dist/src/basic-editor/extensions/search/index.d.ts +0 -1
- package/dist/src/basic-editor/extensions/search/panel.d.ts +0 -33
- package/dist/src/basic-editor/extensions/search/theme.d.ts +0 -1
- package/dist/src/basic-editor/extensions/validation.d.ts +0 -8
- package/dist/src/basic-editor/extensions/variable.d.ts +0 -11
- package/dist/src/basic-editor/index.d.ts +0 -29
- package/dist/src/code-editor/json-editor.d.ts +0 -18
- package/dist/src/code-editor/raw-text-editor.d.ts +0 -11
- package/dist/src/dev-layout/index.d.ts +0 -7
- package/dist/src/mermaid-diagram/index.d.ts +0 -12
- package/dist/src/mermaid-diagram/use-svg-pan-zoom.d.ts +0 -12
- package/dist/src/model-config-editor/basic-type.d.ts +0 -13
- package/dist/src/model-config-editor/model-config-form.d.ts +0 -13
- package/dist/src/model-config-editor/popover-type.d.ts +0 -19
- package/dist/src/model-select/index.d.ts +0 -27
- package/dist/src/model-select/model-option/index.d.ts +0 -25
- package/dist/src/model-select/model-option-group/index.d.ts +0 -16
- package/dist/src/prompt-editor/index.d.ts +0 -31
- package/dist/src/prompt-editor/message-type-select.d.ts +0 -11
- package/dist/src/schema-editor/index.d.ts +0 -11
- package/dist/src/utils/model-config.d.ts +0 -5
- package/dist/style.css +0 -1
- package/dist/test-build.d.ts +0 -7
- package/dist/vite.config.d.ts +0 -2
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
21
|
+
import { useEffect, useState } from "react";
|
|
22
|
+
import {
|
|
23
|
+
Mention,
|
|
24
|
+
getCurrentMentionReplaceRange,
|
|
25
|
+
useEditor,
|
|
26
|
+
PositionMirror,
|
|
27
|
+
useLatest
|
|
28
|
+
} from "@coze-editor/editor/react";
|
|
29
|
+
import { Popover, Typography } from "@coze-arch/coze-design";
|
|
30
|
+
function Variable({
|
|
31
|
+
variables,
|
|
32
|
+
isGoTemplate
|
|
33
|
+
}) {
|
|
34
|
+
const [posKey, setPosKey] = useState("");
|
|
35
|
+
const [visible, setVisible] = useState(false);
|
|
36
|
+
const [position, setPosition] = useState(-1);
|
|
37
|
+
const editor = useEditor();
|
|
38
|
+
function insert(variableName) {
|
|
39
|
+
const range = getCurrentMentionReplaceRange(editor.$view.state);
|
|
40
|
+
if (!range) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
editor.replaceText(__spreadProps(__spreadValues({}, range), {
|
|
44
|
+
text: isGoTemplate ? `{{.${variableName}}}` : `{{${variableName}}}`,
|
|
45
|
+
cursorOffset: variableName ? 0 : -2
|
|
46
|
+
}));
|
|
47
|
+
setVisible(false);
|
|
48
|
+
}
|
|
49
|
+
function handleOpenChange(e) {
|
|
50
|
+
setPosition(e.state.selection.main.head);
|
|
51
|
+
setVisible(e.value && variables.length > 0);
|
|
52
|
+
}
|
|
53
|
+
useEffect(() => {
|
|
54
|
+
if (!editor) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
if (visible) {
|
|
58
|
+
editor.disableKeybindings(["ArrowUp", "ArrowDown", "Enter"]);
|
|
59
|
+
} else {
|
|
60
|
+
editor.disableKeybindings([]);
|
|
61
|
+
}
|
|
62
|
+
}, [editor, visible]);
|
|
63
|
+
const selectedIndex = usePopoverNavigation({
|
|
64
|
+
enable: visible,
|
|
65
|
+
variables,
|
|
66
|
+
onApply: insert
|
|
67
|
+
});
|
|
68
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
69
|
+
/* @__PURE__ */ jsx(
|
|
70
|
+
Mention,
|
|
71
|
+
{
|
|
72
|
+
trigger: (tr) => {
|
|
73
|
+
if (tr.docChanged) {
|
|
74
|
+
let context = void 0;
|
|
75
|
+
tr.changes.iterChanges((fromA, toA, fromB, toB, inserted) => {
|
|
76
|
+
if (fromA > 0 && // 新增,非替换
|
|
77
|
+
fromA === toA && // 新增内容为 {
|
|
78
|
+
inserted.toString() === "{}" && // { 前还有个 {
|
|
79
|
+
tr.state.sliceDoc(
|
|
80
|
+
Math.max(0, fromA - 1),
|
|
81
|
+
Math.max(0, fromA)
|
|
82
|
+
) === "{") {
|
|
83
|
+
context = {
|
|
84
|
+
from: fromB - 1,
|
|
85
|
+
to: toB + 1,
|
|
86
|
+
triggerCharacter: "{{",
|
|
87
|
+
cursorPosition: tr.state.selection.main.head
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
return context;
|
|
92
|
+
}
|
|
93
|
+
return void 0;
|
|
94
|
+
},
|
|
95
|
+
onOpenChange: handleOpenChange
|
|
96
|
+
}
|
|
97
|
+
),
|
|
98
|
+
/* @__PURE__ */ jsx(
|
|
99
|
+
Popover,
|
|
100
|
+
{
|
|
101
|
+
visible,
|
|
102
|
+
trigger: "custom",
|
|
103
|
+
position: "topLeft",
|
|
104
|
+
rePosKey: posKey,
|
|
105
|
+
content: /* @__PURE__ */ jsxs("div", { className: "p-1 min-w-[100px] flex flex-col gap-1", children: [
|
|
106
|
+
/* @__PURE__ */ jsx(Typography.Text, { type: "secondary", strong: true, children: "插入变量" }),
|
|
107
|
+
/* @__PURE__ */ jsx("div", { className: "max-h-[200px] overflow-y-auto", children: variables.map((variable, index) => /* @__PURE__ */ jsx(
|
|
108
|
+
"div",
|
|
109
|
+
{
|
|
110
|
+
className: `cursor-pointer hover:bg-gray-100 px-2 py-1 mb-0.5 rounded ${selectedIndex === index ? "!bg-gray-200" : ""}`,
|
|
111
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
112
|
+
onClick: () => (variable == null ? void 0 : variable.key) && insert(variable.key),
|
|
113
|
+
children: variable.key
|
|
114
|
+
},
|
|
115
|
+
variable.key
|
|
116
|
+
)) })
|
|
117
|
+
] }),
|
|
118
|
+
onClickOutSide: () => setVisible(false),
|
|
119
|
+
children: /* @__PURE__ */ jsx(
|
|
120
|
+
PositionMirror,
|
|
121
|
+
{
|
|
122
|
+
position,
|
|
123
|
+
onChange: () => setPosKey(String(Math.random()))
|
|
124
|
+
}
|
|
125
|
+
)
|
|
126
|
+
}
|
|
127
|
+
)
|
|
128
|
+
] });
|
|
129
|
+
}
|
|
130
|
+
function usePopoverNavigation(options) {
|
|
131
|
+
const { enable, variables, onApply } = options;
|
|
132
|
+
const [selectedIndex, setSelectedIndex] = useState(0);
|
|
133
|
+
const indexRef = useLatest(selectedIndex);
|
|
134
|
+
const variablesRef = useLatest([...variables, { key: "" }]);
|
|
135
|
+
const onApplyRef = useLatest(onApply);
|
|
136
|
+
useEffect(() => {
|
|
137
|
+
setSelectedIndex(0);
|
|
138
|
+
}, [enable]);
|
|
139
|
+
useEffect(() => {
|
|
140
|
+
if (!enable) {
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
function handleNavigation(e) {
|
|
144
|
+
switch (e.key) {
|
|
145
|
+
case "ArrowUp":
|
|
146
|
+
setSelectedIndex((prevIndex) => {
|
|
147
|
+
const nextIndex = prevIndex - 1;
|
|
148
|
+
return Math.max(0, nextIndex);
|
|
149
|
+
});
|
|
150
|
+
break;
|
|
151
|
+
case "ArrowDown":
|
|
152
|
+
setSelectedIndex((prevIndex) => {
|
|
153
|
+
const nextIndex = prevIndex + 1;
|
|
154
|
+
return Math.min(variablesRef.current.length - 1, nextIndex);
|
|
155
|
+
});
|
|
156
|
+
break;
|
|
157
|
+
case "Enter": {
|
|
158
|
+
const variableName = variablesRef.current[indexRef.current];
|
|
159
|
+
if (variableName) {
|
|
160
|
+
onApplyRef.current(variableName.key || "");
|
|
161
|
+
}
|
|
162
|
+
break;
|
|
163
|
+
}
|
|
164
|
+
default:
|
|
165
|
+
break;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
document.addEventListener("keydown", handleNavigation, false);
|
|
169
|
+
return () => {
|
|
170
|
+
document.removeEventListener("keydown", handleNavigation, false);
|
|
171
|
+
};
|
|
172
|
+
}, [enable]);
|
|
173
|
+
return selectedIndex;
|
|
174
|
+
}
|
|
175
|
+
var variable_default = Variable;
|
|
176
|
+
export {
|
|
177
|
+
variable_default as default
|
|
178
|
+
};
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
21
|
+
import {
|
|
22
|
+
forwardRef,
|
|
23
|
+
useEffect,
|
|
24
|
+
useImperativeHandle,
|
|
25
|
+
useMemo,
|
|
26
|
+
useRef
|
|
27
|
+
} from "react";
|
|
28
|
+
import {
|
|
29
|
+
EditorProvider,
|
|
30
|
+
Renderer,
|
|
31
|
+
Placeholder
|
|
32
|
+
} from "@coze-editor/editor/react";
|
|
33
|
+
import preset from "@coze-editor/editor/preset-prompt";
|
|
34
|
+
import { EditorView, keymap } from "@codemirror/view";
|
|
35
|
+
import { Prec } from "@codemirror/state";
|
|
36
|
+
import { indentWithTab } from "@codemirror/commands";
|
|
37
|
+
import Variable from "./extensions/variable";
|
|
38
|
+
import Validation from "./extensions/validation";
|
|
39
|
+
import { search } from "./extensions/search";
|
|
40
|
+
import MarkdownHighlight from "./extensions/markdown";
|
|
41
|
+
import LanguageSupport from "./extensions/language-support";
|
|
42
|
+
import { insertFourSpaces } from "./extensions/keymap";
|
|
43
|
+
import JinjaHighlight from "./extensions/jinja";
|
|
44
|
+
import { goExtension } from "./extensions/go-template";
|
|
45
|
+
const extensions = [
|
|
46
|
+
EditorView.theme({
|
|
47
|
+
".cm-gutters": {
|
|
48
|
+
backgroundColor: "transparent",
|
|
49
|
+
borderRight: "none"
|
|
50
|
+
},
|
|
51
|
+
".cm-scroller": {
|
|
52
|
+
paddingLeft: "10px",
|
|
53
|
+
paddingRight: "6px !important"
|
|
54
|
+
}
|
|
55
|
+
}),
|
|
56
|
+
Prec.high(keymap.of([{ key: "Tab", run: insertFourSpaces }, indentWithTab]))
|
|
57
|
+
];
|
|
58
|
+
const PromptBasicEditor = forwardRef(
|
|
59
|
+
({
|
|
60
|
+
defaultValue,
|
|
61
|
+
onChange,
|
|
62
|
+
variables,
|
|
63
|
+
height,
|
|
64
|
+
minHeight,
|
|
65
|
+
maxHeight,
|
|
66
|
+
fontSize = 13,
|
|
67
|
+
forbidJinjaHighlight,
|
|
68
|
+
forbidVariables,
|
|
69
|
+
readOnly,
|
|
70
|
+
linePlaceholder = "请输入内容,支持按此格式书写变量:{{USER_NAME}}",
|
|
71
|
+
customExtensions = [],
|
|
72
|
+
autoScrollToBottom,
|
|
73
|
+
onBlur,
|
|
74
|
+
isGoTemplate,
|
|
75
|
+
onFocus,
|
|
76
|
+
canSearch,
|
|
77
|
+
children,
|
|
78
|
+
isJinja2Template
|
|
79
|
+
}, ref) => {
|
|
80
|
+
const editorRef = useRef(null);
|
|
81
|
+
useImperativeHandle(ref, () => ({
|
|
82
|
+
setEditorValue: (value) => {
|
|
83
|
+
var _a;
|
|
84
|
+
const editor = editorRef.current;
|
|
85
|
+
if (!editor) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
(_a = editor == null ? void 0 : editor.setValue) == null ? void 0 : _a.call(editor, value || "");
|
|
89
|
+
},
|
|
90
|
+
insertText: (text) => {
|
|
91
|
+
const editor = editorRef.current;
|
|
92
|
+
if (!editor) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
const range = editor.getSelection();
|
|
96
|
+
if (!range) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
editor.replaceText(__spreadProps(__spreadValues({}, range), {
|
|
100
|
+
text,
|
|
101
|
+
cursorOffset: 0
|
|
102
|
+
}));
|
|
103
|
+
}
|
|
104
|
+
}));
|
|
105
|
+
const newExtensions = useMemo(() => {
|
|
106
|
+
const xExtensions = [...extensions, ...customExtensions];
|
|
107
|
+
const searchExt = canSearch ? [...search()] : [];
|
|
108
|
+
if (isGoTemplate) {
|
|
109
|
+
return [...xExtensions, goExtension, ...searchExt];
|
|
110
|
+
}
|
|
111
|
+
return [...xExtensions, ...searchExt];
|
|
112
|
+
}, [customExtensions, extensions, isGoTemplate, canSearch]);
|
|
113
|
+
useEffect(() => {
|
|
114
|
+
if (isJinja2Template || isGoTemplate) {
|
|
115
|
+
setTimeout(() => {
|
|
116
|
+
var _a;
|
|
117
|
+
(_a = editorRef.current) == null ? void 0 : _a.updateWholeDecorations();
|
|
118
|
+
}, 150);
|
|
119
|
+
}
|
|
120
|
+
}, [variables, isJinja2Template, isGoTemplate]);
|
|
121
|
+
return /* @__PURE__ */ jsxs(EditorProvider, { children: [
|
|
122
|
+
/* @__PURE__ */ jsx(
|
|
123
|
+
Renderer,
|
|
124
|
+
{
|
|
125
|
+
plugins: preset,
|
|
126
|
+
defaultValue,
|
|
127
|
+
options: {
|
|
128
|
+
editable: !readOnly,
|
|
129
|
+
readOnly,
|
|
130
|
+
height,
|
|
131
|
+
minHeight: minHeight || height,
|
|
132
|
+
maxHeight: maxHeight || height,
|
|
133
|
+
fontSize
|
|
134
|
+
},
|
|
135
|
+
onChange: (e) => onChange == null ? void 0 : onChange(e.value),
|
|
136
|
+
onFocus,
|
|
137
|
+
onBlur,
|
|
138
|
+
extensions: newExtensions,
|
|
139
|
+
didMount: (editor) => {
|
|
140
|
+
editorRef.current = editor;
|
|
141
|
+
if (autoScrollToBottom) {
|
|
142
|
+
editor.$view.dispatch({
|
|
143
|
+
effects: EditorView.scrollIntoView(
|
|
144
|
+
editor.$view.state.doc.length
|
|
145
|
+
)
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
),
|
|
151
|
+
!forbidVariables && /* @__PURE__ */ jsx(Variable, { variables: variables || [], isGoTemplate }),
|
|
152
|
+
/* @__PURE__ */ jsx(LanguageSupport, {}),
|
|
153
|
+
!forbidJinjaHighlight && !isGoTemplate && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
154
|
+
/* @__PURE__ */ jsx(
|
|
155
|
+
Validation,
|
|
156
|
+
{
|
|
157
|
+
variables,
|
|
158
|
+
isNormalTemplate: !isJinja2Template && !isGoTemplate
|
|
159
|
+
}
|
|
160
|
+
),
|
|
161
|
+
/* @__PURE__ */ jsx(JinjaHighlight, { isJinja2Template })
|
|
162
|
+
] }),
|
|
163
|
+
/* @__PURE__ */ jsx(MarkdownHighlight, {}),
|
|
164
|
+
/* @__PURE__ */ jsx(Placeholder, { children: linePlaceholder }),
|
|
165
|
+
children
|
|
166
|
+
] });
|
|
167
|
+
}
|
|
168
|
+
);
|
|
169
|
+
export {
|
|
170
|
+
PromptBasicEditor
|
|
171
|
+
};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { createRenderer, option } from "@coze-editor/editor/react";
|
|
2
|
+
import preset, { languages, themes } from "@coze-editor/editor/preset-code";
|
|
3
|
+
import { shell } from "@coze-editor/editor/language-shell";
|
|
4
|
+
import { json } from "@coze-editor/editor/language-json";
|
|
5
|
+
import { mixLanguages } from "@coze-editor/editor";
|
|
6
|
+
import { EditorView } from "@codemirror/view";
|
|
7
|
+
import { cozeLight } from "./themes/coze-light";
|
|
8
|
+
import { cozeDark } from "./themes/coze-dark";
|
|
9
|
+
languages.register("json", {
|
|
10
|
+
// mixLanguages 用于解决 「插值也使用了括号,导致无法正确高亮」的问题
|
|
11
|
+
language: mixLanguages({
|
|
12
|
+
outerLanguage: json.language
|
|
13
|
+
}),
|
|
14
|
+
languageService: json.languageService
|
|
15
|
+
});
|
|
16
|
+
languages.register("shell", shell);
|
|
17
|
+
themes.register("coze-light", cozeLight);
|
|
18
|
+
themes.register("coze-dark", cozeDark);
|
|
19
|
+
const minHeightOption = (value) => EditorView.theme({
|
|
20
|
+
".cm-content, .cm-gutter, .cm-right-gutter": {
|
|
21
|
+
minHeight: typeof value === "number" ? `${value}px` : typeof value === "string" ? value : "unset"
|
|
22
|
+
},
|
|
23
|
+
"&.cm-editor": {
|
|
24
|
+
minHeight: typeof value === "number" ? `${value}px` : typeof value === "string" ? value : "unset"
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
const maxHeightOption = (value) => EditorView.theme({
|
|
28
|
+
"&.cm-editor": {
|
|
29
|
+
maxHeight: typeof value === "number" ? `${value}px` : typeof value === "string" ? value : "unset"
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
const heightOption = (value) => EditorView.theme({
|
|
33
|
+
"&.cm-editor": {
|
|
34
|
+
height: typeof value === "number" ? `${value}px` : typeof value === "string" ? value : "unset"
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
const paddingOption = (value) => EditorView.theme({
|
|
38
|
+
"&.cm-editor": {
|
|
39
|
+
padding: typeof value === "number" ? `${value}px` : typeof value === "string" ? value : "unset"
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
const borderRadiusOption = (value) => EditorView.theme({
|
|
43
|
+
"&.cm-editor, .cm-gutters": {
|
|
44
|
+
borderRadius: typeof value === "number" ? `${value}px` : typeof value === "string" ? value : "unset"
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
const lineHeightOption = (value) => EditorView.theme({
|
|
48
|
+
".cm-content, .cm-gutter, .cm-right-gutter": {
|
|
49
|
+
lineHeight: typeof value === "number" ? `${value}px` : typeof value === "string" ? value : "unset"
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
function createStyleOptions() {
|
|
53
|
+
return [
|
|
54
|
+
option("minHeight", minHeightOption),
|
|
55
|
+
option("maxHeight", maxHeightOption),
|
|
56
|
+
option("editerHeight", heightOption),
|
|
57
|
+
option("borderRadius", borderRadiusOption),
|
|
58
|
+
option("padding", paddingOption),
|
|
59
|
+
option("lineHeight", lineHeightOption)
|
|
60
|
+
];
|
|
61
|
+
}
|
|
62
|
+
const builtinExtensions = [
|
|
63
|
+
EditorView.theme({
|
|
64
|
+
"&.cm-focused": {
|
|
65
|
+
outline: "none"
|
|
66
|
+
},
|
|
67
|
+
"& *": {
|
|
68
|
+
fontFamily: 'Menlo, Monaco, "Courier New", monospace'
|
|
69
|
+
}
|
|
70
|
+
}),
|
|
71
|
+
EditorView.theme({
|
|
72
|
+
"&.cm-content": {
|
|
73
|
+
wordBreak: "break-all"
|
|
74
|
+
}
|
|
75
|
+
})
|
|
76
|
+
];
|
|
77
|
+
const CodeEditor = createRenderer(
|
|
78
|
+
[...preset, ...createStyleOptions()],
|
|
79
|
+
builtinExtensions
|
|
80
|
+
);
|
|
81
|
+
export {
|
|
82
|
+
CodeEditor
|
|
83
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { EditorProvider } from "@coze-editor/editor/react";
|
|
2
|
+
import { CodeEditor } from "./code-editor";
|
|
3
|
+
import { TextEditor } from "./text-editor";
|
|
4
|
+
import { BaseJsonEditor } from "./json-editor";
|
|
5
|
+
import { BaseRawTextEditor } from "./raw-text-editor";
|
|
6
|
+
export {
|
|
7
|
+
BaseJsonEditor,
|
|
8
|
+
BaseRawTextEditor,
|
|
9
|
+
CodeEditor,
|
|
10
|
+
EditorProvider,
|
|
11
|
+
TextEditor
|
|
12
|
+
};
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
var __async = (__this, __arguments, generator) => {
|
|
2
|
+
return new Promise((resolve, reject) => {
|
|
3
|
+
var fulfilled = (value) => {
|
|
4
|
+
try {
|
|
5
|
+
step(generator.next(value));
|
|
6
|
+
} catch (e) {
|
|
7
|
+
reject(e);
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
var rejected = (value) => {
|
|
11
|
+
try {
|
|
12
|
+
step(generator.throw(value));
|
|
13
|
+
} catch (e) {
|
|
14
|
+
reject(e);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
18
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
import { jsx } from "react/jsx-runtime";
|
|
22
|
+
import React, {
|
|
23
|
+
useCallback,
|
|
24
|
+
useEffect,
|
|
25
|
+
useRef,
|
|
26
|
+
useImperativeHandle
|
|
27
|
+
} from "react";
|
|
28
|
+
import { EditorProvider } from "@coze-editor/editor/react";
|
|
29
|
+
import {
|
|
30
|
+
transformerCreator
|
|
31
|
+
} from "@coze-editor/editor/preset-code";
|
|
32
|
+
import { json } from "@coze-editor/editor/language-json";
|
|
33
|
+
import { EditorView } from "@codemirror/view";
|
|
34
|
+
import { CodeEditor } from "./code-editor";
|
|
35
|
+
const extensions = [
|
|
36
|
+
EditorView.theme({
|
|
37
|
+
".cm-activeLineGutter": {
|
|
38
|
+
backgroundColor: "transparent !important"
|
|
39
|
+
},
|
|
40
|
+
".cm-activeLine": {
|
|
41
|
+
backgroundColor: "transparent !important"
|
|
42
|
+
}
|
|
43
|
+
})
|
|
44
|
+
];
|
|
45
|
+
function findAllMatches(inputString, regex) {
|
|
46
|
+
const globalRegex = new RegExp(
|
|
47
|
+
regex,
|
|
48
|
+
regex.flags.includes("g") ? regex.flags : `${regex.flags}g`
|
|
49
|
+
);
|
|
50
|
+
let match;
|
|
51
|
+
const matches = [];
|
|
52
|
+
while (true) {
|
|
53
|
+
match = globalRegex.exec(inputString);
|
|
54
|
+
if (!match) {
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
if (match.index === globalRegex.lastIndex) {
|
|
58
|
+
globalRegex.lastIndex++;
|
|
59
|
+
}
|
|
60
|
+
matches.push({
|
|
61
|
+
match: match[0],
|
|
62
|
+
range: [match.index, match.index + match[0].length]
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
return matches;
|
|
66
|
+
}
|
|
67
|
+
const transformer = transformerCreator((text) => {
|
|
68
|
+
const originalSource = text.toString();
|
|
69
|
+
const matches = findAllMatches(originalSource, /\{\{([^\}]*)\}\}/g);
|
|
70
|
+
if (matches.length > 0) {
|
|
71
|
+
matches.forEach(({ range }) => {
|
|
72
|
+
text.replaceRange(range[0], range[1], "null");
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
return text;
|
|
76
|
+
});
|
|
77
|
+
const BaseJsonEditor = React.forwardRef(
|
|
78
|
+
(props, ref) => {
|
|
79
|
+
const {
|
|
80
|
+
value,
|
|
81
|
+
onChange,
|
|
82
|
+
placeholder,
|
|
83
|
+
className,
|
|
84
|
+
isDarkTheme,
|
|
85
|
+
readonly,
|
|
86
|
+
minHeight = "100px",
|
|
87
|
+
maxHeight,
|
|
88
|
+
editerHeight,
|
|
89
|
+
padding,
|
|
90
|
+
borderRadius
|
|
91
|
+
} = props;
|
|
92
|
+
const apiRef = useRef(null);
|
|
93
|
+
const handleChange = useCallback(
|
|
94
|
+
(e) => {
|
|
95
|
+
if (typeof onChange === "function") {
|
|
96
|
+
onChange(e.value);
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
[onChange]
|
|
100
|
+
);
|
|
101
|
+
useEffect(() => {
|
|
102
|
+
var _a;
|
|
103
|
+
(_a = apiRef.current) == null ? void 0 : _a.updateASTDecorations();
|
|
104
|
+
}, [isDarkTheme]);
|
|
105
|
+
useEffect(() => {
|
|
106
|
+
const editor = apiRef.current;
|
|
107
|
+
if (!editor) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
if (typeof value === "string" && value !== editor.getValue()) {
|
|
111
|
+
editor.setValue(value);
|
|
112
|
+
}
|
|
113
|
+
}, [value]);
|
|
114
|
+
const formatJson = () => __async(void 0, null, function* () {
|
|
115
|
+
var _a;
|
|
116
|
+
const view = (_a = apiRef.current) == null ? void 0 : _a.$view;
|
|
117
|
+
if (!view) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
view.dispatch(
|
|
121
|
+
yield json.languageService.format(view.state, {
|
|
122
|
+
tabSize: 2
|
|
123
|
+
})
|
|
124
|
+
);
|
|
125
|
+
});
|
|
126
|
+
useImperativeHandle(ref, () => ({
|
|
127
|
+
formatJson
|
|
128
|
+
}));
|
|
129
|
+
return /* @__PURE__ */ jsx(EditorProvider, { children: /* @__PURE__ */ jsx("div", { className, children: /* @__PURE__ */ jsx(
|
|
130
|
+
CodeEditor,
|
|
131
|
+
{
|
|
132
|
+
defaultValue: value != null ? value : "",
|
|
133
|
+
onChange: handleChange,
|
|
134
|
+
options: {
|
|
135
|
+
placeholder,
|
|
136
|
+
lineWrapping: true,
|
|
137
|
+
theme: isDarkTheme ? "coze-dark" : "coze-light",
|
|
138
|
+
languageId: "json",
|
|
139
|
+
editable: !readonly,
|
|
140
|
+
transformer,
|
|
141
|
+
minHeight,
|
|
142
|
+
maxHeight,
|
|
143
|
+
editerHeight,
|
|
144
|
+
borderRadius,
|
|
145
|
+
padding,
|
|
146
|
+
fontSize: 13,
|
|
147
|
+
lineHeight: 20
|
|
148
|
+
},
|
|
149
|
+
didMount: (api) => apiRef.current = api,
|
|
150
|
+
extensions
|
|
151
|
+
}
|
|
152
|
+
) }) });
|
|
153
|
+
}
|
|
154
|
+
);
|
|
155
|
+
export {
|
|
156
|
+
BaseJsonEditor
|
|
157
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useCallback, useEffect, useRef } from "react";
|
|
3
|
+
import { EditorProvider } from "@coze-editor/editor/react";
|
|
4
|
+
import { TextEditor } from "./text-editor";
|
|
5
|
+
const BaseRawTextEditor = forwardRef(
|
|
6
|
+
(props, ref) => {
|
|
7
|
+
const { value, onChange, placeholder, className, minHeight, readonly } = props;
|
|
8
|
+
const apiRef = useRef(null);
|
|
9
|
+
const handleChange = useCallback(
|
|
10
|
+
(e) => {
|
|
11
|
+
if (typeof onChange === "function") {
|
|
12
|
+
onChange(e.value);
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
[onChange]
|
|
16
|
+
);
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
const editor = apiRef.current;
|
|
19
|
+
if (!editor) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
if (typeof value === "string" && value !== editor.getValue()) {
|
|
23
|
+
editor.setValue(value);
|
|
24
|
+
}
|
|
25
|
+
}, [value]);
|
|
26
|
+
return /* @__PURE__ */ jsx(EditorProvider, { children: /* @__PURE__ */ jsx("div", { ref, className, children: /* @__PURE__ */ jsx(
|
|
27
|
+
TextEditor,
|
|
28
|
+
{
|
|
29
|
+
defaultValue: value != null ? value : "",
|
|
30
|
+
onChange: handleChange,
|
|
31
|
+
options: {
|
|
32
|
+
placeholder,
|
|
33
|
+
lineWrapping: true,
|
|
34
|
+
minHeight,
|
|
35
|
+
fontSize: 13,
|
|
36
|
+
editable: !readonly,
|
|
37
|
+
lineHeight: 20
|
|
38
|
+
},
|
|
39
|
+
didMount: (api) => apiRef.current = api
|
|
40
|
+
}
|
|
41
|
+
) }) });
|
|
42
|
+
}
|
|
43
|
+
);
|
|
44
|
+
export {
|
|
45
|
+
BaseRawTextEditor
|
|
46
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { createRenderer, option } from "@coze-editor/editor/react";
|
|
2
|
+
import universal from "@coze-editor/editor/preset-universal";
|
|
3
|
+
import { mixLanguages } from "@coze-editor/editor";
|
|
4
|
+
import { keymap, EditorView } from "@codemirror/view";
|
|
5
|
+
import { defaultKeymap, history, historyKeymap } from "@codemirror/commands";
|
|
6
|
+
const RawEditorTheme = EditorView.theme({
|
|
7
|
+
"&.cm-editor": {
|
|
8
|
+
outline: "none"
|
|
9
|
+
},
|
|
10
|
+
"&.cm-content": {
|
|
11
|
+
wordBreak: "break-all"
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
const minHeightOption = (value) => EditorView.theme({
|
|
15
|
+
".cm-content, .cm-gutter, .cm-right-gutter": {
|
|
16
|
+
minHeight: typeof value === "number" ? `${value}px` : typeof value === "string" ? value : "unset"
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
const lineHeightOption = (value) => EditorView.theme({
|
|
20
|
+
".cm-content, .cm-gutter, .cm-right-gutter": {
|
|
21
|
+
lineHeight: typeof value === "number" ? `${value}px` : typeof value === "string" ? value : "unset"
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
const extensions = [
|
|
25
|
+
mixLanguages({}),
|
|
26
|
+
RawEditorTheme,
|
|
27
|
+
// ...其他 extensions
|
|
28
|
+
history(),
|
|
29
|
+
keymap.of([...defaultKeymap, ...historyKeymap])
|
|
30
|
+
];
|
|
31
|
+
const TextEditor = createRenderer(
|
|
32
|
+
[
|
|
33
|
+
...universal,
|
|
34
|
+
option("minHeight", minHeightOption),
|
|
35
|
+
option("lineHeight", lineHeightOption)
|
|
36
|
+
],
|
|
37
|
+
extensions
|
|
38
|
+
);
|
|
39
|
+
export {
|
|
40
|
+
TextEditor
|
|
41
|
+
};
|