Browse Source

Merge branch 'master' into enhance/mobile

llcc 3 years ago
parent
commit
3dfa44eeba

+ 11 - 3
.github/workflows/build-desktop-release.yml

@@ -379,6 +379,13 @@ jobs:
           name: logseq-win64-builds
           path: ./
 
+      - name: Generate SHA256 checksums
+        run: |
+          sha256sum *-darwin-* > SHA256SUMS.txt
+          sha256sum *-win-* >> SHA256SUMS.txt
+          sha256sum *-linux-* >> SHA256SUMS.txt
+          cat SHA256SUMS.txt
+
       - name: List files
         run: ls -rl
 
@@ -388,12 +395,13 @@ jobs:
           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
         with:
           tag_name: nightly
-          name: 'Desktop App Nightly Relase $$'
+          name: 'Desktop APP Nightly Release $$'
           draft: false
           prerelease: ${{ (github.event_name == 'workflow_dispatch' && github.event.inputs.is-pre-release) || (github.event_name == 'schedule')}}
-          body: "This is a nightly release of the Logseq desktop app."
+          body: |
+            This is a nightly release of the Logseq desktop app.
+            It's unstable compared to the official releases, **use it with caution**!
           files: |
-            ./VERSION
             ./SHA256SUMS.txt
             ./*.zip
             ./*.dmg

+ 29 - 0
e2e-tests/code-editing.spec.ts

@@ -177,3 +177,32 @@ test('multiple code block', async ({ page }) => {
   expect(await page.inputValue('.block-editor textarea'))
     .toBe('中文 Heading\n```clojure\n:key-test\n\n```\nMiddle 🚀\n```clojure\n\n  :key-test 日本語\n\n```\nFooter')
 })
+
+test('click outside to exit', async ({ page }) => {
+  await createRandomPage(page)
+
+  await page.fill('.block-editor textarea', 'Header ``Click``\n```\n  ABC\n```')
+  await page.waitForTimeout(500) // wait for fill
+  await escapeToCodeEditor(page)
+  await page.type('.CodeMirror textarea', '  DEF\nGHI')
+
+  await page.waitForTimeout(500)
+  await page.click('text=Click')
+  await page.waitForTimeout(500)
+  // NOTE: auto-indent is on
+  expect(await page.inputValue('.block-editor textarea')).toBe('Header ``Click``\n```\n  ABC  DEF\n  GHI\n```')
+})
+
+test('click lanuage label to exit #3463', async ({ page }) => {
+  await createRandomPage(page)
+
+  await page.fill('.block-editor textarea', '```cpp\n```')
+  await page.waitForTimeout(500)
+  await escapeToCodeEditor(page)
+  await page.type('.CodeMirror textarea', '#include<iostream>')
+
+  await page.waitForTimeout(500)
+  await page.click('text=cpp') // the language label
+  await page.waitForTimeout(500)
+  expect(await page.inputValue('.block-editor textarea')).toBe('```cpp\n#include<iostream>\n```')
+})

+ 6 - 14
ios/App/App.xcodeproj/project.pbxproj

@@ -16,7 +16,6 @@
 		50B271D11FEDC1A000F3C39B /* public in Resources */ = {isa = PBXBuildFile; fileRef = 50B271D01FEDC1A000F3C39B /* public */; };
 		7435D10C2704659F00AB88E0 /* FolderPicker.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7435D10B2704659F00AB88E0 /* FolderPicker.swift */; };
 		7435D10F2704660B00AB88E0 /* FolderPicker.m in Sources */ = {isa = PBXBuildFile; fileRef = 7435D10E2704660B00AB88E0 /* FolderPicker.m */; };
-		B50C6194D06FE919721B594B /* Pods_Logseq.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 659A484D0A608EE5D778DEF1 /* Pods_Logseq.framework */; };
 		D32752BE275496C60039291C /* CloudKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D32752BD275496C60039291C /* CloudKit.framework */; };
 		D3D62A0A275C92880003FBDC /* FileContainer.swift in Sources */ = {isa = PBXBuildFile; fileRef = D3D62A09275C92880003FBDC /* FileContainer.swift */; };
 		D3D62A0C275C928F0003FBDC /* FileContainer.m in Sources */ = {isa = PBXBuildFile; fileRef = D3D62A0B275C928F0003FBDC /* FileContainer.m */; };
@@ -32,13 +31,10 @@
 		504EC3111FED79650016851F /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
 		504EC3131FED79650016851F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
 		50B271D01FEDC1A000F3C39B /* public */ = {isa = PBXFileReference; lastKnownFileType = folder; path = public; sourceTree = "<group>"; };
