From 4476517dcb4a9b4a399f7d6a3eca9b467acd8f9c Mon Sep 17 00:00:00 2001 From: zzs Date: Tue, 25 Mar 2025 14:13:48 +0800 Subject: [PATCH] wip: replace bookmark and insert table row --- src/views/infra/bookmark/index.vue | 32 ++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/views/infra/bookmark/index.vue b/src/views/infra/bookmark/index.vue index bf184be..b596ea3 100644 --- a/src/views/infra/bookmark/index.vue +++ b/src/views/infra/bookmark/index.vue @@ -113,6 +113,9 @@ onMounted(async () => { case 'ModifyStatus': handleSendModifyStatus() break + case 'ReplaceTextAndInsertTableRow': + handleReplaceTextAndInsertTableRow(data) + break } // WOPI Client发送消息 switch (MessageId) { @@ -577,6 +580,35 @@ function handleDocumentReady(data: any) { } } +function handleReplaceTextAndInsertTableRow(data: any) { + const Payload = data.Payload + const text = Payload.text + const table = Payload.table + const tableData: any[] = [] + for (const tab_obj of table) { + tableData.push({ + location_bookmark_name: tab_obj.bookmarkName, + start_row_index: tab_obj.startRowIndex, + data: tab_obj.data, + }) + } + sendMessageToWopiClient({ + MessageId: 'CallPythonScript', + SendTime: Date.now(), + ScriptFile: 'BookmarkOP.py', + Function: 'ReplaceTextAndInsertTableRow', + Values: { + params: { + type: 'string', + value: JSON.stringify({ + text, + table: tableData, + }), + }, + }, + }) +} + function logEvent(e: MessageEvent) { console.log('=============receive message start=======') console.log(typeof e.data)