@rowsncolumns/ui 15.0.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +100 -0
- package/dist/cjs/arrow/index.d.ts +17 -0
- package/dist/cjs/arrow/index.d.ts.map +1 -0
- package/dist/cjs/arrow/index.js +46 -0
- package/dist/cjs/button/index.d.ts +14 -0
- package/dist/cjs/button/index.d.ts.map +1 -0
- package/dist/cjs/button/index.js +46 -0
- package/dist/cjs/calendar/index.d.ts +5 -0
- package/dist/cjs/calendar/index.d.ts.map +1 -0
- package/dist/cjs/calendar/index.js +13 -0
- package/dist/cjs/card/index.d.ts +10 -0
- package/dist/cjs/card/index.d.ts.map +1 -0
- package/dist/cjs/card/index.js +32 -0
- package/dist/cjs/cell-tooltip/index.d.ts +17 -0
- package/dist/cjs/cell-tooltip/index.d.ts.map +1 -0
- package/dist/cjs/cell-tooltip/index.js +38 -0
- package/dist/cjs/circular-loader/index.d.ts +9 -0
- package/dist/cjs/circular-loader/index.d.ts.map +1 -0
- package/dist/cjs/circular-loader/index.js +11 -0
- package/dist/cjs/color-picker/index.d.ts +12 -0
- package/dist/cjs/color-picker/index.d.ts.map +1 -0
- package/dist/cjs/color-picker/index.js +101 -0
- package/dist/cjs/color-picker/style.d.ts +5 -0
- package/dist/cjs/color-picker/style.d.ts.map +1 -0
- package/dist/cjs/color-picker/style.js +11 -0
- package/dist/cjs/command/index.d.ts +74 -0
- package/dist/cjs/command/index.d.ts.map +1 -0
- package/dist/cjs/command/index.js +37 -0
- package/dist/cjs/conditional-wrapper/index.d.ts +9 -0
- package/dist/cjs/conditional-wrapper/index.d.ts.map +1 -0
- package/dist/cjs/conditional-wrapper/index.js +4 -0
- package/dist/cjs/dialog/index.d.ts +17 -0
- package/dist/cjs/dialog/index.d.ts.map +1 -0
- package/dist/cjs/dialog/index.js +50 -0
- package/dist/cjs/dropdown/index.d.ts +34 -0
- package/dist/cjs/dropdown/index.d.ts.map +1 -0
- package/dist/cjs/dropdown/index.js +73 -0
- package/dist/cjs/editor/constants.d.ts +7 -0
- package/dist/cjs/editor/constants.d.ts.map +1 -0
- package/dist/cjs/editor/constants.js +50 -0
- package/dist/cjs/editor/editor-error-boundary.d.ts +3 -0
- package/dist/cjs/editor/editor-error-boundary.d.ts.map +1 -0
- package/dist/cjs/editor/editor-error-boundary.js +9 -0
- package/dist/cjs/editor/style.d.ts +12 -0
- package/dist/cjs/editor/style.d.ts.map +1 -0
- package/dist/cjs/editor/style.js +24 -0
- package/dist/cjs/editor/suggestions-dropdown.d.ts +25 -0
- package/dist/cjs/editor/suggestions-dropdown.d.ts.map +1 -0
- package/dist/cjs/editor/suggestions-dropdown.js +120 -0
- package/dist/cjs/editor-pm/constants.d.ts +2 -0
- package/dist/cjs/editor-pm/constants.d.ts.map +1 -0
- package/dist/cjs/editor-pm/constants.js +2 -0
- package/dist/cjs/editor-pm/decoration-plugin.d.ts +15 -0
- package/dist/cjs/editor-pm/decoration-plugin.d.ts.map +1 -0
- package/dist/cjs/editor-pm/decoration-plugin.js +38 -0
- package/dist/cjs/editor-pm/helpers.d.ts +197 -0
- package/dist/cjs/editor-pm/helpers.d.ts.map +1 -0
- package/dist/cjs/editor-pm/helpers.js +1170 -0
- package/dist/cjs/editor-pm/index.d.ts +10 -0
- package/dist/cjs/editor-pm/index.d.ts.map +1 -0
- package/dist/cjs/editor-pm/index.js +9 -0
- package/dist/cjs/editor-pm/mention-nodeview.d.ts +31 -0
- package/dist/cjs/editor-pm/mention-nodeview.d.ts.map +1 -0
- package/dist/cjs/editor-pm/mention-nodeview.js +105 -0
- package/dist/cjs/editor-pm/mentions-dropdown.d.ts +13 -0
- package/dist/cjs/editor-pm/mentions-dropdown.d.ts.map +1 -0
- package/dist/cjs/editor-pm/mentions-dropdown.js +19 -0
- package/dist/cjs/editor-pm/mentions-plugin.d.ts +18 -0
- package/dist/cjs/editor-pm/mentions-plugin.d.ts.map +1 -0
- package/dist/cjs/editor-pm/mentions-plugin.js +72 -0
- package/dist/cjs/editor-pm/placeholder-plugin.d.ts +4 -0
- package/dist/cjs/editor-pm/placeholder-plugin.d.ts.map +1 -0
- package/dist/cjs/editor-pm/placeholder-plugin.js +20 -0
- package/dist/cjs/editor-pm/prosemirror-editor.d.ts +493 -0
- package/dist/cjs/editor-pm/prosemirror-editor.d.ts.map +1 -0
- package/dist/cjs/editor-pm/prosemirror-editor.js +1145 -0
- package/dist/cjs/editor-pm/schema.d.ts +3 -0
- package/dist/cjs/editor-pm/schema.d.ts.map +1 -0
- package/dist/cjs/editor-pm/schema.js +183 -0
- package/dist/cjs/editor-pm/types.d.ts +8 -0
- package/dist/cjs/editor-pm/types.d.ts.map +1 -0
- package/dist/cjs/editor-pm/types.js +1 -0
- package/dist/cjs/editor-pm/unfocused-selection-plugin.d.ts +25 -0
- package/dist/cjs/editor-pm/unfocused-selection-plugin.d.ts.map +1 -0
- package/dist/cjs/editor-pm/unfocused-selection-plugin.js +61 -0
- package/dist/cjs/editor-pm/use-dropdown-change-pm.d.ts +24 -0
- package/dist/cjs/editor-pm/use-dropdown-change-pm.d.ts.map +1 -0
- package/dist/cjs/editor-pm/use-dropdown-change-pm.js +140 -0
- package/dist/cjs/editor-pm/use-editor-change-pm.d.ts +29 -0
- package/dist/cjs/editor-pm/use-editor-change-pm.d.ts.map +1 -0
- package/dist/cjs/editor-pm/use-editor-change-pm.js +154 -0
- package/dist/cjs/editor-pm/use-editor-decorator-pm.d.ts +17 -0
- package/dist/cjs/editor-pm/use-editor-decorator-pm.d.ts.map +1 -0
- package/dist/cjs/editor-pm/use-editor-decorator-pm.js +59 -0
- package/dist/cjs/editor-pm/use-editor-keydown-pm.d.ts +21 -0
- package/dist/cjs/editor-pm/use-editor-keydown-pm.d.ts.map +1 -0
- package/dist/cjs/editor-pm/use-editor-keydown-pm.js +81 -0
- package/dist/cjs/editor-pm/use-mention-keydown.d.ts +11 -0
- package/dist/cjs/editor-pm/use-mention-keydown.d.ts.map +1 -0
- package/dist/cjs/editor-pm/use-mention-keydown.js +59 -0
- package/dist/cjs/editor-pm/use-parameter-suggestions.d.ts +19 -0
- package/dist/cjs/editor-pm/use-parameter-suggestions.d.ts.map +1 -0
- package/dist/cjs/editor-pm/use-parameter-suggestions.js +79 -0
- package/dist/cjs/editor-pm/use-parameter-suggestions.test.d.ts +2 -0
- package/dist/cjs/editor-pm/use-parameter-suggestions.test.d.ts.map +1 -0
- package/dist/cjs/editor-pm/use-parameter-suggestions.test.js +122 -0
- package/dist/cjs/eye-dropper/index.d.ts +10 -0
- package/dist/cjs/eye-dropper/index.d.ts.map +1 -0
- package/dist/cjs/eye-dropper/index.js +24 -0
- package/dist/cjs/function-info/helpers.d.ts +10 -0
- package/dist/cjs/function-info/helpers.d.ts.map +1 -0
- package/dist/cjs/function-info/helpers.js +20 -0
- package/dist/cjs/function-info/index.d.ts +11 -0
- package/dist/cjs/function-info/index.d.ts.map +1 -0
- package/dist/cjs/function-info/index.js +71 -0
- package/dist/cjs/function-info/style.d.ts +7 -0
- package/dist/cjs/function-info/style.d.ts.map +1 -0
- package/dist/cjs/function-info/style.js +13 -0
- package/dist/cjs/hex-color-picker/index.d.ts +8 -0
- package/dist/cjs/hex-color-picker/index.d.ts.map +1 -0
- package/dist/cjs/hex-color-picker/index.js +47 -0
- package/dist/cjs/hooks/use-cycle-reference.d.ts +16 -0
- package/dist/cjs/hooks/use-cycle-reference.d.ts.map +1 -0
- package/dist/cjs/hooks/use-cycle-reference.js +72 -0
- package/dist/cjs/hooks/use-dropdown-categories.d.ts +9 -0
- package/dist/cjs/hooks/use-dropdown-categories.d.ts.map +1 -0
- package/dist/cjs/hooks/use-dropdown-categories.js +45 -0
- package/dist/cjs/hooks/use-dropdown.d.ts +38 -0
- package/dist/cjs/hooks/use-dropdown.d.ts.map +1 -0
- package/dist/cjs/hooks/use-dropdown.js +236 -0
- package/dist/cjs/hooks/use-isomorphic-layout-effect.ts.d.ts +6 -0
- package/dist/cjs/hooks/use-isomorphic-layout-effect.ts.d.ts.map +1 -0
- package/dist/cjs/hooks/use-isomorphic-layout-effect.ts.js +8 -0
- package/dist/cjs/hooks/use-modal.d.ts +28 -0
- package/dist/cjs/hooks/use-modal.d.ts.map +1 -0
- package/dist/cjs/hooks/use-modal.js +101 -0
- package/dist/cjs/hooks/use-visibility.d.ts +2 -0
- package/dist/cjs/hooks/use-visibility.d.ts.map +1 -0
- package/dist/cjs/hooks/use-visibility.js +12 -0
- package/dist/cjs/icon-button/index.d.ts +15 -0
- package/dist/cjs/icon-button/index.d.ts.map +1 -0
- package/dist/cjs/icon-button/index.js +34 -0
- package/dist/cjs/index.d.ts +34 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +33 -0
- package/dist/cjs/input/index.d.ts +9 -0
- package/dist/cjs/input/index.d.ts.map +1 -0
- package/dist/cjs/input/index.js +9 -0
- package/dist/cjs/popover/index.d.ts +13 -0
- package/dist/cjs/popover/index.d.ts.map +1 -0
- package/dist/cjs/popover/index.js +29 -0
- package/dist/cjs/progress/index.d.ts +10 -0
- package/dist/cjs/progress/index.d.ts.map +1 -0
- package/dist/cjs/progress/index.js +15 -0
- package/dist/cjs/select/index.d.ts +14 -0
- package/dist/cjs/select/index.d.ts.map +1 -0
- package/dist/cjs/select/index.js +46 -0
- package/dist/cjs/separator/index.d.ts +5 -0
- package/dist/cjs/separator/index.d.ts.map +1 -0
- package/dist/cjs/separator/index.js +10 -0
- package/dist/cjs/skeleton/index.d.ts +7 -0
- package/dist/cjs/skeleton/index.d.ts.map +1 -0
- package/dist/cjs/skeleton/index.js +11 -0
- package/dist/cjs/stack/index.d.ts +11 -0
- package/dist/cjs/stack/index.d.ts.map +1 -0
- package/dist/cjs/stack/index.js +22 -0
- package/dist/cjs/tabs/index.d.ts +8 -0
- package/dist/cjs/tabs/index.d.ts.map +1 -0
- package/dist/cjs/tabs/index.js +21 -0
- package/dist/cjs/tooltip/index.d.ts +12 -0
- package/dist/cjs/tooltip/index.d.ts.map +1 -0
- package/dist/cjs/tooltip/index.js +20 -0
- package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -0
- package/dist/cjs/utils.d.ts +3 -0
- package/dist/cjs/utils.d.ts.map +1 -0
- package/dist/cjs/utils.js +9 -0
- package/dist/cjs/vitest.config.d.ts +3 -0
- package/dist/cjs/vitest.config.d.ts.map +1 -0
- package/dist/cjs/vitest.config.js +21 -0
- package/dist/esm/arrow/index.d.ts +17 -0
- package/dist/esm/arrow/index.d.ts.map +1 -0
- package/dist/esm/arrow/index.js +45 -0
- package/dist/esm/button/index.d.ts +14 -0
- package/dist/esm/button/index.d.ts.map +1 -0
- package/dist/esm/button/index.js +44 -0
- package/dist/esm/calendar/index.d.ts +5 -0
- package/dist/esm/calendar/index.d.ts.map +1 -0
- package/dist/esm/calendar/index.js +34 -0
- package/dist/esm/card/index.d.ts +10 -0
- package/dist/esm/card/index.d.ts.map +1 -0
- package/dist/esm/card/index.js +24 -0
- package/dist/esm/cell-tooltip/index.d.ts +17 -0
- package/dist/esm/cell-tooltip/index.d.ts.map +1 -0
- package/dist/esm/cell-tooltip/index.js +31 -0
- package/dist/esm/circular-loader/index.d.ts +9 -0
- package/dist/esm/circular-loader/index.d.ts.map +1 -0
- package/dist/esm/circular-loader/index.js +7 -0
- package/dist/esm/color-picker/index.d.ts +12 -0
- package/dist/esm/color-picker/index.d.ts.map +1 -0
- package/dist/esm/color-picker/index.js +99 -0
- package/dist/esm/color-picker/style.d.ts +5 -0
- package/dist/esm/color-picker/style.d.ts.map +1 -0
- package/dist/esm/color-picker/style.js +7 -0
- package/dist/esm/command/index.d.ts +74 -0
- package/dist/esm/command/index.d.ts.map +1 -0
- package/dist/esm/command/index.js +18 -0
- package/dist/esm/conditional-wrapper/index.d.ts +9 -0
- package/dist/esm/conditional-wrapper/index.d.ts.map +1 -0
- package/dist/esm/conditional-wrapper/index.js +1 -0
- package/dist/esm/dialog/index.d.ts +17 -0
- package/dist/esm/dialog/index.d.ts.map +1 -0
- package/dist/esm/dialog/index.js +30 -0
- package/dist/esm/dropdown/index.d.ts +34 -0
- package/dist/esm/dropdown/index.d.ts.map +1 -0
- package/dist/esm/dropdown/index.js +42 -0
- package/dist/esm/editor/constants.d.ts +7 -0
- package/dist/esm/editor/constants.d.ts.map +1 -0
- package/dist/esm/editor/constants.js +51 -0
- package/dist/esm/editor/editor-error-boundary.d.ts +3 -0
- package/dist/esm/editor/editor-error-boundary.d.ts.map +1 -0
- package/dist/esm/editor/editor-error-boundary.js +9 -0
- package/dist/esm/editor/style.d.ts +12 -0
- package/dist/esm/editor/style.d.ts.map +1 -0
- package/dist/esm/editor/style.js +17 -0
- package/dist/esm/editor/suggestions-dropdown.d.ts +25 -0
- package/dist/esm/editor/suggestions-dropdown.d.ts.map +1 -0
- package/dist/esm/editor/suggestions-dropdown.js +115 -0
- package/dist/esm/editor-pm/constants.d.ts +2 -0
- package/dist/esm/editor-pm/constants.d.ts.map +1 -0
- package/dist/esm/editor-pm/constants.js +2 -0
- package/dist/esm/editor-pm/decoration-plugin.d.ts +15 -0
- package/dist/esm/editor-pm/decoration-plugin.d.ts.map +1 -0
- package/dist/esm/editor-pm/decoration-plugin.js +38 -0
- package/dist/esm/editor-pm/helpers.d.ts +197 -0
- package/dist/esm/editor-pm/helpers.d.ts.map +1 -0
- package/dist/esm/editor-pm/helpers.js +1113 -0
- package/dist/esm/editor-pm/index.d.ts +10 -0
- package/dist/esm/editor-pm/index.d.ts.map +1 -0
- package/dist/esm/editor-pm/index.js +9 -0
- package/dist/esm/editor-pm/mention-nodeview.d.ts +31 -0
- package/dist/esm/editor-pm/mention-nodeview.d.ts.map +1 -0
- package/dist/esm/editor-pm/mention-nodeview.js +88 -0
- package/dist/esm/editor-pm/mentions-dropdown.d.ts +13 -0
- package/dist/esm/editor-pm/mentions-dropdown.d.ts.map +1 -0
- package/dist/esm/editor-pm/mentions-dropdown.js +17 -0
- package/dist/esm/editor-pm/mentions-plugin.d.ts +18 -0
- package/dist/esm/editor-pm/mentions-plugin.d.ts.map +1 -0
- package/dist/esm/editor-pm/mentions-plugin.js +92 -0
- package/dist/esm/editor-pm/placeholder-plugin.d.ts +4 -0
- package/dist/esm/editor-pm/placeholder-plugin.d.ts.map +1 -0
- package/dist/esm/editor-pm/placeholder-plugin.js +20 -0
- package/dist/esm/editor-pm/prosemirror-editor.d.ts +493 -0
- package/dist/esm/editor-pm/prosemirror-editor.d.ts.map +1 -0
- package/dist/esm/editor-pm/prosemirror-editor.js +1135 -0
- package/dist/esm/editor-pm/schema.d.ts +3 -0
- package/dist/esm/editor-pm/schema.d.ts.map +1 -0
- package/dist/esm/editor-pm/schema.js +179 -0
- package/dist/esm/editor-pm/types.d.ts +8 -0
- package/dist/esm/editor-pm/types.d.ts.map +1 -0
- package/dist/esm/editor-pm/types.js +1 -0
- package/dist/esm/editor-pm/unfocused-selection-plugin.d.ts +25 -0
- package/dist/esm/editor-pm/unfocused-selection-plugin.d.ts.map +1 -0
- package/dist/esm/editor-pm/unfocused-selection-plugin.js +61 -0
- package/dist/esm/editor-pm/use-dropdown-change-pm.d.ts +24 -0
- package/dist/esm/editor-pm/use-dropdown-change-pm.d.ts.map +1 -0
- package/dist/esm/editor-pm/use-dropdown-change-pm.js +137 -0
- package/dist/esm/editor-pm/use-editor-change-pm.d.ts +29 -0
- package/dist/esm/editor-pm/use-editor-change-pm.d.ts.map +1 -0
- package/dist/esm/editor-pm/use-editor-change-pm.js +152 -0
- package/dist/esm/editor-pm/use-editor-decorator-pm.d.ts +17 -0
- package/dist/esm/editor-pm/use-editor-decorator-pm.d.ts.map +1 -0
- package/dist/esm/editor-pm/use-editor-decorator-pm.js +57 -0
- package/dist/esm/editor-pm/use-editor-keydown-pm.d.ts +21 -0
- package/dist/esm/editor-pm/use-editor-keydown-pm.d.ts.map +1 -0
- package/dist/esm/editor-pm/use-editor-keydown-pm.js +79 -0
- package/dist/esm/editor-pm/use-mention-keydown.d.ts +11 -0
- package/dist/esm/editor-pm/use-mention-keydown.d.ts.map +1 -0
- package/dist/esm/editor-pm/use-mention-keydown.js +57 -0
- package/dist/esm/editor-pm/use-parameter-suggestions.d.ts +19 -0
- package/dist/esm/editor-pm/use-parameter-suggestions.d.ts.map +1 -0
- package/dist/esm/editor-pm/use-parameter-suggestions.js +66 -0
- package/dist/esm/editor-pm/use-parameter-suggestions.test.d.ts +2 -0
- package/dist/esm/editor-pm/use-parameter-suggestions.test.d.ts.map +1 -0
- package/dist/esm/editor-pm/use-parameter-suggestions.test.js +66 -0
- package/dist/esm/eye-dropper/index.d.ts +10 -0
- package/dist/esm/eye-dropper/index.d.ts.map +1 -0
- package/dist/esm/eye-dropper/index.js +23 -0
- package/dist/esm/function-info/helpers.d.ts +10 -0
- package/dist/esm/function-info/helpers.d.ts.map +1 -0
- package/dist/esm/function-info/helpers.js +20 -0
- package/dist/esm/function-info/index.d.ts +11 -0
- package/dist/esm/function-info/index.d.ts.map +1 -0
- package/dist/esm/function-info/index.js +68 -0
- package/dist/esm/function-info/style.d.ts +7 -0
- package/dist/esm/function-info/style.d.ts.map +1 -0
- package/dist/esm/function-info/style.js +10 -0
- package/dist/esm/hex-color-picker/index.d.ts +8 -0
- package/dist/esm/hex-color-picker/index.d.ts.map +1 -0
- package/dist/esm/hex-color-picker/index.js +44 -0
- package/dist/esm/hooks/use-cycle-reference.d.ts +16 -0
- package/dist/esm/hooks/use-cycle-reference.d.ts.map +1 -0
- package/dist/esm/hooks/use-cycle-reference.js +70 -0
- package/dist/esm/hooks/use-dropdown-categories.d.ts +9 -0
- package/dist/esm/hooks/use-dropdown-categories.d.ts.map +1 -0
- package/dist/esm/hooks/use-dropdown-categories.js +38 -0
- package/dist/esm/hooks/use-dropdown.d.ts +38 -0
- package/dist/esm/hooks/use-dropdown.d.ts.map +1 -0
- package/dist/esm/hooks/use-dropdown.js +236 -0
- package/dist/esm/hooks/use-isomorphic-layout-effect.ts.d.ts +6 -0
- package/dist/esm/hooks/use-isomorphic-layout-effect.ts.d.ts.map +1 -0
- package/dist/esm/hooks/use-isomorphic-layout-effect.ts.js +8 -0
- package/dist/esm/hooks/use-modal.d.ts +28 -0
- package/dist/esm/hooks/use-modal.d.ts.map +1 -0
- package/dist/esm/hooks/use-modal.js +93 -0
- package/dist/esm/hooks/use-visibility.d.ts +2 -0
- package/dist/esm/hooks/use-visibility.d.ts.map +1 -0
- package/dist/esm/hooks/use-visibility.js +12 -0
- package/dist/esm/icon-button/index.d.ts +15 -0
- package/dist/esm/icon-button/index.d.ts.map +1 -0
- package/dist/esm/icon-button/index.js +32 -0
- package/dist/esm/index.d.ts +34 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +33 -0
- package/dist/esm/input/index.d.ts +9 -0
- package/dist/esm/input/index.d.ts.map +1 -0
- package/dist/esm/input/index.js +7 -0
- package/dist/esm/popover/index.d.ts +13 -0
- package/dist/esm/popover/index.d.ts.map +1 -0
- package/dist/esm/popover/index.js +22 -0
- package/dist/esm/progress/index.d.ts +10 -0
- package/dist/esm/progress/index.d.ts.map +1 -0
- package/dist/esm/progress/index.js +12 -0
- package/dist/esm/select/index.d.ts +14 -0
- package/dist/esm/select/index.d.ts.map +1 -0
- package/dist/esm/select/index.js +30 -0
- package/dist/esm/separator/index.d.ts +5 -0
- package/dist/esm/separator/index.d.ts.map +1 -0
- package/dist/esm/separator/index.js +6 -0
- package/dist/esm/skeleton/index.d.ts +7 -0
- package/dist/esm/skeleton/index.d.ts.map +1 -0
- package/dist/esm/skeleton/index.js +9 -0
- package/dist/esm/stack/index.d.ts +11 -0
- package/dist/esm/stack/index.d.ts.map +1 -0
- package/dist/esm/stack/index.js +20 -0
- package/dist/esm/tabs/index.d.ts +8 -0
- package/dist/esm/tabs/index.d.ts.map +1 -0
- package/dist/esm/tabs/index.js +11 -0
- package/dist/esm/tooltip/index.d.ts +12 -0
- package/dist/esm/tooltip/index.d.ts.map +1 -0
- package/dist/esm/tooltip/index.js +13 -0
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -0
- package/dist/esm/utils.d.ts +3 -0
- package/dist/esm/utils.d.ts.map +1 -0
- package/dist/esm/utils.js +5 -0
- package/dist/esm/vitest.config.d.ts +3 -0
- package/dist/esm/vitest.config.d.ts.map +1 -0
- package/dist/esm/vitest.config.js +21 -0
- package/package.json +78 -0
|
@@ -0,0 +1,1170 @@
|
|
|
1
|
+
import { __assign, __read, __spreadArray, __values } from "tslib";
|
|
2
|
+
import { cleanupColumnName } from "@rowsncolumns/calculator";
|
|
3
|
+
import { tokenVocabulary } from "@rowsncolumns/fast-formula-parser";
|
|
4
|
+
import { CELL_SUGGESTION_PREFIX, CELL_SUGGESTION_SUFFIX, } from "../editor/constants";
|
|
5
|
+
/**
|
|
6
|
+
* Converts string to ProseMirror document
|
|
7
|
+
* @param str
|
|
8
|
+
* @param schema
|
|
9
|
+
* @returns
|
|
10
|
+
*/
|
|
11
|
+
export var deserializeString = function (str, schema) {
|
|
12
|
+
try {
|
|
13
|
+
if (typeof str === "object") {
|
|
14
|
+
str = tryParseRichText(str);
|
|
15
|
+
}
|
|
16
|
+
// Validate input
|
|
17
|
+
if (typeof str !== "string") {
|
|
18
|
+
console.warn("deserializeString: input is not a string, using empty string");
|
|
19
|
+
str = "";
|
|
20
|
+
}
|
|
21
|
+
// Sanitize string - remove null characters and other problematic chars
|
|
22
|
+
str = str
|
|
23
|
+
.replace(/\0/g, "")
|
|
24
|
+
.replace(/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]/g, "");
|
|
25
|
+
var lines = str.split("\n");
|
|
26
|
+
var nodes = lines.map(function (line) {
|
|
27
|
+
return schema.node("line", null, line ? [schema.text(line)] : []);
|
|
28
|
+
});
|
|
29
|
+
return schema.node("doc", null, nodes);
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
console.error("Error deserializing string:", error);
|
|
33
|
+
// Return empty document as fallback
|
|
34
|
+
return schema.node("doc", null, [schema.node("line", null, [])]);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
export var tryParseRichText = function (str) {
|
|
38
|
+
var _a;
|
|
39
|
+
// Temporary workaround for .richText
|
|
40
|
+
if ("richText" in str) {
|
|
41
|
+
str = (_a = str === null || str === void 0 ? void 0 : str.richText) === null || _a === void 0 ? void 0 : _a.map(function (value) { return value.text; }).join("");
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
str = "Unable to parse string";
|
|
45
|
+
}
|
|
46
|
+
return str;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Converts ProseMirror document to string
|
|
50
|
+
* @param doc
|
|
51
|
+
* @returns
|
|
52
|
+
*/
|
|
53
|
+
export var serializeEditorValue = function (doc) {
|
|
54
|
+
var text = "";
|
|
55
|
+
doc.content.forEach(function (node, offset, index) {
|
|
56
|
+
if (node.type.name === "line") {
|
|
57
|
+
if (index > 0)
|
|
58
|
+
text += "\n";
|
|
59
|
+
// Serialize line content, handling mention nodes properly
|
|
60
|
+
var lineText_1 = "";
|
|
61
|
+
node.content.forEach(function (child) {
|
|
62
|
+
if (child.type.name === "mention") {
|
|
63
|
+
// Serialize mention as just the label
|
|
64
|
+
lineText_1 += child.attrs.label;
|
|
65
|
+
}
|
|
66
|
+
else if (child.isText) {
|
|
67
|
+
// Regular text node
|
|
68
|
+
lineText_1 += child.text;
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
text += lineText_1;
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
return text;
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* Extracts text format runs from ProseMirror document
|
|
78
|
+
* @param doc ProseMirror document node
|
|
79
|
+
* @returns Array of TextFormatRun objects
|
|
80
|
+
*/
|
|
81
|
+
export var extractTextFormatRuns = function (doc) {
|
|
82
|
+
if (!doc) {
|
|
83
|
+
return undefined;
|
|
84
|
+
}
|
|
85
|
+
var formatRuns = [];
|
|
86
|
+
var currentIndex = 0;
|
|
87
|
+
doc.content.forEach(function (node, _, lineIndex) {
|
|
88
|
+
if (node.type.name === "line") {
|
|
89
|
+
if (lineIndex > 0) {
|
|
90
|
+
// Add newline character to index
|
|
91
|
+
currentIndex++;
|
|
92
|
+
}
|
|
93
|
+
// First pass: collect all child nodes with their start positions
|
|
94
|
+
var childNodes_1 = [];
|
|
95
|
+
var nodeIndex_1 = currentIndex;
|
|
96
|
+
node.content.forEach(function (child) {
|
|
97
|
+
childNodes_1.push({
|
|
98
|
+
node: child,
|
|
99
|
+
startIndex: nodeIndex_1,
|
|
100
|
+
});
|
|
101
|
+
// Calculate the next start index based on the node type
|
|
102
|
+
if (child.type.name === "mention") {
|
|
103
|
+
// For mentions, use just the label length for positioning
|
|
104
|
+
nodeIndex_1 += child.attrs.label.length;
|
|
105
|
+
}
|
|
106
|
+
else if (child.isText && child.text) {
|
|
107
|
+
nodeIndex_1 += child.text.length;
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
// Second pass: create format runs using next child's start index as end boundary
|
|
111
|
+
childNodes_1.forEach(function (childData, index) {
|
|
112
|
+
var child = childData.node, startIndex = childData.startIndex;
|
|
113
|
+
// Calculate endIndex using next child's startIndex, or end of line
|
|
114
|
+
var nextChild = childNodes_1[index + 1];
|
|
115
|
+
var endIndex = nextChild ? nextChild.startIndex : nodeIndex_1;
|
|
116
|
+
if (child.type.name === "mention") {
|
|
117
|
+
formatRuns.push({
|
|
118
|
+
startIndex: startIndex,
|
|
119
|
+
endIndex: endIndex,
|
|
120
|
+
nodeType: "mention",
|
|
121
|
+
mention: __assign({}, child.attrs),
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
else if (child.isText && child.text) {
|
|
125
|
+
if (child.marks && child.marks.length > 0) {
|
|
126
|
+
// Extract format from marks
|
|
127
|
+
var format_1 = {};
|
|
128
|
+
child.marks.forEach(function (mark) {
|
|
129
|
+
switch (mark.type.name) {
|
|
130
|
+
case "bold":
|
|
131
|
+
format_1.bold = true;
|
|
132
|
+
break;
|
|
133
|
+
case "italic":
|
|
134
|
+
format_1.italic = true;
|
|
135
|
+
break;
|
|
136
|
+
case "underline":
|
|
137
|
+
format_1.underline = true;
|
|
138
|
+
break;
|
|
139
|
+
case "strikethrough":
|
|
140
|
+
format_1.strikethrough = true;
|
|
141
|
+
break;
|
|
142
|
+
case "superscript":
|
|
143
|
+
format_1.baselineOffset = "superscript";
|
|
144
|
+
break;
|
|
145
|
+
case "subscript":
|
|
146
|
+
format_1.baselineOffset = "subscript";
|
|
147
|
+
break;
|
|
148
|
+
case "color":
|
|
149
|
+
format_1.color = mark.attrs.color;
|
|
150
|
+
break;
|
|
151
|
+
case "fontSize":
|
|
152
|
+
format_1.fontSize = mark.attrs.size;
|
|
153
|
+
break;
|
|
154
|
+
case "fontFamily":
|
|
155
|
+
format_1.fontFamily = mark.attrs.family;
|
|
156
|
+
break;
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
formatRuns.push({
|
|
160
|
+
startIndex: startIndex,
|
|
161
|
+
endIndex: endIndex,
|
|
162
|
+
format: format_1,
|
|
163
|
+
nodeType: "text",
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
// Plain text without formatting
|
|
168
|
+
formatRuns.push({
|
|
169
|
+
startIndex: startIndex,
|
|
170
|
+
endIndex: endIndex,
|
|
171
|
+
format: {},
|
|
172
|
+
nodeType: "text",
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
currentIndex = nodeIndex_1;
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
// Filter out text nodes with empty format objects
|
|
181
|
+
var filteredRuns = formatRuns.filter(function (run) {
|
|
182
|
+
if (run.nodeType === "text" && Object.keys(run.format).length === 0) {
|
|
183
|
+
return false;
|
|
184
|
+
}
|
|
185
|
+
return true;
|
|
186
|
+
});
|
|
187
|
+
return filteredRuns.length === 0 ? undefined : filteredRuns;
|
|
188
|
+
};
|
|
189
|
+
export var applyTextFormatRuns = function (text, formatRuns, schema, resolveColor) {
|
|
190
|
+
// Handle empty text case
|
|
191
|
+
if (text === "") {
|
|
192
|
+
return schema.nodes.doc.create(null, [schema.nodes.line.create(null, [])]);
|
|
193
|
+
}
|
|
194
|
+
// If no format runs, create simple document with plain text
|
|
195
|
+
if (!formatRuns || (formatRuns === null || formatRuns === void 0 ? void 0 : formatRuns.length) === 0) {
|
|
196
|
+
var lines_1 = text.split("\n");
|
|
197
|
+
var lineNodes_1 = lines_1.map(function (lineText) {
|
|
198
|
+
return schema.nodes.line.create(null, lineText ? [schema.text(lineText)] : []);
|
|
199
|
+
});
|
|
200
|
+
return schema.nodes.doc.create(null, lineNodes_1);
|
|
201
|
+
}
|
|
202
|
+
var sortedFormatRuns = __spreadArray([], __read(formatRuns), false).sort(function (a, b) { return a.startIndex - b.startIndex || a.endIndex - b.endIndex; });
|
|
203
|
+
var createMarks = function (formatRun) {
|
|
204
|
+
var marks = [];
|
|
205
|
+
// Engine-emitted runs (rnc window cells) can omit `format` on the
|
|
206
|
+
// unformatted gap runs between styled spans.
|
|
207
|
+
if (!formatRun.format) {
|
|
208
|
+
return marks;
|
|
209
|
+
}
|
|
210
|
+
if (formatRun.format.bold) {
|
|
211
|
+
marks.push(schema.marks.bold.create());
|
|
212
|
+
}
|
|
213
|
+
if (formatRun.format.italic) {
|
|
214
|
+
marks.push(schema.marks.italic.create());
|
|
215
|
+
}
|
|
216
|
+
if (formatRun.format.underline) {
|
|
217
|
+
marks.push(schema.marks.underline.create());
|
|
218
|
+
}
|
|
219
|
+
if (formatRun.format.strikethrough) {
|
|
220
|
+
marks.push(schema.marks.strikethrough.create());
|
|
221
|
+
}
|
|
222
|
+
if (formatRun.format.color) {
|
|
223
|
+
var css = typeof formatRun.format.color === "string"
|
|
224
|
+
? formatRun.format.color
|
|
225
|
+
: resolveColor === null || resolveColor === void 0 ? void 0 : resolveColor(formatRun.format.color);
|
|
226
|
+
if (css) {
|
|
227
|
+
marks.push(schema.marks.color.create({ color: css }));
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
if (formatRun.format.baselineOffset === "superscript") {
|
|
231
|
+
marks.push(schema.marks.superscript.create());
|
|
232
|
+
}
|
|
233
|
+
else if (formatRun.format.baselineOffset === "subscript") {
|
|
234
|
+
marks.push(schema.marks.subscript.create());
|
|
235
|
+
}
|
|
236
|
+
if (formatRun.format.fontSize != null) {
|
|
237
|
+
marks.push(schema.marks.fontSize.create({ size: formatRun.format.fontSize }));
|
|
238
|
+
}
|
|
239
|
+
if (formatRun.format.fontFamily) {
|
|
240
|
+
marks.push(schema.marks.fontFamily.create({ family: formatRun.format.fontFamily }));
|
|
241
|
+
}
|
|
242
|
+
return marks;
|
|
243
|
+
};
|
|
244
|
+
// Split text into lines
|
|
245
|
+
var lines = text.split("\n");
|
|
246
|
+
var lineNodes = [];
|
|
247
|
+
var currentTextIndex = 0;
|
|
248
|
+
var _loop_1 = function (lineIndex) {
|
|
249
|
+
var e_1, _a;
|
|
250
|
+
var lineText = lines[lineIndex];
|
|
251
|
+
var lineContent = [];
|
|
252
|
+
if (lineIndex > 0) {
|
|
253
|
+
// Account for newline character
|
|
254
|
+
currentTextIndex++;
|
|
255
|
+
}
|
|
256
|
+
var lineStartIndex = currentTextIndex;
|
|
257
|
+
var lineEndIndex = currentTextIndex + lineText.length;
|
|
258
|
+
// Get format runs that overlap this line. Runs may span newlines,
|
|
259
|
+
// but ProseMirror stores each line separately, so split by line.
|
|
260
|
+
var lineFormatRuns = sortedFormatRuns.filter(function (run) { return run.startIndex < lineEndIndex && run.endIndex > lineStartIndex; });
|
|
261
|
+
if (lineFormatRuns.length === 0 && lineText.length > 0) {
|
|
262
|
+
// No formatting, create plain text node
|
|
263
|
+
lineContent.push(schema.text(lineText));
|
|
264
|
+
}
|
|
265
|
+
else if (lineText.length > 0) {
|
|
266
|
+
// Process format runs for this line
|
|
267
|
+
var processedIndex = lineStartIndex;
|
|
268
|
+
try {
|
|
269
|
+
for (var lineFormatRuns_1 = (e_1 = void 0, __values(lineFormatRuns)), lineFormatRuns_1_1 = lineFormatRuns_1.next(); !lineFormatRuns_1_1.done; lineFormatRuns_1_1 = lineFormatRuns_1.next()) {
|
|
270
|
+
var formatRun = lineFormatRuns_1_1.value;
|
|
271
|
+
var runStart = Math.max(formatRun.startIndex, lineStartIndex);
|
|
272
|
+
var runEnd = Math.min(formatRun.endIndex, lineEndIndex);
|
|
273
|
+
if (runEnd <= runStart || processedIndex >= lineEndIndex) {
|
|
274
|
+
continue;
|
|
275
|
+
}
|
|
276
|
+
// Add any unformatted text before this run
|
|
277
|
+
if (processedIndex < runStart) {
|
|
278
|
+
var unformattedText = text.substring(processedIndex, runStart);
|
|
279
|
+
if (unformattedText) {
|
|
280
|
+
lineContent.push(schema.text(unformattedText));
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
if (formatRun.nodeType === "mention") {
|
|
284
|
+
// Create mention node from format run data
|
|
285
|
+
if (formatRun.mention && formatRun.startIndex >= lineStartIndex) {
|
|
286
|
+
lineContent.push(schema.nodes.mention.create({
|
|
287
|
+
label: formatRun.mention.label,
|
|
288
|
+
value: formatRun.mention.value,
|
|
289
|
+
}));
|
|
290
|
+
// Since mentions are now stored as just the label, advance by label length
|
|
291
|
+
processedIndex = runStart + formatRun.mention.label.length;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
else {
|
|
295
|
+
// Any non-mention run is a text run. xlsx-imported runs (rnc
|
|
296
|
+
// engine and excel-parser) omit `nodeType`, so an exact
|
|
297
|
+
// `=== "text"` check skipped them entirely — processedIndex
|
|
298
|
+
// never advanced and the gap/tail fillers re-emitted the
|
|
299
|
+
// already-covered text (e.g. "kpmg" painting as "kpmgkpmg").
|
|
300
|
+
var runText = text.substring(Math.max(processedIndex, runStart), runEnd);
|
|
301
|
+
if (runText) {
|
|
302
|
+
lineContent.push(schema.text(runText, createMarks(formatRun)));
|
|
303
|
+
processedIndex = runEnd;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
309
|
+
finally {
|
|
310
|
+
try {
|
|
311
|
+
if (lineFormatRuns_1_1 && !lineFormatRuns_1_1.done && (_a = lineFormatRuns_1.return)) _a.call(lineFormatRuns_1);
|
|
312
|
+
}
|
|
313
|
+
finally { if (e_1) throw e_1.error; }
|
|
314
|
+
}
|
|
315
|
+
// Add any remaining unformatted text at the end of the line
|
|
316
|
+
if (processedIndex < lineEndIndex) {
|
|
317
|
+
var remainingText = text.substring(processedIndex, lineEndIndex);
|
|
318
|
+
if (remainingText) {
|
|
319
|
+
lineContent.push(schema.text(remainingText));
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
// Create line node
|
|
324
|
+
lineNodes.push(schema.nodes.line.create(null, lineContent));
|
|
325
|
+
currentTextIndex += lineText.length;
|
|
326
|
+
};
|
|
327
|
+
for (var lineIndex = 0; lineIndex < lines.length; lineIndex++) {
|
|
328
|
+
_loop_1(lineIndex);
|
|
329
|
+
}
|
|
330
|
+
// Create document
|
|
331
|
+
return schema.nodes.doc.create(null, lineNodes);
|
|
332
|
+
};
|
|
333
|
+
/**
|
|
334
|
+
* Applies a `TextFormat` patch to the editor's CURRENT SELECTION as marks —
|
|
335
|
+
* the per-run counterpart of the toolbar's cell-level `onChangeFormatting`.
|
|
336
|
+
* This is what makes the toolbar's bold/superscript/font-size controls format
|
|
337
|
+
* just the selected span while the cell editor is open, the way Cmd+B already
|
|
338
|
+
* does through the keymap.
|
|
339
|
+
*
|
|
340
|
+
* Semantics per key (only keys PRESENT on `format` are touched):
|
|
341
|
+
* - `bold`/`italic`/`underline`/`strikethrough`: TOGGLE against the
|
|
342
|
+
* selection's own mark state (same rule as prosemirror-commands
|
|
343
|
+
* `toggleMark`: any marked text in range → remove, else add) — the caller's
|
|
344
|
+
* cell-level boolean is ignored because it describes the cell, not the span.
|
|
345
|
+
* - `baselineOffset`: if the selection already carries the target offset the
|
|
346
|
+
* pair is cleared; otherwise the target replaces both (mutually exclusive).
|
|
347
|
+
* - `fontSize`/`fontFamily`/`color`: SET to the given value (clear on nullish).
|
|
348
|
+
* Theme-object colors resolve through `resolveColor`.
|
|
349
|
+
*
|
|
350
|
+
* A collapsed selection applies the change to the stored marks, so it affects
|
|
351
|
+
* what is typed next — Google Sheets behavior.
|
|
352
|
+
*
|
|
353
|
+
* Returns `false` (and dispatches nothing) when `format` carries none of the
|
|
354
|
+
* run-representable keys, so the caller can fall back to cell-level formatting.
|
|
355
|
+
*/
|
|
356
|
+
export var applyTextFormatToSelection = function (state, dispatch, format, schema, resolveColor) {
|
|
357
|
+
var e_2, _a;
|
|
358
|
+
var _b;
|
|
359
|
+
var _c = state.selection, from = _c.from, to = _c.to, empty = _c.empty;
|
|
360
|
+
var cursorMarks = (_b = state.storedMarks) !== null && _b !== void 0 ? _b : state.selection.$from.marks();
|
|
361
|
+
var tr = state.tr;
|
|
362
|
+
var handled = false;
|
|
363
|
+
var hasMark = function (markType) {
|
|
364
|
+
return empty
|
|
365
|
+
? markType.isInSet(cursorMarks) != null
|
|
366
|
+
: state.doc.rangeHasMark(from, to, markType);
|
|
367
|
+
};
|
|
368
|
+
var add = function (mark) {
|
|
369
|
+
tr = empty ? tr.addStoredMark(mark) : tr.addMark(from, to, mark);
|
|
370
|
+
};
|
|
371
|
+
var remove = function (markType) {
|
|
372
|
+
tr = empty ? tr.removeStoredMark(markType) : tr.removeMark(from, to, markType);
|
|
373
|
+
};
|
|
374
|
+
try {
|
|
375
|
+
for (var _d = __values(["bold", "italic", "underline", "strikethrough"]), _e = _d.next(); !_e.done; _e = _d.next()) {
|
|
376
|
+
var key = _e.value;
|
|
377
|
+
if (!(key in format))
|
|
378
|
+
continue;
|
|
379
|
+
handled = true;
|
|
380
|
+
var markType = schema.marks[key];
|
|
381
|
+
if (hasMark(markType)) {
|
|
382
|
+
remove(markType);
|
|
383
|
+
}
|
|
384
|
+
else {
|
|
385
|
+
add(markType.create());
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
390
|
+
finally {
|
|
391
|
+
try {
|
|
392
|
+
if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
|
|
393
|
+
}
|
|
394
|
+
finally { if (e_2) throw e_2.error; }
|
|
395
|
+
}
|
|
396
|
+
if ("baselineOffset" in format) {
|
|
397
|
+
handled = true;
|
|
398
|
+
var target = format.baselineOffset;
|
|
399
|
+
var targetType = target ? schema.marks[target] : undefined;
|
|
400
|
+
var alreadyOn = targetType ? hasMark(targetType) : false;
|
|
401
|
+
remove(schema.marks.superscript);
|
|
402
|
+
remove(schema.marks.subscript);
|
|
403
|
+
if (targetType && !alreadyOn) {
|
|
404
|
+
add(targetType.create());
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
if ("fontSize" in format) {
|
|
408
|
+
handled = true;
|
|
409
|
+
remove(schema.marks.fontSize);
|
|
410
|
+
if (format.fontSize != null) {
|
|
411
|
+
add(schema.marks.fontSize.create({ size: format.fontSize }));
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
if ("fontFamily" in format) {
|
|
415
|
+
handled = true;
|
|
416
|
+
remove(schema.marks.fontFamily);
|
|
417
|
+
if (format.fontFamily) {
|
|
418
|
+
add(schema.marks.fontFamily.create({ family: format.fontFamily }));
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
if ("color" in format) {
|
|
422
|
+
handled = true;
|
|
423
|
+
remove(schema.marks.color);
|
|
424
|
+
var css = typeof format.color === "string"
|
|
425
|
+
? format.color
|
|
426
|
+
: format.color
|
|
427
|
+
? resolveColor === null || resolveColor === void 0 ? void 0 : resolveColor(format.color)
|
|
428
|
+
: undefined;
|
|
429
|
+
if (css) {
|
|
430
|
+
add(schema.marks.color.create({ color: css }));
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
if (!handled) {
|
|
434
|
+
return false;
|
|
435
|
+
}
|
|
436
|
+
dispatch === null || dispatch === void 0 ? void 0 : dispatch(tr);
|
|
437
|
+
return true;
|
|
438
|
+
};
|
|
439
|
+
/**
|
|
440
|
+
* Effective fontSize (pt) of the current selection, or `null` when the
|
|
441
|
+
* selection carries no fontSize mark. A collapsed selection reads the stored
|
|
442
|
+
* marks (what the next typed character would get); a range reads the marks of
|
|
443
|
+
* the first text node in the range, matching how the run is rendered.
|
|
444
|
+
*/
|
|
445
|
+
export var getSelectionFontSize = function (state) {
|
|
446
|
+
var _a, _b;
|
|
447
|
+
var _c = state.selection, from = _c.from, to = _c.to, empty = _c.empty;
|
|
448
|
+
var marks = null;
|
|
449
|
+
if (empty) {
|
|
450
|
+
marks = (_a = state.storedMarks) !== null && _a !== void 0 ? _a : state.selection.$from.marks();
|
|
451
|
+
}
|
|
452
|
+
else {
|
|
453
|
+
state.doc.nodesBetween(from, to, function (node) {
|
|
454
|
+
if (marks)
|
|
455
|
+
return false;
|
|
456
|
+
if (node.isText) {
|
|
457
|
+
marks = node.marks;
|
|
458
|
+
return false;
|
|
459
|
+
}
|
|
460
|
+
return true;
|
|
461
|
+
});
|
|
462
|
+
}
|
|
463
|
+
var mark = marks === null || marks === void 0 ? void 0 : marks.find(function (m) { return m.type.name === "fontSize"; });
|
|
464
|
+
var size = (_b = mark === null || mark === void 0 ? void 0 : mark.attrs) === null || _b === void 0 ? void 0 : _b.size;
|
|
465
|
+
return typeof size === "number" && Number.isFinite(size) ? size : null;
|
|
466
|
+
};
|
|
467
|
+
/**
|
|
468
|
+
* Get current cursor position
|
|
469
|
+
* @param state
|
|
470
|
+
* @returns
|
|
471
|
+
*/
|
|
472
|
+
export var getCursorPosition = function (state) {
|
|
473
|
+
try {
|
|
474
|
+
var selection = state.selection;
|
|
475
|
+
if (!selection || !selection.empty) {
|
|
476
|
+
return undefined;
|
|
477
|
+
}
|
|
478
|
+
// Bounds checking
|
|
479
|
+
var pos = selection.from;
|
|
480
|
+
if (pos < 0 || pos > state.doc.content.size) {
|
|
481
|
+
console.warn("Invalid cursor position: ".concat(pos, ", doc size: ").concat(state.doc.content.size));
|
|
482
|
+
return undefined;
|
|
483
|
+
}
|
|
484
|
+
return pos;
|
|
485
|
+
}
|
|
486
|
+
catch (error) {
|
|
487
|
+
console.warn("Error getting cursor position:", error);
|
|
488
|
+
return undefined;
|
|
489
|
+
}
|
|
490
|
+
};
|
|
491
|
+
/**
|
|
492
|
+
* Get currently focused token
|
|
493
|
+
* @param position
|
|
494
|
+
* @param tokens
|
|
495
|
+
* @returns
|
|
496
|
+
*/
|
|
497
|
+
export var getActiveToken = function (position, tokens) {
|
|
498
|
+
return tokens.find(function (token) { return token.endColumn >= position; });
|
|
499
|
+
};
|
|
500
|
+
export var enableCellSelection = function (position, cursorPos, tokens) {
|
|
501
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
502
|
+
if (!Number.isFinite(cursorPos) || !tokens.length) {
|
|
503
|
+
return false;
|
|
504
|
+
}
|
|
505
|
+
var _q = __read(getSurroundingTokens(position, tokens), 3), prev = _q[0], active = _q[1], next = _q[2];
|
|
506
|
+
var isStringLike = function (token) {
|
|
507
|
+
return !!token &&
|
|
508
|
+
(token.tokenType.name === tokenVocabulary.String.name ||
|
|
509
|
+
token.tokenType.name === tokenVocabulary.UnterminatedStringStart.name ||
|
|
510
|
+
token.image === '"');
|
|
511
|
+
};
|
|
512
|
+
var isCoveringPosition = function (token) {
|
|
513
|
+
var _a, _b;
|
|
514
|
+
return isStringLike(token) &&
|
|
515
|
+
position >= ((_a = token === null || token === void 0 ? void 0 : token.startColumn) !== null && _a !== void 0 ? _a : position) &&
|
|
516
|
+
position <= ((_b = token === null || token === void 0 ? void 0 : token.endColumn) !== null && _b !== void 0 ? _b : position);
|
|
517
|
+
};
|
|
518
|
+
if (isStringLike(active) || isStringLike(next) || isCoveringPosition(prev)) {
|
|
519
|
+
return false;
|
|
520
|
+
}
|
|
521
|
+
var isEmptyFunctionCall = (prev === null || prev === void 0 ? void 0 : prev.tokenType.name) === tokenVocabulary.Function.name &&
|
|
522
|
+
(active === null || active === void 0 ? void 0 : active.tokenType.name) === tokenVocabulary.CloseParen.name &&
|
|
523
|
+
((_a = prev.image) !== null && _a !== void 0 ? _a : "").endsWith("(") &&
|
|
524
|
+
((_b = active.startColumn) !== null && _b !== void 0 ? _b : 0) === ((_c = prev.endColumn) !== null && _c !== void 0 ? _c : -1) + 1;
|
|
525
|
+
if (isEmptyFunctionCall) {
|
|
526
|
+
return false;
|
|
527
|
+
}
|
|
528
|
+
var isAfterCloseParen = (active === null || active === void 0 ? void 0 : active.tokenType.name) === tokenVocabulary.CloseParen.name &&
|
|
529
|
+
cursorPos === position + 1;
|
|
530
|
+
if (isAfterCloseParen) {
|
|
531
|
+
return false;
|
|
532
|
+
}
|
|
533
|
+
var prevAllowed = prev &&
|
|
534
|
+
CELL_SUGGESTION_PREFIX.includes(prev.tokenType.name) &&
|
|
535
|
+
position > ((_d = prev.endColumn) !== null && _d !== void 0 ? _d : -Infinity);
|
|
536
|
+
// The cursor must actually be inside (or at the trailing edge of) the
|
|
537
|
+
// active token for it to count as the prefix that enables cell
|
|
538
|
+
// selection. Without the `position >= startColumn` guard, a cursor
|
|
539
|
+
// positioned BEFORE the active token (e.g. caret at index 0 of `=$12`)
|
|
540
|
+
// would still treat the leading `=` as the prefix and flip the editor
|
|
541
|
+
// into cell-suggestion mode. Calculator columns are 1-indexed while
|
|
542
|
+
// `position` (offsetInLine) is 0-indexed, so cursor-just-before-token
|
|
543
|
+
// satisfies `position < startColumn`.
|
|
544
|
+
var activeAllowed = active &&
|
|
545
|
+
CELL_SUGGESTION_PREFIX.includes(active.tokenType.name) &&
|
|
546
|
+
position >= ((_e = active.startColumn) !== null && _e !== void 0 ? _e : Infinity) &&
|
|
547
|
+
position <= ((_f = active.endColumn) !== null && _f !== void 0 ? _f : position);
|
|
548
|
+
var prefixToken = prevAllowed ? prev : activeAllowed ? active : undefined;
|
|
549
|
+
if (!prefixToken) {
|
|
550
|
+
return false;
|
|
551
|
+
}
|
|
552
|
+
var isActiveReferenceStart = active &&
|
|
553
|
+
isReferenceToken(active) &&
|
|
554
|
+
position + 1 === ((_g = active.startColumn) !== null && _g !== void 0 ? _g : position + 1);
|
|
555
|
+
if (isActiveReferenceStart) {
|
|
556
|
+
return false;
|
|
557
|
+
}
|
|
558
|
+
var isNextReferenceStart = next &&
|
|
559
|
+
isReferenceToken(next) &&
|
|
560
|
+
position + 1 === ((_h = next.startColumn) !== null && _h !== void 0 ? _h : position + 1);
|
|
561
|
+
if (isNextReferenceStart) {
|
|
562
|
+
return false;
|
|
563
|
+
}
|
|
564
|
+
if (next && !CELL_SUGGESTION_SUFFIX.includes(next.tokenType.name)) {
|
|
565
|
+
return false;
|
|
566
|
+
}
|
|
567
|
+
var activeType = (_j = active === null || active === void 0 ? void 0 : active.tokenType) === null || _j === void 0 ? void 0 : _j.name;
|
|
568
|
+
var isInsideReference = isReferenceToken(active) &&
|
|
569
|
+
position >= ((_k = active === null || active === void 0 ? void 0 : active.startColumn) !== null && _k !== void 0 ? _k : position) &&
|
|
570
|
+
position <= ((_l = active === null || active === void 0 ? void 0 : active.endColumn) !== null && _l !== void 0 ? _l : position);
|
|
571
|
+
var isInsideFunctionName = false;
|
|
572
|
+
if (activeType === tokenVocabulary.Function.name && active) {
|
|
573
|
+
var start = (_m = active.startColumn) !== null && _m !== void 0 ? _m : position;
|
|
574
|
+
var nameEnd = (_o = active.endColumn) !== null && _o !== void 0 ? _o : position;
|
|
575
|
+
var image = (_p = active.image) !== null && _p !== void 0 ? _p : "";
|
|
576
|
+
if (image.endsWith("(") && image.length > 1) {
|
|
577
|
+
var nameLength = image.length - 1;
|
|
578
|
+
nameEnd = start + nameLength - 1;
|
|
579
|
+
}
|
|
580
|
+
isInsideFunctionName = position >= start && position <= nameEnd;
|
|
581
|
+
}
|
|
582
|
+
if (isInsideReference ||
|
|
583
|
+
isInsideFunctionName ||
|
|
584
|
+
activeType === tokenVocabulary.String.name ||
|
|
585
|
+
activeType === tokenVocabulary.UnterminatedStringStart.name ||
|
|
586
|
+
activeType === tokenVocabulary.Number.name ||
|
|
587
|
+
activeType === tokenVocabulary.Boolean.name) {
|
|
588
|
+
return false;
|
|
589
|
+
}
|
|
590
|
+
return true;
|
|
591
|
+
};
|
|
592
|
+
/**
|
|
593
|
+
* Get prev, current and next tokens using a position
|
|
594
|
+
* @param position
|
|
595
|
+
* @param tokens
|
|
596
|
+
* @returns
|
|
597
|
+
*/
|
|
598
|
+
export var getSurroundingTokens = function (position, tokens) {
|
|
599
|
+
var activeToken = getActiveToken(position, tokens);
|
|
600
|
+
return [
|
|
601
|
+
getPreviousToken(position, tokens),
|
|
602
|
+
activeToken,
|
|
603
|
+
getNextToken(position, tokens, activeToken),
|
|
604
|
+
];
|
|
605
|
+
};
|
|
606
|
+
/**
|
|
607
|
+
* Get the previous token from the current position
|
|
608
|
+
* @param position
|
|
609
|
+
* @param tokens
|
|
610
|
+
* @returns
|
|
611
|
+
*/
|
|
612
|
+
export var getPreviousToken = function (position, tokens) {
|
|
613
|
+
var e_3, _a;
|
|
614
|
+
var previous;
|
|
615
|
+
try {
|
|
616
|
+
for (var tokens_1 = __values(tokens), tokens_1_1 = tokens_1.next(); !tokens_1_1.done; tokens_1_1 = tokens_1.next()) {
|
|
617
|
+
var token = tokens_1_1.value;
|
|
618
|
+
if (token.endColumn < position) {
|
|
619
|
+
previous = token;
|
|
620
|
+
continue;
|
|
621
|
+
}
|
|
622
|
+
if (token.startColumn <= position && token.endColumn >= position) {
|
|
623
|
+
return previous;
|
|
624
|
+
}
|
|
625
|
+
if (token.startColumn > position) {
|
|
626
|
+
break;
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
631
|
+
finally {
|
|
632
|
+
try {
|
|
633
|
+
if (tokens_1_1 && !tokens_1_1.done && (_a = tokens_1.return)) _a.call(tokens_1);
|
|
634
|
+
}
|
|
635
|
+
finally { if (e_3) throw e_3.error; }
|
|
636
|
+
}
|
|
637
|
+
return previous;
|
|
638
|
+
};
|
|
639
|
+
/**
|
|
640
|
+
* Get next token from position
|
|
641
|
+
* @param position
|
|
642
|
+
* @param tokens
|
|
643
|
+
* @returns
|
|
644
|
+
*/
|
|
645
|
+
export var getNextToken = function (position, tokens, activeToken) {
|
|
646
|
+
return tokens.find(function (token) {
|
|
647
|
+
if (activeToken && token === activeToken) {
|
|
648
|
+
return false;
|
|
649
|
+
}
|
|
650
|
+
var start = token.startColumn && token.startColumn > 0
|
|
651
|
+
? token.startColumn - 1
|
|
652
|
+
: token.startOffset;
|
|
653
|
+
return start !== undefined && start >= position;
|
|
654
|
+
});
|
|
655
|
+
};
|
|
656
|
+
/**
|
|
657
|
+
* Is current token a cell token
|
|
658
|
+
* @param token
|
|
659
|
+
* @returns
|
|
660
|
+
*/
|
|
661
|
+
export var isCellToken = function (token) {
|
|
662
|
+
return token.tokenType.name === tokenVocabulary.Cell.name || token.selection;
|
|
663
|
+
};
|
|
664
|
+
export var isTableColumnToken = function (token) {
|
|
665
|
+
return token.tokenType.name === tokenVocabulary.TableColumnName.name;
|
|
666
|
+
};
|
|
667
|
+
export var isTableNameToken = function (token) {
|
|
668
|
+
return token.tokenType.name === tokenVocabulary.TableName.name;
|
|
669
|
+
};
|
|
670
|
+
export var isNamedRangeToken = function (token) {
|
|
671
|
+
return token.tokenType.name === tokenVocabulary.Name.name;
|
|
672
|
+
};
|
|
673
|
+
export var isStringToken = function (token) {
|
|
674
|
+
return token.tokenType.name === tokenVocabulary.String.name;
|
|
675
|
+
};
|
|
676
|
+
export var isNumberToken = function (token) {
|
|
677
|
+
return token.tokenType.name === tokenVocabulary.Number.name;
|
|
678
|
+
};
|
|
679
|
+
var isReferenceToken = function (token) {
|
|
680
|
+
if (!token)
|
|
681
|
+
return false;
|
|
682
|
+
return (isCellToken(token) ||
|
|
683
|
+
isTableColumnToken(token) ||
|
|
684
|
+
isTableNameToken(token) ||
|
|
685
|
+
isNamedRangeToken(token) ||
|
|
686
|
+
token.tokenType.name === tokenVocabulary.Column.name);
|
|
687
|
+
};
|
|
688
|
+
/**
|
|
689
|
+
* Check if token is a cell reference with property (e.g., A1.title or A1.)
|
|
690
|
+
* @param token
|
|
691
|
+
* @returns
|
|
692
|
+
*/
|
|
693
|
+
export var getPropertyStartIndex = function (token) {
|
|
694
|
+
if (!(token === null || token === void 0 ? void 0 : token.image)) {
|
|
695
|
+
return -1;
|
|
696
|
+
}
|
|
697
|
+
if (token.tokenType.name === tokenVocabulary.Cell.name ||
|
|
698
|
+
token.tokenType.name === tokenVocabulary.Name.name) {
|
|
699
|
+
return token.image.indexOf(".");
|
|
700
|
+
}
|
|
701
|
+
if (token.tokenType.name === tokenVocabulary.TableColumnName.name ||
|
|
702
|
+
token.tokenType.name === tokenVocabulary.SpecialItem.name ||
|
|
703
|
+
token.tokenType.name === tokenVocabulary.TableName.name) {
|
|
704
|
+
var lastClosingBracket = token.image.lastIndexOf("]");
|
|
705
|
+
if (lastClosingBracket === -1) {
|
|
706
|
+
return -1;
|
|
707
|
+
}
|
|
708
|
+
return token.image.indexOf(".", lastClosingBracket + 1);
|
|
709
|
+
}
|
|
710
|
+
return -1;
|
|
711
|
+
};
|
|
712
|
+
export var hasPropertyReference = function (token) {
|
|
713
|
+
var index = getPropertyStartIndex(token);
|
|
714
|
+
return index !== -1;
|
|
715
|
+
};
|
|
716
|
+
/**
|
|
717
|
+
* Get current active function
|
|
718
|
+
* @param curToken
|
|
719
|
+
* @param tokens
|
|
720
|
+
*/
|
|
721
|
+
export var getActiveFunctionToken = function (curToken, tokens) {
|
|
722
|
+
if (!curToken)
|
|
723
|
+
return void 0;
|
|
724
|
+
var i = tokens.findIndex(function (token) { return token === curToken; });
|
|
725
|
+
var fn;
|
|
726
|
+
var skip = 0;
|
|
727
|
+
while (i > 0) {
|
|
728
|
+
var token = tokens[i];
|
|
729
|
+
if (token.tokenType.name === tokenVocabulary.CloseParen.name) {
|
|
730
|
+
skip++;
|
|
731
|
+
}
|
|
732
|
+
if (token.tokenType.name === tokenVocabulary.Function.name) {
|
|
733
|
+
if (skip > 0) {
|
|
734
|
+
skip--;
|
|
735
|
+
}
|
|
736
|
+
else {
|
|
737
|
+
fn = token;
|
|
738
|
+
break;
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
i--;
|
|
742
|
+
}
|
|
743
|
+
return fn;
|
|
744
|
+
};
|
|
745
|
+
/**
|
|
746
|
+
* get selection index from activetoken
|
|
747
|
+
* @param activeToken
|
|
748
|
+
* @returns
|
|
749
|
+
*/
|
|
750
|
+
export var getActiveSelectionIndex = function (activeToken) {
|
|
751
|
+
var _a;
|
|
752
|
+
return (activeToken === null || activeToken === void 0 ? void 0 : activeToken.structured) ||
|
|
753
|
+
(activeToken === null || activeToken === void 0 ? void 0 : activeToken.isNamedRange) ||
|
|
754
|
+
(activeToken === null || activeToken === void 0 ? void 0 : activeToken.selection)
|
|
755
|
+
? (_a = activeToken.index) !== null && _a !== void 0 ? _a : -1
|
|
756
|
+
: -1;
|
|
757
|
+
};
|
|
758
|
+
/**
|
|
759
|
+
* Suggestion token
|
|
760
|
+
* @param position
|
|
761
|
+
* @param activeToken
|
|
762
|
+
* @param view
|
|
763
|
+
* @returns
|
|
764
|
+
*/
|
|
765
|
+
export var getActiveSuggestionToken = function (position, activeToken, view) {
|
|
766
|
+
var _a, _b;
|
|
767
|
+
// If the token is already a function, lets ignore
|
|
768
|
+
if (!activeToken ||
|
|
769
|
+
activeToken.tokenType.name === tokenVocabulary.Function.name) {
|
|
770
|
+
return undefined;
|
|
771
|
+
}
|
|
772
|
+
var propertyStart = hasPropertyReference(activeToken)
|
|
773
|
+
? getPropertyStartIndex(activeToken)
|
|
774
|
+
: -1;
|
|
775
|
+
if (propertyStart !== -1 && (activeToken === null || activeToken === void 0 ? void 0 : activeToken.image) != null) {
|
|
776
|
+
var propertyImage = activeToken.image.slice(propertyStart + 1);
|
|
777
|
+
var propertyStartOffset = ((_a = activeToken.startOffset) !== null && _a !== void 0 ? _a : 0) + propertyStart + 1;
|
|
778
|
+
var propertyStartColumn = ((_b = activeToken.startColumn) !== null && _b !== void 0 ? _b : 0) + propertyStart + 1;
|
|
779
|
+
var suggestionToken = __assign(__assign({}, activeToken), { image: propertyImage, startOffset: propertyStartOffset, endOffset: propertyStartOffset + propertyImage.length, startColumn: propertyStartColumn, endColumn: propertyStartColumn + propertyImage.length });
|
|
780
|
+
suggestionToken.basePropertyToken = activeToken;
|
|
781
|
+
return suggestionToken;
|
|
782
|
+
}
|
|
783
|
+
// Named ranges.
|
|
784
|
+
// Resolved named ranges have `index` property. If its resolved,
|
|
785
|
+
// lets not show suggestions anymore
|
|
786
|
+
if (activeToken.tokenType.name === tokenVocabulary.Name.name &&
|
|
787
|
+
activeToken.index !== undefined) {
|
|
788
|
+
return undefined;
|
|
789
|
+
}
|
|
790
|
+
// For tables
|
|
791
|
+
if (activeToken.tokenType.name === tokenVocabulary.TableName.name ||
|
|
792
|
+
activeToken.tokenType.name === tokenVocabulary.TableColumnName.name) {
|
|
793
|
+
try {
|
|
794
|
+
var result = getWordAtPosition(view.state, position);
|
|
795
|
+
if ((result === null || result === void 0 ? void 0 : result.end) === position) {
|
|
796
|
+
return undefined;
|
|
797
|
+
}
|
|
798
|
+
// Use the token's image directly for cleanup
|
|
799
|
+
// This avoids complex ProseMirror position calculations
|
|
800
|
+
var tokenImage = activeToken.image || "";
|
|
801
|
+
var tableNameLength = activeToken.tableName
|
|
802
|
+
? activeToken.tableName.length + 1
|
|
803
|
+
: 0;
|
|
804
|
+
if (!tokenImage) {
|
|
805
|
+
return undefined;
|
|
806
|
+
}
|
|
807
|
+
var cleanupImage = cleanupColumnName(tokenImage);
|
|
808
|
+
var change = tokenImage.length - cleanupImage.length;
|
|
809
|
+
return __assign(__assign({}, activeToken), { startOffset: activeToken.startOffset + tableNameLength + change, image: cleanupImage });
|
|
810
|
+
}
|
|
811
|
+
catch (error) {
|
|
812
|
+
console.warn("Error processing table suggestion token:", error);
|
|
813
|
+
return activeToken;
|
|
814
|
+
}
|
|
815
|
+
}
|
|
816
|
+
return activeToken.tokenType.name === tokenVocabulary.TableColumnName.name ||
|
|
817
|
+
activeToken.tokenType.name === tokenVocabulary.Column.name ||
|
|
818
|
+
activeToken.tokenType.name === tokenVocabulary.Name.name ||
|
|
819
|
+
activeToken.tokenType.name === tokenVocabulary.Function.name ||
|
|
820
|
+
activeToken.tokenType.name === tokenVocabulary.UnterminatedStringStart.name
|
|
821
|
+
? activeToken
|
|
822
|
+
: undefined;
|
|
823
|
+
};
|
|
824
|
+
export var resolveCellPropertyToken = function (activeToken, tokens) {
|
|
825
|
+
if (hasPropertyReference(activeToken)) {
|
|
826
|
+
return activeToken;
|
|
827
|
+
}
|
|
828
|
+
if (!activeToken) {
|
|
829
|
+
return undefined;
|
|
830
|
+
}
|
|
831
|
+
var index = tokens.findIndex(function (token) { return token === activeToken; });
|
|
832
|
+
if (index === -1) {
|
|
833
|
+
return undefined;
|
|
834
|
+
}
|
|
835
|
+
for (var i = index - 1; i >= 0; i--) {
|
|
836
|
+
var token = tokens[i];
|
|
837
|
+
if (token.tokenType.name === tokenVocabulary.Cell.name ||
|
|
838
|
+
token.tokenType.name === tokenVocabulary.TableColumnName.name ||
|
|
839
|
+
token.tokenType.name === tokenVocabulary.TableName.name) {
|
|
840
|
+
if (hasPropertyReference(token)) {
|
|
841
|
+
return token;
|
|
842
|
+
}
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
return undefined;
|
|
846
|
+
};
|
|
847
|
+
/**
|
|
848
|
+
* Get active table token
|
|
849
|
+
* @param position
|
|
850
|
+
* @param activeToken
|
|
851
|
+
* @param tokens
|
|
852
|
+
* @param view
|
|
853
|
+
* @param isEdge
|
|
854
|
+
* @returns
|
|
855
|
+
*/
|
|
856
|
+
export var getActiveTableToken = function (position, activeToken, tokens, view, isEdge) {
|
|
857
|
+
if (!activeToken)
|
|
858
|
+
return undefined;
|
|
859
|
+
var table = void 0;
|
|
860
|
+
// Get character before cursor - use tokenized content for consistency
|
|
861
|
+
var state = view.state;
|
|
862
|
+
var fullContent = state.doc.textContent;
|
|
863
|
+
// Map position back to the original content
|
|
864
|
+
// For now, use simple approach since position is within tokenized text
|
|
865
|
+
var previousCharacter = position > 0 && fullContent.length > position - 1
|
|
866
|
+
? fullContent.charAt(position - 1)
|
|
867
|
+
: "";
|
|
868
|
+
var isFocusOutsideToken = position > activeToken.endColumn;
|
|
869
|
+
// Table1[Column]<--
|
|
870
|
+
if (isEdge && previousCharacter === "]") {
|
|
871
|
+
return undefined;
|
|
872
|
+
}
|
|
873
|
+
// Table[Column] <--- token with spaces
|
|
874
|
+
if (activeToken.tokenType.name === tokenVocabulary.TableName.name &&
|
|
875
|
+
!isFocusOutsideToken) {
|
|
876
|
+
return activeToken;
|
|
877
|
+
}
|
|
878
|
+
// [ <--- Square with space
|
|
879
|
+
if (activeToken.tokenType.name === tokenVocabulary.OpenSquareParen.name &&
|
|
880
|
+
!isFocusOutsideToken) {
|
|
881
|
+
table = activeToken;
|
|
882
|
+
}
|
|
883
|
+
var i = tokens.findIndex(function (token) { return token === activeToken; });
|
|
884
|
+
while (i > 0) {
|
|
885
|
+
var token = tokens[i];
|
|
886
|
+
// User starts with [ or [Column
|
|
887
|
+
if (token.tokenType.name === tokenVocabulary.OpenSquareParen.name ||
|
|
888
|
+
token.tokenType.name === tokenVocabulary.TableColumnName.name) {
|
|
889
|
+
var previousToken = tokens[i - 1];
|
|
890
|
+
if (!previousToken ||
|
|
891
|
+
CELL_SUGGESTION_PREFIX.indexOf(previousToken.tokenType.name) !== -1) {
|
|
892
|
+
return token;
|
|
893
|
+
}
|
|
894
|
+
}
|
|
895
|
+
// Find tableName by going back from the
|
|
896
|
+
// current location
|
|
897
|
+
if ([
|
|
898
|
+
tokenVocabulary.Name.name,
|
|
899
|
+
tokenVocabulary.OpenSquareParen.name,
|
|
900
|
+
tokenVocabulary.CloseSquareParen.name,
|
|
901
|
+
tokenVocabulary.Colon.name,
|
|
902
|
+
tokenVocabulary.Column.name,
|
|
903
|
+
].indexOf(token.tokenType.name) !== -1) {
|
|
904
|
+
i--;
|
|
905
|
+
continue;
|
|
906
|
+
}
|
|
907
|
+
// Exclude certain tokens that should not be inside
|
|
908
|
+
// a structured reference
|
|
909
|
+
if (CELL_SUGGESTION_SUFFIX.indexOf(token.tokenType.name) !== -1 ||
|
|
910
|
+
CELL_SUGGESTION_PREFIX.indexOf(token.tokenType.name) !== -1) {
|
|
911
|
+
return undefined;
|
|
912
|
+
}
|
|
913
|
+
// Found table
|
|
914
|
+
if (token.tokenType.name === tokenVocabulary.TableName.name) {
|
|
915
|
+
table = token;
|
|
916
|
+
break;
|
|
917
|
+
}
|
|
918
|
+
i--;
|
|
919
|
+
}
|
|
920
|
+
return table;
|
|
921
|
+
};
|
|
922
|
+
/**
|
|
923
|
+
* Get current parameter index that use is focused on
|
|
924
|
+
* @param curToken
|
|
925
|
+
* @param functionToken
|
|
926
|
+
* @param tokens
|
|
927
|
+
*/
|
|
928
|
+
export var getParameterIndex = function (curToken, functionToken, tokens) {
|
|
929
|
+
var startIndex = tokens.findIndex(function (token) { return token === curToken; });
|
|
930
|
+
var endIndex = tokens.findIndex(function (token) { return token === functionToken; });
|
|
931
|
+
var count = 0;
|
|
932
|
+
/* Skips nested functions */
|
|
933
|
+
var skip = 0;
|
|
934
|
+
// Fix for =SUMX2MY2({1, 2, 3}, {4, 5, 6}), Store indices we should skip
|
|
935
|
+
var replace = false;
|
|
936
|
+
var skipCommaIndices = [];
|
|
937
|
+
for (var i = tokens.length - 1; i >= 0; i--) {
|
|
938
|
+
var token = tokens[i];
|
|
939
|
+
if (token.image === "}") {
|
|
940
|
+
replace = true;
|
|
941
|
+
}
|
|
942
|
+
else if (token.image === "{") {
|
|
943
|
+
replace = false;
|
|
944
|
+
}
|
|
945
|
+
else {
|
|
946
|
+
if (replace) {
|
|
947
|
+
skipCommaIndices.push(i);
|
|
948
|
+
}
|
|
949
|
+
}
|
|
950
|
+
}
|
|
951
|
+
while (startIndex > endIndex) {
|
|
952
|
+
var token = tokens[startIndex];
|
|
953
|
+
if (token.image === ")") {
|
|
954
|
+
skip++;
|
|
955
|
+
}
|
|
956
|
+
else if (token.tokenType.name === "Comma" &&
|
|
957
|
+
skip === 0 &&
|
|
958
|
+
!(skipCommaIndices.indexOf(startIndex) !== -1)) {
|
|
959
|
+
count++;
|
|
960
|
+
}
|
|
961
|
+
if (token.tokenType.name === "Function") {
|
|
962
|
+
if (skip > 0)
|
|
963
|
+
skip--;
|
|
964
|
+
}
|
|
965
|
+
startIndex--;
|
|
966
|
+
}
|
|
967
|
+
return count;
|
|
968
|
+
};
|
|
969
|
+
export var getFunctionParameters = function (input, functionToken) {
|
|
970
|
+
var _a;
|
|
971
|
+
if (!functionToken) {
|
|
972
|
+
return { parameters: [], ranges: [] };
|
|
973
|
+
}
|
|
974
|
+
var searchStart = (_a = functionToken.startColumn) !== null && _a !== void 0 ? _a : 0;
|
|
975
|
+
var openIndex = input.indexOf("(", searchStart);
|
|
976
|
+
if (openIndex === -1) {
|
|
977
|
+
return { parameters: [], ranges: [] };
|
|
978
|
+
}
|
|
979
|
+
var depth = 0;
|
|
980
|
+
var closeIndex = -1;
|
|
981
|
+
for (var i = openIndex; i < input.length; i++) {
|
|
982
|
+
var ch = input[i];
|
|
983
|
+
if (ch === "(")
|
|
984
|
+
depth++;
|
|
985
|
+
else if (ch === ")") {
|
|
986
|
+
depth--;
|
|
987
|
+
if (depth === 0) {
|
|
988
|
+
closeIndex = i;
|
|
989
|
+
break;
|
|
990
|
+
}
|
|
991
|
+
}
|
|
992
|
+
}
|
|
993
|
+
// If user hasn't typed the closing paren yet, use the end of the string
|
|
994
|
+
if (closeIndex === -1) {
|
|
995
|
+
closeIndex = input.length;
|
|
996
|
+
}
|
|
997
|
+
if (closeIndex <= openIndex) {
|
|
998
|
+
return { parameters: [], ranges: [] };
|
|
999
|
+
}
|
|
1000
|
+
var argsSlice = input.slice(openIndex + 1, closeIndex);
|
|
1001
|
+
var parameters = [];
|
|
1002
|
+
var ranges = [];
|
|
1003
|
+
var start = 0;
|
|
1004
|
+
var brace = 0;
|
|
1005
|
+
var bracket = 0;
|
|
1006
|
+
var paren = 0;
|
|
1007
|
+
var inSingle = false;
|
|
1008
|
+
var inDouble = false;
|
|
1009
|
+
var pushParam = function (endIndex) {
|
|
1010
|
+
var raw = argsSlice.slice(start, endIndex);
|
|
1011
|
+
var leading = raw.length - raw.trimStart().length;
|
|
1012
|
+
var trailing = raw.length - raw.trimEnd().length;
|
|
1013
|
+
var absoluteStart = openIndex + 1 + start + leading;
|
|
1014
|
+
var absoluteEnd = openIndex + 1 + endIndex - trailing;
|
|
1015
|
+
parameters.push(raw.trim());
|
|
1016
|
+
ranges.push({ start: absoluteStart, end: absoluteEnd });
|
|
1017
|
+
};
|
|
1018
|
+
for (var i = 0; i <= argsSlice.length; i++) {
|
|
1019
|
+
var ch = argsSlice[i];
|
|
1020
|
+
if (i === argsSlice.length ||
|
|
1021
|
+
(ch === "," &&
|
|
1022
|
+
paren === 0 &&
|
|
1023
|
+
brace === 0 &&
|
|
1024
|
+
bracket === 0 &&
|
|
1025
|
+
!inSingle &&
|
|
1026
|
+
!inDouble)) {
|
|
1027
|
+
pushParam(i);
|
|
1028
|
+
start = i + 1;
|
|
1029
|
+
continue;
|
|
1030
|
+
}
|
|
1031
|
+
if (ch === "'" && !inDouble) {
|
|
1032
|
+
inSingle = !inSingle;
|
|
1033
|
+
continue;
|
|
1034
|
+
}
|
|
1035
|
+
if (ch === '"' && !inSingle) {
|
|
1036
|
+
inDouble = !inDouble;
|
|
1037
|
+
continue;
|
|
1038
|
+
}
|
|
1039
|
+
if (inSingle || inDouble)
|
|
1040
|
+
continue;
|
|
1041
|
+
if (ch === "(")
|
|
1042
|
+
paren++;
|
|
1043
|
+
else if (ch === ")")
|
|
1044
|
+
paren--;
|
|
1045
|
+
else if (ch === "{")
|
|
1046
|
+
brace++;
|
|
1047
|
+
else if (ch === "}")
|
|
1048
|
+
brace--;
|
|
1049
|
+
else if (ch === "[")
|
|
1050
|
+
bracket++;
|
|
1051
|
+
else if (ch === "]")
|
|
1052
|
+
bracket--;
|
|
1053
|
+
}
|
|
1054
|
+
return { parameters: parameters, ranges: ranges };
|
|
1055
|
+
};
|
|
1056
|
+
/**
|
|
1057
|
+
* Get content and offset for tokenization, handling both single and multi-line scenarios
|
|
1058
|
+
* @param state ProseMirror editor state
|
|
1059
|
+
* @param cursorPos Current cursor position
|
|
1060
|
+
* @returns Object with line content and offset within that content
|
|
1061
|
+
*/
|
|
1062
|
+
export var getTokenizationContent = function (state, cursorPos) {
|
|
1063
|
+
try {
|
|
1064
|
+
// Validate cursor position
|
|
1065
|
+
if (cursorPos < 0 || cursorPos > state.doc.content.size) {
|
|
1066
|
+
console.warn("Invalid cursor position: ".concat(cursorPos, ", doc size: ").concat(state.doc.content.size));
|
|
1067
|
+
return {
|
|
1068
|
+
line: state.doc.textContent || "",
|
|
1069
|
+
offsetInLine: 0,
|
|
1070
|
+
};
|
|
1071
|
+
}
|
|
1072
|
+
var $pos = state.doc.resolve(cursorPos);
|
|
1073
|
+
// Strategy 1: For typical spreadsheet formulas, tokenize entire content
|
|
1074
|
+
// This works best when content is a single formula that may span lines
|
|
1075
|
+
var fullContent = state.doc.textContent;
|
|
1076
|
+
if (fullContent.startsWith("=") || fullContent.length <= 1000) {
|
|
1077
|
+
// This looks like a formula or is short enough to tokenize entirely
|
|
1078
|
+
// Calculate position in the full text content
|
|
1079
|
+
// Need to account for ProseMirror's document structure vs plain text
|
|
1080
|
+
var textPosition_1 = 0;
|
|
1081
|
+
var found_1 = false;
|
|
1082
|
+
state.doc.descendants(function (node, pos) {
|
|
1083
|
+
var _a;
|
|
1084
|
+
if (found_1)
|
|
1085
|
+
return false;
|
|
1086
|
+
if (node.isText) {
|
|
1087
|
+
if (pos <= cursorPos && cursorPos <= pos + node.nodeSize) {
|
|
1088
|
+
// Cursor is within this text node
|
|
1089
|
+
textPosition_1 += cursorPos - pos;
|
|
1090
|
+
found_1 = true;
|
|
1091
|
+
return false;
|
|
1092
|
+
}
|
|
1093
|
+
else if (pos + node.nodeSize < cursorPos) {
|
|
1094
|
+
// This text node is before cursor position
|
|
1095
|
+
textPosition_1 += ((_a = node.text) === null || _a === void 0 ? void 0 : _a.length) || 0;
|
|
1096
|
+
}
|
|
1097
|
+
}
|
|
1098
|
+
return !found_1;
|
|
1099
|
+
});
|
|
1100
|
+
return {
|
|
1101
|
+
line: fullContent,
|
|
1102
|
+
offsetInLine: Math.max(0, textPosition_1),
|
|
1103
|
+
};
|
|
1104
|
+
}
|
|
1105
|
+
// Strategy 2: For non-formula content, use current line approach
|
|
1106
|
+
// This works better for multi-line text that isn't a single formula
|
|
1107
|
+
var parent_1 = $pos.parent;
|
|
1108
|
+
if (parent_1 && parent_1.isTextblock) {
|
|
1109
|
+
var lineStart = $pos.start($pos.depth);
|
|
1110
|
+
var offsetInLine = Math.max(0, cursorPos - lineStart);
|
|
1111
|
+
return {
|
|
1112
|
+
line: parent_1.textContent || "",
|
|
1113
|
+
offsetInLine: offsetInLine,
|
|
1114
|
+
};
|
|
1115
|
+
}
|
|
1116
|
+
// Strategy 3: Fallback to full content with simple position mapping
|
|
1117
|
+
return {
|
|
1118
|
+
line: fullContent,
|
|
1119
|
+
offsetInLine: Math.max(0, Math.min(cursorPos, fullContent.length)),
|
|
1120
|
+
};
|
|
1121
|
+
}
|
|
1122
|
+
catch (error) {
|
|
1123
|
+
console.warn("Error getting tokenization content:", error);
|
|
1124
|
+
// Safe fallback
|
|
1125
|
+
var safeContent = state.doc.textContent || "";
|
|
1126
|
+
return {
|
|
1127
|
+
line: safeContent,
|
|
1128
|
+
offsetInLine: Math.max(0, Math.min(cursorPos, safeContent.length)),
|
|
1129
|
+
};
|
|
1130
|
+
}
|
|
1131
|
+
};
|
|
1132
|
+
/**
|
|
1133
|
+
* Cleanup function token to remove parentheses
|
|
1134
|
+
* @param text
|
|
1135
|
+
*/
|
|
1136
|
+
export var cleanFunctionToken = function (text) {
|
|
1137
|
+
return text.replace(new RegExp(/\(|\)/, "gi"), "");
|
|
1138
|
+
};
|
|
1139
|
+
// Alternative approach using ProseMirror's built-in word detection:
|
|
1140
|
+
function getWordAtPosition(editorState, pos) {
|
|
1141
|
+
var doc = editorState.doc;
|
|
1142
|
+
var $pos = doc.resolve(pos);
|
|
1143
|
+
// Use ProseMirror's word pattern matching
|
|
1144
|
+
var wordRE = /\w+/g;
|
|
1145
|
+
var textNode = $pos.parent;
|
|
1146
|
+
var textContent = textNode.textContent;
|
|
1147
|
+
var localPos = $pos.parentOffset;
|
|
1148
|
+
var match;
|
|
1149
|
+
var wordStart = null;
|
|
1150
|
+
var wordEnd = null;
|
|
1151
|
+
// Find all word matches and determine which one contains our position
|
|
1152
|
+
while ((match = wordRE.exec(textContent)) !== null) {
|
|
1153
|
+
var matchStart = match.index;
|
|
1154
|
+
var matchEnd = match.index + match[0].length;
|
|
1155
|
+
if (localPos >= matchStart && localPos <= matchEnd) {
|
|
1156
|
+
wordStart = $pos.start() + matchStart;
|
|
1157
|
+
wordEnd = $pos.start() + matchEnd;
|
|
1158
|
+
break;
|
|
1159
|
+
}
|
|
1160
|
+
}
|
|
1161
|
+
if (wordStart === null || wordEnd === null) {
|
|
1162
|
+
return undefined;
|
|
1163
|
+
}
|
|
1164
|
+
var wordText = doc.textBetween(wordStart, wordEnd, " ");
|
|
1165
|
+
return {
|
|
1166
|
+
start: wordStart,
|
|
1167
|
+
end: wordEnd,
|
|
1168
|
+
text: wordText,
|
|
1169
|
+
};
|
|
1170
|
+
}
|