Procházet zdrojové kódy

fix: v2.4.6 二轮测试修复

wzl před 3 měsíci
rodič
revize
96cd16c8c8

+ 1 - 1
packages/core/src/editor/content_container.js

@@ -344,7 +344,7 @@ export class ContentContainer {
 
   handleKeyDown (e) {
     const selectedEditor = this.frameEditorList[this._selectedFrameIndex]
-    if (!selectedEditor || selectedEditor.state !== 1) return
+    if (!selectedEditor || selectedEditor.state !== 1 || document.querySelector('.n-color-picker-panel')) return
 
     const keyCode = e.keyCode || e.which
     if (keyCode === 8 || keyCode === 46) { // 8 delete键,46 backspace键

+ 12 - 8
packages/core/src/editor/text_editor.js

@@ -141,8 +141,7 @@ export class TextEditor {
         height: '100%',
         resize: 'none',
         opacity: 0,
-        touchAction: 'none',
-        zIndex: 1
+        touchAction: 'none'
       }
     )
     this.textContainer.append(textarea)
@@ -444,8 +443,6 @@ export class TextEditor {
       
     } else if (this.state === 2) {
       if (isMobileDevice) {
-        this.textarea.focus()
-
         const offsetX = e.changedTouches[0].clientX - this.pageViewer.div.getBoundingClientRect().left
         const offsetY = e.changedTouches[0].clientY - this.pageViewer.div.getBoundingClientRect().top
 
@@ -575,6 +572,7 @@ export class TextEditor {
 
       let endPoint
       if (isMobileDevice) {
+        this.textarea.focus()
         const offsetX = e.changedTouches[0].clientX - this.pageViewer.div.getBoundingClientRect().left
         const offsetY = e.changedTouches[0].clientY - this.pageViewer.div.getBoundingClientRect().top
 
@@ -635,10 +633,11 @@ export class TextEditor {
       this.textarea.addEventListener('blur', this.onBlur)
       this.textarea.addEventListener('keydown', this.onKeydown)
       this.textarea.addEventListener(this.textInput, this.onTextInput)
-      if (this.isFirefox) {
+      if (this.isFirefox || isMobileDevice) {
         this.textarea.addEventListener('compositionstart', this.onCompositionstart)
         this.textarea.addEventListener('compositionend', this.onCompositionend)
       }
+      onClickOutsideUp([this.textContainer], this.handleTextOutside.bind(this))
     }
 
     this.frameContainer.classList.add('selected')
@@ -836,6 +835,11 @@ export class TextEditor {
     // console.log('blur')
   }
 
+  handleTextOutside () {
+    this.cursor?.remove()
+    this.cursor = null
+  }
+
   async handleOutside () {
     if (this.moving) {
       const elements = [this.textContainer, this.outerLine, this.deletetButton]
@@ -911,7 +915,7 @@ export class TextEditor {
     this.textarea.removeEventListener('blur', this.onBlur)
     this.textarea.removeEventListener('keydown', this.onKeydown)
     this.textarea.removeEventListener(this.textInput, this.onTextInput)
-    if (this.isFirefox) {
+    if (this.isFirefox || isMobileDevice) {
       this.textarea.removeEventListener('compositionstart', this.onCompositionstart)
       this.textarea.removeEventListener('compositionend', this.onCompositionend)
     }
@@ -996,7 +1000,7 @@ export class TextEditor {
 
     let data = e.data
 
-    if (this.isFirefox) {
+    if (this.isFirefox || isMobileDevice) {
       if (e.inputType === 'insertLineBreak') {
         data = '\n'
       } else if (this.composing || data === null) {
@@ -1740,7 +1744,7 @@ export class TextEditor {
     this.textarea.addEventListener('blur', this.onBlur)
     this.textarea.addEventListener('keydown', this.onKeydown)
     this.textarea.addEventListener(this.textInput, this.onTextInput)
-    if (this.isFirefox) {
+    if (this.isFirefox || isMobileDevice) {
       this.textarea.addEventListener('compositionstart', this.onCompositionstart)
       this.textarea.addEventListener('compositionend', this.onCompositionend)
     }

+ 1 - 1
packages/webview/package.json

@@ -28,7 +28,7 @@
     "eslint": "^8.22.0",
     "eslint-plugin-vue": "^9.3.0",
     "jsdom": "^20.0.1",
-    "naive-ui": "^2.34.3",
+    "naive-ui": "^2.39.0",
     "sass": "^1.55.0",
     "unplugin-vue-components": "^0.22.9",
     "vite": "^3.1.8",

+ 1 - 1
packages/webview/src/components/ContentEditorPanel/ContentEditorPanel.vue

@@ -182,7 +182,7 @@
     }
   }
   core.addEvent('LoadFont', loadFont)
-  const fontFamilyArr = ['Helvetica', 'Courier', 'Times-Roman']
+  const fontFamilyArr = ['Helvetica', 'Courier', 'Times-Roman', 'NotoSansSC-Regular', 'NotoSansSC-Bold', 'NotoSerifSC-Regular']
   const fontFamilyOptions = ref([])
   fontFamilyOptions.value = fontFamilyArr.map(fontFamily => {
     return {

+ 1 - 0
packages/webview/src/components/DocumentContainer/DocumentContainer.vue

@@ -761,6 +761,7 @@ window.instances.UI.loadDocument = async (file, {
         z-index: 1;
       }
       
+      .text-container,
       .text-container textarea {
         cursor: text;
       }

+ 12 - 12
packages/webview/src/components/LinkPanel/LinkPanel.vue

@@ -62,7 +62,7 @@
   const useViewer = useViewerStore()
   const useDocument = useDocumentStore()
 
-  const activePanelTab = ref('url')
+  const activePanelTab = ref('URL')
   const isOpen = computed(() => useViewer.isElementOpen('linkPanel'))
   const activeTool = computed(() => useDocument.getActiveTool)
   const currentPage = computed(() => useViewer.getCurrentPage)
@@ -81,7 +81,7 @@
   watch(() => isOpen.value, (newValue, oldValue) => {
     if (newValue) {
       useViewer.closeElement('pageModePanel')
-      activePanelTab.value = urlValue.value ? 'url' : pageValue.value ? 'page' : emailValue.value ? 'email' : 'url'
+      activePanelTab.value = urlValue.value ? 'URL' : pageValue.value ? 'PAGE' : emailValue.value ? 'EMAIL' : 'URL'
     }
   })
 
@@ -97,7 +97,7 @@
   }
 
   const saveAvailable = () => {
-    return ((activePanelTab.value === 'url' && validateLink(urlValue.value)) || (activePanelTab.value === 'page' && pageValue.value) || (activePanelTab.value === 'email' && validateEmail(emailValue.value)))
+    return ((activePanelTab.value === 'URL' && validateLink(urlValue.value)) || (activePanelTab.value === 'PAGE' && pageValue.value) || (activePanelTab.value === 'EMAIL' && validateEmail(emailValue.value)))
   }
 
   const validateEmail = (email) => {
@@ -111,13 +111,13 @@
   }
 
   const save = () => {
-    if (activePanelTab.value === 'url') {
+    if (activePanelTab.value === 'URL') {
       // const start = urlValue.value.startsWith('http://') || urlValue.value.startsWith('https://') || urlValue.value.startsWith('ftp://')
       // useDocument.setPropertyPanel({ 'url': start ? urlValue.value : 'https://' + urlValue.value })
       useDocument.setPropertyPanel({ 'destPage': '', 'url': urlValue.value })
-    } else if (activePanelTab.value === 'page') {
+    } else if (activePanelTab.value === 'PAGE') {
       useDocument.setPropertyPanel({ 'url': '', 'destPage': pageValue.value })
-    } else if (activePanelTab.value === 'email') {
+    } else if (activePanelTab.value === 'EMAIL') {
       const start = emailValue.value.startsWith('mailto:')
       useDocument.setPropertyPanel({ 'destPage': '', 'url': start ? emailValue.value : 'mailto:' + emailValue.value })
     }
@@ -135,17 +135,17 @@
         urlValue.value = props.url
         emailValue.value = ''
         pageValue.value = ''
-        activePanelTab.value = 'url'
+        activePanelTab.value = 'URL'
       } else if (props.destPage) {
         pageValue.value = props.destPage
         urlValue.value = ''
         emailValue.value = ''
-        activePanelTab.value = 'page'
+        activePanelTab.value = 'PAGE'
       } else {
         pageValue.value = ''
         urlValue.value = ''
         emailValue.value = ''
-        activePanelTab.value = 'url'
+        activePanelTab.value = 'URL'
       }
       useViewer.openElement('linkPanel')
     } else {
@@ -155,11 +155,11 @@
   core.addEvent('linkPanelChange', updateProperty)
 
   const empty = () => {
-    if (activePanelTab.value === 'url') {
+    if (activePanelTab.value === 'URL') {
       urlValue.value = ''
-    } else if (activePanelTab.value === 'page') {
+    } else if (activePanelTab.value === 'PAGE') {
       pageValue.value = ''
-    } else if (activePanelTab.value === 'email') {
+    } else if (activePanelTab.value === 'EMAIL') {
       emailValue.value = ''
     }
   }