Skip to content

Migrate to ParserV2#98

Merged
Nowely merged 9 commits intonextfrom
use-parser-v2
Nov 12, 2025
Merged

Migrate to ParserV2#98
Nowely merged 9 commits intonextfrom
use-parser-v2

Conversation

@Nowely
Copy link
Owner

@Nowely Nowely commented Nov 12, 2025

🚨 Breaking Changes: Migration to ParserV2

1. Markup Format Change

- @[__label__](__value__)  // OLD - no longer supported
+ @[__value__](__meta__)   // NEW - required format

Impact: All markup patterns must be updated to use the new placeholder names.

2. Mark Component Props Change

// OLD - no longer supported
const Mark = ({label, value}) => (
  <mark title={value}>{label}</mark>
)

// NEW - required
const Mark = ({value, meta}) => (
  <mark title={meta}>{value}</mark>
)

Impact: All custom Mark components must update their prop destructuring.

3. initMark Function Signature Change

// OLD - no longer supported
{
  initMark: ({label, value}) => ({
    children: label,
    data: value
  })
}

// NEW - required
{
  initMark: ({value, meta}) => ({
    children: value,
    data: meta
  })
}

Impact: All option configurations with initMark must be updated.

4. useMark Hook Props Change

// OLD - no longer supported
const {label, value, ref} = useMark()

// NEW - required
const {value, meta, ref} = useMark()

Impact: All editable marks using the useMark hook must update prop names.

5. Removed Types & Functions

// ❌ REMOVED - these no longer exist
import {MarkStruct, MarkMatch, ParserV1Markup} from 'rc-marked-input'
import {denoteV1, annotateV1, isAnnotated} from 'rc-marked-input'

// ✅ USE INSTEAD - new API
import {MarkToken, Token, TextToken, Markup} from 'rc-marked-input'
import {denote, annotate} from 'rc-marked-input'
// For type checking: token.type === 'mark'

Impact: All imports and usage of deprecated APIs must be updated.

6. Token Structure Change

// OLD - MarkStruct array
tokens: MarkStruct[]  // {label: string, value?: string}

// NEW - Token union array  
tokens: Token[]       // TextToken | MarkToken

Impact: Internal changes, but affects any code directly accessing tokens.

📋 Migration Steps

  1. Update all markup patterns: __label____value__, __value____meta__
  2. Update Mark components: Change prop destructuring from {label, value} to {value, meta}
  3. Update initMark functions: Change parameter destructuring
  4. Update useMark usage: Change prop destructuring in editable marks
  5. Replace deprecated imports: Use new ParserV2 types and functions
  6. Update denote/annotate calls: Use new API

…erV2 as the default. Mark ParserV1 exports as deprecated with migration notes. Update related types and constants to align with new ParserV2 structure. Add utility functions for adapting between ParserV1 and ParserV2 formats.
…ME with breaking changes and migration instructions. Refactor related types and constants to align with new structure. Enhance components and utilities to utilize Token and MarkToken types, ensuring compatibility with the new parsing system.
@vercel
Copy link

vercel bot commented Nov 12, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
marked-input Ready Ready Preview Comment Nov 12, 2025 9:23pm

@Nowely Nowely changed the title Use ParserV2 Migrate to ParserV2 Nov 12, 2025
… to ParserV2. This includes the deletion of constants, types, utilities, and tests associated with the deprecated ParserV1. Update README to reflect the removal and emphasize migration to ParserV2.
…e new parser. Refactor parsing logic to ensure compatibility with the updated store structure, enhancing token processing and management.
…e definitions to use semicolons instead of commas for object properties. Clean up whitespace in various files for improved readability. Adjust test cases in TriggerFinder.spec.ts to enhance clarity and maintainability.
…ving all references to ParserV1. Update performance metrics and results storage structure for consistency. Revise README to reflect current benchmark results and performance characteristics of ParserV2. Remove deprecated utility tests for assertAnnotated.
…djust table formatting for improved readability and consistency in performance metrics presentation.
@Nowely Nowely merged commit cbf7a5a into next Nov 12, 2025
7 checks passed
@Nowely Nowely deleted the use-parser-v2 branch November 12, 2025 21:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant