From 45a1596bcccc12a18f53dc8c99e7e6fb1db14412 Mon Sep 17 00:00:00 2001 From: Max Anstie Date: Sun, 10 Aug 2025 15:48:59 +0800 Subject: [PATCH 01/11] kedyou: add pipeline --- .github/dependabot.yml | 96 ++++---------------------------- .github/workflows/playwright.yml | 4 +- .github/workflows/publish.yml | 29 ++++++++++ .github/workflows/tests.yml | 4 +- .npmrc | 5 +- README.md | 42 +++++++++++++- package-lock.json | 4 +- package.json | 12 ++-- 8 files changed, 96 insertions(+), 100 deletions(-) create mode 100644 .github/workflows/publish.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 671531914..b8c0f6afa 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,87 +1,15 @@ +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for all configuration options: +# https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file + version: 2 updates: - - package-ecosystem: npm - directory: '/' + - package-ecosystem: "github-actions" + directory: "/" schedule: - interval: weekly - day: saturday - time: '07:07' - timezone: America/Los_Angeles - open-pull-requests-limit: 10 - versioning-strategy: increase - ignore: - - dependency-name: husky - versions: - - '>= 6.a, < 7' - - dependency-name: postcss - versions: - - 8.2.10 - - 8.2.12 - - 8.2.6 - - 8.2.7 - - 8.2.8 - - 8.2.9 - - dependency-name: '@types/jest' - versions: - - 26.0.21 - - 26.0.22 - - dependency-name: eslint - versions: - - 7.22.0 - - 7.23.0 - - 7.24.0 - - dependency-name: '@typescript-eslint/eslint-plugin' - versions: - - 4.14.1 - - 4.15.0 - - 4.15.1 - - 4.15.2 - - 4.16.1 - - 4.17.0 - - 4.18.0 - - 4.19.0 - - 4.20.0 - - 4.21.0 - - 4.22.0 - - dependency-name: husky - versions: - - 5.0.9 - - 5.1.1 - - 5.1.3 - - 5.2.0 - - dependency-name: typescript - versions: - - 4.1.5 - - 4.2.2 - - 4.2.3 - - dependency-name: ts-jest - versions: - - 26.5.0 - - 26.5.1 - - 26.5.2 - - 26.5.3 - - dependency-name: check-node-version - versions: - - 4.1.0 - - dependency-name: lint-staged - versions: - - 10.5.4 - - dependency-name: '@types/node' - versions: - - 14.14.22 - - 14.14.27 - - dependency-name: autoprefixer - versions: - - 10.2.3 - - 10.2.4 - - dependency-name: '@typescript-eslint/parser' - versions: - - 4.14.1 - - 4.18.0 - - 4.19.0 - - 4.20.0 - - 4.21.0 - - 4.22.0 - - dependency-name: '@typescript-eslint/typescript-estree' - versions: - - 4.14.1 + interval: "daily" + - package-ecosystem: "npm" + directory: "/" + schedule: + interval: "daily" diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index b5ea07427..c8eea8846 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -9,8 +9,8 @@ jobs: timeout-minutes: 60 runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 with: node-version: 22 - name: Install dependencies diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 000000000..61609e250 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,29 @@ +name: Publish package to GitHub Packages +on: + release: + types: [created] + workflow_dispatch: + +permissions: + contents: read + packages: write + +jobs: + build: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - uses: actions/checkout@v4 + # Setup .npmrc file to publish to GitHub Packages + - uses: actions/setup-node@v4 + with: + node-version: '22.x' + registry-url: 'https://npm.pkg.github.com' + # Defaults to the user or organization that owns the workflow file + scope: '@kedyou' + - run: npm ci + - run: npm publish + env: + NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 5c38e5747..222a22e92 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -9,8 +9,8 @@ jobs: timeout-minutes: 20 runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 with: node-version: 22 - name: Install dependencies diff --git a/.npmrc b/.npmrc index 7394de28d..fbe344986 100644 --- a/.npmrc +++ b/.npmrc @@ -1 +1,4 @@ -loglevel="warn" \ No newline at end of file +//npm.pkg.github.com/:_authToken=${NODE_AUTH_TOKEN} +@kedyou:registry=https://npm.pkg.github.com +always-auth=true +loglevel="warn" diff --git a/README.md b/README.md index 3d3abbef3..5672b0c22 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ math live -

