| 938 | } |
| 939 | |
| 940 | private setupMobileViewportFix(root: HTMLElement) { |
| 941 | if (!Platform.isMobileApp) return; |
| 942 | const vv = window.visualViewport; |
| 943 | if (!vv) return; |
| 944 | |
| 945 | const apply = () => { |
| 946 | // Use the visual viewport to avoid layout issues when the on-screen keyboard is shown. |
| 947 | root.setCssProps({ height: `${vv.height}px` }); |
| 948 | this.editorView?.requestMeasure(); |
| 949 | }; |
| 950 | |
| 951 | apply(); |
| 952 | |
| 953 | vv.addEventListener("resize", apply); |
| 954 | vv.addEventListener("scroll", apply); |
| 955 | |
| 956 | this.cleanupMobileViewportFix = () => { |
| 957 | vv.removeEventListener("resize", apply); |
| 958 | vv.removeEventListener("scroll", apply); |
| 959 | root.setCssProps({ height: "" }); |
| 960 | }; |
| 961 | } |
| 962 | |
| 963 | // 重写 save 方法,只在真正有未保存修改时才保存 |
| 964 | async save(): Promise<void> { |