Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion 2 lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"packages/*"
],
"useWorkspaces": true,
"version": "2.0.7-formula-editor.20",
"version": "2.0.7-cline-formulaeditor.0",
"command": {
"version": {
"message": "chore(release): publish %s \n [skip ci]"
Expand Down
2 changes: 1 addition & 1 deletion 2 package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion 2 packages/formula-editor/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@fw-components/formula-editor",
"version": "2.0.7-formula-editor.20",
"version": "2.0.7-cline-formulaeditor.0",
"description": "A WYSIWYG type formula editor",
"main": "dist/formula-editor/src/formula-builder.js",
"publishConfig": {
Expand Down
15 changes: 15 additions & 0 deletions 15 packages/formula-editor/src/cursor.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export declare class Cursor {
/**
* The functions `getCurrentCursorPosition`, `setCurrentCursorPosition` and their
* helpers `_createRange` and `_isChildOf` are not used for caret manipulation,
* but are still in the code for future reference, if the functionality breaks
* somehow in some obsolete browser.
*/
static getCurrentCursorPosition(parentElement: any): number;
static setCurrentCursorPosition(chars: number, element: any): void;
static _createRange(node: any, chars: any, range: any): any;
static _isChildOf(node: any, parentElement: any): boolean;
static getCaretPosition(shadowRoot: ShadowRoot, element: HTMLElement): any;
static setCaretPosition: (pos: any, parent: any) => any;
static getCursorRect(shadowRoot: ShadowRoot): any;
}
Comment on lines +1 to +15

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Convert class to a module with functions and improve type safety.

  1. The class contains only static methods and maintains no state. Consider converting it to a module with exported functions for better modularity.
  2. The extensive use of any type reduces type safety. Consider using more specific types.

Apply this diff to improve the code:

-export declare class Cursor {
+export declare const Cursor = {
     /**
      * The functions `getCurrentCursorPosition`, `setCurrentCursorPosition` and their
      * helpers `_createRange` and `_isChildOf` are not used for caret manipulation,
      * but are still in the code for future reference, if the functionality breaks
      * somehow in some obsolete browser.
      */
-    static getCurrentCursorPosition(parentElement: any): number;
-    static setCurrentCursorPosition(chars: number, element: any): void;
-    static _createRange(node: any, chars: any, range: any): any;
-    static _isChildOf(node: any, parentElement: any): boolean;
-    static getCaretPosition(shadowRoot: ShadowRoot, element: HTMLElement): any;
-    static setCaretPosition: (pos: any, parent: any) => any;
-    static getCursorRect(shadowRoot: ShadowRoot): any;
+    getCurrentCursorPosition(parentElement: HTMLElement): number;
+    setCurrentCursorPosition(chars: number, element: HTMLElement): void;
+    _createRange(node: Node, chars: number, range: Range): Range;
+    _isChildOf(node: Node, parentElement: HTMLElement): boolean;
+    getCaretPosition(shadowRoot: ShadowRoot, element: HTMLElement): DOMRect;
+    setCaretPosition: (pos: number, parent: HTMLElement) => void;
+    getCursorRect(shadowRoot: ShadowRoot): DOMRect;
-}
+};

Committable suggestion skipped: line range outside the PR's diff.

🧰 Tools
🪛 Biome (1.9.4)

[error] 1-15: Avoid classes that contain only static members.

Prefer using simple functions instead of classes with only static members.

(lint/complexity/noStaticOnlyClass)

126 changes: 126 additions & 0 deletions 126 packages/formula-editor/src/cursor.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions 1 packages/formula-editor/src/cursor.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions 1 packages/formula-editor/src/formula-builder.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export {};
148 changes: 148 additions & 0 deletions 148 packages/formula-editor/src/formula-builder.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions 1 packages/formula-editor/src/formula-builder.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions 1 packages/formula-editor/src/formula-creator.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export {};
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.