You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When switching between WYSIWYG and Markup modes in the MarkdownEditor, the structure of the original text in Markdown format may be modified. This is particularly problematic for certain blocks, such as yfm-table, where the serialized output differs from the original input. Users expect the original text in Markdown format to remain intact, preserving its exact structure when toggling modes.
Proposal
Introduce a new entity called MarkupManager to act as a centralized store for the original text in Markdown format and metadata about token positions. This will enable accurate reconstruction of the original Markdown during serialization.
This issue focuses on adding the MarkupManager class and integrating it with the existing MarkdownEditor infrastructure without altering the current functionality.
Requirements
MarkupManager Responsibilities:
Store the original text in Markdown format (rawMarkdown).
Maintain token positions (poses) as a mapping from a Unique Token Identifier to [start, end] positions in the rawMarkdown.
Ensure that each token has a Unique Token Identifier for tracking. If a token lacks an identifier, it should be generated during parsing.
Provide methods to retrieve and update rawMarkdown and poses.
Store and expose the Markdown Parser instance.
Integration Points:
Pass an instance of MarkupManager to the Markdown Parser and Markdown Serializer during initialization in ExtensionsManager.
Non-breaking Changes:
Ensure that the new MarkupManager is integrated without affecting the current behavior of the MarkdownEditor.
Tests:
Verify that MarkupManager correctly stores and retrieves rawMarkdown.
Validate that poses are updated and accessed as expected.
Ensure Unique Token Identifiers are correctly assigned to tokens without identifiers.
Ensure no regression in existing functionality.
Implementation Steps
Create the MarkupManager class with the following methods:
Description
When switching between WYSIWYG and Markup modes in the MarkdownEditor, the structure of the original text in Markdown format may be modified. This is particularly problematic for certain blocks, such as
yfm-table
, where the serialized output differs from the original input. Users expect the original text in Markdown format to remain intact, preserving its exact structure when toggling modes.Proposal
Introduce a new entity called
MarkupManager
to act as a centralized store for the original text in Markdown format and metadata about token positions. This will enable accurate reconstruction of the original Markdown during serialization.This issue focuses on adding the
MarkupManager
class and integrating it with the existingMarkdownEditor
infrastructure without altering the current functionality.Requirements
MarkupManager Responsibilities:
rawMarkdown
).poses
) as a mapping from a Unique Token Identifier to[start, end]
positions in therawMarkdown
.rawMarkdown
andposes
.Integration Points:
MarkupManager
to the Markdown Parser and Markdown Serializer during initialization inExtensionsManager
.Non-breaking Changes:
MarkupManager
is integrated without affecting the current behavior of the MarkdownEditor.Tests:
MarkupManager
correctly stores and retrievesrawMarkdown
.poses
are updated and accessed as expected.Implementation Steps
Create the
MarkupManager
class with the following methods:setMarkup(rawMarkdown: string): void
getMarkup(): string
setPos(tokenId: string, pos: [number, number]): void
getPos(tokenId: string): [number, number] | null
setParser(parser: MarkdownParser): void
getParser(): MarkdownParser
reset(): void
Ensure unique token identifier assignment:
Update
ExtensionsManager
:MarkupManager
increateDeps
.MarkdownParser
andMarkdownSerializer
during their initialization.Write unit tests:
MarkupManager
for text in Markdown formatstorage, position management, and parser handling.ExtensionsManager
.Submit the initial implementation with no impact on serialization logic.
The text was updated successfully, but these errors were encountered: