Skip to content

#225 Edytor Markdown'a - #278

Open
Qufel wants to merge 35 commits into
devfrom
feat/225-markdown-latex
Open

Qufel wants to merge 35 commits into
devfrom
feat/225-markdown-latex

Conversation

@Qufel

@Qufel Qufel commented Jun 11, 2026 •

Copy link
Copy Markdown
Contributor

Podsumowanie

Dodano edytor markdown wykorzystujący logikę istniejącego już edytora Overtype. Edytor jest dostosowany zarówno do PC jak i urządzeń mobilnych.
Poprawiono renderowanie pytań w quizie, ze względu na złe wyświetlanie markdownu w starej wersji.

Dodano

  • Edytor Markdown OverTypeEditor z menu formatowania i podglądem
  • Customowego hooka useOverType inicjalizujący referencję do edytora
  • Poprawiono wyświetlanie nr pytania w question-card.tsx

Zmiana w wyświetlaniu pytania

Wyświetlanie pytań obecnie usuwało formatowanie z pierwszej linii tekstu, przez co tekst nie wyświetlał się poprawnie
image

Po wprowadzeniu zmian przeniosłem tekst "Pytanie" wraz z numerem pytania w celu poprawnego formatowania do osobnego elemntu, rozdzielając treść od numeracji.
image

Edytor

Pytania i odpowiedzi domyślnie pokazują wyrenderowaną treść Markdown/LaTeX, tak jak wcześniej. Kliknięcie treści od razu otwiera edycję i pokazuje jej narzędzia, bez osobnego przycisku „Edytuj”.

  • Pasek formatowania pojawia się nad aktywnym polem; na telefonie dostępne jest kompaktowe menu.
  • Kliknięcie poza edytorem lub przycisku „Podgląd” przywraca wyrenderowaną treść i chowa narzędzia.
  • Puste pola są od razu gotowe do pisania; narzędzia pojawiają się po wejściu do pola.
  • Klawiatura umożliwia wejście do edycji, formatowanie zaznaczenia i powrót do podglądu.
  • Zachowano poprawki synchronizacji wartości, cyklu życia wielu edytorów, podświetlania wzorów i unikalności identyfikatorów.
  • Jedyną nową zależnością jest OverType 2.4.0.

Weryfikacja

  • 136 testów przechodzi, w tym testy prawdziwego edytora, przejść między podglądem i edycją, formularza linku oraz tworzenia quizu.
  • Lint, formatowanie, TypeScript i produkcyjny build przechodzą.
  • Sprawdzono podgląd oraz ujawnianie narzędzi na komputerze i telefonie.

CLOSES #225

@Qufel Qufel self-assigned this Jun 11, 2026
@Qufel
Qufel requested a review from olios123 as a code owner June 11, 2026 14:23
@Qufel Qufel linked an issue Jun 11, 2026 that may be closed by this pull request
@solvro-ci

solvro-ci Bot commented Jun 11, 2026 •

Copy link
Copy Markdown

The preview deployment for frontend-testownik-dev is ready. 🟢

Open Preview | Open Build Logs | Open Application Logs

Last updated at: 2026-09-06 15:22:32 CET

Comment thread src/components/overtype-editor.tsx Fixed

@Antoni-Czaplicki Antoni-Czaplicki left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Note

AI-generated review comment.

I reviewed the Markdown/LaTeX editor PR against current dev, including the editor integration, quiz display rendering, tests, build/typecheck/lint behavior, and mergeability.

Main blockers:

  • The PR is currently not mergeable. GitHub reports it as CONFLICTING; the conflict areas include pnpm-lock.yaml and src/components/ai/ai-explain-card.tsx.
  • pnpm lint fails locally with 18 @typescript-eslint/no-unsafe-* route typing errors after this PR's dependency/lockfile refresh. pnpm typecheck passes after pnpm next typegen, and the create-quiz page tests pass with a larger timeout, but lint needs to be clean before merge.
  • The OverType preview/value synchronization issue called out inline can make existing editor content render blank/stale.

Needed to merge: rebase/merge current dev and resolve conflicts, fix the lint regression or narrow the lockfile/tooling bump, fix the OverType controlled-value/initial-preview behavior, and add a targeted regression test for existing quiz text or parent-driven value updates in the editor.

Comment thread src/components/overtype-editor.tsx Outdated
Copilot AI review requested due to automatic review settings July 13, 2026 12:14

