Repository navigation
Conversation
🦋 Changeset detectedLatest commit: 08d5d64 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
✅ Deploy Preview for stacks-editor ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
dancormier
left a comment
There was a problem hiding this comment.
Hey @ocorona92, thanks for the PR. I hit a few data-loss and editing issues while testing locally that need fixing before this merges. Details and GIFs are inline.
| const blockStart = paragraph.before(); | ||
| const blockEnd = paragraph.after(); | ||
| const mathNode = nodeType.create({ | ||
| source, | ||
| openDelimiter: open, | ||
| closeDelimiter: close, | ||
| }); | ||
| const tr = state.tr.replaceWith(blockStart, blockEnd, mathNode); |
There was a problem hiding this comment.
Completing display math in the middle of a paragraph deletes everything after the cursor. Can we preserve that text, or only convert when the formula fills the whole paragraph?
To reproduce
- In an empty Rich Text editor, type
$$x$ KEEP THIScharacter by character - Place the cursor immediately before the space preceding
KEEP THIS - Type one more
$to complete$$x$$ - Note that the formula renders, but
KEEP THISis deleted
There was a problem hiding this comment.
Copying a paragraph with math into a plain-text editor drops the formula entirely. These nodes need clipboard text, such as leafText, so copying preserves the delimited source. Escaped-dollar nodes need this too.
To reproduce
- In an empty Rich Text editor, type
Before $x^2$ after - Confirm that the formula renders
- Select and copy the entire paragraph
- Paste it into a plain-text editor
- Note that the pasted text is
Before after, with the formula missing
| ...mathJaxMarkdownParser, | ||
| } | ||
| ); | ||
| const parsed = parser.parse(text); |
There was a problem hiding this comment.
Pasting ~~text~~ or a Markdown table throws an unsupported-token error, even without any math. Can we use the editor’s configured parser and let unsupported content fall through to normal paste handling?
To reproduce
- Open the browser console on the editor demo page
- Run this:
document.body.insertAdjacentHTML(
"afterbegin",
'<p id="paste-fixture"><strong>Bold phrase</strong> and <a href="https://example.com/">linked phrase</a> with $x$.</p>'
);- Select and copy the entire line added above the editor, including
$x$ - Paste it into an empty Rich Text editor using normal paste, not “paste as plain text”
- Note that the formula renders, but the bold formatting and hyperlink are lost
| appendTransaction: (transactions, _, state) => { | ||
| if ( | ||
| !transactions.some((transaction) => transaction.docChanged) || | ||
| transactions.some((transaction) => | ||
| state.plugins.some( | ||
| (plugin) => | ||
| ( | ||
| plugin.spec as { | ||
| isInputRules?: boolean; | ||
| } | ||
| ).isInputRules && transaction.getMeta(plugin) | ||
| ) | ||
| ) | ||
| ) { | ||
| return null; | ||
| } |
There was a problem hiding this comment.
Backspace immediately after typing $x$ doesn’t undo the conversion. This hook turns the restored text straight back into math. Can we exclude input-rule undo transactions here?
To reproduce
- In an empty Rich Text editor, type
$x$character by character - Once the formula renders, immediately press Backspace without moving the cursor
- Note that the formula remains rendered instead of reverting to literal
$x$
| view.dispatch( | ||
| view.state.tr.replaceSelection( | ||
| Slice.maxOpen(parsed.content) | ||
| ) | ||
| ); | ||
| return true; |
There was a problem hiding this comment.
Pasting rich text containing $x$ strips bold formatting and links; images are lost too. Can we preserve the supplied rich-text slice instead of rebuilding the entire paste from plain text?
To reproduce
- Open the console
- Paste this:
document.body.insertAdjacentHTML(
"afterbegin",
'<p id="paste-fixture"><strong>Bold phrase</strong> and <a href="https://example.com/">linked phrase</a> with $x$.</p>'
);- Copy the entire line added above the editor
- Paste it into the editor
- Note that bolding and link are missing
|
|
||
| /** Build a non-empty, single-line capture that stops at the closing delimiter. */ | ||
| function sourceCapture(close: string): string { | ||
| return `((?:(?!${escapeRegExp(close)})[^\\n])+?)`; |
There was a problem hiding this comment.
Typing $x+\$y$ never converts, but entering the same source in Markdown mode renders correctly. This regex stops at escaped dollars too—can we use escape-aware delimiter matching here?
To reproduce
- In an empty Rich Text editor, type
$x+\$y$character by character - Note that it stays as literal text instead of rendering
- Switch to Markdown mode
- Replace the contents with the exact same source:
$x+\$y$ - Switch back to Rich Text mode
- Note that the formula now renders—the typing and Markdown parsing paths handle the same source differently
Summary
Context
Enterprise editors do not have access to the optional Markdown preview mode, so MathJax needs to render directly in Rich Text. The StackOverflow integration will be submitted separately after this editor API is reviewed.
Validation
npm run test:unit -- --runInBand --testPathIgnorePatterns=/node_modules/ \\.e2e\\.test /dist/— 51 suites passed, 1,130 tests passednpm run lint— passed with two unrelated existing test warningsnpm run prepublishOnly— Webpack and TypeScript passedstackenterprise.localwith MathJax 3.2.2