diff --git a/clinical-web/.gitignore b/clinical-web/.gitignore index d6f55d5..de7a357 100644 --- a/clinical-web/.gitignore +++ b/clinical-web/.gitignore @@ -16,6 +16,10 @@ dist-ssr scripts/.session.json scripts/.captcha.json scripts/.captcha.png + +# 浏览器行为探针(验证编辑器原子占位符用),构建产物与本地产物都不进仓库 +.probe-field-node/dist/ +.probe-field-node/node_modules/ # Editor directories and files .vscode/* !.vscode/extensions.json diff --git a/clinical-web/.probe-field-node/index.html b/clinical-web/.probe-field-node/index.html new file mode 100644 index 0000000..171f808 --- /dev/null +++ b/clinical-web/.probe-field-node/index.html @@ -0,0 +1,61 @@ + + +
+ +PENDING+ + + diff --git a/clinical-web/.probe-field-node/main.ts b/clinical-web/.probe-field-node/main.ts new file mode 100644 index 0000000..554ac41 --- /dev/null +++ b/clinical-web/.probe-field-node/main.ts @@ -0,0 +1,443 @@ +/** + * 「签署占位符 = 原子节点」的浏览器行为探针。 + * + * 为什么需要它:类型检查、构建、纯逻辑断言都只能证明"代码写得对", + * 证明不了 wangEditor/Slate 在真实浏览器里**真的**把占位符当成了原子节点。 + * 用户的核心诉求是「一次退格就能整块删掉」,这件事只有真跑一遍才算验证过。 + * + * 探针只 import 生产源码(utils/signing-field-node),不复制任何逻辑。 + * 通过 window.__probe 暴露一组原语,由 CDP 脚本编排场景。 + */ +import '@wangeditor/editor/dist/css/style.css' + +import { createEditor, DomEditor, SlateEditor, SlateTransforms } from '@wangeditor/editor' +import type { IDomEditor } from '@wangeditor/editor' + +import type { SigningFieldDef } from '../src/api/workbench/types' +import { + createSignFieldNode, + isSignFieldElement, + readFieldFromSignFieldNode, + registerSigningFieldNode, + removeSignFieldNodes, + SIGN_FIELD_CHIP_CLASS, + SIGN_FIELD_NODE_CLASS, + SIGN_FIELD_TYPE, + updateSignFieldNodes, +} from '../src/utils/signing-field-node' + +// 与 EditorWangPane.vue 一样,在创建编辑器之前注册 +registerSigningFieldNode() + +const FIELD: SigningFieldDef = { + id: 'patient', + label: '患者姓名', + kind: 'text', + required: true, + options: [], +} + +const INITIAL_HTML = '
甲乙丙
' + +function createProbeEditor(html: string): IDomEditor { + const container = document.getElementById('editor') + + // 复用同一个容器重建,先把上一次留下的 DOM 清掉 + if (container) { + container.innerHTML = '' + } + + return createEditor({ + selector: '#editor', + html, + mode: 'default', + config: { placeholder: '正文' }, + }) +} + +let editor: IDomEditor = createProbeEditor(INITIAL_HTML) + +function plain文书中还没有任何填写项,签署时不会采集患者填写内容。
+ +@@ -388,6 +619,7 @@ function save() { ref="paneRef" :model-value="valueHtml" @update:model-value="valueHtml = $event" + @select-field="selectFieldFromEditor" />