@olios123 olios123 left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Dzięki za PR,
przejrzyj sobie jeszcze komentarze od Copilota. Rozwiązałem problemy z lintem i parę drobnych poprawek.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 11 out of 12 changed files in this pull request and generated 15 comments.

Comment thread apps/web/src/hooks/use-overtype.ts
Comment thread apps/web/src/components/overtype-editor.tsx
Comment thread src/components/overtype-editor.tsx Outdated
Comment thread src/components/overtype-editor.tsx Outdated
Comment thread src/components/overtype-editor.tsx Outdated
Comment thread .github/workflows/ci.yml
Comment thread package.json Outdated
Comment thread package.json Outdated
Comment thread package.json Outdated
Comment thread package.json Outdated
Copilot AI review requested due to automatic review settings August 17, 2026 12:21

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 11 out of 12 changed files in this pull request and generated no new comments.

Suppressed comments (3)

src/components/overtype-editor.tsx:230

  • styleId includes a leading # and is then assigned to style.id, producing an invalid HTML id value and breaking the selector logic (querySelector expects #id, but the element id should not include #).
    const styleId = "#ot-math-styles";
    if (document.querySelector(styleId) === null) {
      const style = document.createElement("style");
      style.id = styleId;
      style.textContent = `

src/components/overtype-editor.tsx:292

  • The cleanup removes the shared <style> element from document.head. Since multiple OverTypeEditor instances can be mounted at once (question + multiple answers), unmounting any one instance can remove styles still needed by the others.
    return () => {
      observer.disconnect();
      document.querySelector(styleId)?.remove();
    };

.github/workflows/ci.yml:3

  • The workflow no longer pins minimal token permissions. Without an explicit permissions: block, the default GITHUB_TOKEN permissions depend on repository/org settings and may be broader than necessary.
name: CI

on:

Copilot AI review requested due to automatic review settings August 17, 2026 12:25

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 11 out of 12 changed files in this pull request and generated 1 comment.

Suppressed comments (8)

src/components/overtype-editor.tsx:229

  • styleId includes a leading # and is assigned to style.id, which makes the id invalid and breaks both the existence check and cleanup (querySelector("#...") won’t match an element whose id literally contains #).
    const styleId = "#ot-math-styles";
    if (document.querySelector(styleId) === null) {
      const style = document.createElement("style");
      style.id = styleId;

src/components/overtype-editor.tsx:292

  • This effect injects a global <style> tag. Removing it on unmount can break other OverTypeEditor instances that are still mounted (e.g., question + multiple answers). It’s safer to leave the style in place (or implement ref-counting) rather than always removing it.
    return () => {
      observer.disconnect();
      document.querySelector(styleId)?.remove();
    };

src/components/overtype-editor.tsx:251

  • processMath returns from the whole function when it encounters a non-text child or a text child without $, which prevents processing any later siblings in the same node. This should skip that child and continue.
        if (child.nodeType !== Node.TEXT_NODE) {
          return;
        }
        const text = child.textContent ?? "";
        if (!text.includes("$")) {
          return;
        }

.github/workflows/ci.yml:3

  • The workflow no longer pins permissions, so it will inherit the repository/org default token permissions (which may be broader than needed). Re-adding minimal permissions reduces the blast radius if a workflow is compromised.
name: CI

on:

package.json:60

  • is-url-superb is added as a dependency but is not imported/used anywhere in the repository. Keeping unused deps increases install size and audit surface; consider removing it (and updating the lockfile) unless it’s used in a follow-up commit.
    "input-otp": "^1.4.2",
    "is-url-superb": "^6.1.0",
    "jose": "^6.1.3",

package.json:86

  • remark-stringify is added to dependencies but there are no imports/usages in the repo. If it’s not needed for runtime, consider removing it (and updating the lockfile) to reduce bundle/install surface.
    "remark-gfm": "^4.0.1",
    "remark-math": "^6.0.0",
    "remark-stringify": "^11.0.0",
    "seedrandom": "^3.0.5",

package.json:121

  • remark-parse is added to devDependencies but there are no imports/usages in the repo. If it’s not needed, consider removing it (and updating the lockfile) to keep tooling deps minimal.
    "msw": "^2.12.7",
    "prettier": "^3.7.4",
    "remark-parse": "^11.0.0",
    "server-only": "^0.0.1",

src/hooks/use-overtype.ts:82

  • handleInput creates a plain object and casts it to React.ChangeEvent, so handlers that rely on preventDefault, stopPropagation, nativeEvent, etc. can break at runtime. Since you already have the native Event from addEventListener, pass it through (casted) instead of fabricating a partial object.
      onChangeRef.current?.({
        target,
        currentTarget: target,
      } as React.ChangeEvent<HTMLTextAreaElement>);
    };

Comment thread pnpm-workspace.yaml Outdated
Copilot AI review requested due to automatic review settings September 6, 2026 14:39

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

PR zamyka #225, ale w zmianach nie widać implementacji pickera symboli matematycznych wymaganego w opisie issue.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details

Files not reviewed (1)

  • pnpm-lock.yaml: Generated file
  • Files reviewed: 8/9 changed files
  • Comments generated: 1
  • Review effort level: Lite

Comment on lines +118 to +138
{
label: "Matematyka",
actions: [
{
label: "Wzór w tekście",
icon: SigmaIcon,
apply: (ta) => {
markdownActions.applyCustomFormat(ta, { prefix: "$", suffix: "$" });
},
},
{
label: "Blok wzoru",
icon: PiIcon,
apply: (ta) => {
markdownActions.applyCustomFormat(ta, {
prefix: "\n$$\n",
suffix: "\n$$\n",
});
},
},
],
Copilot AI review requested due to automatic review settings September 6, 2026 14:43

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Wykryte problemy w useOverType (idempotencja highlightowania i niespójna synchronizacja opcji) oraz potencjalna niezgodność z zakresem zamykanego #225 wymagają korekt przed akceptacją.

Review details

Files not reviewed (1)

  • pnpm-lock.yaml: Generated file

Suppressed comments (3)

Previously missed (3) — in code that hasn't changed since the last review.

src/components/overtype-editor.tsx:122

  • The PR description closes #225, but the referenced issue explicitly calls for a math symbol picker and a dedicated raw/source toggle (</>) for switching between live preview and Markdown/LaTeX source. The current toolbar only applies wrappers (e.g. $…$, $$…$$) and the UI provides a preview popover, not a source/preview toggle or symbol picker.
    src/hooks/use-overtype.ts:29
  • highlightMath() can re-process text nodes that are already inside a previously inserted .ot-math span, which makes the function non-idempotent (a second onRender call can nest .ot-math spans). Excluding .ot-math from the walker filter keeps repeated renders stable.
    src/hooks/use-overtype.ts:142
  • useOverType() exposes theme/minHeight/maxHeight/autoResize as options, but the hook only synchronizes value and placeholder after mount. If these props change, the editor instance will keep the initial sizing/theme options, which is surprising for a hook that accepts controlled options.
  • Files reviewed: 8/9 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

Copilot AI review requested due to automatic review settings September 6, 2026 15:19

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

PR oznacza CLOSES #225, ale w implementacji brakuje wymaganego w issue pickera symboli matematycznych (co najmniej doprecyzowania scope lub uzupełnienia funkcjonalności).

Review details

Files not reviewed (1)

  • pnpm-lock.yaml: Generated file

Suppressed comments (1)

src/components/overtype-editor.tsx:137

  • PR description closes #225, but Issue #225 explicitly calls for a math symbol picker (e.g. a “∑/fx” button opening a palette of common symbols and inserting LaTeX templates like \frac{}{}). The current implementation only adds actions to wrap selection with $…$ / $$…$$, so closing the issue looks premature unless the picker is intentionally out of scope.
  {
    label: "Matematyka",
    actions: [
      {
        label: "Wzór w tekście",
        icon: SigmaIcon,
        apply: (ta) => {
          markdownActions.applyCustomFormat(ta, { prefix: "$", suffix: "$" });
        },
      },
      {
        label: "Blok wzoru",
        icon: PiIcon,
        apply: (ta) => {
          markdownActions.applyCustomFormat(ta, {
            prefix: "\n$$\n",
            suffix: "\n$$\n",
          });
        },
      },
  • Files reviewed: 8/9 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

# Conflicts:
#	apps/web/src/__tests__/overtype-editor.spec.tsx
#	apps/web/src/components/overtype-editor.tsx
#	apps/web/src/hooks/use-overtype.ts
#	package.json

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Formatowanie markdown i latex

5 participants