feat: Integrate input rules and paste rules into the core (#1997)
* refactoring * improve link regex * WIP: add new markPasteRule und linkify to image mark * move copy of inputrule to core * trigger codeblock inputrule on enter * refactoring * add regex match to markpasterulematch * refactoring * improve link regex * WIP: add new markPasteRule und linkify to image mark * move copy of inputrule to core * trigger codeblock inputrule on enter * refactoring * add regex match to markpasterulematch * update linkify * wip * wip * log * wip * remove debug code * wip * wip * wip * wip * wip * wip * wip * wip * rename matcher * add data to ExtendedRegExpMatchArray * remove logging * add code option to marks, prevent inputrules in code mark * remove link regex * fix codeblock inputrule on enter * refactoring * refactoring * refactoring * refactoring * fix position bug * add test * export InputRule and PasteRule * clean up link demo * fix types
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { MaybeReturnType } from '../types'
|
||||
import isFunction from './isFunction'
|
||||
|
||||
/**
|
||||
* Optionally calls `value` as a function.
|
||||
@@ -8,7 +9,7 @@ import { MaybeReturnType } from '../types'
|
||||
* @param props Optional props to pass to function.
|
||||
*/
|
||||
export default function callOrReturn<T>(value: T, context: any = undefined, ...props: any[]): MaybeReturnType<T> {
|
||||
if (typeof value === 'function') {
|
||||
if (isFunction(value)) {
|
||||
if (context) {
|
||||
return value.bind(context)(...props)
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
export default function isClass(item: any): boolean {
|
||||
if (item.constructor?.toString().substring(0, 5) !== 'class') {
|
||||
export default function isClass(value: any): boolean {
|
||||
if (value.constructor?.toString().substring(0, 5) !== 'class') {
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
export default function isEmptyObject(object = {}): boolean {
|
||||
return Object.keys(object).length === 0 && object.constructor === Object
|
||||
export default function isEmptyObject(value = {}): boolean {
|
||||
return Object.keys(value).length === 0 && value.constructor === Object
|
||||
}
|
||||
|
||||
3
packages/core/src/utilities/isFunction.ts
Normal file
3
packages/core/src/utilities/isFunction.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
export default function isObject(value: any): value is Function {
|
||||
return typeof value === 'function'
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
import isClass from './isClass'
|
||||
|
||||
export default function isObject(item: any): boolean {
|
||||
export default function isObject(value: any): boolean {
|
||||
return (
|
||||
item
|
||||
&& typeof item === 'object'
|
||||
&& !Array.isArray(item)
|
||||
&& !isClass(item)
|
||||
value
|
||||
&& typeof value === 'object'
|
||||
&& !Array.isArray(value)
|
||||
&& !isClass(value)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
// see: https://github.com/mesqueeb/is-what/blob/88d6e4ca92fb2baab6003c54e02eedf4e729e5ab/src/index.ts
|
||||
|
||||
function getType(payload: any): string {
|
||||
return Object.prototype.toString.call(payload).slice(8, -1)
|
||||
function getType(value: any): string {
|
||||
return Object.prototype.toString.call(value).slice(8, -1)
|
||||
}
|
||||
|
||||
export default function isPlainObject(payload: any): payload is Record<string, any> {
|
||||
if (getType(payload) !== 'Object') return false
|
||||
return payload.constructor === Object && Object.getPrototypeOf(payload) === Object.prototype
|
||||
export default function isPlainObject(value: any): value is Record<string, any> {
|
||||
if (getType(value) !== 'Object') return false
|
||||
return value.constructor === Object && Object.getPrototypeOf(value) === Object.prototype
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
export default function isRegExp(value: any): boolean {
|
||||
export default function isRegExp(value: any): value is RegExp {
|
||||
return Object.prototype.toString.call(value) === '[object RegExp]'
|
||||
}
|
||||
|
||||
3
packages/core/src/utilities/isString.ts
Normal file
3
packages/core/src/utilities/isString.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
export default function isString(value: any): value is string {
|
||||
return typeof value === 'string'
|
||||
}
|
||||
Reference in New Issue
Block a user