|
@@ -18,6 +18,7 @@ export class ContentContainer {
|
|
|
|
|
|
this.destroyed = false
|
|
|
this.rendered = false
|
|
|
+ this.isRendering = false
|
|
|
this.frameEditorList = []
|
|
|
this.tool = this.pageViewer.tool || ''
|
|
|
this.color = this.pageViewer.color || ''
|
|
@@ -62,6 +63,8 @@ export class ContentContainer {
|
|
|
if (this.contentContainer) {
|
|
|
return;
|
|
|
}
|
|
|
+ const rendering = this.isRendering
|
|
|
+ this.isRendering = true
|
|
|
|
|
|
const contentContainer = document.createElement('div')
|
|
|
contentContainer.className = 'contentContainer'
|
|
@@ -75,54 +78,59 @@ export class ContentContainer {
|
|
|
})
|
|
|
this.frameEditorList.length = 0
|
|
|
|
|
|
- const editAreaCount = await this.messageHandler.sendWithPromise('GetEditAreaCount', this.editPagePtr)
|
|
|
-
|
|
|
- for (let i = 0; i < editAreaCount; i++) {
|
|
|
- const editAreaPtr = await this.messageHandler.sendWithPromise('GetEditArea', {
|
|
|
- editPagePtr: this.editPagePtr,
|
|
|
- index: i
|
|
|
- })
|
|
|
- if (!editAreaPtr) continue
|
|
|
-
|
|
|
- const isTextPtr = await this.messageHandler.sendWithPromise('IsTextArea', editAreaPtr)
|
|
|
- if (isTextPtr) {
|
|
|
- const frameEditor = new TextEditor({
|
|
|
- eventBus: this.eventBus,
|
|
|
- contentContainer: this,
|
|
|
- container: this.contentContainer,
|
|
|
- pagePtr: this.pagePtr,
|
|
|
- editPagePtr: this.editPagePtr,
|
|
|
- editAreaPtr,
|
|
|
- editAreaIndex: i,
|
|
|
- viewport: this.pageViewer.viewport,
|
|
|
- scale: this.pageViewer.scale,
|
|
|
- messageHandler: this.messageHandler,
|
|
|
- pageViewer: this.pageViewer,
|
|
|
- hidden: this.tool === 'addImage'
|
|
|
- })
|
|
|
- this.frameEditorList.push(frameEditor)
|
|
|
- continue
|
|
|
- }
|
|
|
+ try {
|
|
|
+ const editAreaCount = await this.messageHandler.sendWithPromise('GetEditAreaCount', this.editPagePtr)
|
|
|
+ for (let i = 0; i < editAreaCount; i++) {
|
|
|
+ if (rendering) break
|
|
|
|
|
|
- const isImagePtr = await this.messageHandler.sendWithPromise('IsImageArea', editAreaPtr)
|
|
|
- if (isImagePtr) {
|
|
|
- const frameEditor = new ImageEditor({
|
|
|
- eventBus: this.eventBus,
|
|
|
- contentContainer: this,
|
|
|
- container: this.contentContainer,
|
|
|
- pagePtr: this.pagePtr,
|
|
|
+ const editAreaPtr = await this.messageHandler.sendWithPromise('GetEditArea', {
|
|
|
editPagePtr: this.editPagePtr,
|
|
|
- editAreaPtr,
|
|
|
- editAreaIndex: i,
|
|
|
- viewport: this.pageViewer.viewport,
|
|
|
- scale: this.pageViewer.scale,
|
|
|
- messageHandler: this.messageHandler,
|
|
|
- pageViewer: this.pageViewer,
|
|
|
- $t: this.$t,
|
|
|
- hidden: this.tool === 'addText'
|
|
|
+ index: i
|
|
|
})
|
|
|
- this.frameEditorList.push(frameEditor)
|
|
|
+ if (!editAreaPtr) continue
|
|
|
+
|
|
|
+ const isTextPtr = await this.messageHandler.sendWithPromise('IsTextArea', editAreaPtr)
|
|
|
+ if (isTextPtr) {
|
|
|
+ const frameEditor = new TextEditor({
|
|
|
+ eventBus: this.eventBus,
|
|
|
+ contentContainer: this,
|
|
|
+ container: this.contentContainer,
|
|
|
+ pagePtr: this.pagePtr,
|
|
|
+ editPagePtr: this.editPagePtr,
|
|
|
+ editAreaPtr,
|
|
|
+ editAreaIndex: i,
|
|
|
+ viewport: this.pageViewer.viewport,
|
|
|
+ scale: this.pageViewer.scale,
|
|
|
+ messageHandler: this.messageHandler,
|
|
|
+ pageViewer: this.pageViewer,
|
|
|
+ hidden: this.tool === 'addImage'
|
|
|
+ })
|
|
|
+ this.frameEditorList.push(frameEditor)
|
|
|
+ continue
|
|
|
+ }
|
|
|
+
|
|
|
+ const isImagePtr = await this.messageHandler.sendWithPromise('IsImageArea', editAreaPtr)
|
|
|
+ if (isImagePtr) {
|
|
|
+ const frameEditor = new ImageEditor({
|
|
|
+ eventBus: this.eventBus,
|
|
|
+ contentContainer: this,
|
|
|
+ container: this.contentContainer,
|
|
|
+ pagePtr: this.pagePtr,
|
|
|
+ editPagePtr: this.editPagePtr,
|
|
|
+ editAreaPtr,
|
|
|
+ editAreaIndex: i,
|
|
|
+ viewport: this.pageViewer.viewport,
|
|
|
+ scale: this.pageViewer.scale,
|
|
|
+ messageHandler: this.messageHandler,
|
|
|
+ pageViewer: this.pageViewer,
|
|
|
+ $t: this.$t,
|
|
|
+ hidden: this.tool === 'addText'
|
|
|
+ })
|
|
|
+ this.frameEditorList.push(frameEditor)
|
|
|
+ }
|
|
|
}
|
|
|
+ } finally {
|
|
|
+ this.isRendering = false
|
|
|
}
|
|
|
|
|
|
if (this.tool === 'addText') {
|
|
@@ -243,6 +251,7 @@ export class ContentContainer {
|
|
|
tool: this.tool,
|
|
|
color: this.color,
|
|
|
container: this.pageDiv,
|
|
|
+ pageViewer: this.pageViewer,
|
|
|
viewport: this.pageViewer.viewport,
|
|
|
scale: this.pageViewer.scale,
|
|
|
page: this.page,
|
|
@@ -260,6 +269,7 @@ export class ContentContainer {
|
|
|
tool: this.tool,
|
|
|
color: this.color,
|
|
|
container: this.pageDiv,
|
|
|
+ pageViewer: this.pageViewer,
|
|
|
viewport: this.pageViewer.viewport,
|
|
|
scale: this.pageViewer.scale,
|
|
|
page: this.page,
|