Parcourir la source

Merge branch 'master' into feat/vue3

tophf il y a 3 ans
Parent
commit
51c60475c8
3 fichiers modifiés avec 13 ajouts et 7 suppressions
  1. 8 4
      src/common/ui/code.vue
  2. 1 1
      src/common/ui/externals.vue
  3. 4 2
      src/options/views/app.vue

+ 8 - 4
src/common/ui/code.vue

@@ -214,15 +214,19 @@ export default {
       this.cm.setOption('mode', value || cmDefaults.mode);
     },
     value(value) {
+      const hasLongLines = new RegExp(`^\\s*.{${maxDisplayLength},}`, 'm').test(value);
       const { cm } = this;
       if (!cm) return;
-      const lines = value.split('\n');
-      const modified = this.createPlaceholders({ text: lines, from: { line: 0 } });
+      if (hasLongLines) {
+        const lines = value.split('\n');
+        this.createPlaceholders({ text: lines, from: { line: 0 } });
+        value = lines.join('\n');
+      }
       cm.off('beforeChange', this.onBeforeChange);
       cm.off('changes', this.onChanges);
       cm.operation(() => {
-        cm.setValue(modified ? lines.join('\n') : value);
-        if (modified) this.renderPlaceholders();
+        cm.setValue(value);
+        if (hasLongLines) this.renderPlaceholders();
       });
       cm.clearHistory();
       cm.markClean();

+ 1 - 1
src/common/ui/externals.vue

@@ -98,7 +98,7 @@ async function update() {
     } else if (contentType) {
       contentType = contentType.split(/[:;]/)[1];
     }
-    code = dataUri2text(raw);
+    code = dataUri2text(`${contentType};base64,${code}`);
     data.value = {
       mode: contentType === 'text/css' || /\.css([#&?]|$)/i.test(url) ? 'css' : null,
       code,

+ 4 - 2
src/options/views/app.vue

@@ -33,10 +33,11 @@ import About from './tab-about';
 
 const SETTINGS = 'settings';
 const SCRIPTS = 'scripts';
+const ABOUT = 'about';
 const tabs = [
   { name: SCRIPTS, comp: Installed, label: i18n('sideMenuInstalled') },
   { name: SETTINGS, comp: Settings, label: i18n('sideMenuSettings') },
-  { name: 'about', comp: About, label: i18n('sideMenuAbout') },
+  { name: ABOUT, comp: About, label: i18n('sideMenuAbout') },
 ];
 const extName = i18n('extName');
 const conditionNotEdit = '!editScript';
@@ -91,7 +92,8 @@ export default {
   },
   created() {
     document.addEventListener('dragover', evt => {
-      if (this.current !== SETTINGS && evt.dataTransfer.types.includes('Files')) {
+      if ([ABOUT, SCRIPTS].includes(window.location.hash.slice(1))
+      && /^application\/(zip|x-zip-compressed)$/.test(evt.dataTransfer.items[0]?.type)) {
         window.location.hash = `#${SETTINGS}`;
       }
     });