Bhargava 6063bd1724 Help Project:
1. Initial Commit - a boiler plate code and POC to realize the concept of context
sensitive help
2. Frontend code written in ReactJS
3. Backend code written in Java, Spring Boot Framework
4. Frontend Start:
        pre-requisites : node, npm
	npm run dev  ==> to start the frontend vite server
5. Backend Start:
	pre-requisites : java, mvn
        mvn spring-boot:run  ==> to start the backend server
6. Visit http://localhost:5173/ for basic demo of help, press F1 in textboxes
7. Visit http://localhost:5173/editor and enter "admin123" to add/modify texts.

Happy Coding !!!

Thank you,
Bhargava.
2025-07-04 15:54:13 +05:30

70 lines
1.8 KiB
JavaScript

/**
* @typedef {import('hast').Element} Element
* @typedef {import('hast').ElementContent} ElementContent
* @typedef {import('hast').Properties} Properties
* @typedef {import('mdast').Parents} Parents
* @typedef {import('mdast').TableRow} TableRow
* @typedef {import('../state.js').State} State
*/
// Make VS Code show references to the above types.
''
/**
* Turn an mdast `tableRow` node into hast.
*
* @param {State} state
* Info passed around.
* @param {TableRow} node
* mdast node.
* @param {Parents | undefined} parent
* Parent of `node`.
* @returns {Element}
* hast node.
*/
export function tableRow(state, node, parent) {
const siblings = parent ? parent.children : undefined
// Generate a body row when without parent.
const rowIndex = siblings ? siblings.indexOf(node) : 1
const tagName = rowIndex === 0 ? 'th' : 'td'
// To do: option to use `style`?
const align = parent && parent.type === 'table' ? parent.align : undefined
const length = align ? align.length : node.children.length
let cellIndex = -1
/** @type {Array<ElementContent>} */
const cells = []
while (++cellIndex < length) {
// Note: can also be undefined.
const cell = node.children[cellIndex]
/** @type {Properties} */
const properties = {}
const alignValue = align ? align[cellIndex] : undefined
if (alignValue) {
properties.align = alignValue
}
/** @type {Element} */
let result = {type: 'element', tagName, properties, children: []}
if (cell) {
result.children = state.all(cell)
state.patch(cell, result)
result = state.applyData(cell, result)
}
cells.push(result)
}
/** @type {Element} */
const result = {
type: 'element',
tagName: 'tr',
properties: {},
children: state.wrap(cells, true)
}
state.patch(node, result)
return state.applyData(node, result)
}