-		659A484D0A608EE5D778DEF1 /* Pods_Logseq.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Logseq.framework; sourceTree = BUILT_PRODUCTS_DIR; };
 		7435D10B2704659F00AB88E0 /* FolderPicker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FolderPicker.swift; sourceTree = "<group>"; };
 		7435D10D2704660A00AB88E0 /* App-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "App-Bridging-Header.h"; sourceTree = "<group>"; };
 		7435D10E2704660B00AB88E0 /* FolderPicker.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FolderPicker.m; sourceTree = "<group>"; };
 		8A489CEC51E94726DDD58810 /* Pods-Logseq.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Logseq.release.xcconfig"; path = "Target Support Files/Pods-Logseq/Pods-Logseq.release.xcconfig"; sourceTree = "<group>"; };
-		A693BFCEA424C37DF4D9AF1B /* Pods-App.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-App.release.xcconfig"; path = "Target Support Files/Pods-App/Pods-App.release.xcconfig"; sourceTree = "<group>"; };
-		B9A79754543D95E609C23F91 /* Pods-App.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-App.debug.xcconfig"; path = "Target Support Files/Pods-App/Pods-App.debug.xcconfig"; sourceTree = "<group>"; };
 		D32752BC275496A60039291C /* App.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = App.entitlements; sourceTree = "<group>"; };
 		D32752BD275496C60039291C /* CloudKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CloudKit.framework; path = System/Library/Frameworks/CloudKit.framework; sourceTree = SDKROOT; };
 		D32752BF2754C5AB0039291C /* AppDebug.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = AppDebug.entitlements; sourceTree = "<group>"; };
@@ -53,7 +49,6 @@
 			buildActionMask = 2147483647;
 			files = (
 				D32752BE275496C60039291C /* CloudKit.framework in Frameworks */,
-				B50C6194D06FE919721B594B /* Pods_Logseq.framework in Frameworks */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -104,7 +99,6 @@
 			isa = PBXGroup;
 			children = (
 				D32752BD275496C60039291C /* CloudKit.framework */,
-				659A484D0A608EE5D778DEF1 /* Pods_Logseq.framework */,
 			);
 			name = Frameworks;
 			sourceTree = "<group>";