The MathLive mathfield

+

Kedyou's fork of MathLive

A Web Component for Math Input

[![Maintenance](https://img.shields.io/maintenance/yes/2025.svg)]() @@ -124,3 +124,43 @@ contribution. ## 📃 License This project is licensed under the [MIT License](LICENSE.txt). + +## Kedyou + +The Kedyou modification of MathLive allows users to type multi-lined math +quickly and easily, simplifying the inputs to create and modify aligned +environments. + +Update with the latest changes from arnog: + +```sh +# Add the remote, call it "upstream": +git remote add upstream https://github.com/arnog/mathlive/ +# Fetch all the branches of that remote into remote-tracking branches +git fetch upstream +# Make sure that you're on your master branch: +git checkout master +# Rewrite your master branch so that any commits of yours that +# aren't already in upstream/master are replayed on top of that +# other branch: +git rebase upstream/master +# After finishing rebase/merging changes, force push +git push --force +``` + +### Local testing + +To test the MathLive in Kedyou before publishing, use `pnpm link --global`: + +```sh +# In mathlive repo +pnpm link --global +# In the kedyou-frontend repo +pnpm link --global @kedyou/mathlive +``` + +#### **`sites/frontend/package.json`** +```diff +-"@kedyou/mathlive": "^0.98.6" ++"@kedyou/mathlive": "link:^0.98.6" +``` diff --git a/package-lock.json b/package-lock.json index 9de70e8e7..f749fdf12 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,11 +1,11 @@ { - "name": "mathlive", + "name": "@kedyou/mathlive", "version": "0.106.0", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "mathlive", + "name": "@kedyou/mathlive", "version": "0.106.0", "license": "MIT", "dependencies": { diff --git a/package.json b/package.json index 0560e6c76..b6f5c6867 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "mathlive", + "name": "@kedyou/mathlive", "version": "0.106.0", "description": "A web component for math input", "license": "MIT", @@ -31,10 +31,6 @@ "require": "./mathlive.js" } }, - "node": { - "types": "./types/mathlive-ssr.d.ts", - "import": "./mathlive-ssr.min.mjs" - }, "default": { "types": "./types/mathlive.d.ts", "import": "./mathlive.min.mjs", @@ -48,9 +44,8 @@ }, "repository": { "type": "git", - "url": "git+https://github.com/arnog/mathlive.git" + "url": "git+https://github.com/kedyou/mathlive.git" }, - "bugs": "https://github.com/arnog/mathlive/issues/", "scripts": { "doc": "bash ./scripts/update-docs.sh", "build": "bash ./scripts/build.sh", @@ -171,5 +166,6 @@ "mathjax", "katex", "mathquill" - ] + ], + "homepage": "https://github.com/kedyou/mathlive#readme" } From 52452424c28f823d60a5e81e68707e4b419d4803 Mon Sep 17 00:00:00 2001 From: Max Anstie Date: Sun, 10 Aug 2025 15:51:22 +0800 Subject: [PATCH 02/11] kedyou: style changes --- css/mathfield.less | 2 +- css/suggestion-popover.less | 2 +- css/virtual-keyboard.less | 7 ++++--- src/common/stylesheet.ts | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/css/mathfield.less b/css/mathfield.less index ddb724637..15e1484a0 100644 --- a/css/mathfield.less +++ b/css/mathfield.less @@ -47,7 +47,7 @@ /* This attribute is necessary to work around a Firefox issue where where clicking multiple times on the border leads to a focused mathfield that cannot be edited until focus is lost and regained (also fixes the multiple cursor issue on firefox that can occur with the same sequence of events). */ - pointer-events: auto; + pointer-events: var(--pointer-events, auto); /* Prevent the browser from trying to interpret touch gestures in the field */ /* "Disabling double-tap to zoom removes the need for browsers to diff --git a/css/suggestion-popover.less b/css/suggestion-popover.less index 96435c8e3..a041628f3 100644 --- a/css/suggestion-popover.less +++ b/css/suggestion-popover.less @@ -13,7 +13,7 @@ text-align: center; border-radius: 8px; position: fixed; - z-index: var(--_suggestion-zindex); + z-index: var(--_suggestion-zindex, 99); display: none; flex-direction: column; diff --git a/css/virtual-keyboard.less b/css/virtual-keyboard.less index 747b0db39..722f79ad5 100644 --- a/css/virtual-keyboard.less +++ b/css/virtual-keyboard.less @@ -122,7 +122,6 @@ --_keycap-max-width: var(--keycap-max-width, 100px); --_keycap-gap: var(--keycap-gap, 8px); - --_keycap-font-size: var(--keycap-font-size, ~'clamp(16px, 4cqw, 24px)'); --_keycap-small-font-size: var( --keycap-small-font-size, calc(var(--keycap-font-size) * 0.8) @@ -426,7 +425,8 @@ body > .ML__keyboard.is-visible.animate > .MLK__backdrop { } .big-op { - font-size: calc(1.25 * var(--_keycap-font-size)); + font-size: calc(1.25 * var(--keycap-font-size, ~"clamp(16px, 4vw, 24px)")); + font-size: calc(1.25 * var(--keycap-font-size, ~"clamp(16px, 4cqw, 24px)")); } .small { @@ -563,7 +563,8 @@ body > .ML__keyboard.is-visible.animate > .MLK__backdrop { color: var(--_keycap-text); fill: currentColor; - font-size: var(--_keycap-font-size); + font-size: var(--keycap-font-size, ~"clamp(16px, 4vw, 24px)"); + font-size: var(--keycap-font-size, ~"clamp(16px, 4cqw, 24px)"); background: var(--_keycap-background); border: 1px solid var(--_keycap-border); border-bottom-color: var(--_keycap-border-bottom); diff --git a/src/common/stylesheet.ts b/src/common/stylesheet.ts index f95d5de9d..dba53d6d8 100644 --- a/src/common/stylesheet.ts +++ b/src/common/stylesheet.ts @@ -36,7 +36,7 @@ export function getStylesheetContent(id: StylesheetId): string { // case 'mathfield-element': content = ` - :host { display: inline-block; background-color: field; color: fieldtext; border-width: 1px; border-style: solid; border-color: #acacac; border-radius: 2px;} + :host { display: inline-block; color: fieldtext; padding:4px; } :host([hidden]) { display: none; } :host([disabled]), :host([disabled]:focus), :host([disabled]:focus-within) { outline: none; opacity: .5; } :host(:focus), :host(:focus-within) { From f80cd97e0c0a1bb13cb3c90d9edbb52045797208 Mon Sep 17 00:00:00 2001 From: Max Anstie Date: Sun, 10 Aug 2025 15:52:13 +0800 Subject: [PATCH 03/11] kedyou: add test print page --- scripts/start.js | 1 + test/mathfield-states/index.html | 1 + test/printing/index.html | 87 ++++++++++++++++++++++++++++++++ test/prompts/index.html | 1 + test/smoke/index.html | 1 + test/virtual-keyboard/index.html | 1 + 6 files changed, 92 insertions(+) create mode 100644 test/printing/index.html diff --git a/scripts/start.js b/scripts/start.js index e5b603b9e..fc6c7ff61 100644 --- a/scripts/start.js +++ b/scripts/start.js @@ -9,6 +9,7 @@ context({ entryPoints: [ './test/style.css', './test/smoke/index.html', + './test/printing/index.html', './test/virtual-keyboard/index.html', './test/mathfield-states/index.html', './test/prompts/index.html', diff --git a/test/mathfield-states/index.html b/test/mathfield-states/index.html index 0c028d880..75a62b44e 100644 --- a/test/mathfield-states/index.html +++ b/test/mathfield-states/index.html @@ -209,6 +209,7 @@

Mathfield States

  • Smoke
  • +
  • Printing
  • Virtual Keyboard
  • diff --git a/test/printing/index.html b/test/printing/index.html new file mode 100644 index 000000000..4abb2c6ef --- /dev/null +++ b/test/printing/index.html @@ -0,0 +1,87 @@ + + + + + Print Test + + + + + + +
    +

    Print Test

    + +
    +
    + x^2+1 + + +
    + + + + diff --git a/test/prompts/index.html b/test/prompts/index.html index beb08cd45..8cdb81610 100644 --- a/test/prompts/index.html +++ b/test/prompts/index.html @@ -28,6 +28,7 @@

    Prompts Test

    • Smoke
    • +
    • Printing
    • Virtual Keyboard
    • diff --git a/test/smoke/index.html b/test/smoke/index.html index 6f675606a..64f06dc47 100644 --- a/test/smoke/index.html +++ b/test/smoke/index.html @@ -30,6 +30,7 @@

      Smoke Test

      • Smoke
      • +
      • Printing
      • Virtual Keyboard
      • diff --git a/test/virtual-keyboard/index.html b/test/virtual-keyboard/index.html index 477f0699f..838e47025 100644 --- a/test/virtual-keyboard/index.html +++ b/test/virtual-keyboard/index.html @@ -45,6 +45,7 @@

        Virtual Keyboard Test

        • Smoke
        • +
        • Printing
        • Virtual Keyboard
        • From 6dd81fd7c6ee8e0b3c8d9dc9b8686d88e452349f Mon Sep 17 00:00:00 2001 From: Max Anstie Date: Sun, 10 Aug 2025 16:09:06 +0800 Subject: [PATCH 04/11] kedyou: export DEFAULT_KEYBOARD_TOGGLE_GLYPH --- src/api.md | 20 ++++++++++++++++++++ src/editor-mathfield/mathfield-private.ts | 4 ++-- src/mathlive.ts | 4 ++++ src/public/mathlive.ts | 3 +++ 4 files changed, 29 insertions(+), 2 deletions(-) diff --git a/src/api.md b/src/api.md index 9bd909225..91ac670c0 100644 --- a/src/api.md +++ b/src/api.md @@ -6463,6 +6463,26 @@ LaTeX global registers override. +### DEFAULT\_KEYBOARD\_TOGGLE\_GLYPH + +```ts +const DEFAULT_KEYBOARD_TOGGLE_GLYPH: string; +``` + + + + + +### MENU\_GLYPH + +```ts +const MENU_GLYPH: string; +``` + + + + + ### version ```ts diff --git a/src/editor-mathfield/mathfield-private.ts b/src/editor-mathfield/mathfield-private.ts index e3db3dcc2..2b1544b1a 100644 --- a/src/editor-mathfield/mathfield-private.ts +++ b/src/editor-mathfield/mathfield-private.ts @@ -137,11 +137,11 @@ import { TextAtom } from 'atoms/text'; import { getLatexGroup } from './mode-editor-latex'; import { MenuItem } from 'public/ui-menu-types'; -const DEFAULT_KEYBOARD_TOGGLE_GLYPH = ``; -const MENU_GLYPH = ``; diff --git a/src/mathlive.ts b/src/mathlive.ts index 0f0801c9e..d1852f4fc 100644 --- a/src/mathlive.ts +++ b/src/mathlive.ts @@ -16,6 +16,10 @@ import { convertLatexToSpeakableText, convertMathJsonToLatex, } from './public/mathlive-ssr'; +export { + DEFAULT_KEYBOARD_TOGGLE_GLYPH, + MENU_GLYPH, +} from 'editor-mathfield/mathfield-private'; export { MenuItemType, diff --git a/src/public/mathlive.ts b/src/public/mathlive.ts index cf6dd3c57..03e60e61c 100644 --- a/src/public/mathlive.ts +++ b/src/public/mathlive.ts @@ -55,6 +55,9 @@ export declare const version: { mathlive: string; }; +export declare const DEFAULT_KEYBOARD_TOGGLE_GLYPH: string; +export declare const MENU_GLYPH: string; + declare global { interface Window { mathVirtualKeyboard: VirtualKeyboardInterface & EventTarget; From 8a6d31a23c9be0273dccf31b63b9f876f917b4cf Mon Sep 17 00:00:00 2001 From: Max Anstie Date: Sun, 10 Aug 2025 16:18:37 +0800 Subject: [PATCH 05/11] kedyou: add manual close button to virtual keyboard --- src/api.md | 17 +++++++++++++++++ src/editor/l10n-strings.ts | 1 + src/public/virtual-keyboard.ts | 2 ++ src/virtual-keyboard/commands.ts | 4 ++++ src/virtual-keyboard/proxy.ts | 4 ++++ src/virtual-keyboard/utils.ts | 20 +++++++++++--------- src/virtual-keyboard/virtual-keyboard.ts | 14 ++++++++++++++ 7 files changed, 53 insertions(+), 9 deletions(-) diff --git a/src/api.md b/src/api.md index 91ac670c0..2bb6b786a 100644 --- a/src/api.md +++ b/src/api.md @@ -5045,6 +5045,22 @@ hide(options?): void +##### VirtualKeyboardInterface.manualClose() + +```ts +manualClose(options?): void +``` + +###### options? + +###### animate + +`boolean` + + + + + ##### VirtualKeyboardInterface.setKeycap() ```ts @@ -5759,6 +5775,7 @@ type VirtualKeyboardMessageAction = | "execute-command" | "show" | "hide" + | "manual-close" | "update-setting" | "update-toolbar" | "synchronize-proxy" diff --git a/src/editor/l10n-strings.ts b/src/editor/l10n-strings.ts index e853313f3..b1047d748 100644 --- a/src/editor/l10n-strings.ts +++ b/src/editor/l10n-strings.ts @@ -28,6 +28,7 @@ export const STRINGS = { 'tooltip.cut to clipboard': 'Cut to Clipboard', 'tooltip.paste from clipboard': 'Paste from Clipboard', 'tooltip.redo': 'Redo', + 'tooltip.close': 'Close', 'tooltip.toggle virtual keyboard': 'Toggle Virtual Keyboard', 'tooltip.menu': 'Menu', 'tooltip.undo': 'Undo', diff --git a/src/public/virtual-keyboard.ts b/src/public/virtual-keyboard.ts index 826d849cb..f1029f7fa 100644 --- a/src/public/virtual-keyboard.ts +++ b/src/public/virtual-keyboard.ts @@ -297,6 +297,7 @@ export interface MathfieldProxy { export interface VirtualKeyboardInterface extends VirtualKeyboardOptions { show(options?: { animate: boolean }): void; hide(options?: { animate: boolean }): void; + manualClose(options?: { animate: boolean }): void; visible: boolean; readonly isShifted: boolean; readonly boundingRect: DOMRect; @@ -335,6 +336,7 @@ export type VirtualKeyboardMessageAction = | 'execute-command' // From proxy to VK | 'show' // From proxy to VK | 'hide' // From proxy to VK + | 'manual-close' // From proxy to VK | 'update-setting' // From proxy to VK | 'update-toolbar' // From proxy to VK | 'synchronize-proxy' // From VK to proxy diff --git a/src/virtual-keyboard/commands.ts b/src/virtual-keyboard/commands.ts index a4f5d490e..e3b326894 100644 --- a/src/virtual-keyboard/commands.ts +++ b/src/virtual-keyboard/commands.ts @@ -42,6 +42,10 @@ register( window.mathVirtualKeyboard.show({ animate: true }); return false; }, + closeVirtualKeyboard: () => { + window.mathVirtualKeyboard.manualClose(); + return false; + }, }, { target: 'virtual-keyboard' } ); diff --git a/src/virtual-keyboard/proxy.ts b/src/virtual-keyboard/proxy.ts index 3ce4310ce..92d253fd2 100644 --- a/src/virtual-keyboard/proxy.ts +++ b/src/virtual-keyboard/proxy.ts @@ -118,6 +118,10 @@ export class VirtualKeyboardProxy } } + manualClose(options?: { animate: boolean } | undefined): void { + this.sendMessage('manual-close', options); + } + get isShifted(): boolean { return this._isShifted; } diff --git a/src/virtual-keyboard/utils.ts b/src/virtual-keyboard/utils.ts index ab63870ae..8f1910b41 100644 --- a/src/virtual-keyboard/utils.ts +++ b/src/virtual-keyboard/utils.ts @@ -323,15 +323,10 @@ export function makeEditToolbar( const availableActions: string[] = []; - if (mathfield.selectionIsCollapsed) - availableActions.push('undo', 'redo', 'pasteFromClipboard'); - else { - availableActions.push( - 'cutToClipboard', - 'copyToClipboard', - 'pasteFromClipboard' - ); - } + if (mathfield.selectionIsCollapsed) availableActions.push('undo', 'redo'); + else availableActions.push('cutToClipboard', 'copyToClipboard'); + + availableActions.push('pasteFromClipboard', 'closeVirtualKeyboard'); const actionsMarkup = { undo: `
          `, + closeVirtualKeyboard: ` +
          ×
          + `, }; // The right hand side of the toolbar, with the copy/undo/redo commands diff --git a/src/virtual-keyboard/virtual-keyboard.ts b/src/virtual-keyboard/virtual-keyboard.ts index d004639b0..9bd9e6182 100644 --- a/src/virtual-keyboard/virtual-keyboard.ts +++ b/src/virtual-keyboard/virtual-keyboard.ts @@ -315,6 +315,20 @@ export class VirtualKeyboard implements VirtualKeyboardInterface, EventTarget { return !event.defaultPrevented; } + /** + * Fire a specific event for when the close button is clicked on the virtual keyboard + */ + manualClose({ animate = false } = {}): void { + this.hide({ animate }); + this.dispatchEvent( + new Event('manual-close', { + bubbles: true, + cancelable: false, + composed: true, + }) + ); + } + removeEventListener( type: string, callback: EventListenerOrEventListenerObject | null, From 2d312376a2664f2fdcc460d32d53a7090d018ca6 Mon Sep 17 00:00:00 2001 From: Max Anstie Date: Sun, 10 Aug 2025 16:21:14 +0800 Subject: [PATCH 06/11] kedyou: remove focus event listeners --- src/virtual-keyboard/virtual-keyboard.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/virtual-keyboard/virtual-keyboard.ts b/src/virtual-keyboard/virtual-keyboard.ts index 9bd9e6182..09d9a4675 100644 --- a/src/virtual-keyboard/virtual-keyboard.ts +++ b/src/virtual-keyboard/virtual-keyboard.ts @@ -266,6 +266,8 @@ export class VirtualKeyboard implements VirtualKeyboardInterface, EventTarget { window.addEventListener('message', this); } + /* Kedyou: remove focus event listeners to allow our client to choose + /* whether the virtual keyboard is shown when focused // Listen for when a mathfield gets focused, and show // the virtual keyboard if needed document.addEventListener('focusin', (event: FocusEvent) => { @@ -294,6 +296,7 @@ export class VirtualKeyboard implements VirtualKeyboardInterface, EventTarget { }, 300); } }); + */ } addEventListener( From 590fae1cb1a66c223ab5fcd1b3d8e51f4bd574bd Mon Sep 17 00:00:00 2001 From: Max Anstie Date: Sun, 10 Aug 2025 16:35:33 +0800 Subject: [PATCH 07/11] kedyou: stub scrollIntoView --- src/editor-mathfield/mathfield-private.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/editor-mathfield/mathfield-private.ts b/src/editor-mathfield/mathfield-private.ts index 2b1544b1a..574667d52 100644 --- a/src/editor-mathfield/mathfield-private.ts +++ b/src/editor-mathfield/mathfield-private.ts @@ -1004,6 +1004,8 @@ If you are using Vue, this may be because you are using the runtime-only build o */ scrollIntoView(): void { if (!this.element) return; + + /* Kedyou: stub scrollIntoView // // 1/ If using a mathfield element, make sure that the element is visible. // @@ -1030,6 +1032,7 @@ If you are using Vue, this may be because you are using the runtime-only build o } } } + */ // // 2/ If a render is pending, do it now to make sure we have correct layout @@ -1037,6 +1040,7 @@ If you are using Vue, this may be because you are using the runtime-only build o // if (this.dirty) render(this, { interactive: true }); + /* Kedyou: we need the mathfield to render, but not the rest // // 3/ Get the position of the caret // @@ -1096,6 +1100,7 @@ If you are using Vue, this may be because you are using the runtime-only build o left, }); } + */ } insert(s: string, options?: InsertOptions): boolean { From 402037d49204b2477c45d2ba6835b0edf645f9e2 Mon Sep 17 00:00:00 2001 From: Max Anstie Date: Sun, 10 Aug 2025 16:40:05 +0800 Subject: [PATCH 08/11] kedyou: make latex commands faster to enter --- src/editor-mathfield/autocomplete.ts | 8 +++----- src/editor/keybindings-definitions.ts | 4 ++-- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/editor-mathfield/autocomplete.ts b/src/editor-mathfield/autocomplete.ts index 449eafcd9..e3b5c6509 100644 --- a/src/editor-mathfield/autocomplete.ts +++ b/src/editor-mathfield/autocomplete.ts @@ -127,7 +127,7 @@ export function complete( | 'accept' | 'accept-suggestion' | 'accept-all' = 'accept', - options?: { mode?: ParseMode; selectItem?: boolean } + options?: { mode?: ParseMode } ): boolean { hideSuggestionPopover(mathfield); const latexGroup = getLatexGroup(mathfield.model); @@ -147,9 +147,7 @@ export function complete( if (completion === 'accept-suggestion') return suggestions.length !== 0; } - const body = getLatexGroupBody(mathfield.model).filter( - (x) => !x.isSuggestion - ); + const body = getLatexGroupBody(mathfield.model); const latex = body.map((x) => x.value).join(''); @@ -168,7 +166,7 @@ export function complete( } ModeEditor.insert(mathfield.model, latex, { - selectionMode: options?.selectItem ?? false ? 'item' : 'placeholder', + selectionMode: 'placeholder', format: 'latex', mode: 'math', style, diff --git a/src/editor/keybindings-definitions.ts b/src/editor/keybindings-definitions.ts index a4b2947fc..01c8a918c 100644 --- a/src/editor/keybindings-definitions.ts +++ b/src/editor/keybindings-definitions.ts @@ -60,8 +60,8 @@ export const DEFAULT_KEYBINDINGS: Keybinding[] = [ { key: '[Escape]', ifMode: 'latex', - command: ['complete', 'complete', { selectItem: 'true' }], - }, // Accept the entry (without the suggestion) and select + command: ['complete', 'reject'], + }, // Cancel LaTeX mode { key: '\\', From b1a73fe7e7baafbdc0498add2cb7961e5986aa61 Mon Sep 17 00:00:00 2001 From: Max Anstie Date: Sun, 10 Aug 2025 16:48:18 +0800 Subject: [PATCH 09/11] kedyou: skip userSelect check on pointerdown events --- src/editor-mathfield/mathfield-private.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/editor-mathfield/mathfield-private.ts b/src/editor-mathfield/mathfield-private.ts index 574667d52..64a933bb2 100644 --- a/src/editor-mathfield/mathfield-private.ts +++ b/src/editor-mathfield/mathfield-private.ts @@ -807,7 +807,9 @@ If you are using Vue, this may be because you are using the runtime-only build o break; case 'pointerdown': - if (!evt.defaultPrevented && this.userSelect !== 'none') { + // Kedyou: comment out this.userSelect !== none because it breaks on Chrome + // https://github.com/kedyou/kedyou-frontend/issues/1150 + if (!evt.defaultPrevented /** && this.userSelect !== 'none' */) { onPointerDown(this, evt as PointerEvent); // Firefox convention: holding the shift key disables custom context menu if ((evt as PointerEvent).shiftKey === false) { From 9fb03181c8788041f59255772a9bb6287ac3edac Mon Sep 17 00:00:00 2001 From: Max Anstie Date: Sun, 10 Aug 2025 17:04:05 +0800 Subject: [PATCH 10/11] kedyou: create aligned environment --- src/api.md | 10 +++ src/atoms/array.ts | 12 ++-- src/editor-mathfield/commands.ts | 5 +- src/editor-mathfield/keyboard-input.ts | 5 +- src/editor-mathfield/mode-editor-math.ts | 51 +++++++++++++- src/editor-mathfield/pointer-input.ts | 26 +++++-- src/editor-model/array.ts | 89 +++++++++++++++++------- src/editor-model/commands-move.ts | 28 ++++++-- src/editor-model/commands.ts | 52 +++++++++++++- src/editor-model/delete.ts | 51 ++++++++++++++ src/editor-model/model-private.ts | 26 ++++++- src/editor/a11y.ts | 2 - src/editor/keybindings-definitions.ts | 1 + src/public/commands.ts | 4 ++ src/virtual-keyboard/utils.ts | 2 +- 15 files changed, 311 insertions(+), 53 deletions(-) diff --git a/src/api.md b/src/api.md index 2bb6b786a..49a011891 100644 --- a/src/api.md +++ b/src/api.md @@ -3756,6 +3756,16 @@ addRowBefore: (model) => boolean; +##### Commands.createAlignedEnvironment() + +```ts +createAlignedEnvironment: (model) => boolean; +``` + + + + + ##### Commands.removeColumn() ```ts diff --git a/src/atoms/array.ts b/src/atoms/array.ts index e2d1a8e66..e382099b9 100644 --- a/src/atoms/array.ts +++ b/src/atoms/array.ts @@ -737,25 +737,29 @@ export class ArrayAtom extends Atom { this.isDirty = true; } - addRowBefore(row: number): void { + addRowBefore(row: number, placeholders = !this.isMultiline): void { console.assert(this.type === 'array' && Array.isArray(this._rows)); this._rows.splice( row, 0, - new Array(this.colCount).fill(makeEmptyCell(this, !this.isMultiline)) + Array.from({ length: this.colCount }, () => + makeEmptyCell(this, placeholders) + ) ); adjustBranches(this); this.isDirty = true; } - addRowAfter(row: number): void { + addRowAfter(row: number, placeholders = !this.isMultiline): void { console.assert(this.type === 'array' && Array.isArray(this._rows)); this._rows.splice( row + 1, 0, - new Array(this.colCount).fill(makeEmptyCell(this, !this.isMultiline)) + Array.from({ length: this.colCount }, () => + makeEmptyCell(this, placeholders) + ) ); adjustBranches(this); diff --git a/src/editor-mathfield/commands.ts b/src/editor-mathfield/commands.ts index 8dc5a9dbc..072f04270 100644 --- a/src/editor-mathfield/commands.ts +++ b/src/editor-mathfield/commands.ts @@ -77,9 +77,10 @@ registerCommand({ mathfield.host?.dispatchEvent( new Event('change', { bubbles: true, composed: true }) ); + // Kedyou: prefer our alined environment code // If we're in a multiline environment, insert a newline - if (model.parentEnvironment?.isMultiline) - mathfield.executeCommand('addRowAfter'); + // if (model.parentEnvironment?.isMultiline) + // mathfield.executeCommand('addRowAfter'); model.contentDidChange({ inputType: 'insertLineBreak' }); } diff --git a/src/editor-mathfield/keyboard-input.ts b/src/editor-mathfield/keyboard-input.ts index 87fda16f6..922387df0 100644 --- a/src/editor-mathfield/keyboard-input.ts +++ b/src/editor-mathfield/keyboard-input.ts @@ -213,9 +213,10 @@ export function onKeystroke( evt.preventDefault(); evt.stopPropagation(); } else { + // Kedyou: prefer our alined environment code // If we're in a multiline environment, insert a newline - if (model.parentEnvironment?.isMultiline) - mathfield.executeCommand('addRowAfter'); + // if (model.parentEnvironment?.isMultiline) + // mathfield.executeCommand('addRowAfter'); // Dispatch an 'input' event matching the behavior of `