forked from FINAKON/HelpProject
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.
68 lines
1.7 KiB
JavaScript
68 lines
1.7 KiB
JavaScript
'use strict'
|
|
|
|
let Document = require('./document')
|
|
let LazyResult = require('./lazy-result')
|
|
let NoWorkResult = require('./no-work-result')
|
|
let Root = require('./root')
|
|
|
|
class Processor {
|
|
constructor(plugins = []) {
|
|
this.version = '8.5.6'
|
|
this.plugins = this.normalize(plugins)
|
|
}
|
|
|
|
normalize(plugins) {
|
|
let normalized = []
|
|
for (let i of plugins) {
|
|
if (i.postcss === true) {
|
|
i = i()
|
|
} else if (i.postcss) {
|
|
i = i.postcss
|
|
}
|
|
|
|
if (typeof i === 'object' && Array.isArray(i.plugins)) {
|
|
normalized = normalized.concat(i.plugins)
|
|
} else if (typeof i === 'object' && i.postcssPlugin) {
|
|
normalized.push(i)
|
|
} else if (typeof i === 'function') {
|
|
normalized.push(i)
|
|
} else if (typeof i === 'object' && (i.parse || i.stringify)) {
|
|
if (process.env.NODE_ENV !== 'production') {
|
|
throw new Error(
|
|
'PostCSS syntaxes cannot be used as plugins. Instead, please use ' +
|
|
'one of the syntax/parser/stringifier options as outlined ' +
|
|
'in your PostCSS runner documentation.'
|
|
)
|
|
}
|
|
} else {
|
|
throw new Error(i + ' is not a PostCSS plugin')
|
|
}
|
|
}
|
|
return normalized
|
|
}
|
|
|
|
process(css, opts = {}) {
|
|
if (
|
|
!this.plugins.length &&
|
|
!opts.parser &&
|
|
!opts.stringifier &&
|
|
!opts.syntax
|
|
) {
|
|
return new NoWorkResult(this, css, opts)
|
|
} else {
|
|
return new LazyResult(this, css, opts)
|
|
}
|
|
}
|
|
|
|
use(plugin) {
|
|
this.plugins = this.plugins.concat(this.normalize([plugin]))
|
|
return this
|
|
}
|
|
}
|
|
|
|
module.exports = Processor
|
|
Processor.default = Processor
|
|
|
|
Root.registerProcessor(Processor)
|
|
Document.registerProcessor(Processor)
|