@@ -112,8 +106,6 @@
 		D337740F89DEEAD18C87762B /* Pods */ = {
 			isa = PBXGroup;
 			children = (
-				B9A79754543D95E609C23F91 /* Pods-App.debug.xcconfig */,
-				A693BFCEA424C37DF4D9AF1B /* Pods-App.release.xcconfig */,
 				DE5650F4AD4E2242AB9C012D /* Pods-Logseq.debug.xcconfig */,
 				8A489CEC51E94726DDD58810 /* Pods-Logseq.release.xcconfig */,
 			);
@@ -388,14 +380,14 @@
 				CLANG_ENABLE_MODULES = YES;
 				CODE_SIGN_ENTITLEMENTS = App/AppDebug.entitlements;
 				CODE_SIGN_STYLE = Automatic;
-				CURRENT_PROJECT_VERSION = 2.2;
+				CURRENT_PROJECT_VERSION = 1;
 				DEVELOPMENT_TEAM = K378MFWK59;
 				INFOPLIST_FILE = App/Info.plist;
 				IPHONEOS_DEPLOYMENT_TARGET = 12.0;
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
-				MARKETING_VERSION = 2.2;
+				MARKETING_VERSION = 0.0.1;
 				OTHER_SWIFT_FLAGS = "$(inherited) \"-D\" \"COCOAPODS\" \"-DDEBUG\"";
-				PRODUCT_BUNDLE_IDENTIFIER = com.logseq.app;
+				PRODUCT_BUNDLE_IDENTIFIER = com.logseq.logseq;
 				PRODUCT_NAME = "$(TARGET_NAME)";
 				SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
 				SWIFT_OBJC_BRIDGING_HEADER = "App/App-Bridging-Header.h";
@@ -413,13 +405,13 @@
 				CLANG_ENABLE_MODULES = YES;
 				CODE_SIGN_ENTITLEMENTS = App/App.entitlements;
 				CODE_SIGN_STYLE = Automatic;
-				CURRENT_PROJECT_VERSION = 2.2;
+				CURRENT_PROJECT_VERSION = 1;
 				DEVELOPMENT_TEAM = K378MFWK59;
 				INFOPLIST_FILE = App/Info.plist;
 				IPHONEOS_DEPLOYMENT_TARGET = 12.0;
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
-				MARKETING_VERSION = 2.2;
-				PRODUCT_BUNDLE_IDENTIFIER = com.logseq.app;
+				MARKETING_VERSION = 0.0.1;
+				PRODUCT_BUNDLE_IDENTIFIER = com.logseq.logseq;
 				PRODUCT_NAME = "$(TARGET_NAME)";
 				SWIFT_ACTIVE_COMPILATION_CONDITIONS = "";
 				SWIFT_OBJC_BRIDGING_HEADER = "App/App-Bridging-Header.h";

+ 2 - 2
ios/App/App/App.entitlements

@@ -6,7 +6,7 @@
 	<string>development</string>
 	<key>com.apple.developer.icloud-container-identifiers</key>
 	<array>
-		<string>iCloud.com.logseq.app</string>
+		<string>iCloud.com.logseq.logseq</string>
 	</array>
 	<key>com.apple.developer.icloud-services</key>
 	<array>
@@ -14,7 +14,7 @@
 	</array>
 	<key>com.apple.developer.ubiquity-container-identifiers</key>
 	<array>
-		<string>iCloud.com.logseq.app</string>
+		<string>iCloud.com.logseq.logseq</string>
 	</array>
 </dict>
 </plist>

+ 2 - 2
ios/App/App/AppDebug.entitlements

@@ -8,7 +8,7 @@
 	<string>Development</string>
 	<key>com.apple.developer.icloud-container-identifiers</key>
 	<array>
-		<string>iCloud.com.logseq.app</string>
+		<string>iCloud.com.logseq.logseq</string>
 	</array>
 	<key>com.apple.developer.icloud-services</key>
 	<array>
@@ -16,7 +16,7 @@
 	</array>
 	<key>com.apple.developer.ubiquity-container-identifiers</key>
 	<array>
-		<string>iCloud.com.logseq.app</string>
+		<string>iCloud.com.logseq.logseq</string>
 	</array>
 </dict>
 </plist>

+ 10 - 2
ios/App/App/FileContainer.swift

@@ -14,8 +14,7 @@ public class FileContainer: CAPPlugin, UIDocumentPickerDelegate {
     public var _call: CAPPluginCall? = nil
 
     var containerUrl: URL? {
-        let id = "iCloud.com.logseq.app"
-        return FileManager.default.url(forUbiquityContainerIdentifier: id)?.appendingPathComponent("Documents")
+        return FileManager.default.url(forUbiquityContainerIdentifier: nil)?.appendingPathComponent("Documents")
     }
 
     @objc func ensureDocuments(_ call: CAPPluginCall) {
@@ -33,6 +32,15 @@ public class FileContainer: CAPPlugin, UIDocumentPickerDelegate {
             }
         }
 
+        let str = ""
+        let filename = (self.containerUrl?.appendingPathComponent(".logseq"))!
+
+        do {
+            try str.write(to: filename, atomically: true, encoding: String.Encoding.utf8)
+        } catch {
+            // failed to write file – bad permissions, bad filename, missing permissions, or more likely it can't be converted to the encoding
+        }
+
         self._call?.resolve([
             "path": self.containerUrl!.path
                             ])

+ 83 - 89
ios/App/App/Info.plist

@@ -2,94 +2,88 @@
 <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
 <plist version="1.0">
 <dict>
-	<key>APFiles</key>
-	<dict>
-		<key>APFileDescriptionKey</key>
-		<string></string>
-		<key>APFileDestinationPath</key>
-		<string></string>
-		<key>APFileName</key>
-		<string></string>
-		<key>APFileSourcePath</key>
-		<string></string>
-	</dict>
-	<key>CFBundleDevelopmentRegion</key>
-	<string>en</string>
-	<key>CFBundleDisplayName</key>
-	<string>Logseq</string>
-	<key>CFBundleExecutable</key>
-	<string>$(EXECUTABLE_NAME)</string>
-	<key>CFBundleIdentifier</key>
-	<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
-	<key>CFBundleInfoDictionaryVersion</key>
-	<string>6.0</string>
-	<key>CFBundleName</key>
-	<string>$(PRODUCT_NAME)</string>
-	<key>CFBundlePackageType</key>
-	<string>APPL</string>
-	<key>CFBundleShortVersionString</key>
-	<string>$(MARKETING_VERSION)</string>
-	<key>CFBundleVersion</key>
-	<string>$(CURRENT_PROJECT_VERSION)</string>
-	<key>LSRequiresIPhoneOS</key>
-	<true/>
-	<key>LSSupportsOpeningDocumentsInPlace</key>
-	<true/>
-	<key>NSAppTransportSecurity</key>
-	<dict>
-		<key>NSAllowsArbitraryLoads</key>
-		<true/>
-	</dict>
-	<key>NSCameraUsageDescription</key>
-	<string></string>
-	<key>NSDocumentsFolderUsageDescription</key>
-	<string></string>
-	<key>NSDownloadsFolderUsageDescription</key>
-	<string></string>
-	<key>NSFileProviderDomainUsageDescription</key>
-	<string></string>
-	<key>NSFileProviderPresenceUsageDescription</key>
-	<string></string>
-	<key>NSPhotoLibraryAddUsageDescription</key>
-	<string></string>
-	<key>NSPhotoLibraryUsageDescription</key>
-	<string></string>
-	<key>NSUbiquitousContainers</key>
-	<dict>
-		<key>iCloud.$(PRODUCT_BUNDLE_IDENTIFIER)</key>
-		<dict>
-			<key>NSUbiquitousContainerIsDocumentScopePublic</key>
-			<true/>
-			<key>NSUbiquitousContainerName</key>
-			<string>Logseq</string>
-			<key>NSUbiquitousContainerSupportedFolderLevels</key>
-			<string>None</string>
-		</dict>
-	</dict>
-	<key>UILaunchStoryboardName</key>
-	<string>LaunchScreen</string>
-	<key>UIMainStoryboardFile</key>
-	<string>Main</string>
-	<key>UIRequiredDeviceCapabilities</key>
-	<array>
-		<string>armv7</string>
-	</array>
-	<key>UISupportedInterfaceOrientations</key>
-	<array>
-		<string>UIInterfaceOrientationPortrait</string>
-		<string>UIInterfaceOrientationLandscapeLeft</string>
-		<string>UIInterfaceOrientationLandscapeRight</string>
-	</array>
-	<key>UISupportedInterfaceOrientations~ipad</key>
-	<array>
-		<string>UIInterfaceOrientationPortrait</string>
-		<string>UIInterfaceOrientationPortraitUpsideDown</string>
-		<string>UIInterfaceOrientationLandscapeLeft</string>
-		<string>UIInterfaceOrientationLandscapeRight</string>
-	</array>
-	<key>UISupportsDocumentBrowser</key>
-	<true/>
-	<key>UIViewControllerBasedStatusBarAppearance</key>
-	<true/>
+        <key>APFiles</key>
+        <dict>
+                <key>APFileDescriptionKey</key>
+                <string></string>
+                <key>APFileDestinationPath</key>
+                <string></string>
+                <key>APFileName</key>
+                <string></string>
+                <key>APFileSourcePath</key>
+                <string></string>
+        </dict>
+        <key>CFBundleDevelopmentRegion</key>
+        <string>en</string>
+        <key>CFBundleDisplayName</key>
+        <string>Logseq</string>
+        <key>CFBundleExecutable</key>
+        <string>$(EXECUTABLE_NAME)</string>
+        <key>CFBundleIdentifier</key>
+        <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
+        <key>CFBundleInfoDictionaryVersion</key>
+        <string>6.0</string>
+        <key>CFBundleName</key>
+        <string>$(PRODUCT_NAME)</string>
+        <key>CFBundlePackageType</key>
+        <string>APPL</string>
+        <key>CFBundleShortVersionString</key>
+        <string>$(MARKETING_VERSION)</string>
+        <key>CFBundleVersion</key>
+        <string>$(CURRENT_PROJECT_VERSION)</string>
+        <key>LSRequiresIPhoneOS</key>
+        <true/>
+        <key>LSSupportsOpeningDocumentsInPlace</key>
+        <true/>
+        <key>NSAppTransportSecurity</key>
+        <dict>
+                <key>NSAllowsArbitraryLoads</key>
+                <true/>
+        </dict>
+        <key>NSDocumentsFolderUsageDescription</key>
+        <string></string>
+        <key>NSDownloadsFolderUsageDescription</key>
+        <string></string>
+        <key>NSFileProviderDomainUsageDescription</key>
+        <string></string>
+        <key>NSFileProviderPresenceUsageDescription</key>
+        <string></string>
+        <key>NSUbiquitousContainers</key>
+        <dict>
+                <key>iCloud.com.logseq.logseq</key>
+                <dict>
+                        <key>NSUbiquitousContainerIsDocumentScopePublic</key>
+                        <true/>
+                        <key>NSUbiquitousContainerName</key>
+                        <string>Logseq</string>
+                        <key>NSUbiquitousContainerSupportedFolderLevels</key>
+                        <string>ANY</string>
+                </dict>
+        </dict>
+        <key>UILaunchStoryboardName</key>
+        <string>LaunchScreen</string>
+        <key>UIMainStoryboardFile</key>
+        <string>Main</string>
+        <key>UIRequiredDeviceCapabilities</key>
+        <array>
+                <string>armv7</string>
+        </array>
+        <key>UISupportedInterfaceOrientations</key>
+        <array>
+                <string>UIInterfaceOrientationPortrait</string>
+                <string>UIInterfaceOrientationLandscapeLeft</string>
+                <string>UIInterfaceOrientationLandscapeRight</string>
+        </array>
+        <key>UISupportedInterfaceOrientations~ipad</key>
+        <array>
+                <string>UIInterfaceOrientationPortrait</string>
+                <string>UIInterfaceOrientationPortraitUpsideDown</string>
+                <string>UIInterfaceOrientationLandscapeLeft</string>
+                <string>UIInterfaceOrientationLandscapeRight</string>
+        </array>
+        <key>UISupportsDocumentBrowser</key>
+        <true/>
+        <key>UIViewControllerBasedStatusBarAppearance</key>
+        <true/>
 </dict>
 </plist>

+ 4 - 0
ios/App/App/capacitor.config.json

@@ -14,5 +14,9 @@
 	},
 	"ios": {
 		"scheme": "Logseq"
+	},
+	"server": {
+		"url": "http://192.168.1.59:3001",
+		"cleartext": true
 	}
 }

