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

96 lines
1.9 KiB
JavaScript

/**
* @typedef {import('unist').Node} Node
* @typedef {import('unist').Point} Point
* @typedef {import('unist').Position} Position
*/
/**
* @typedef NodeLike
* @property {string} type
* @property {PositionLike | null | undefined} [position]
*
* @typedef PositionLike
* @property {PointLike | null | undefined} [start]
* @property {PointLike | null | undefined} [end]
*
* @typedef PointLike
* @property {number | null | undefined} [line]
* @property {number | null | undefined} [column]
* @property {number | null | undefined} [offset]
*/
/**
* Get the ending point of `node`.
*
* @param node
* Node.
* @returns
* Point.
*/
export const pointEnd = point('end')
/**
* Get the starting point of `node`.
*
* @param node
* Node.
* @returns
* Point.
*/
export const pointStart = point('start')
/**
* Get the positional info of `node`.
*
* @param {'end' | 'start'} type
* Side.
* @returns
* Getter.
*/
function point(type) {
return point
/**
* Get the point info of `node` at a bound side.
*
* @param {Node | NodeLike | null | undefined} [node]
* @returns {Point | undefined}
*/
function point(node) {
const point = (node && node.position && node.position[type]) || {}
if (
typeof point.line === 'number' &&
point.line > 0 &&
typeof point.column === 'number' &&
point.column > 0
) {
return {
line: point.line,
column: point.column,
offset:
typeof point.offset === 'number' && point.offset > -1
? point.offset
: undefined
}
}
}
}
/**
* Get the positional info of `node`.
*
* @param {Node | NodeLike | null | undefined} [node]
* Node.
* @returns {Position | undefined}
* Position.
*/
export function position(node) {
const start = pointStart(node)
const end = pointEnd(node)
if (start && end) {
return {start, end}
}
}