Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rich text viewer | Implementation of markdown parser (#1335)
# Pull Request ## 🤨 Rationale This PR includes the logic for parsing markdown input and rendering the rich text content into the viewer component. Issue: #1288 AzDo User Story: [Show the rich text content by parsing the markdown input](https://dev.azure.com/ni/DevCentral/_backlogs/backlog/ASW%20SystemLink%20Platform/Initiatives/?workitem=2426496) ## 👩💻 Implementation * Added [prosemirror-markdown](https://github.com/ProseMirror/prosemirror-markdown/tree/master) package for parsing markdown strings, and [prosemirror-model ](https://github.com/ProseMirror/prosemirror-model) package for DOM serializer to serialize the content and render the rich text content in the UI. * Added `markdownValue` accessors to allow setting and retrieving the markdown value. When setting the markdown input string, the component performs operations to convert the markdown string into corresponding document fragments for loading it into the container of the viewer component. * Enabled `emphasis`, `list`, and `autolink` from the [markdown-it](https://github.com/markdown-it/markdown-it/tree/master), which is internally used by prosemirror-markdown. This allows users to add bold, italics, numbered, and bulleted lists, as well as direct links in a CommonMark flavor. All other basic markdown formats are disabled. * Added `json()` from the "@rollup/plugin-json" in the rollup.config.js because prosemirror-markdown and markdown-it internally use JSON files during the build process. Referred to this solution from the discussion [here](https://discuss.prosemirror.net/t/unexpected-token-on-importing-of-markdown-stuff/2360/4). * Also, added `nodePolyfills()` from [rollup-plugin-polyfill-node](https://www.npmjs.com/package/rollup-plugin-polyfill-node) as the `markdown-it` requires `punycode`([code reference](https://github.com/markdown-it/markdown-it/blob/master/lib/index.js#L14)) but as mentioned in the [punycode](https://www.npmjs.com/package/punycode), the right way to use it is `require('punycode/')`. So use `nodePolyfills()` to rollup the bundle with the `punycode` properly imported in the `all-components.bundle.js`. Spec update: 1. Latest `comments` desktop and mobile mockup links and updated a few GitHub permalinks. 2. Removed the `fit-to-content` attribute for the viewer component. 3. `markdown` accessor is changed to a property for the viewer component. ## 🧪 Testing Added unit tests and manually tested and verified the changes. ## ✅ Checklist <!--- Review the list and put an x in the boxes that apply or ~~strike through~~ around items that don't (along with an explanation). --> - [x] I have updated the project documentation to reflect my changes or determined no changes are needed.
- Loading branch information