chore: begins next / ui esm transform
This commit is contained in:
28
packages/richtext-slate/src/field/enablePlugins.tsx
Normal file
28
packages/richtext-slate/src/field/enablePlugins.tsx
Normal file
@@ -0,0 +1,28 @@
|
||||
import elementTypes from './elements/index.js'
|
||||
import leafTypes from './leaves/index.js'
|
||||
|
||||
const addPluginReducer = (EditorWithPlugins, plugin) => {
|
||||
if (typeof plugin === 'function') return plugin(EditorWithPlugins)
|
||||
return EditorWithPlugins
|
||||
}
|
||||
|
||||
const enablePlugins = (CreatedEditor, functions) =>
|
||||
functions.reduce((CreatedEditorWithPlugins, func) => {
|
||||
if (typeof func === 'object' && Array.isArray(func.plugins)) {
|
||||
return func.plugins.reduce(addPluginReducer, CreatedEditorWithPlugins)
|
||||
}
|
||||
|
||||
if (typeof func === 'string') {
|
||||
if (elementTypes[func] && elementTypes[func].plugins) {
|
||||
return elementTypes[func].plugins.reduce(addPluginReducer, CreatedEditorWithPlugins)
|
||||
}
|
||||
|
||||
if (leafTypes[func] && leafTypes[func].plugins) {
|
||||
return leafTypes[func].plugins.reduce(addPluginReducer, CreatedEditorWithPlugins)
|
||||
}
|
||||
}
|
||||
|
||||
return CreatedEditorWithPlugins
|
||||
}, CreatedEditor)
|
||||
|
||||
export default enablePlugins
|
||||
15
packages/richtext-slate/src/field/icons/headings/index.tsx
Normal file
15
packages/richtext-slate/src/field/icons/headings/index.tsx
Normal file
@@ -0,0 +1,15 @@
|
||||
import { H1 } from './H1/index.js'
|
||||
import { H2 } from './H2/index.js'
|
||||
import { H3 } from './H3/index.js'
|
||||
import { H4 } from './H4/index.js'
|
||||
import { H5 } from './H5/index.js'
|
||||
import { H6 } from './H6/index.js'
|
||||
|
||||
export default {
|
||||
H1,
|
||||
H2,
|
||||
H3,
|
||||
H4,
|
||||
H5,
|
||||
H6,
|
||||
}
|
||||
@@ -15,5 +15,3 @@ export const bold: RichTextCustomLeaf = {
|
||||
),
|
||||
Leaf: Bold,
|
||||
}
|
||||
|
||||
export default bold
|
||||
|
||||
25
packages/richtext-slate/src/field/mergeCustomFunctions.tsx
Normal file
25
packages/richtext-slate/src/field/mergeCustomFunctions.tsx
Normal file
@@ -0,0 +1,25 @@
|
||||
export default (enabledFunctions, builtInFunctions) => {
|
||||
const formattedEnabledFunctions = [...enabledFunctions]
|
||||
|
||||
if (enabledFunctions.indexOf('ul') > -1 || enabledFunctions.indexOf('ol') > -1) {
|
||||
formattedEnabledFunctions.push('li')
|
||||
}
|
||||
|
||||
return formattedEnabledFunctions.reduce((resultingFunctions, func) => {
|
||||
if (typeof func === 'object' && func.name) {
|
||||
return {
|
||||
...resultingFunctions,
|
||||
[func.name]: func,
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof func === 'string' && builtInFunctions[func]) {
|
||||
return {
|
||||
...resultingFunctions,
|
||||
[func]: builtInFunctions[func],
|
||||
}
|
||||
}
|
||||
|
||||
return resultingFunctions
|
||||
}, {})
|
||||
}
|
||||
Reference in New Issue
Block a user