feat: enhance document versioning and metadata handling in Word add-in
All checks were successful
Deploy eCourt Note Web to Server / Validate Database Schema (Drizzle) (push) Successful in 3s
Deploy eCourt Note Web to Server / Build Web Docker Image (push) Successful in 1m21s
Deploy eCourt Note Web to Server / Deploy eCourt Note Web to Server (push) Successful in 4s
Deploy eCourt Note Web to Server / Notify Deployment Status (push) Successful in 1s
All checks were successful
Deploy eCourt Note Web to Server / Validate Database Schema (Drizzle) (push) Successful in 3s
Deploy eCourt Note Web to Server / Build Web Docker Image (push) Successful in 1m21s
Deploy eCourt Note Web to Server / Deploy eCourt Note Web to Server (push) Successful in 4s
Deploy eCourt Note Web to Server / Notify Deployment Status (push) Successful in 1s
- Updated API documentation for document versioning to clarify usage and requirements. - Improved metadata service to support all content control types in Word API 1.5+. - Added tests for reading content control fields to ensure compatibility with various Word versions. - Refactored template service to utilize shared metadata functions for better maintainability.
This commit is contained in:
parent
677de2fc29
commit
3726cb742f
7 changed files with 187 additions and 58 deletions
|
|
@ -1,4 +1,4 @@
|
|||
/* global Word, Office */
|
||||
/* global Word */
|
||||
|
||||
/**
|
||||
* แท็บ "เครื่องมือ Template" (แท็บที่สองของ taskpane) — เครื่องมือจัดการ Content Controls
|
||||
|
|
@ -13,7 +13,8 @@
|
|||
* Body.contentControls: "rich text content control objects") — template ของศาลส่วนใหญ่เป็น
|
||||
* plain text CC จึงต้องใช้ `Document.getContentControls()` (WordApi 1.5, ครอบทุกชนิดที่รองรับ)
|
||||
* ผ่าน feature-detect ตอน runtime แทนการยก MinVersion ของ manifest (Office 2019 = 1.3
|
||||
* ต้องยังโหลดได้ — เห็นเฉพาะ rich text + UI แจ้งเตือน)
|
||||
* ต้องยังโหลดได้ — เห็นเฉพาะ rich text + UI แจ้งเตือน) — helper supportedContentControls
|
||||
* อยู่ที่ metadataService (แชร์กับ readContentControlFields ของฝั่ง versioning ด้วย)
|
||||
*
|
||||
* กติกาตาม repo: ห้ามมี Office/Word access ระดับ top-level (module นี้ถูก evaluate ใน
|
||||
* browser ธรรมดาตอนโหมด `?addindemo` ที่ไม่มี Office global — top-level access จะ throw ก่อน UI ทัน render) · operation ที่เขียนเอกสารต้อง suspend/resume
|
||||
|
|
@ -23,6 +24,7 @@
|
|||
|
||||
import { autoSaveService } from "./autoSaveService";
|
||||
import { getDetailedErrorMessage } from "./errors";
|
||||
import { supportsAllContentControlTypes, supportedContentControls } from "./metadataService";
|
||||
|
||||
/** ผลสแกนหนึ่งช่อง — id ของ CC ไม่เสถียรข้าม session/coauthor (ตาม docstring ของ Office.js
|
||||
* เอง: "The ID differs across sessions and coauthors") จึงใช้ได้เฉพาะอายุผลสแกนรอบเดียว ห้ามเก็บไปใช้ภายหลัง */
|
||||
|
|
@ -50,23 +52,10 @@ function toScannedField(control: Word.ContentControl): ScannedField {
|
|||
};
|
||||
}
|
||||
|
||||
/** host นี้มองเห็น CC ทุกชนิด (รวม plain text) ได้ไหม — WordApi 1.5+ เท่านั้น
|
||||
* (เรียกนอก Word เช่น browser ธรรมดา → catch คืน false เสมอ ตามแบบ canCloseDocument) */
|
||||
export function supportsAllContentControlTypes(): boolean {
|
||||
try {
|
||||
return Office.context.requirements.isSetSupported("WordApi", "1.5");
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/** collection ของ CC ที่ host รองรับสูงสุด — 1.5+ ใช้ getContentControls() (ทุกชนิด)
|
||||
* ต่ำกว่านั้นต้องยอมรับ collection rich-text-only */
|
||||
function supportedContentControls(context: Word.RequestContext): Word.ContentControlCollection {
|
||||
return supportsAllContentControlTypes()
|
||||
? context.document.getContentControls()
|
||||
: context.document.contentControls;
|
||||
}
|
||||
/** host นี้มองเห็น CC ทุกชนิด (รวม plain text) ได้ไหม — ย้ายไปอยู่ที่ metadataService
|
||||
* (2026-10-28) ให้ readContentControlFields ของฝั่ง versioning ใช้ร่วม แล้ว re-export
|
||||
* ไว้ที่นี่เพื่อให้ TemplateToolsPanel เรียกจาก templateService ได้ตามเดิม */
|
||||
export { supportsAllContentControlTypes } from "./metadataService";
|
||||
|
||||
/** สแกน Content Controls ทั้งเอกสาร (1 sync) — เรียงตามลำดับในเอกสาร · ไม่มีช่อง = คืน [] ไม่ error
|
||||
* อ่านอย่างเดียวจึงไม่ต้อง suspend auto-save */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue