diff --git a/src/views/infra/bookmark/index.vue b/src/views/infra/bookmark/index.vue index b596ea3..40a3f3b 100644 --- a/src/views/infra/bookmark/index.vue +++ b/src/views/infra/bookmark/index.vue @@ -116,6 +116,12 @@ onMounted(async () => { case 'ReplaceTextAndInsertTableRow': handleReplaceTextAndInsertTableRow(data) break + case 'ReplaceTextAndInsertTableRowWithContentControl': + handleReplaceTextAndInsertTableRowWithContentControl(data) + break + case 'NextEditableZone': + handleNextEditableZone() + break } // WOPI Client发送消息 switch (MessageId) { @@ -609,6 +615,53 @@ function handleReplaceTextAndInsertTableRow(data: any) { }) } +function handleReplaceTextAndInsertTableRowWithContentControl(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: 'ReplaceTextAndInsertTableRowWithContentControl', + Values: { + params: { + type: 'string', + value: JSON.stringify({ + text, + table: tableData, + }), + }, + }, + }) +} + +const callCount = ref(0) + +function handleNextEditableZone() { + sendMessageToWopiClient({ + MessageId: 'CallPythonScript', + SendTime: Date.now(), + ScriptFile: 'BookmarkOP.py', + Function: 'NextEditableZone', + Values: { + params: { + type: 'string', + value: callCount.value.toString(), + }, + }, + }) + callCount.value++ +} + function logEvent(e: MessageEvent) { console.log('=============receive message start=======') console.log(typeof e.data)