Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core): added preserving and managing original markdown formatting for YfmTable #558

Merged
merged 22 commits into from
Feb 11, 2025

Conversation

makhnatkin
Copy link
Collaborator

@makhnatkin makhnatkin commented Jan 22, 2025

Fixes #557

Enhancements in the Markdown Parser and Serializer

  1. Dynamic Modifiers
    Dynamic modifiers have been added to the parser MarkdownParser and serializer MarkdownSerializer to enable flexible token, attribute, and node modifications. The changes follow SOLID principles and maintain backward compatibility.

    Change diagram: illustrates the integration points of the modifiers.

    enhancements_parser_serializer

  2. New Modifier Classes
    Introduced classes: MarkdownParserDynamicModifier and MarkdownSerializerDynamicModifier. They support configurations with composite keys, allowing shared handlers for different element types.

    Example:

      'paragraph,heading': /* fn */,
      paragraph: /* fn */,
  3. ExtensionsManager Update
    The ExtensionsManager has been modified to pass dynamic modifiers to the parser and serializer, enabling their automatic integration and processing.

  4. Preserving Raw Markup in yfm_table
    Configurations for dynamic modifiers and a markup manager have been added to ensure proper preservation and restoration of table contents.

  5. Content Hashing for Raw Markup
    Introduced classes: MarkupManager.The markup manager uses content hashing (UUID v5) to store and accurately restore raw markup during serialization.

@makhnatkin makhnatkin requested a review from d3m1d0v as a code owner January 22, 2025 08:52
@gravity-ui-bot
Copy link
Contributor

Preview is ready.

@makhnatkin makhnatkin changed the title feat(core): added MarkupManager to manage markdown, integrated with ExtensionsManager, parser and serializer feat(core): added MarkupManager for managing initial markup during serialization Jan 24, 2025
@makhnatkin makhnatkin force-pushed the feat/markup-manager branch 2 times, most recently from 81cbbf0 to 5ac82e2 Compare February 3, 2025 08:39
@makhnatkin makhnatkin requested a review from shevnv February 3, 2025 11:40
@makhnatkin
Copy link
Collaborator Author

proposal:

export type WysiwygOptions = {
    modifiers: WysiwygModifier[];
};

export type WysiwygModifier =
    | MdTokenModifer
    | NodeAttrsModified
    | SchemaSpecModifier
    | SerializeNodeMidifier;

export type MdTokenModifer = {
    type: 'mdToken';
    tokenName: string;
    fn: (...args: any[]) => any;
};

export type NodeAttrsModified = {
    type: 'nodeAttrs';
    nodeName: string;
    fn: (...args: any[]) => any;
};

export type SchemaSpecModifier = {
    type: 'schemaSpec';
    nodeName: string;
    fn: (...args: any[]) => any;
};

export type SerializeNodeMidifier = {
    type: 'serializeNode';
    nodeName: string;
    fn: (...args: any[]) => any;
};

@makhnatkin makhnatkin changed the title feat(core): added MarkupManager for managing initial markup during serialization feat(core): added preserving and managing original markdown formatting for YfmTable Feb 11, 2025
@makhnatkin makhnatkin merged commit 59549eb into main Feb 11, 2025
4 checks passed
@makhnatkin makhnatkin deleted the feat/markup-manager branch February 11, 2025 09:14
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.

Preserve and Manage Original Markdown Formatting Across Editor Modes
3 participants