+ 2 - 2
package.json

@@ -82,7 +82,6 @@
         "d3-force": "3.0.0",
         "diff": "5.0.0",
         "diff-match-patch": "1.0.5",
-        "electron": "15.1.2",
         "fs": "0.0.1-security",
         "fs-extra": "9.1.0",
         "fuse.js": "6.4.6",
@@ -108,6 +107,7 @@
         "react-tweet-embed": "1.2.2",
         "reakit": "0.11.1",
         "threads": "1.6.5",
-        "yargs-parser": "20.2.4"
+        "yargs-parser": "20.2.4",
+        "electron": "15.1.2"
     }
 }

+ 1 - 1
resources/package.json

@@ -38,7 +38,7 @@
     "@electron-forge/maker-rpm": "^6.0.0-beta.57",
     "@electron-forge/maker-squirrel": "^6.0.0-beta.57",
     "@electron-forge/maker-zip": "^6.0.0-beta.57",
-    "electron": "16.0.4",
+    "electron": "15.1.2",
     "electron-builder": "^22.11.7",
     "electron-forge-maker-appimage": "trusktr/electron-forge-maker-appimage#patch-1",
     "electron-rebuild": "3.2.5"

+ 8 - 6
src/main/frontend/components/block.cljs

@@ -1742,18 +1742,18 @@
                  (d/has-class? target "image-resize"))
         (editor-handler/clear-selection!)
         (editor-handler/unhighlight-blocks!)
