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/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/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" } 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/src/api.md b/src/api.md index 9bd909225..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 @@ -5045,6 +5055,22 @@ hide(options?): void +##### VirtualKeyboardInterface.manualClose() + +```ts +manualClose(options?): void +``` + +###### options? + +###### animate + +`boolean` + + + + + ##### VirtualKeyboardInterface.setKeycap() ```ts @@ -5759,6 +5785,7 @@ type VirtualKeyboardMessageAction = | "execute-command" | "show" | "hide" + | "manual-close" | "update-setting" | "update-toolbar" | "synchronize-proxy" @@ -6463,6 +6490,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/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/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) { 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-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 `