Tienson Qin před 1 rokem
rodič
revize
b0b24f795a

+ 202 - 202
deps/shui/shui-graph/pages/contents.md

@@ -1,208 +1,208 @@
 - [[About Shui]]
 - [[shui/components]] if there was text here
-	- beta
-		- [[shui/components/table]]
-	- up next
-		- [[shui/components/button]]
-		- [[shui/components/input]]
-		- [[shui/components/tooltip]]
-		- [[shui/components/text]]
-	- future
-		- [[shui/components/icon]]
-		- [[shui/components/tag]]
-		- [[shui/components/toggle]]
-		- [[shui/components/context-menu]]
-		- [[shui/components/right-sidebar]]
-		- [[shui/components/modal]]
-		- [[shui/components/properties]]
-		- [[shui/components/code]]
-		  collapsed:: true
-			- ```css
-			  :root {
-			    --lx-blue-1: #123456;
-			  }
-			  ```
-			- ```clojurescript
-			  (js/document.style.setProperty "--lx-blue-1" ""#abcdef")
-			  ```
-			- ```python
-			  # This is a single-line comment
-			  """
-			  This is a 
-			  multi-line comment (docstring)
-			  """
-			  
-			  # Import statement
-			  import math
-			  
-			  # Constant
-			  CONSTANT = 3.14159
-			  
-			  # Function definition, decorators and function call
-			  @staticmethod
-			  def add_numbers(x, y):
-			      """This function adds two numbers"""
-			      return x + y
-			  
-			  result = add_numbers(5, 7)
-			  
-			  # Built-in functions
-			  print(f"Sum is: {result}")
-			  
-			  # Class definition and object creation
-			  class MyClass:
-			      # Class variable
-			      class_var = "I'm a class variable"
-			  
-			      def __init__(self, instance_var):
-			          # Instance variable
-			          self.instance_var = instance_var
-			  
-			      def method(self):
-			          return self.instance_var
-			  
-			  # Creating object of the class
-			  obj = MyClass("I'm an instance variable")
-			  print(obj.method())
-			  
-			  # Control flow - if, elif, else
-			  num = 10
-			  if num > 0:
-			      print("Positive number")
-			  elif num == 0:
-			      print("Zero")
-			  else:
-			      print("Negative number")
-			  
-			  # For loop and range function
-			  for i in range(5):
-			      print(i)
-			  
-			  # List comprehension
-			  squares = [x**2 for x in range(10)]
-			  
-			  # Generator expression
-			  gen = (x**2 for x in range(10))
-			  
-			  # While loop
-			  count = 0
-			  while count < 5:
-			      print(count)
-			      count += 1
-			  
-			  # Exception handling
-			  try:
-			      # Division by zero
-			      x = 1 / 0
-			  except ZeroDivisionError as e:
-			      print("Handling run-time error:", e)
-			  
-			  # Lambda function
-			  double = lambda x: x * 2
-			  print(double(5))
-			  
-			  # File I/O
-			  with open('test.txt', 'r') as file:
-			      content = file.read()
-			  
-			  # Assert
-			  assert num > 0, "Number is not positive"
-			  
-			  ```
-			- ```clojure
-			  ;; This is a comment
-			  
-			  ;; Numbers
-			  42
-			  2.71828
-			  
-			  ;; Strings
-			  "Hello, world!"
-			  
-			  ;; Characters
-			  \a
-			  
-			  ;; Booleans
-			  true
-			  false
-			  
-			  ;; Lists
-			  '(1 2 3 4 5)
-			  
-			  ;; Vectors
-			  [1 2 3 4 5]
-			  
-			  ;; Maps
-			  {:name "John Doe" :age 30 :email "[email protected]"}
-			  
-			  ;; Sets
-			  #{1 2 3 4 5}
-			  
-			  ;; Functions
-			  (defn add-numbers [x y]
-			    "This function adds two numbers."
-			    (+ x y))
-			  
-			  (def result (add-numbers 5 7))
-			  (println "Sum is: " result)
-			  
-			  ;; Anonymous function
-			  (#(+ %1 %2) 5 7)
-			  
-			  ;; Conditionals
-			  (if (> result 0)
-			    (println "Positive number")
-			    (println "Zero or negative number"))
-			  
-			  ;; Loops
-			  (loop [x 0]
-			    (when (< x 5)
-			      (println x)
-			      (recur (+ x 1))))
-			  
-			  ;; For
-			  (for [x (range 5)] (println x))
-			  
-			  ;; Map over a list
-			  (map inc '(1 2 3))
-			  
-			  ;; Exception handling
-			  (try 
-			    (/ 1 0)
-			    (catch ArithmeticException e 
-			      (println "Caught an exception: " (.getMessage e))))
-			  
-			  ;; Macros
-			  (defmacro unless [pred a b]
-			    `(if (not ~pred) ~a ~b))
-			  
-			  (unless true
-			    (println "This will not print")
-			    (println "This will print"))
-			  
-			  ;; Keywords
-			  :foo
-			  :bar/baz
-			  
-			  
-			  ```
-			- ```css
-			  .example {
-			    something: "#abc123"
-			  }
-			  ```
+    - beta
+        - [[shui/components/table]]
+    - up next
+        - [[shui/components/button]]
+        - [[shui/components/input]]
+        - [[shui/components/tooltip]]
+        - [[shui/components/text]]
+    - future
+        - [[shui/components/icon]]
+        - [[shui/components/tag]]
+        - [[shui/components/toggle]]
+        - [[shui/components/context-menu]]
+        - [[shui/components/right-sidebar]]
+        - [[shui/components/modal]]
+        - [[shui/components/properties]]
+        - [[shui/components/code]]
+          collapsed:: true
+            - ```css
+              :root {
+                --lx-blue-1: #123456;
+              }
+              ```
+            - ```clojurescript
+              (js/document.style.setProperty "--lx-blue-1" ""#abcdef")
+              ```
+            - ```python
+              # This is a single-line comment
+              """
+              This is a
+              multi-line comment (docstring)
+              """
+
+              # Import statement
+              import math
+
+              # Constant
+              CONSTANT = 3.14159
+
+              # Function definition, decorators and function call
+              @staticmethod
+              def add_numbers(x, y):
+                  """This function adds two numbers"""
+                  return x + y
+
+              result = add_numbers(5, 7)
+
+              # Built-in functions
+              print(f"Sum is: {result}")
+
+              # Class definition and object creation
+              class MyClass:
+                  # Class variable
+                  class_var = "I'm a class variable"
+
+                  def __init__(self, instance_var):
+                      # Instance variable
+                      self.instance_var = instance_var
+
+                  def method(self):
+                      return self.instance_var
+
+              # Creating object of the class
+              obj = MyClass("I'm an instance variable")
+              print(obj.method())
+
+              # Control flow - if, elif, else
+              num = 10
+              if num > 0:
+                  print("Positive number")
+              elif num == 0:
+                  print("Zero")
+              else:
+                  print("Negative number")
+
+              # For loop and range function
+              for i in range(5):
+                  print(i)
+
+              # List comprehension
+              squares = [x**2 for x in range(10)]
+
+              # Generator expression
+              gen = (x**2 for x in range(10))
+
+              # While loop
+              count = 0
+              while count < 5:
+                  print(count)
+                  count += 1
+
+              # Exception handling
+              try:
+                  # Division by zero
+                  x = 1 / 0
+              except ZeroDivisionError as e:
+                  print("Handling run-time error:", e)
+
+              # Lambda function
+              double = lambda x: x * 2
+              print(double(5))
+
+              # File I/O
+              with open('test.txt', 'r') as file:
+                  content = file.read()
+
+              # Assert
+              assert num > 0, "Number is not positive"
+
+              ```
+            - ```clojure
+              ;; This is a comment
+
+              ;; Numbers
+              42
+              2.71828
+
+              ;; Strings
+              "Hello, world!"
+
+              ;; Characters
+              \a
+
+              ;; Booleans
+              true
+              false
+
+              ;; Lists
+              '(1 2 3 4 5)
+
+              ;; Vectors
+              [1 2 3 4 5]
+
+              ;; Maps
+              {:name "John Doe" :age 30 :email "[email protected]"}
+
+              ;; Sets
+              #{1 2 3 4 5}
+
+              ;; Functions
+              (defn add-numbers [x y]
+                "This function adds two numbers."
+                (+ x y))
+
+              (def result (add-numbers 5 7))
+              (println "Sum is: " result)
+
+              ;; Anonymous function
+              (#(+ %1 %2) 5 7)
+
+              ;; Conditionals
+              (if (> result 0)
+                (println "Positive number")
+                (println "Zero or negative number"))
+
+              ;; Loops
+              (loop [x 0]
+                (when (< x 5)
+                  (println x)
+                  (recur (+ x 1))))
+
+              ;; For
+              (for [x (range 5)] (println x))
+
+              ;; Map over a list
+              (map inc '(1 2 3))
+
+              ;; Exception handling
+              (try
+                (/ 1 0)
+                (catch ArithmeticException e
+                  (println "Caught an exception: " (.getMessage e))))
+
+              ;; Macros
+              (defmacro unless [pred a b]
+                `(if (not ~pred) ~a ~b))
+
+              (unless true
+                (println "This will not print")
+                (println "This will print"))
+
+              ;; Keywords
+              :foo
+              :bar/baz
+
+
+              ```
+            - ```css
+              .example {
+                something: "#abc123"
+              }
+              ```
 - [[shui/colors]]
-	- We want to switch to radix varaibles
-	- We want to make it easy to customize with themes
-	- We want to support as much old themes as possible
-	- var(--shui-button-color,
-	  collapsed:: true
-		- var(--logseq-button-primary-color,
-		  collapsed:: true
-			- var(--lx-color-6)))
-	- light and dark variants
+    - We want to switch to radix variables
+    - We want to make it easy to customize with themes
+    - We want to support as much old themes as possible
+    - var(--shui-button-color,
+      collapsed:: true
+        - var(--logseq-button-primary-color,
+          collapsed:: true
+            - var(--lx-color-6)))
+    - light and dark variants
 - [[shui/inline]]
-	-
+    -
 - /
 -
--
+-

+ 5 - 3
e2e-tests/fs.spec.ts

@@ -99,6 +99,8 @@ test("Rename file on disk", async ({ page, block, graphDir }) => {
     await fsp.rename(filePath, newFilePath);
     await captureConsoleWithPrefix(page, "Parsing finished:", 5000);
 
+    await page.waitForTimeout(500);
+
     // Test that the page is renamed
     const results = await searchPage(page, newPageTitle);
     const firstResultRow = await results[0].innerText()
@@ -113,7 +115,6 @@ test('special page names', async ({ page, block, graphDir }) => {
   const testCases = [
     {pageTitle: "User:John", fileName: "User%3AJohn"},
     {pageTitle: "_#%ff", fileName: "_%23%25ff"},
-    {pageTitle: "_#%23", fileName: "_%23%2523"},
     {pageTitle: "@!#%", fileName: "@!%23%"},
     {pageTitle: "aàáâ", fileName: "aàáâ"},
     {pageTitle: "_#%gggg", fileName: "_%23%gggg"}
@@ -125,10 +126,11 @@ test('special page names', async ({ page, block, graphDir }) => {
     await createPage(page, pageTitle)
     const text = `content for ${pageTitle}`
     await block.mustFill(text)
-    await page.keyboard.press("Enter")
+    await page.keyboard.press("Enter", { delay: 50 })
+    await page.keyboard.press("Escape", { delay: 50 })
 
     // Wait for the file to be created on disk
-    await page.waitForTimeout(2000);
+    await page.waitForTimeout(2500);
     // Validate that the file is created on disk with the content
     const filePath = path.join(graphDir, "pages", `${fileName}.md`);
     const fileContent = await fsp.readFile(filePath, "utf8");

+ 5 - 5
src/main/frontend/components/cmdk.cljs

@@ -141,7 +141,7 @@
           (:filter highlighted-item) :filter
           :else nil)))
 
-;; Each result gorup has it's own load-results function
+;; Each result group has it's own load-results function
 (defmulti load-results (fn [group _state] group))
 
 ;; Initially we want to load the recents into the results
@@ -166,7 +166,7 @@
     (reset! !results (-> default-results (assoc-in [:recents :items] recent-items)
                          (assoc-in [:commands :items] command-items)))))
 
-;; The commands search uses the command-palette hander
+;; The commands search uses the command-palette handler
 (defmethod load-results :commands [group state]
   (let [!input (::input state)
         !results (::results state)]
@@ -501,7 +501,7 @@
        (when-not @!load-results-throttled
          (reset! !load-results-throttled (gfun/throttle load-results 50)))
 
-     ;; retreive the laod-results function and update all the results
+     ;; retrieve the load-results function and update all the results
        (when-let [load-results-throttled @!load-results-throttled]
          (load-results-throttled :default state))))))
 
@@ -561,7 +561,7 @@
         input-ref (::input-ref state)]
     ;; use-effect [results-ordered input] to check whether the highlighted item is still in the results,
     ;; if not then clear that puppy out!
-    ;; This was moved to a fucntional component
+    ;; This was moved to a functional component
     (rum/use-effect! (fn []
                        (when (and highlighted-item (= -1 (.indexOf all-items (dissoc highlighted-item :mouse-enter-triggered-highlight))))
                          (reset! (::highlighted-item state) nil)))
@@ -599,7 +599,7 @@
         input-ref (::input-ref state)]
     ;; use-effect [results-ordered input] to check whether the highlighted item is still in the results,
     ;; if not then clear that puppy out!
-    ;; This was moved to a fucntional component
+    ;; This was moved to a functional component
     (rum/use-effect! (fn []
                        (when (= -1 (.indexOf all-items highlighted-item))
                          (reset! (::highlighted-item state) nil)))

+ 3 - 3
src/main/frontend/ui.cljs

@@ -395,9 +395,9 @@
         (.on js/window.apis event function))
 
       (p/then (ipc/ipc :getAppBaseInfo) #(let [{:keys [isFullScreen isMaximized]} (js->clj % :keywordize-keys true)]
-                                           (when isFullScreen (do
-                                                               (.add cl "is-fullscreen")
-                                                               (state/set-state! :electron/window-fullscreen? true)))
+                                           (when isFullScreen
+                                             (.add cl "is-fullscreen")
+                                             (state/set-state! :electron/window-fullscreen? true))
                                            (when isMaximized (state/set-state! :electron/window-maximized? true)))))))
 
 (defn inject-dynamic-style-node!