-        (let [block (or (db/pull [:block/uuid (:block/uuid block)]) block)
-              f #(let [cursor-range (util/caret-range (gdom/getElement block-id))
+        (let [f #(let [block (or (db/pull [:block/uuid (:block/uuid block)]) block)
+                       cursor-range (util/caret-range (gdom/getElement block-id))
+                       new-content (:block/content block)
                        content (-> (property/remove-built-in-properties (:block/format block)
                                                                         content)
                                    (drawer/remove-logbook))]
                    ;; save current editing block
                    (let [{:keys [value] :as state} (editor-handler/get-state)]
                      (editor-handler/save-block! state value))
-
                    (state/set-editing!
                     edit-input-id
-                    content
+                    new-content
                     block
                     cursor-range
                     false))]
@@ -1934,8 +1934,8 @@
       [:div.flex.flex-row.block-content-wrapper
        [:div.flex-1.w-full {:style {:display (if (:slide? config) "block" "flex")}}
         (ui/catch-error
-          (block-content-fallback edit-input-id block)
-          (block-content config block edit-input-id block-id slide?))]
+         (block-content-fallback edit-input-id block)
+         (block-content config block edit-input-id block-id slide?))]
        [:div.flex.flex-row
         (when (and (:embed? config)
                    (:embed-parent config))
@@ -2612,6 +2612,8 @@
             (highlight/highlight (str (medley/random-uuid)) {:data-lang language} code)
             [:div
              (lazy-editor/editor config (str (dc/squuid)) attr code options)
+             ;; FIXME: The following code seemed unreachable
+             ;; options has key: :lines, :language, :full_content, :pos_meta
              (let [options (:options options)]
                (when (and (= language "text/x-clojure") (contains? (set options) ":results"))
                  (sci/eval-result code)))]))))))

+ 1 - 1
src/main/frontend/components/datetime.cljs

@@ -108,10 +108,10 @@
                                      block-id (or (:block/uuid (state/get-edit-block))
                                                   (:block/uuid block))
                                      typ (or @commands/*current-command typ)]
+                                 (state/clear-edit!)
                                  (editor-handler/set-block-timestamp! block-id
                                                                       typ
                                                                       text)
-                                 (state/clear-edit!)
                                  (when show?
                                    (reset! show? false))))
                              (clear-timestamp!)

+ 0 - 1
src/main/frontend/components/editor.cljs

@@ -104,7 +104,6 @@
       (when input
         (let [current-pos (cursor/pos input)
               edit-content (or (state/sub [:editor/content id]) "")
-              edit-block (state/sub :editor/block)
               sidebar? (in-sidebar? input)
               q (or
                  @editor-handler/*selected-text

+ 4 - 3
src/main/frontend/components/search.cljs

@@ -15,7 +15,7 @@
             [frontend.config :as config]
             [frontend.search :as search]
             [clojure.string :as string]
-            [goog.dom :as gdom]
+            [goog.object :as gobj]
             [medley.core :as medley]
             [frontend.context.i18n :as i18n]
             [frontend.date :as date]
@@ -387,8 +387,9 @@
             :on-change     (fn [e]
                              (when @search-timeout
                                (js/clearTimeout @search-timeout))
-                             (let [value (util/evalue e)]
-                               (if (string/blank? value)
+                             (let [value (util/evalue e)
+                                   is-composing? (util/event-is-composing? e)]
+                               (if (and (string/blank? value) (not is-composing?))
                                  (search-handler/clear-search! false)
                                  (let [search-mode (state/get-search-mode)
                                        opts (if (= :page search-mode)

+ 2 - 1
src/main/frontend/handler.cljs

@@ -216,6 +216,8 @@
     (on-load-events)
     (set-network-watcher!)
 
+    (mobile/init!)
+
     (util/indexeddb-check?
      (fn [_error]
        (notification/show! "Sorry, it seems that your browser doesn't support IndexedDB, we recommend to use latest Chrome(Chromium) or Firefox(Non-private mode)." :error false)
@@ -237,7 +239,6 @@
       (enable-datalog-console))
     (when (util/electron?)
       (el/listen!))
-    (mobile/init!)
     (js/setTimeout instrument! (* 60 1000))))
 
 (defn stop! []

+ 106 - 108
src/main/frontend/handler/editor.cljs

@@ -1257,7 +1257,7 @@
                ;; expand collapsed blocks
                (mapv (fn [b] (if (:collapsed (:block/properties b))
                                (vec (tree/sort-blocks (db/get-block-children repo (:block/uuid b)) b))
-                               [b])) )
+                               [b])))
                (flatten))
           block-ids* (mapv :block/uuid blocks*)
           level-blocks (blocks-with-level blocks*)
@@ -1702,9 +1702,9 @@
    "^" "^"
    "=" "="
    "/" "/"
-   "+" "+"
+   "+" "+"})
    ;; ":" ":"                              ; TODO: only properties editing and org mode tag
-   })
+
 
 (def reversed-autopair-map
   (zipmap (vals autopair-map)
@@ -2790,13 +2790,11 @@
           value (gobj/get input "value")
           ctrlKey (gobj/get e "ctrlKey")
           metaKey (gobj/get e "metaKey")
-          is-composing? (gobj/getValueByKeys e "event_" "isComposing")
           pos (cursor/pos input)
           shift? (.-shiftKey e)
           code (gobj/getValueByKeys e "event_" "code")]
       (cond
-        (and (or is-composing? (= key-code 229))
-             (not (state/get-editor-show-page-search-hashtag?)))
+        (util/event-is-composing? e)
         nil
 
         (or ctrlKey metaKey)
@@ -2873,112 +2871,112 @@
         :else
         nil))))
 
-;; key up
 (defn keyup-handler
   [state input input-id search-timeout]
   (fn [e key-code]
-    (let [k (gobj/get e "key")]
-      (when-not (= k "Process")
-        (let [code (gobj/getValueByKeys e "event_" "code")
-              format (:format (get-state))
-              current-pos (cursor/pos input)
-              value (gobj/get input "value")
-              c (util/nth-safe value (dec current-pos))
-              last-key-code (state/get-last-key-code)
-              blank-selected? (string/blank? (util/get-selected-text))
-              shift? (.-shiftKey e)]
-          (when-not (state/get-editor-show-input)
-            (cond
-              (and (not (contains? #{"ArrowDown" "ArrowLeft" "ArrowRight" "ArrowUp"} k))
-                   (not (:editor/show-page-search? @state/state))
-                   (not (:editor/show-page-search-hashtag? @state/state))
-                   (wrapped-by? input "[[" "]]"))
-              (let [orig-pos (cursor/get-caret-pos input)
-                    value (gobj/get input "value")
-                    square-pos (string/last-index-of (subs value 0 (:pos orig-pos)) "[[")
-                    pos (+ square-pos 2)
-                    _ (state/set-last-pos! pos)
-                    pos (assoc orig-pos :pos pos)
-                    command-step (if (= \# (util/nth-safe value (dec square-pos)))
-                                   :editor/search-page-hashtag
-                                   :editor/search-page)]
-                (commands/handle-step [command-step])
-                (reset! commands/*slash-caret-pos pos))
-
-              (and blank-selected?
-                   (or (= keycode/left-square-bracket key-code (:key-code last-key-code))
-                       (= keycode/left-square-bracket-code code (:code last-key-code)))
-                   (not shift?)
-                   (> current-pos 0)
-                   (not (wrapped-by? input "[[" "]]")))
-              (do
-                (commands/handle-step [:editor/input "[[]]" {:backward-truncate-number 2
-                                                             :backward-pos 2}])
-                (commands/handle-step [:editor/search-page])
-                (reset! commands/*slash-caret-pos (cursor/get-caret-pos input)))
-
-              (and blank-selected?
-                   (or (= keycode/left-paren key-code (:key-code last-key-code))
-                       (= keycode/left-paren-code code (:code last-key-code)))
-                   (:shift? last-key-code)
-                   shift?
-                   (> current-pos 0)
-                   (not (wrapped-by? input "((" "))")))
-              (do
-                (commands/handle-step [:editor/input "(())" {:backward-truncate-number 2
-                                                             :backward-pos 2}])
-                (commands/handle-step [:editor/search-block :reference])
-                (reset! commands/*slash-caret-pos (cursor/get-caret-pos input)))
-
-              (and (= "〈" c)
-                   (= "《" (util/nth-safe value (dec (dec current-pos))))
-                   (> current-pos 0))
-              (do
-                (commands/handle-step [:editor/input commands/angle-bracket {:last-pattern "《〈"
-                                                                             :backward-pos 0}])
-                (reset! commands/*angle-bracket-caret-pos (cursor/get-caret-pos input))
-                (reset! commands/*show-block-commands true))
-
-              (and (= c " ")
-                   (or (= (util/nth-safe value (dec (dec current-pos))) "#")
-                       (not (state/get-editor-show-page-search?))
-                       (and (state/get-editor-show-page-search?)
-                            (not= (util/nth-safe value current-pos) "]"))))
-              (state/set-editor-show-page-search-hashtag! false)
-
-              (and @*show-commands (not= k (state/get-editor-command-trigger)))
-              (let [matched-commands (get-matched-commands input)]
-                (if (seq matched-commands)
-                  (do
-                    (reset! *show-commands true)
-                    (reset! commands/*matched-commands matched-commands))
-                  (reset! *show-commands false)))
-
-              (and @*show-block-commands (not= key-code 188)) ; not <
-              (let [matched-block-commands (get-matched-block-commands input)]
-                (if (seq matched-block-commands)
-                  (cond
-                    (= key-code 9)       ;tab
-                    (when @*show-block-commands
-                      (util/stop e)
-                      (insert-command! input-id
-                                       (last (first matched-block-commands))
-                                       format
-                                       {:last-pattern commands/angle-bracket}))
-
-                    :else
-                    (reset! commands/*matched-block-commands matched-block-commands))
-                  (reset! *show-block-commands false)))
-
-              (nil? @search-timeout)
-              (close-autocomplete-if-outside input)
+    (when-not (util/event-is-composing? e)
+      (let [k (gobj/get e "key")
+            code (gobj/getValueByKeys e "event_" "code")
+            format (:format (get-state))
+            current-pos (cursor/pos input)
+            value (gobj/get input "value")
+            c (util/nth-safe value (dec current-pos))
+            last-key-code (state/get-last-key-code)
+            blank-selected? (string/blank? (util/get-selected-text))
+            shift? (.-shiftKey e)]
+        (when-not (state/get-editor-show-input)
+          (cond
+            (and (not (contains? #{"ArrowDown" "ArrowLeft" "ArrowRight" "ArrowUp"} k))
+                 (not (:editor/show-page-search? @state/state))
+                 (not (:editor/show-page-search-hashtag? @state/state))
+                 (wrapped-by? input "[[" "]]"))
+            (let [orig-pos (cursor/get-caret-pos input)
+                  value (gobj/get input "value")
+                  square-pos (string/last-index-of (subs value 0 (:pos orig-pos)) "[[")
+                  pos (+ square-pos 2)
+                  _ (state/set-last-pos! pos)
+                  pos (assoc orig-pos :pos pos)
+                  command-step (if (= \# (util/nth-safe value (dec square-pos)))
+                                 :editor/search-page-hashtag
+                                 :editor/search-page)]
+              (commands/handle-step [command-step])
+              (reset! commands/*slash-caret-pos pos))
+
+            (and blank-selected?
+                 (or (= keycode/left-square-bracket key-code (:key-code last-key-code))
+                     (= keycode/left-square-bracket-code code (:code last-key-code)))
+                 (not shift?)
+                 (> current-pos 0)
+                 (not (wrapped-by? input "[[" "]]")))
+            (do
+              (commands/handle-step [:editor/input "[[]]" {:backward-truncate-number 2
+                                                           :backward-pos 2}])
+              (commands/handle-step [:editor/search-page])
+              (reset! commands/*slash-caret-pos (cursor/get-caret-pos input)))
+
+            (and blank-selected?
+                 (or (= keycode/left-paren key-code (:key-code last-key-code))
+                     (= keycode/left-paren-code code (:code last-key-code)))
+                 (:shift? last-key-code)
+                 shift?
+                 (> current-pos 0)
+                 (not (wrapped-by? input "((" "))")))
+            (do
+              (commands/handle-step [:editor/input "(())" {:backward-truncate-number 2
+                                                           :backward-pos 2}])
+              (commands/handle-step [:editor/search-block :reference])
+              (reset! commands/*slash-caret-pos (cursor/get-caret-pos input)))
+
+            (and (= "〈" c)
+                 (= "《" (util/nth-safe value (dec (dec current-pos))))
+                 (> current-pos 0))
+            (do
+              (commands/handle-step [:editor/input commands/angle-bracket {:last-pattern "《〈"
+                                                                           :backward-pos 0}])
+              (reset! commands/*angle-bracket-caret-pos (cursor/get-caret-pos input))
+              (reset! commands/*show-block-commands true))
+
+            (and (= c " ")
+                 (or (= (util/nth-safe value (dec (dec current-pos))) "#")
+                     (not (state/get-editor-show-page-search?))
+                     (and (state/get-editor-show-page-search?)
+                          (not= (util/nth-safe value current-pos) "]"))))
+            (state/set-editor-show-page-search-hashtag! false)
+
+            (and @*show-commands (not= k (state/get-editor-command-trigger)))
+            (let [matched-commands (get-matched-commands input)]
+              (if (seq matched-commands)
+                (do
+                  (reset! *show-commands true)
+                  (reset! commands/*matched-commands matched-commands))
+                (reset! *show-commands false)))
+
+            (and @*show-block-commands (not= key-code 188)) ; not <
+            (let [matched-block-commands (get-matched-block-commands input)]
+              (if (seq matched-block-commands)
+                (cond
+                  (= key-code 9)       ;tab
+                  (when @*show-block-commands
+                    (util/stop e)
+                    (insert-command! input-id
+                                     (last (first matched-block-commands))
+                                     format
+                                     {:last-pattern commands/angle-bracket}))
+
+                  :else
+                  (reset! commands/*matched-block-commands matched-block-commands))
+                (reset! *show-block-commands false)))
+
+            (nil? @search-timeout)
+            (close-autocomplete-if-outside input)
+
+            :else
+            nil))
+        (when-not (= k "Shift")
+          (state/set-last-key-code! {:key-code key-code
+                                     :code code
+                                     :shift? (.-shiftKey e)}))))))
 
-              :else
-              nil))
-          (when-not (= k "Shift")
-            (state/set-last-key-code! {:key-code key-code
-                                       :code code
-                                       :shift? (.-shiftKey e)})))))))
 
 (defn editor-on-click!
   [id]

+ 6 - 3
src/main/frontend/mobile/core.cljs

@@ -3,8 +3,8 @@
             [frontend.state :as state]
             ["@capacitor/app" :refer [^js App]]
             [reitit.frontend.easy :as rfe]
-            [clojure.string :as string]))
-
+            [clojure.string :as string]
+            [frontend.fs.capacitor-fs :as fs]))
 
 (defn init!
   []
@@ -28,4 +28,7 @@
                                (string/ends-with? href "/")
                                (not (string/includes? href "#/")))
                          (.exitApp App)
-                         (js/window.history.back)))))))
+                         (js/window.history.back))))))
+  (when (mobile-util/native-ios?)
+    (let [path (fs/iOS-ensure-documents!)]
+      (println "iOS container path: " path))))

+ 7 - 7
src/main/frontend/page.cljs

@@ -10,11 +10,12 @@
   [view route-match]
   (view route-match))
 
-(defn- teardown-fn
+(defn- setup-fns!
   []
   (try
-    (ui/setup-active-keystroke!)
-    (ui/setup-patch-ios-visual-viewport-state!)
+    (comp
+      (ui/setup-active-keystroke!)
+      (ui/setup-patch-ios-visual-viewport-state!))
     (catch js/Error _e
       nil)))
 
@@ -25,11 +26,10 @@
                    (ui/inject-document-devices-envs!)
                    (ui/inject-dynamic-style-node!)
                    (plugin-handler/host-mounted!)
-                   (assoc state ::teardown teardown-fn))
+                   (assoc state ::teardown (setup-fns!) ))
    :will-unmount (fn [state]
-                   (let [teardown (::teardown state)]
-                     (when-not (nil? teardown)
-                       (teardown))))}
+                   (when-let [teardown (::teardown state)]
+                     (teardown)))}
   []
   (when-let [route-match (state/sub :route-match)]
     (i18n/tongue-provider

+ 6 - 0
src/main/frontend/util.cljc

@@ -1490,3 +1490,9 @@
    (defn sm-breakpoint?
      []
      (< (.-offsetWidth js/document.documentElement) 640)))
+
+#?(:cljs
+   (defn event-is-composing?
+     [e]
+     (or (gobj/getValueByKeys e "event_" "isComposing")
+         (= (.-keyCode e) 229))))