@bangle.dev/base-components
Advanced tools
Comparing version 0.29.0 to 0.29.1-alpha.0
@@ -7,2 +7,3 @@ /** | ||
import { psx, sendKeyToPm, typeText } from '@bangle.dev/test-helpers'; | ||
import { blockquote } from '../src/index'; | ||
@@ -9,0 +10,0 @@ import { defaultTestEditor } from './test-editor'; |
@@ -7,2 +7,3 @@ /** | ||
import { psx, sendKeyToPm, setSelectionNear } from '@bangle.dev/test-helpers'; | ||
import { bold } from '../src/index'; | ||
@@ -9,0 +10,0 @@ import { defaultTestEditor } from './test-editor'; |
@@ -7,2 +7,3 @@ /** | ||
import { psx, sendKeyToPm } from '@bangle.dev/test-helpers'; | ||
import { codeBlock } from '../src/index'; | ||
@@ -9,0 +10,0 @@ import { defaultTestEditor } from './test-editor'; |
@@ -12,2 +12,3 @@ /** | ||
} from '@bangle.dev/test-helpers'; | ||
import { code } from '../src/index'; | ||
@@ -14,0 +15,0 @@ import { defaultTestEditor } from './test-editor'; |
@@ -12,16 +12,16 @@ /** | ||
} from '@bangle.dev/test-helpers'; | ||
import { toggleHeadingCollapse, uncollapseAllHeadings } from '../src/heading'; | ||
import { | ||
bulletList, | ||
codeBlock, | ||
doc, | ||
hardBreak, | ||
heading, | ||
listItem, | ||
orderedList, | ||
hardBreak, | ||
underline, | ||
codeBlock, | ||
doc, | ||
paragraph, | ||
strike, | ||
text, | ||
paragraph, | ||
heading, | ||
underline, | ||
} from '../src/index'; | ||
@@ -28,0 +28,0 @@ |
@@ -7,2 +7,3 @@ /** | ||
import { psx, sendKeyToPm } from '@bangle.dev/test-helpers'; | ||
import { hardBreak } from '../src/index'; | ||
@@ -9,0 +10,0 @@ import { defaultTestEditor } from './test-editor'; |
@@ -6,2 +6,3 @@ /** | ||
import { psx, sendKeyToPm, typeChar, typeText } from '@bangle.dev/test-helpers'; | ||
import { heading } from '../src/index'; | ||
@@ -8,0 +9,0 @@ import { defaultTestEditor } from './test-editor'; |
@@ -7,2 +7,3 @@ /** | ||
import { psx, typeText } from '@bangle.dev/test-helpers'; | ||
import { defaultTestEditor } from './test-editor'; | ||
@@ -9,0 +10,0 @@ |
@@ -13,2 +13,3 @@ /** | ||
import { sleep } from '@bangle.dev/utils'; | ||
import { defaultTestEditor } from './test-editor'; | ||
@@ -15,0 +16,0 @@ |
@@ -12,2 +12,3 @@ /** | ||
} from '@bangle.dev/test-helpers'; | ||
import { italic } from '../src/index'; | ||
@@ -14,0 +15,0 @@ import { defaultTestEditor } from './test-editor'; |
@@ -6,2 +6,3 @@ /** | ||
import { psx, typeText } from '@bangle.dev/test-helpers'; | ||
import { defaultTestEditor } from './test-editor'; | ||
@@ -8,0 +9,0 @@ |
@@ -14,2 +14,3 @@ /** | ||
} from '@bangle.dev/test-helpers'; | ||
import { | ||
@@ -16,0 +17,0 @@ bold, |
@@ -8,4 +8,4 @@ /** | ||
import { psx, sendKeyToPm, typeText } from '@bangle.dev/test-helpers'; | ||
import { doc, heading, paragraph, text } from '../src/index'; | ||
import { defaultTestEditor } from './test-editor'; | ||
@@ -12,0 +12,0 @@ |
@@ -7,2 +7,3 @@ /** | ||
import { psx } from '@bangle.dev/test-helpers'; | ||
import { defaultTestEditor } from './test-editor'; | ||
@@ -9,0 +10,0 @@ |
@@ -7,2 +7,3 @@ /** | ||
import { psx, sendKeyToPm, setSelectionNear } from '@bangle.dev/test-helpers'; | ||
import { strike } from '../src/index'; | ||
@@ -9,0 +10,0 @@ import { defaultTestEditor } from './test-editor'; |
import { SpecRegistry } from '@bangle.dev/core'; | ||
import { renderTestEditor } from '@bangle.dev/test-helpers'; | ||
import { defaultPlugins, defaultSpecs } from './all-base-components'; | ||
@@ -4,0 +5,0 @@ |
@@ -6,4 +6,5 @@ /** | ||
import { psx, sendKeyToPm, typeText } from '@bangle.dev/test-helpers'; | ||
import { listItem } from '../src/index'; | ||
import { siblingsAndNodesBetween } from '../src/list-item/todo'; | ||
import { siblingsAndNodesBetween } from '../src/list-todo'; | ||
import { defaultTestEditor } from './test-editor'; | ||
@@ -10,0 +11,0 @@ |
@@ -7,2 +7,3 @@ /** | ||
import { psx, sendKeyToPm, setSelectionNear } from '@bangle.dev/test-helpers'; | ||
import { underline } from '../src/index'; | ||
@@ -9,0 +10,0 @@ import { defaultTestEditor } from './test-editor'; |
import { RawSpecs, RawPlugins } from '@bangle.dev/core'; | ||
export { doc, editorStateCounter, history, paragraph, text } from '@bangle.dev/core'; | ||
import { Command, EditorState, InputRule, Plugin, NodeType, EditorView, Node } from '@bangle.dev/pm'; | ||
import { EditorState, Command, NodeType, EditorView, Node, InputRule, Plugin } from '@bangle.dev/pm'; | ||
import { NodeWithPos } from '@bangle.dev/utils'; | ||
@@ -9,7 +9,13 @@ | ||
declare const commands$c: { | ||
toggleBold: typeof toggleBold; | ||
queryIsBoldActive: typeof queryIsBoldActive; | ||
queryIsBlockquoteActive: typeof queryIsBlockquoteActive; | ||
wrapInBlockquote: typeof wrapInBlockquote; | ||
}; | ||
declare const defaultKeys$b: { | ||
toggleBold: string; | ||
wrapIn: string; | ||
moveDown: string; | ||
moveUp: string; | ||
emptyCopy: string; | ||
emptyCut: string; | ||
insertEmptyParaAbove: string; | ||
insertEmptyParaBelow: string; | ||
}; | ||
@@ -20,11 +26,19 @@ declare function specFactory$e(): RawSpecs; | ||
keybindings?: { | ||
toggleBold: string; | ||
wrapIn: string; | ||
moveDown: string; | ||
moveUp: string; | ||
emptyCopy: string; | ||
emptyCut: string; | ||
insertEmptyParaAbove: string; | ||
insertEmptyParaBelow: string; | ||
} | undefined; | ||
}): RawPlugins; | ||
declare function toggleBold(): Command; | ||
declare function queryIsBoldActive(): (state: EditorState) => boolean; | ||
declare function queryIsBlockquoteActive(): (state: EditorState) => boolean; | ||
declare function wrapInBlockquote(): Command; | ||
declare function insertEmptyParaAbove$1(): Command; | ||
declare function insertEmptyParaBelow$1(): Command; | ||
declare const bold_d_toggleBold: typeof toggleBold; | ||
declare const bold_d_queryIsBoldActive: typeof queryIsBoldActive; | ||
declare namespace bold_d { | ||
declare const blockquote_d_queryIsBlockquoteActive: typeof queryIsBlockquoteActive; | ||
declare const blockquote_d_wrapInBlockquote: typeof wrapInBlockquote; | ||
declare namespace blockquote_d { | ||
export { | ||
@@ -35,4 +49,6 @@ spec$e as spec, | ||
defaultKeys$b as defaultKeys, | ||
bold_d_toggleBold as toggleBold, | ||
bold_d_queryIsBoldActive as queryIsBoldActive, | ||
blockquote_d_queryIsBlockquoteActive as queryIsBlockquoteActive, | ||
blockquote_d_wrapInBlockquote as wrapInBlockquote, | ||
insertEmptyParaAbove$1 as insertEmptyParaAbove, | ||
insertEmptyParaBelow$1 as insertEmptyParaBelow, | ||
}; | ||
@@ -44,22 +60,21 @@ } | ||
declare const commands$b: { | ||
toggleCode: typeof toggleCode; | ||
queryIsCodeActive: typeof queryIsCodeActive; | ||
toggleBold: typeof toggleBold; | ||
queryIsBoldActive: typeof queryIsBoldActive; | ||
}; | ||
declare const defaultKeys$a: { | ||
toggleCode: string; | ||
toggleBold: string; | ||
}; | ||
declare function specFactory$d(): RawSpecs; | ||
declare function pluginsFactory$d({ markdownShortcut, escapeAtEdge, keybindings, }?: { | ||
declare function pluginsFactory$d({ markdownShortcut, keybindings, }?: { | ||
markdownShortcut?: boolean | undefined; | ||
escapeAtEdge?: boolean | undefined; | ||
keybindings?: { | ||
toggleCode: string; | ||
toggleBold: string; | ||
} | undefined; | ||
}): RawPlugins; | ||
declare function toggleCode(): Command; | ||
declare function queryIsCodeActive(): (state: EditorState) => boolean; | ||
declare function toggleBold(): Command; | ||
declare function queryIsBoldActive(): (state: EditorState) => boolean; | ||
declare const code_d_toggleCode: typeof toggleCode; | ||
declare const code_d_queryIsCodeActive: typeof queryIsCodeActive; | ||
declare namespace code_d { | ||
declare const bold_d_toggleBold: typeof toggleBold; | ||
declare const bold_d_queryIsBoldActive: typeof queryIsBoldActive; | ||
declare namespace bold_d { | ||
export { | ||
@@ -70,4 +85,4 @@ spec$d as spec, | ||
defaultKeys$a as defaultKeys, | ||
code_d_toggleCode as toggleCode, | ||
code_d_queryIsCodeActive as queryIsCodeActive, | ||
bold_d_toggleBold as toggleBold, | ||
bold_d_queryIsBoldActive as queryIsBoldActive, | ||
}; | ||
@@ -79,20 +94,28 @@ } | ||
declare const commands$a: { | ||
toggleItalic: typeof toggleItalic; | ||
queryIsItalicActive: typeof queryIsItalicActive; | ||
toggleBulletList: typeof toggleBulletList; | ||
queryIsBulletListActive: typeof queryIsBulletListActive; | ||
}; | ||
declare const defaultKeys$9: { | ||
toggleItalic: string; | ||
toggle: string; | ||
toggleTodo: string; | ||
}; | ||
declare function specFactory$c(): RawSpecs; | ||
declare function pluginsFactory$c({ keybindings }?: { | ||
declare function pluginsFactory$c({ markdownShortcut, todoMarkdownShortcut, keybindings, }?: { | ||
markdownShortcut?: boolean | undefined; | ||
todoMarkdownShortcut?: boolean | undefined; | ||
keybindings?: { | ||
toggleItalic: string; | ||
toggle: string; | ||
toggleTodo: string; | ||
} | undefined; | ||
}): RawPlugins; | ||
declare function toggleItalic(): Command; | ||
declare function queryIsItalicActive(): (state: EditorState) => boolean; | ||
declare function toggleBulletList(): Command; | ||
declare function toggleTodoList(): Command; | ||
declare function queryIsBulletListActive(): (state: EditorState) => boolean; | ||
declare function queryIsTodoListActive(): (state: EditorState) => boolean; | ||
declare const italic_d_toggleItalic: typeof toggleItalic; | ||
declare const italic_d_queryIsItalicActive: typeof queryIsItalicActive; | ||
declare namespace italic_d { | ||
declare const bulletList_d_toggleBulletList: typeof toggleBulletList; | ||
declare const bulletList_d_toggleTodoList: typeof toggleTodoList; | ||
declare const bulletList_d_queryIsBulletListActive: typeof queryIsBulletListActive; | ||
declare const bulletList_d_queryIsTodoListActive: typeof queryIsTodoListActive; | ||
declare namespace bulletList_d { | ||
export { | ||
@@ -103,4 +126,6 @@ spec$c as spec, | ||
defaultKeys$9 as defaultKeys, | ||
italic_d_toggleItalic as toggleItalic, | ||
italic_d_queryIsItalicActive as queryIsItalicActive, | ||
bulletList_d_toggleBulletList as toggleBulletList, | ||
bulletList_d_toggleTodoList as toggleTodoList, | ||
bulletList_d_queryIsBulletListActive as queryIsBulletListActive, | ||
bulletList_d_queryIsTodoListActive as queryIsTodoListActive, | ||
}; | ||
@@ -112,41 +137,22 @@ } | ||
declare const commands$9: { | ||
createLink: typeof createLink; | ||
updateLink: typeof updateLink; | ||
queryLinkAttrs: typeof queryLinkAttrs; | ||
queryIsLinkAllowedInRange: typeof queryIsLinkAllowedInRange; | ||
queryIsLinkActive: typeof queryIsLinkActive; | ||
queryIsSelectionAroundLink: typeof queryIsSelectionAroundLink; | ||
toggleCode: typeof toggleCode; | ||
queryIsCodeActive: typeof queryIsCodeActive; | ||
}; | ||
declare function specFactory$b({ openOnClick }?: { | ||
openOnClick?: boolean | undefined; | ||
}): RawSpecs; | ||
declare function pluginsFactory$b(): RawPlugins; | ||
declare const URL_REGEX: RegExp; | ||
/** | ||
* | ||
* Commands | ||
* | ||
*/ | ||
/** | ||
* Sets the selection to href | ||
* @param {*} href | ||
*/ | ||
declare function createLink(href: string): Command; | ||
declare function updateLink(href?: string): Command; | ||
declare function queryLinkAttrs(): (state: EditorState) => { | ||
href: any; | ||
text: string; | ||
} | undefined; | ||
declare function queryIsLinkAllowedInRange(from: number, to: number): (state: EditorState) => boolean | undefined; | ||
declare function queryIsLinkActive(): (state: EditorState) => boolean; | ||
declare function queryIsSelectionAroundLink(): (state: EditorState) => boolean; | ||
declare const defaultKeys$8: { | ||
toggleCode: string; | ||
}; | ||
declare function specFactory$b(): RawSpecs; | ||
declare function pluginsFactory$b({ markdownShortcut, escapeAtEdge, keybindings, }?: { | ||
markdownShortcut?: boolean | undefined; | ||
escapeAtEdge?: boolean | undefined; | ||
keybindings?: { | ||
toggleCode: string; | ||
} | undefined; | ||
}): RawPlugins; | ||
declare function toggleCode(): Command; | ||
declare function queryIsCodeActive(): (state: EditorState) => boolean; | ||
declare const link_d_URL_REGEX: typeof URL_REGEX; | ||
declare const link_d_createLink: typeof createLink; | ||
declare const link_d_updateLink: typeof updateLink; | ||
declare const link_d_queryLinkAttrs: typeof queryLinkAttrs; | ||
declare const link_d_queryIsLinkAllowedInRange: typeof queryIsLinkAllowedInRange; | ||
declare const link_d_queryIsLinkActive: typeof queryIsLinkActive; | ||
declare const link_d_queryIsSelectionAroundLink: typeof queryIsSelectionAroundLink; | ||
declare namespace link_d { | ||
declare const code_d_toggleCode: typeof toggleCode; | ||
declare const code_d_queryIsCodeActive: typeof queryIsCodeActive; | ||
declare namespace code_d { | ||
export { | ||
@@ -156,9 +162,5 @@ spec$b as spec, | ||
commands$9 as commands, | ||
link_d_URL_REGEX as URL_REGEX, | ||
link_d_createLink as createLink, | ||
link_d_updateLink as updateLink, | ||
link_d_queryLinkAttrs as queryLinkAttrs, | ||
link_d_queryIsLinkAllowedInRange as queryIsLinkAllowedInRange, | ||
link_d_queryIsLinkActive as queryIsLinkActive, | ||
link_d_queryIsSelectionAroundLink as queryIsSelectionAroundLink, | ||
defaultKeys$8 as defaultKeys, | ||
code_d_toggleCode as toggleCode, | ||
code_d_queryIsCodeActive as queryIsCodeActive, | ||
}; | ||
@@ -170,156 +172,5 @@ } | ||
declare const commands$8: { | ||
toggleStrike: typeof toggleStrike; | ||
queryIsStrikeActive: typeof queryIsStrikeActive; | ||
queryIsCodeActiveBlock: typeof queryIsCodeActiveBlock; | ||
}; | ||
declare const defaultKeys$8: { | ||
toggleStrike: string; | ||
}; | ||
declare function specFactory$a(): RawSpecs; | ||
declare function pluginsFactory$a({ keybindings }?: { | ||
keybindings?: { | ||
toggleStrike: string; | ||
} | undefined; | ||
}): RawPlugins; | ||
declare function toggleStrike(): Command; | ||
declare function queryIsStrikeActive(): (state: EditorState) => boolean; | ||
declare const strike_d_toggleStrike: typeof toggleStrike; | ||
declare const strike_d_queryIsStrikeActive: typeof queryIsStrikeActive; | ||
declare namespace strike_d { | ||
export { | ||
spec$a as spec, | ||
plugins$a as plugins, | ||
commands$8 as commands, | ||
defaultKeys$8 as defaultKeys, | ||
strike_d_toggleStrike as toggleStrike, | ||
strike_d_queryIsStrikeActive as queryIsStrikeActive, | ||
}; | ||
} | ||
declare const spec$9: typeof specFactory$9; | ||
declare const plugins$9: typeof pluginsFactory$9; | ||
declare const commands$7: { | ||
toggleUnderline: typeof toggleUnderline; | ||
queryIsUnderlineActive: typeof queryIsUnderlineActive; | ||
}; | ||
declare const defaultKeys$7: { | ||
toggleUnderline: string; | ||
}; | ||
declare function specFactory$9(): RawSpecs; | ||
declare function pluginsFactory$9({ keybindings }?: { | ||
keybindings?: { | ||
toggleUnderline: string; | ||
} | undefined; | ||
}): InputRule | Plugin | undefined; | ||
declare function toggleUnderline(): Command; | ||
declare function queryIsUnderlineActive(): (state: EditorState) => boolean; | ||
declare const underline_d_toggleUnderline: typeof toggleUnderline; | ||
declare const underline_d_queryIsUnderlineActive: typeof queryIsUnderlineActive; | ||
declare namespace underline_d { | ||
export { | ||
spec$9 as spec, | ||
plugins$9 as plugins, | ||
commands$7 as commands, | ||
defaultKeys$7 as defaultKeys, | ||
underline_d_toggleUnderline as toggleUnderline, | ||
underline_d_queryIsUnderlineActive as queryIsUnderlineActive, | ||
}; | ||
} | ||
declare const spec$8: typeof specFactory$8; | ||
declare const plugins$8: typeof pluginsFactory$8; | ||
declare const commands$6: { | ||
queryIsBlockquoteActive: typeof queryIsBlockquoteActive; | ||
wrapInBlockquote: typeof wrapInBlockquote; | ||
}; | ||
declare const defaultKeys$6: { | ||
wrapIn: string; | ||
moveDown: string; | ||
moveUp: string; | ||
emptyCopy: string; | ||
emptyCut: string; | ||
insertEmptyParaAbove: string; | ||
insertEmptyParaBelow: string; | ||
}; | ||
declare function specFactory$8(): RawSpecs; | ||
declare function pluginsFactory$8({ markdownShortcut, keybindings, }?: { | ||
markdownShortcut?: boolean | undefined; | ||
keybindings?: { | ||
wrapIn: string; | ||
moveDown: string; | ||
moveUp: string; | ||
emptyCopy: string; | ||
emptyCut: string; | ||
insertEmptyParaAbove: string; | ||
insertEmptyParaBelow: string; | ||
} | undefined; | ||
}): RawPlugins; | ||
declare function queryIsBlockquoteActive(): (state: EditorState) => boolean; | ||
declare function wrapInBlockquote(): Command; | ||
declare function insertEmptyParaAbove$1(): Command; | ||
declare function insertEmptyParaBelow$1(): Command; | ||
declare const blockquote_d_queryIsBlockquoteActive: typeof queryIsBlockquoteActive; | ||
declare const blockquote_d_wrapInBlockquote: typeof wrapInBlockquote; | ||
declare namespace blockquote_d { | ||
export { | ||
spec$8 as spec, | ||
plugins$8 as plugins, | ||
commands$6 as commands, | ||
defaultKeys$6 as defaultKeys, | ||
blockquote_d_queryIsBlockquoteActive as queryIsBlockquoteActive, | ||
blockquote_d_wrapInBlockquote as wrapInBlockquote, | ||
insertEmptyParaAbove$1 as insertEmptyParaAbove, | ||
insertEmptyParaBelow$1 as insertEmptyParaBelow, | ||
}; | ||
} | ||
declare const spec$7: typeof specFactory$7; | ||
declare const plugins$7: typeof pluginsFactory$7; | ||
declare const commands$5: { | ||
toggleBulletList: typeof toggleBulletList; | ||
queryIsBulletListActive: typeof queryIsBulletListActive; | ||
}; | ||
declare const defaultKeys$5: { | ||
toggle: string; | ||
toggleTodo: string; | ||
}; | ||
declare function specFactory$7(): RawSpecs; | ||
declare function pluginsFactory$7({ markdownShortcut, todoMarkdownShortcut, keybindings, }?: { | ||
markdownShortcut?: boolean | undefined; | ||
todoMarkdownShortcut?: boolean | undefined; | ||
keybindings?: { | ||
toggle: string; | ||
toggleTodo: string; | ||
} | undefined; | ||
}): RawPlugins; | ||
declare function toggleBulletList(): Command; | ||
declare function toggleTodoList(): Command; | ||
declare function queryIsBulletListActive(): (state: EditorState) => boolean; | ||
declare function queryIsTodoListActive(): (state: EditorState) => boolean; | ||
declare const bulletList_d_toggleBulletList: typeof toggleBulletList; | ||
declare const bulletList_d_toggleTodoList: typeof toggleTodoList; | ||
declare const bulletList_d_queryIsBulletListActive: typeof queryIsBulletListActive; | ||
declare const bulletList_d_queryIsTodoListActive: typeof queryIsTodoListActive; | ||
declare namespace bulletList_d { | ||
export { | ||
spec$7 as spec, | ||
plugins$7 as plugins, | ||
commands$5 as commands, | ||
defaultKeys$5 as defaultKeys, | ||
bulletList_d_toggleBulletList as toggleBulletList, | ||
bulletList_d_toggleTodoList as toggleTodoList, | ||
bulletList_d_queryIsBulletListActive as queryIsBulletListActive, | ||
bulletList_d_queryIsTodoListActive as queryIsTodoListActive, | ||
}; | ||
} | ||
declare const spec$6: typeof specFactory$6; | ||
declare const plugins$6: typeof pluginsFactory$6; | ||
declare const commands$4: { | ||
queryIsCodeActiveBlock: typeof queryIsCodeActiveBlock; | ||
}; | ||
declare const defaultKeys$4: { | ||
toCodeBlock: string; | ||
@@ -331,4 +182,4 @@ moveDown: string; | ||
}; | ||
declare function specFactory$6(): RawSpecs; | ||
declare function pluginsFactory$6({ markdownShortcut, keybindings, }?: { | ||
declare function specFactory$a(): RawSpecs; | ||
declare function pluginsFactory$a({ markdownShortcut, keybindings, }?: { | ||
markdownShortcut?: boolean | undefined; | ||
@@ -348,6 +199,6 @@ keybindings?: { | ||
export { | ||
spec$6 as spec, | ||
plugins$6 as plugins, | ||
commands$4 as commands, | ||
defaultKeys$4 as defaultKeys, | ||
spec$a as spec, | ||
plugins$a as plugins, | ||
commands$8 as commands, | ||
defaultKeys$7 as defaultKeys, | ||
codeBlock_d_queryIsCodeActiveBlock as queryIsCodeActiveBlock, | ||
@@ -357,9 +208,9 @@ }; | ||
declare const spec$5: typeof specFactory$5; | ||
declare const plugins$5: typeof pluginsFactory$5; | ||
declare const defaultKeys$3: { | ||
declare const spec$9: typeof specFactory$9; | ||
declare const plugins$9: typeof pluginsFactory$9; | ||
declare const defaultKeys$6: { | ||
insert: string; | ||
}; | ||
declare function specFactory$5(): RawSpecs; | ||
declare function pluginsFactory$5({ keybindings }?: { | ||
declare function specFactory$9(): RawSpecs; | ||
declare function pluginsFactory$9({ keybindings }?: { | ||
keybindings?: { | ||
@@ -372,21 +223,21 @@ insert: string; | ||
export { | ||
spec$5 as spec, | ||
plugins$5 as plugins, | ||
defaultKeys$3 as defaultKeys, | ||
spec$9 as spec, | ||
plugins$9 as plugins, | ||
defaultKeys$6 as defaultKeys, | ||
}; | ||
} | ||
declare const spec$4: typeof specFactory$4; | ||
declare const plugins$4: typeof pluginsFactory$4; | ||
declare const commands$3: { | ||
declare const spec$8: typeof specFactory$8; | ||
declare const plugins$8: typeof pluginsFactory$8; | ||
declare const commands$7: { | ||
toggleHeading: typeof toggleHeading; | ||
queryIsHeadingActive: typeof queryIsHeadingActive; | ||
}; | ||
declare const defaultKeys$2: { | ||
declare const defaultKeys$5: { | ||
[index: string]: string | undefined; | ||
}; | ||
declare function specFactory$4({ levels }?: { | ||
declare function specFactory$8({ levels }?: { | ||
levels?: number[] | undefined; | ||
}): RawSpecs; | ||
declare function pluginsFactory$4({ markdownShortcut, keybindings, }?: { | ||
declare function pluginsFactory$8({ markdownShortcut, keybindings, }?: { | ||
markdownShortcut?: boolean; | ||
@@ -427,6 +278,6 @@ keybindings?: { | ||
export { | ||
spec$4 as spec, | ||
plugins$4 as plugins, | ||
commands$3 as commands, | ||
defaultKeys$2 as defaultKeys, | ||
spec$8 as spec, | ||
plugins$8 as plugins, | ||
commands$7 as commands, | ||
defaultKeys$5 as defaultKeys, | ||
heading_d_toggleHeading as toggleHeading, | ||
@@ -447,6 +298,6 @@ heading_d_queryIsHeadingActive as queryIsHeadingActive, | ||
declare const spec$3: typeof specFactory$3; | ||
declare const plugins$3: typeof pluginsFactory$3; | ||
declare function specFactory$3(): RawSpecs; | ||
declare function pluginsFactory$3({ markdownShortcut }?: { | ||
declare const spec$7: typeof specFactory$7; | ||
declare const plugins$7: typeof pluginsFactory$7; | ||
declare function specFactory$7(): RawSpecs; | ||
declare function pluginsFactory$7({ markdownShortcut }?: { | ||
markdownShortcut?: boolean | undefined; | ||
@@ -457,10 +308,118 @@ }): RawPlugins; | ||
export { | ||
spec$3 as spec, | ||
plugins$3 as plugins, | ||
spec$7 as spec, | ||
plugins$7 as plugins, | ||
}; | ||
} | ||
declare const spec$2: typeof specFactory$2; | ||
declare const plugins$2: typeof pluginsFactory$2; | ||
declare const commands$2: { | ||
declare const spec$6: typeof specFactory$6; | ||
declare const plugins$6: typeof pluginsFactory$6; | ||
declare const commands$6: {}; | ||
declare function specFactory$6(): RawSpecs; | ||
declare function pluginsFactory$6({ handleDragAndDrop, acceptFileType, createImageNodes, }?: { | ||
handleDragAndDrop?: boolean; | ||
acceptFileType?: string; | ||
createImageNodes?: (files: File[], imageType: NodeType, view: EditorView) => Promise<Node[]>; | ||
}): RawPlugins; | ||
declare const updateImageNodeAttribute: (attr?: Node['attrs']) => Command; | ||
declare const image_d_updateImageNodeAttribute: typeof updateImageNodeAttribute; | ||
declare namespace image_d { | ||
export { | ||
spec$6 as spec, | ||
plugins$6 as plugins, | ||
commands$6 as commands, | ||
image_d_updateImageNodeAttribute as updateImageNodeAttribute, | ||
}; | ||
} | ||
declare const spec$5: typeof specFactory$5; | ||
declare const plugins$5: typeof pluginsFactory$5; | ||
declare const commands$5: { | ||
toggleItalic: typeof toggleItalic; | ||
queryIsItalicActive: typeof queryIsItalicActive; | ||
}; | ||
declare const defaultKeys$4: { | ||
toggleItalic: string; | ||
}; | ||
declare function specFactory$5(): RawSpecs; | ||
declare function pluginsFactory$5({ keybindings }?: { | ||
keybindings?: { | ||
toggleItalic: string; | ||
} | undefined; | ||
}): RawPlugins; | ||
declare function toggleItalic(): Command; | ||
declare function queryIsItalicActive(): (state: EditorState) => boolean; | ||
declare const italic_d_toggleItalic: typeof toggleItalic; | ||
declare const italic_d_queryIsItalicActive: typeof queryIsItalicActive; | ||
declare namespace italic_d { | ||
export { | ||
spec$5 as spec, | ||
plugins$5 as plugins, | ||
commands$5 as commands, | ||
defaultKeys$4 as defaultKeys, | ||
italic_d_toggleItalic as toggleItalic, | ||
italic_d_queryIsItalicActive as queryIsItalicActive, | ||
}; | ||
} | ||
declare const spec$4: typeof specFactory$4; | ||
declare const plugins$4: typeof pluginsFactory$4; | ||
declare const commands$4: { | ||
createLink: typeof createLink; | ||
updateLink: typeof updateLink; | ||
queryLinkAttrs: typeof queryLinkAttrs; | ||
queryIsLinkAllowedInRange: typeof queryIsLinkAllowedInRange; | ||
queryIsLinkActive: typeof queryIsLinkActive; | ||
queryIsSelectionAroundLink: typeof queryIsSelectionAroundLink; | ||
}; | ||
declare function specFactory$4({ openOnClick }?: { | ||
openOnClick?: boolean | undefined; | ||
}): RawSpecs; | ||
declare function pluginsFactory$4(): RawPlugins; | ||
declare const URL_REGEX: RegExp; | ||
/** | ||
* | ||
* Commands | ||
* | ||
*/ | ||
/** | ||
* Sets the selection to href | ||
* @param {*} href | ||
*/ | ||
declare function createLink(href: string): Command; | ||
declare function updateLink(href?: string): Command; | ||
declare function queryLinkAttrs(): (state: EditorState) => { | ||
href: any; | ||
text: string; | ||
} | undefined; | ||
declare function queryIsLinkAllowedInRange(from: number, to: number): (state: EditorState) => boolean | undefined; | ||
declare function queryIsLinkActive(): (state: EditorState) => boolean; | ||
declare function queryIsSelectionAroundLink(): (state: EditorState) => boolean; | ||
declare const link_d_URL_REGEX: typeof URL_REGEX; | ||
declare const link_d_createLink: typeof createLink; | ||
declare const link_d_updateLink: typeof updateLink; | ||
declare const link_d_queryLinkAttrs: typeof queryLinkAttrs; | ||
declare const link_d_queryIsLinkAllowedInRange: typeof queryIsLinkAllowedInRange; | ||
declare const link_d_queryIsLinkActive: typeof queryIsLinkActive; | ||
declare const link_d_queryIsSelectionAroundLink: typeof queryIsSelectionAroundLink; | ||
declare namespace link_d { | ||
export { | ||
spec$4 as spec, | ||
plugins$4 as plugins, | ||
commands$4 as commands, | ||
link_d_URL_REGEX as URL_REGEX, | ||
link_d_createLink as createLink, | ||
link_d_updateLink as updateLink, | ||
link_d_queryLinkAttrs as queryLinkAttrs, | ||
link_d_queryIsLinkAllowedInRange as queryIsLinkAllowedInRange, | ||
link_d_queryIsLinkActive as queryIsLinkActive, | ||
link_d_queryIsSelectionAroundLink as queryIsSelectionAroundLink, | ||
}; | ||
} | ||
declare const spec$3: typeof specFactory$3; | ||
declare const plugins$3: typeof pluginsFactory$3; | ||
declare const commands$3: { | ||
indentListItem: typeof indentListItem; | ||
@@ -471,3 +430,3 @@ outdentListItem: typeof outdentListItem; | ||
}; | ||
declare const defaultKeys$1: { | ||
declare const defaultKeys$3: { | ||
toggleDone: string; | ||
@@ -483,4 +442,4 @@ indent: string; | ||
}; | ||
declare function specFactory$2(): RawSpecs; | ||
declare function pluginsFactory$2({ keybindings, nodeView, }?: { | ||
declare function specFactory$3(): RawSpecs; | ||
declare function pluginsFactory$3({ keybindings, nodeView, }?: { | ||
keybindings?: { | ||
@@ -516,6 +475,6 @@ toggleDone: string; | ||
export { | ||
spec$2 as spec, | ||
plugins$2 as plugins, | ||
commands$2 as commands, | ||
defaultKeys$1 as defaultKeys, | ||
spec$3 as spec, | ||
plugins$3 as plugins, | ||
commands$3 as commands, | ||
defaultKeys$3 as defaultKeys, | ||
listItemComponent_d_indentListItem as indentListItem, | ||
@@ -531,13 +490,13 @@ listItemComponent_d_outdentListItem as outdentListItem, | ||
declare const spec$1: typeof specFactory$1; | ||
declare const plugins$1: typeof pluginsFactory$1; | ||
declare const commands$1: { | ||
declare const spec$2: typeof specFactory$2; | ||
declare const plugins$2: typeof pluginsFactory$2; | ||
declare const commands$2: { | ||
toggleOrderedList: typeof toggleOrderedList; | ||
queryIsOrderedListActive: typeof queryIsOrderedListActive; | ||
}; | ||
declare const defaultKeys: { | ||
declare const defaultKeys$2: { | ||
toggle: string; | ||
}; | ||
declare function specFactory$1(): RawSpecs; | ||
declare function pluginsFactory$1({ keybindings }?: { | ||
declare function specFactory$2(): RawSpecs; | ||
declare function pluginsFactory$2({ keybindings }?: { | ||
keybindings?: { | ||
@@ -550,3 +509,2 @@ toggle: string; | ||
declare const orderedList_d_defaultKeys: typeof defaultKeys; | ||
declare const orderedList_d_toggleOrderedList: typeof toggleOrderedList; | ||
@@ -556,8 +514,39 @@ declare const orderedList_d_queryIsOrderedListActive: typeof queryIsOrderedListActive; | ||
export { | ||
spec$2 as spec, | ||
plugins$2 as plugins, | ||
commands$2 as commands, | ||
defaultKeys$2 as defaultKeys, | ||
orderedList_d_toggleOrderedList as toggleOrderedList, | ||
orderedList_d_queryIsOrderedListActive as queryIsOrderedListActive, | ||
}; | ||
} | ||
declare const spec$1: typeof specFactory$1; | ||
declare const plugins$1: typeof pluginsFactory$1; | ||
declare const commands$1: { | ||
toggleStrike: typeof toggleStrike; | ||
queryIsStrikeActive: typeof queryIsStrikeActive; | ||
}; | ||
declare const defaultKeys$1: { | ||
toggleStrike: string; | ||
}; | ||
declare function specFactory$1(): RawSpecs; | ||
declare function pluginsFactory$1({ keybindings }?: { | ||
keybindings?: { | ||
toggleStrike: string; | ||
} | undefined; | ||
}): RawPlugins; | ||
declare function toggleStrike(): Command; | ||
declare function queryIsStrikeActive(): (state: EditorState) => boolean; | ||
declare const strike_d_toggleStrike: typeof toggleStrike; | ||
declare const strike_d_queryIsStrikeActive: typeof queryIsStrikeActive; | ||
declare namespace strike_d { | ||
export { | ||
spec$1 as spec, | ||
plugins$1 as plugins, | ||
commands$1 as commands, | ||
orderedList_d_defaultKeys as defaultKeys, | ||
orderedList_d_toggleOrderedList as toggleOrderedList, | ||
orderedList_d_queryIsOrderedListActive as queryIsOrderedListActive, | ||
defaultKeys$1 as defaultKeys, | ||
strike_d_toggleStrike as toggleStrike, | ||
strike_d_queryIsStrikeActive as queryIsStrikeActive, | ||
}; | ||
@@ -568,21 +557,32 @@ } | ||
declare const plugins: typeof pluginsFactory; | ||
declare const commands: {}; | ||
declare const commands: { | ||
toggleUnderline: typeof toggleUnderline; | ||
queryIsUnderlineActive: typeof queryIsUnderlineActive; | ||
}; | ||
declare const defaultKeys: { | ||
toggleUnderline: string; | ||
}; | ||
declare function specFactory(): RawSpecs; | ||
declare function pluginsFactory({ handleDragAndDrop, acceptFileType, createImageNodes, }?: { | ||
handleDragAndDrop?: boolean; | ||
acceptFileType?: string; | ||
createImageNodes?: (files: File[], imageType: NodeType, view: EditorView) => Promise<Node[]>; | ||
}): RawPlugins; | ||
declare const updateImageNodeAttribute: (attr?: Node['attrs']) => Command; | ||
declare function pluginsFactory({ keybindings }?: { | ||
keybindings?: { | ||
toggleUnderline: string; | ||
} | undefined; | ||
}): InputRule | Plugin | undefined; | ||
declare function toggleUnderline(): Command; | ||
declare function queryIsUnderlineActive(): (state: EditorState) => boolean; | ||
declare const image_d_spec: typeof spec; | ||
declare const image_d_plugins: typeof plugins; | ||
declare const image_d_commands: typeof commands; | ||
declare const image_d_updateImageNodeAttribute: typeof updateImageNodeAttribute; | ||
declare namespace image_d { | ||
declare const underline_d_spec: typeof spec; | ||
declare const underline_d_plugins: typeof plugins; | ||
declare const underline_d_commands: typeof commands; | ||
declare const underline_d_defaultKeys: typeof defaultKeys; | ||
declare const underline_d_toggleUnderline: typeof toggleUnderline; | ||
declare const underline_d_queryIsUnderlineActive: typeof queryIsUnderlineActive; | ||
declare namespace underline_d { | ||
export { | ||
image_d_spec as spec, | ||
image_d_plugins as plugins, | ||
image_d_commands as commands, | ||
image_d_updateImageNodeAttribute as updateImageNodeAttribute, | ||
underline_d_spec as spec, | ||
underline_d_plugins as plugins, | ||
underline_d_commands as commands, | ||
underline_d_defaultKeys as defaultKeys, | ||
underline_d_toggleUnderline as toggleUnderline, | ||
underline_d_queryIsUnderlineActive as queryIsUnderlineActive, | ||
}; | ||
@@ -589,0 +589,0 @@ } |
{ | ||
"name": "@bangle.dev/base-components", | ||
"version": "0.29.0", | ||
"version": "0.29.1-alpha.0", | ||
"homepage": "https://bangle.dev", | ||
@@ -38,10 +38,10 @@ "authors": [ | ||
"dependencies": { | ||
"@bangle.dev/pm-commands": "0.29.0", | ||
"@bangle.dev/utils": "0.29.0", | ||
"@bangle.dev/pm-commands": "0.29.1-alpha.0", | ||
"@bangle.dev/utils": "0.29.1-alpha.0", | ||
"@types/jest": "^27.0.4" | ||
}, | ||
"devDependencies": { | ||
"@bangle.dev/core": "0.29.0", | ||
"@bangle.dev/pm": "0.29.0", | ||
"@bangle.dev/test-helpers": "0.29.0", | ||
"@bangle.dev/core": "0.29.1-alpha.0", | ||
"@bangle.dev/pm": "0.29.1-alpha.0", | ||
"@bangle.dev/test-helpers": "0.29.1-alpha.0", | ||
"@types/markdown-it": "^12.0.3", | ||
@@ -48,0 +48,0 @@ "markdown-it": "^10.0.0", |
@@ -0,1 +1,3 @@ | ||
import type { MarkdownSerializerState } from 'prosemirror-markdown'; | ||
import type { RawPlugins, RawSpecs } from '@bangle.dev/core'; | ||
@@ -8,3 +10,2 @@ import { | ||
Node, | ||
Schema, | ||
wrapIn, | ||
@@ -14,13 +15,14 @@ wrappingInputRule, | ||
import { | ||
copyEmptyCommand, | ||
cutEmptyCommand, | ||
moveNode, | ||
} from '@bangle.dev/pm-commands'; | ||
import { | ||
createObject, | ||
filter, | ||
findParentNodeOfType, | ||
getNodeType, | ||
getParaNodeType, | ||
insertEmpty, | ||
} from '@bangle.dev/utils'; | ||
import type { MarkdownSerializerState } from 'prosemirror-markdown'; | ||
import { | ||
copyEmptyCommand, | ||
cutEmptyCommand, | ||
moveNode, | ||
} from '@bangle.dev/pm-commands'; | ||
@@ -44,3 +46,2 @@ export const spec = specFactory; | ||
const name = 'blockquote'; | ||
const getTypeFromSchema = (schema: Schema) => schema.nodes[name]; | ||
@@ -79,3 +80,3 @@ function specFactory(): RawSpecs { | ||
return ({ schema }) => { | ||
const type = getTypeFromSchema(schema); | ||
const type = getNodeType(schema, name); | ||
return [ | ||
@@ -103,3 +104,3 @@ markdownShortcut && wrappingInputRule(/^\s*>\s$/, type), | ||
return (state: EditorState) => { | ||
const type = getTypeFromSchema(state.schema); | ||
const type = getNodeType(state, name); | ||
return Boolean(findParentNodeOfType(type)(state.selection)); | ||
@@ -113,3 +114,4 @@ }; | ||
(state, dispatch, _view) => { | ||
const type = getTypeFromSchema(state.schema); | ||
const type = getNodeType(state, name); | ||
return wrapIn(type)(state, dispatch); | ||
@@ -123,6 +125,9 @@ }, | ||
return (state, dispatch, view) => { | ||
return filter( | ||
isInBlockquote, | ||
insertEmpty(state.schema.nodes.paragraph, 'above', true), | ||
)(state, dispatch, view); | ||
const para = getParaNodeType(state); | ||
return filter(isInBlockquote, insertEmpty(para, 'above', true))( | ||
state, | ||
dispatch, | ||
view, | ||
); | ||
}; | ||
@@ -134,7 +139,10 @@ } | ||
return (state, dispatch, view) => { | ||
return filter( | ||
isInBlockquote, | ||
insertEmpty(state.schema.nodes.paragraph, 'below', true), | ||
)(state, dispatch, view); | ||
const para = getParaNodeType(state); | ||
return filter(isInBlockquote, insertEmpty(para, 'below', true))( | ||
state, | ||
dispatch, | ||
view, | ||
); | ||
}; | ||
} |
@@ -11,6 +11,7 @@ import type { RawPlugins, RawSpecs } from '@bangle.dev/core'; | ||
import { | ||
assertNotUndefined, | ||
createObject, | ||
isMarkActiveInSelection, | ||
markInputRule, | ||
markPasteRule, | ||
createObject, | ||
} from '@bangle.dev/utils'; | ||
@@ -30,4 +31,7 @@ | ||
const getTypeFromSchema = (schema: Schema) => schema.marks[name]; | ||
const getTypeFromSchema = (schema: Schema) => { | ||
const markType = schema.marks[name]; | ||
assertNotUndefined(markType, `markType ${name} not found`); | ||
return markType; | ||
}; | ||
function specFactory(): RawSpecs { | ||
@@ -93,3 +97,6 @@ return { | ||
return (state, dispatch, _view) => { | ||
return toggleMark(state.schema.marks[name])(state, dispatch); | ||
const markType = state.schema.marks[name]; | ||
assertNotUndefined(markType, `markType ${name} not found`); | ||
return toggleMark(markType)(state, dispatch); | ||
}; | ||
@@ -99,4 +106,7 @@ } | ||
export function queryIsBoldActive() { | ||
return (state: EditorState) => | ||
isMarkActiveInSelection(state.schema.marks[name])(state); | ||
return (state: EditorState) => { | ||
const markType = state.schema.marks[name]; | ||
assertNotUndefined(markType, `markType ${name} not found`); | ||
return isMarkActiveInSelection(markType)(state); | ||
}; | ||
} |
@@ -0,1 +1,4 @@ | ||
import type Token from 'markdown-it/lib/token'; | ||
import type { MarkdownSerializerState } from 'prosemirror-markdown'; | ||
import type { RawPlugins, RawSpecs } from '@bangle.dev/core'; | ||
@@ -9,10 +12,9 @@ import { | ||
Node, | ||
Schema, | ||
wrappingInputRule, | ||
} from '@bangle.dev/pm'; | ||
import type Token from 'markdown-it/lib/token'; | ||
import type { MarkdownSerializerState } from 'prosemirror-markdown'; | ||
import { parentHasDirectParentOfType } from '@bangle.dev/pm-commands'; | ||
import { toggleList } from './list-item/commands'; | ||
import { listIsTight } from './list-item/list-is-tight'; | ||
import { createObject, getNodeType } from '@bangle.dev/utils'; | ||
import { toggleList } from './list-commands'; | ||
import { listIsTight } from './list-is-tight'; | ||
import { | ||
@@ -23,4 +25,4 @@ isNodeTodo, | ||
wrappingInputRuleForTodo, | ||
} from './list-item/todo'; | ||
import { createObject } from '@bangle.dev/utils'; | ||
} from './list-todo'; | ||
export const spec = specFactory; | ||
@@ -39,4 +41,2 @@ export const plugins = pluginsFactory; | ||
const getTypeFromSchema = (schema: Schema) => schema.nodes[name]; | ||
function specFactory(): RawSpecs { | ||
@@ -83,3 +83,3 @@ return { | ||
return ({ schema }) => { | ||
const type = getTypeFromSchema(schema); | ||
const type = getNodeType(schema, name); | ||
@@ -111,3 +111,3 @@ return [ | ||
const handleBulletLists: Command = (state, dispatch, view) => | ||
toggleList(state.schema.nodes.bulletList, state.schema.nodes.listItem)( | ||
toggleList(getNodeType(state, 'bulletList'), state.schema.nodes.listItem)( | ||
state, | ||
@@ -124,3 +124,3 @@ dispatch, | ||
toggleList( | ||
state.schema.nodes.bulletList, | ||
getNodeType(state, 'bulletList'), | ||
state.schema.nodes.listItem, | ||
@@ -135,5 +135,4 @@ true, | ||
return (state: EditorState) => { | ||
const { schema } = state; | ||
return parentHasDirectParentOfType(schema.nodes['listItem'], [ | ||
schema.nodes['bulletList'], | ||
return parentHasDirectParentOfType(getNodeType(state, 'listItem'), [ | ||
getNodeType(state, 'bulletList'), | ||
])(state); | ||
@@ -148,4 +147,4 @@ }; | ||
return ( | ||
parentHasDirectParentOfType(schema.nodes['listItem'], [ | ||
schema.nodes['bulletList'], | ||
parentHasDirectParentOfType(getNodeType(state, 'listItem'), [ | ||
getNodeType(state, 'bulletList'), | ||
])(state) && isNodeTodo(state.selection.$from.node(-1), schema) | ||
@@ -152,0 +151,0 @@ ); |
@@ -0,1 +1,4 @@ | ||
import type Token from 'markdown-it/lib/token'; | ||
import type { MarkdownSerializerState } from 'prosemirror-markdown'; | ||
import type { RawPlugins, RawSpecs } from '@bangle.dev/core'; | ||
@@ -7,3 +10,2 @@ import { | ||
Node, | ||
Schema, | ||
setBlockType, | ||
@@ -17,6 +19,6 @@ textblockTypeInputRule, | ||
findParentNodeOfType, | ||
getNodeType, | ||
getParaNodeType, | ||
insertEmpty, | ||
} from '@bangle.dev/utils'; | ||
import type Token from 'markdown-it/lib/token'; | ||
import type { MarkdownSerializerState } from 'prosemirror-markdown'; | ||
@@ -37,3 +39,2 @@ export const spec = specFactory; | ||
const name = 'codeBlock'; | ||
const getTypeFromSchema = (schema: Schema) => schema.nodes[name]; | ||
@@ -82,3 +83,3 @@ function specFactory(): RawSpecs { | ||
return ({ schema }) => { | ||
const type = getTypeFromSchema(schema); | ||
const type = getNodeType(schema, name); | ||
@@ -99,3 +100,3 @@ return [ | ||
queryIsCodeActiveBlock(), | ||
insertEmpty(schema.nodes.paragraph, 'above', false), | ||
insertEmpty(getParaNodeType(schema), 'above', false), | ||
), | ||
@@ -107,3 +108,3 @@ ], | ||
queryIsCodeActiveBlock(), | ||
insertEmpty(schema.nodes.paragraph, 'below', false), | ||
insertEmpty(getParaNodeType(schema), 'below', false), | ||
), | ||
@@ -119,5 +120,5 @@ ], | ||
return (state: EditorState) => { | ||
const type = getTypeFromSchema(state.schema); | ||
const type = getNodeType(state, name); | ||
return Boolean(findParentNodeOfType(type)(state.selection)); | ||
}; | ||
} |
@@ -14,2 +14,4 @@ import type { RawPlugins, RawSpecs } from '@bangle.dev/core'; | ||
import { | ||
assertNotUndefined, | ||
createObject, | ||
filter, | ||
@@ -19,3 +21,2 @@ isMarkActiveInSelection, | ||
markPasteRule, | ||
createObject, | ||
} from '@bangle.dev/utils'; | ||
@@ -35,5 +36,14 @@ | ||
const getTypeFromSchema = (schema: Schema) => schema.marks[name]; | ||
const getTypeFromState = (state: EditorState) => state.schema.marks[name]; | ||
const getTypeFromSchema = (schema: Schema) => { | ||
const markType = schema.marks[name]; | ||
assertNotUndefined(markType, `markType ${name} not found`); | ||
return markType; | ||
}; | ||
const getTypeFromState = (state: EditorState) => { | ||
const markType = state.schema.marks[name]; | ||
assertNotUndefined(markType, `markType ${name} not found`); | ||
return markType; | ||
}; | ||
function specFactory(): RawSpecs { | ||
@@ -121,3 +131,3 @@ return { | ||
var moveRight: Command = (state, dispatch) => { | ||
const { code } = state.schema.marks; | ||
const code = getTypeFromState(state); | ||
const $cursor = (state.selection as TextSelection).$cursor!; | ||
@@ -239,8 +249,11 @@ | ||
function backticksFor(node: Node, side: number) { | ||
let ticks = /`+/g, | ||
m, | ||
len = 0; | ||
let ticks = /`+/g; | ||
let m: RegExpExecArray | null; | ||
let len = 0; | ||
if (node.isText) { | ||
while ((m = ticks.exec(node.text!))) { | ||
len = Math.max(len, m[0].length); | ||
let res = m[0]; | ||
if (typeof res === 'string') { | ||
len = Math.max(len, res.length); | ||
} | ||
} | ||
@@ -275,9 +288,17 @@ } | ||
export function toggleCode(): Command { | ||
return (state, dispatch) => | ||
toggleMark(state.schema.marks[name])(state, dispatch); | ||
return (state, dispatch) => { | ||
const markType = state.schema.marks[name]; | ||
assertNotUndefined(markType, `markType ${name} not found`); | ||
return toggleMark(markType)(state, dispatch); | ||
}; | ||
} | ||
export function queryIsCodeActive() { | ||
return (state: EditorState) => | ||
isMarkActiveInSelection(state.schema.marks[name])(state); | ||
return (state: EditorState) => { | ||
const markType = state.schema.marks[name]; | ||
assertNotUndefined(markType, `markType ${name} not found`); | ||
return isMarkActiveInSelection(markType)(state); | ||
}; | ||
} |
@@ -8,5 +8,5 @@ import type { RawPlugins, RawSpecs } from '@bangle.dev/core'; | ||
Node, | ||
Schema, | ||
} from '@bangle.dev/pm'; | ||
import { createObject } from '@bangle.dev/utils'; | ||
import { createObject, getNodeType } from '@bangle.dev/utils'; | ||
export const spec = specFactory; | ||
@@ -18,4 +18,2 @@ export const plugins = pluginsFactory; | ||
const getTypeFromSchema = (schema: Schema) => schema.nodes[name]; | ||
const name = 'hardBreak'; | ||
@@ -52,3 +50,3 @@ | ||
return ({ schema }) => { | ||
const type = getTypeFromSchema(schema); | ||
const type = getNodeType(schema, name); | ||
const command = chainCommands(exitCode, (state, dispatch) => { | ||
@@ -55,0 +53,0 @@ if (dispatch) { |
@@ -0,1 +1,4 @@ | ||
import type Token from 'markdown-it/lib/token'; | ||
import type { MarkdownSerializerState } from 'prosemirror-markdown'; | ||
import type { RawPlugins, RawSpecs } from '@bangle.dev/core'; | ||
@@ -8,3 +11,2 @@ import { | ||
Node, | ||
Schema, | ||
setBlockType, | ||
@@ -15,20 +17,20 @@ textblockTypeInputRule, | ||
import { | ||
copyEmptyCommand, | ||
cutEmptyCommand, | ||
jumpToEndOfNode, | ||
jumpToStartOfNode, | ||
moveNode, | ||
} from '@bangle.dev/pm-commands'; | ||
import { | ||
browser, | ||
ContentNodeWithPos, | ||
createObject, | ||
filter, | ||
findChildren, | ||
findParentNodeOfType, | ||
getNodeType, | ||
getParaNodeType, | ||
insertEmpty, | ||
createObject, | ||
NodeWithPos, | ||
} from '@bangle.dev/utils'; | ||
import type Token from 'markdown-it/lib/token'; | ||
import type { MarkdownSerializerState } from 'prosemirror-markdown'; | ||
import { | ||
copyEmptyCommand, | ||
cutEmptyCommand, | ||
jumpToEndOfNode, | ||
jumpToStartOfNode, | ||
moveNode, | ||
} from '@bangle.dev/pm-commands'; | ||
@@ -65,6 +67,5 @@ export const spec = specFactory; | ||
const defaultLevels = [1, 2, 3, 4, 5, 6]; | ||
const getTypeFromSchema = (schema: Schema) => schema.nodes[name]; | ||
const checkIsInHeading = (state: EditorState) => { | ||
const type = getTypeFromSchema(state.schema); | ||
const type = getNodeType(state, name); | ||
return findParentNodeOfType(type)(state.selection); | ||
@@ -161,3 +162,3 @@ }; | ||
const { levels }: OptionsType = specRegistry.options[name]; | ||
const type = getTypeFromSchema(schema); | ||
const type = getNodeType(schema, name); | ||
@@ -202,5 +203,7 @@ const levelBindings = Object.fromEntries( | ||
if (queryIsHeadingActive(level)(state)) { | ||
return setBlockType(state.schema.nodes.paragraph)(state, dispatch); | ||
const para = getParaNodeType(state); | ||
return setBlockType(para)(state, dispatch); | ||
} | ||
return setBlockType(state.schema.nodes[name], { level })(state, dispatch); | ||
return setBlockType(getNodeType(state, name), { level })(state, dispatch); | ||
}; | ||
@@ -211,3 +214,3 @@ } | ||
return (state: EditorState) => { | ||
const match = findParentNodeOfType(state.schema.nodes[name])( | ||
const match = findParentNodeOfType(getNodeType(state, name))( | ||
state.selection, | ||
@@ -228,3 +231,3 @@ ); | ||
return (state: EditorState) => { | ||
const match = findParentNodeOfType(state.schema.nodes[name])( | ||
const match = findParentNodeOfType(getNodeType(state, name))( | ||
state.selection, | ||
@@ -243,3 +246,3 @@ ); | ||
return (state, dispatch) => { | ||
const match = findParentNodeOfType(state.schema.nodes[name])( | ||
const match = findParentNodeOfType(getNodeType(state, name))( | ||
state.selection, | ||
@@ -269,3 +272,3 @@ ); | ||
end, | ||
state.schema.nodes[name].createChecked( | ||
getNodeType(state, name).createChecked( | ||
{ | ||
@@ -293,3 +296,3 @@ ...match.node.attrs, | ||
return (state, dispatch) => { | ||
const match = findParentNodeOfType(state.schema.nodes[name])( | ||
const match = findParentNodeOfType(getNodeType(state, name))( | ||
state.selection, | ||
@@ -317,3 +320,3 @@ ); | ||
Fragment.fromArray([ | ||
state.schema.nodes[name].createChecked( | ||
getNodeType(state, name).createChecked( | ||
{ | ||
@@ -342,7 +345,5 @@ ...match.node.attrs, | ||
return filter(checkIsInHeading, (state, dispatch, view) => { | ||
return insertEmpty(state.schema.nodes.paragraph, 'above', false)( | ||
state, | ||
dispatch, | ||
view, | ||
); | ||
const para = getParaNodeType(state); | ||
return insertEmpty(para, 'above', false)(state, dispatch, view); | ||
}); | ||
@@ -353,7 +354,5 @@ } | ||
return filter(checkIsInHeading, (state, dispatch, view) => { | ||
return insertEmpty(state.schema.nodes.paragraph, 'below', false)( | ||
state, | ||
dispatch, | ||
view, | ||
); | ||
const para = getParaNodeType(state); | ||
return insertEmpty(para, 'below', false)(state, dispatch, view); | ||
}); | ||
@@ -364,3 +363,3 @@ } | ||
return (state, dispatch) => { | ||
const match = findParentNodeOfType(state.schema.nodes[name])( | ||
const match = findParentNodeOfType(getNodeType(state, name))( | ||
state.selection, | ||
@@ -398,3 +397,3 @@ ); | ||
Fragment.fromArray([ | ||
state.schema.nodes[name].createChecked( | ||
getNodeType(state, name).createChecked( | ||
{ | ||
@@ -428,3 +427,3 @@ ...node.attrs, | ||
(node) => | ||
node.type === state.schema.nodes[name] && | ||
node.type === getNodeType(state, name) && | ||
Boolean(node.attrs.collapseContent), | ||
@@ -438,3 +437,3 @@ false, | ||
state.doc, | ||
(node) => node.type === state.schema.nodes[name], | ||
(node) => node.type === getNodeType(state, name), | ||
false, | ||
@@ -441,0 +440,0 @@ ); |
// From Prosemirror https://github.com/prosemirror/prosemirror-markdown/blob/6107527995873d6199bc533a753b614378747056/src/to_markdown.ts#L380 | ||
// Tries to wrap the string with `"` , if not `''` else `()` | ||
@@ -3,0 +4,0 @@ export function quote(str: string) { |
import type { RawPlugins, RawSpecs } from '@bangle.dev/core'; | ||
import { DOMOutputSpec, InputRule, Schema } from '@bangle.dev/pm'; | ||
import { safeInsert } from '@bangle.dev/utils'; | ||
import { getNodeType, getParaNodeType, safeInsert } from '@bangle.dev/utils'; | ||
@@ -10,4 +10,2 @@ export const spec = specFactory; | ||
const getTypeFromSchema = (schema: Schema) => schema.nodes[name]; | ||
function specFactory(): RawSpecs { | ||
@@ -34,3 +32,3 @@ return { | ||
return ({ schema }) => { | ||
const type = getTypeFromSchema(schema); | ||
const type = getNodeType(schema, name); | ||
@@ -67,3 +65,3 @@ return [ | ||
? safeInsert( | ||
state.schema.nodes.paragraph.createChecked(), | ||
getParaNodeType(state).createChecked(), | ||
tr.mapping.map($para.after()), | ||
@@ -70,0 +68,0 @@ )(tr) |
@@ -0,1 +1,3 @@ | ||
import type Token from 'markdown-it/lib/token'; | ||
import type { RawPlugins, RawSpecs } from '@bangle.dev/core'; | ||
@@ -11,6 +13,5 @@ import { | ||
PluginKey, | ||
Schema, | ||
} from '@bangle.dev/pm'; | ||
import { safeInsert } from '@bangle.dev/utils'; | ||
import type Token from 'markdown-it/lib/token'; | ||
import { getNodeType, safeInsert } from '@bangle.dev/utils'; | ||
import { quote } from './helpers'; | ||
@@ -24,4 +25,2 @@ | ||
const getTypeFromSchema = (schema: Schema) => schema.nodes[name]; | ||
function specFactory(): RawSpecs { | ||
@@ -95,3 +94,3 @@ return { | ||
return ({ schema }) => { | ||
const type = getTypeFromSchema(schema); | ||
const type = getNodeType(schema, name); | ||
@@ -152,3 +151,3 @@ return [ | ||
files, | ||
getTypeFromSchema(view.state.schema), | ||
getNodeType(view.state, name), | ||
view, | ||
@@ -180,9 +179,7 @@ ).then((imageNodes) => { | ||
} | ||
createImageNodes( | ||
files, | ||
getTypeFromSchema(view.state.schema), | ||
view, | ||
).then((imageNodes) => { | ||
addImagesToView(view, view.state.selection.from, imageNodes); | ||
}); | ||
createImageNodes(files, getNodeType(view.state, name), view).then( | ||
(imageNodes) => { | ||
addImagesToView(view, view.state.selection.from, imageNodes); | ||
}, | ||
); | ||
@@ -330,3 +327,3 @@ return true; | ||
const { node } = state.selection; | ||
if (node.type !== getTypeFromSchema(state.schema)) { | ||
if (node.type !== getNodeType(state, name)) { | ||
return false; | ||
@@ -333,0 +330,0 @@ } |
// marks | ||
import * as bold from './bold'; | ||
import * as code from './code'; | ||
import * as italic from './italic'; | ||
import * as link from './link'; | ||
import * as strike from './strike'; | ||
import * as underline from './underline'; | ||
// nodes | ||
import * as blockquote from './blockquote'; | ||
import * as bold from './bold'; | ||
import * as bulletList from './bullet-list'; | ||
import * as code from './code'; | ||
import * as codeBlock from './code-block'; | ||
@@ -16,23 +11,23 @@ import * as hardBreak from './hard-break'; | ||
import * as horizontalRule from './horizontal-rule'; | ||
import * as listItem from './list-item/list-item-component'; | ||
import * as image from './image'; | ||
import * as italic from './italic'; | ||
import * as link from './link'; | ||
import * as listItem from './list-item-component'; | ||
import * as orderedList from './ordered-list'; | ||
import * as image from './image'; | ||
import * as strike from './strike'; | ||
import * as underline from './underline'; | ||
export { | ||
doc, | ||
editorStateCounter, | ||
history, | ||
paragraph, | ||
text, | ||
history, | ||
editorStateCounter, | ||
} from '@bangle.dev/core'; | ||
export { | ||
blockquote, | ||
bold, | ||
bulletList, | ||
code, | ||
italic, | ||
link, | ||
strike, | ||
underline, | ||
blockquote, | ||
bulletList, | ||
codeBlock, | ||
@@ -42,5 +37,9 @@ hardBreak, | ||
horizontalRule, | ||
image, | ||
italic, | ||
link, | ||
listItem, | ||
orderedList, | ||
image, | ||
strike, | ||
underline, | ||
}; |
@@ -10,6 +10,7 @@ import type { RawPlugins, RawSpecs } from '@bangle.dev/core'; | ||
import { | ||
assertNotUndefined, | ||
createObject, | ||
isMarkActiveInSelection, | ||
markInputRule, | ||
markPasteRule, | ||
createObject, | ||
} from '@bangle.dev/utils'; | ||
@@ -29,3 +30,7 @@ | ||
const getTypeFromSchema = (schema: Schema) => schema.marks[name]; | ||
const getTypeFromSchema = (schema: Schema) => { | ||
const markType = schema.marks[name]; | ||
assertNotUndefined(markType, `markType ${name} not found`); | ||
return markType; | ||
}; | ||
@@ -71,3 +76,6 @@ function specFactory(): RawSpecs { | ||
return (state, dispatch, _view) => { | ||
return toggleMark(state.schema.marks[name])(state, dispatch); | ||
const markType = state.schema.marks[name]; | ||
assertNotUndefined(markType, `markType ${name} not found`); | ||
return toggleMark(markType)(state, dispatch); | ||
}; | ||
@@ -78,4 +86,7 @@ } | ||
return (state: EditorState) => { | ||
return isMarkActiveInSelection(state.schema.marks[name])(state); | ||
const markType = state.schema.marks[name]; | ||
assertNotUndefined(markType, `markType ${name} not found`); | ||
return isMarkActiveInSelection(markType)(state); | ||
}; | ||
} |
@@ -0,1 +1,3 @@ | ||
import type Token from 'markdown-it/lib/token'; | ||
import type { RawPlugins, RawSpecs } from '@bangle.dev/core'; | ||
@@ -14,2 +16,3 @@ import { | ||
import { | ||
assertNotUndefined, | ||
filter, | ||
@@ -20,3 +23,3 @@ getMarkAttrs, | ||
} from '@bangle.dev/utils'; | ||
import type Token from 'markdown-it/lib/token'; | ||
import { quote } from './helpers'; | ||
@@ -41,3 +44,7 @@ | ||
const getTypeFromSchema = (schema: Schema) => schema.marks[name]; | ||
const getTypeFromSchema = (schema: Schema) => { | ||
const markType = schema.marks[name]; | ||
assertNotUndefined(markType, `markType ${name} not found`); | ||
return markType; | ||
}; | ||
@@ -122,3 +129,3 @@ function specFactory({ openOnClick = false } = {}): RawSpecs { | ||
const { schema } = view.state; | ||
const attrs = getMarkAttrs(view.state, schema.marks.link); | ||
const attrs = getMarkAttrs(view.state, getTypeFromSchema(schema)); | ||
@@ -174,3 +181,3 @@ if (attrs.href && event.target instanceof HTMLAnchorElement) { | ||
// Ignore the leading space, if any | ||
leadingSpace.length > 0 ? start + 1 : start, | ||
leadingSpace && leadingSpace.length > 0 ? start + 1 : start, | ||
end, | ||
@@ -275,6 +282,6 @@ type.create({ href: href }), | ||
(state, dispatch) => { | ||
const linkMark = state.schema.marks.link; | ||
const linkMark = getTypeFromSchema(state.schema); | ||
let tr = state.tr.removeMark(from, to, linkMark); | ||
if (href) { | ||
const mark = state.schema.marks.link.create({ | ||
const mark = getTypeFromSchema(state.schema).create({ | ||
href: href, | ||
@@ -315,3 +322,3 @@ }); | ||
if (href.trim()) { | ||
const mark = state.schema.marks.link.create({ | ||
const mark = getTypeFromSchema(state.schema).create({ | ||
href: href, | ||
@@ -367,3 +374,3 @@ }); | ||
const type = state.schema.marks.link; | ||
const type = getTypeFromSchema(state.schema); | ||
@@ -385,3 +392,3 @@ const mark = type.isInSet(nodeAfter.marks || []); | ||
const $to = state.doc.resolve(to); | ||
const link = state.schema.marks.link; | ||
const link = getTypeFromSchema(state.schema); | ||
if ($from.parent === $to.parent && $from.parent.isTextblock) { | ||
@@ -395,3 +402,5 @@ return $from.parent.type.allowsMarkType(link); | ||
return (state: EditorState) => | ||
!!state.doc.type.schema.marks.link.isInSet(state.selection.$from.marks()); | ||
Boolean( | ||
getTypeFromSchema(state.schema).isInSet(state.selection.$from.marks()), | ||
); | ||
} | ||
@@ -408,5 +417,5 @@ | ||
$to.pos - $from.pos === node.nodeSize && | ||
!!state.doc.type.schema.marks.link.isInSet(node.marks) | ||
Boolean(getTypeFromSchema(state.schema).isInSet(node.marks)) | ||
); | ||
}; | ||
} |
@@ -0,1 +1,3 @@ | ||
import type Token from 'markdown-it/lib/token'; | ||
import type { RawPlugins, RawSpecs } from '@bangle.dev/core'; | ||
@@ -6,11 +8,10 @@ import { | ||
keymap, | ||
Schema, | ||
wrappingInputRule, | ||
} from '@bangle.dev/pm'; | ||
import type Token from 'markdown-it/lib/token'; | ||
import { parentHasDirectParentOfType } from '@bangle.dev/pm-commands'; | ||
import { toggleList } from './list-item/commands'; | ||
import { listIsTight } from './list-item/list-is-tight'; | ||
import { createObject } from '@bangle.dev/utils'; | ||
import { createObject, getNodeType } from '@bangle.dev/utils'; | ||
import { toggleList } from './list-commands'; | ||
import { listIsTight } from './list-is-tight'; | ||
export const spec = specFactory; | ||
@@ -27,3 +28,2 @@ export const plugins = pluginsFactory; | ||
const name = 'orderedList'; | ||
const getTypeFromSchema = (schema: Schema) => schema.nodes[name]; | ||
@@ -89,3 +89,3 @@ function specFactory(): RawSpecs { | ||
return ({ schema }) => { | ||
const type = getTypeFromSchema(schema); | ||
const type = getNodeType(schema, name); | ||
@@ -96,4 +96,4 @@ return [ | ||
type, | ||
(match) => ({ order: +match[1] }), | ||
(match, node) => node.childCount + node.attrs.order === +match[1], | ||
(match) => ({ order: +match[1]! }), | ||
(match, node) => node.childCount + node.attrs.order === +match[1]!, | ||
), | ||
@@ -108,6 +108,7 @@ keybindings && | ||
return (state, dispatch, view) => { | ||
return toggleList( | ||
state.schema.nodes.orderedList, | ||
state.schema.nodes.listItem, | ||
)(state, dispatch, view); | ||
return toggleList(getNodeType(state, name), state.schema.nodes.listItem)( | ||
state, | ||
dispatch, | ||
view, | ||
); | ||
}; | ||
@@ -118,7 +119,6 @@ } | ||
return (state: EditorState) => { | ||
const { schema } = state; | ||
return parentHasDirectParentOfType(schema.nodes['listItem'], [ | ||
schema.nodes[name], | ||
return parentHasDirectParentOfType(getNodeType(state, 'listItem'), [ | ||
getNodeType(state, name), | ||
])(state); | ||
}; | ||
} |
@@ -11,6 +11,7 @@ import type { RawPlugins, RawSpecs } from '@bangle.dev/core'; | ||
import { | ||
assertNotUndefined, | ||
createObject, | ||
isMarkActiveInSelection, | ||
markInputRule, | ||
markPasteRule, | ||
createObject, | ||
} from '@bangle.dev/utils'; | ||
@@ -30,4 +31,7 @@ | ||
const getTypeFromSchema = (schema: Schema) => schema.marks[name]; | ||
const getTypeFromSchema = (schema: Schema) => { | ||
const markType = schema.marks[name]; | ||
assertNotUndefined(markType, `markType ${name} not found`); | ||
return markType; | ||
}; | ||
function specFactory(): RawSpecs { | ||
@@ -84,3 +88,6 @@ return { | ||
return (state, dispatch, _view) => { | ||
return toggleMark(state.schema.marks[name])(state, dispatch); | ||
const markType = state.schema.marks[name]; | ||
assertNotUndefined(markType, `markType ${name} not found`); | ||
return toggleMark(markType)(state, dispatch); | ||
}; | ||
@@ -91,4 +98,7 @@ } | ||
return (state: EditorState) => { | ||
return isMarkActiveInSelection(state.schema.marks[name])(state); | ||
const markType = state.schema.marks[name]; | ||
assertNotUndefined(markType, `markType ${name} not found`); | ||
return isMarkActiveInSelection(markType)(state); | ||
}; | ||
} |
@@ -8,10 +8,11 @@ import type { RawSpecs } from '@bangle.dev/core'; | ||
keymap, | ||
Plugin, | ||
Schema, | ||
toggleMark, | ||
Plugin, | ||
} from '@bangle.dev/pm'; | ||
import { | ||
assertNotUndefined, | ||
createObject, | ||
isMarkActiveInSelection, | ||
markInputRule, | ||
createObject, | ||
markPasteRule, | ||
@@ -32,3 +33,7 @@ } from '@bangle.dev/utils'; | ||
const getTypeFromSchema = (schema: Schema) => schema.marks[name]; | ||
const getTypeFromSchema = (schema: Schema) => { | ||
const markType = schema.marks[name]; | ||
assertNotUndefined(markType, `markType ${name} not found`); | ||
return markType; | ||
}; | ||
@@ -86,3 +91,6 @@ function specFactory(): RawSpecs { | ||
return (state, dispatch, _view) => { | ||
return toggleMark(state.schema.marks[name])(state, dispatch); | ||
const markType = state.schema.marks[name]; | ||
assertNotUndefined(markType, `markType ${name} not found`); | ||
return toggleMark(markType)(state, dispatch); | ||
}; | ||
@@ -93,4 +101,7 @@ } | ||
return (state: EditorState) => { | ||
return isMarkActiveInSelection(state.schema.marks[name])(state); | ||
const markType = state.schema.marks[name]; | ||
assertNotUndefined(markType, `markType ${name} not found`); | ||
return isMarkActiveInSelection(markType)(state); | ||
}; | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
708088
22828
+ Added@bangle.dev/pm-commands@0.29.1-alpha.0(transitive)
+ Added@bangle.dev/utils@0.29.1-alpha.0(transitive)
- Removed@bangle.dev/pm-commands@0.29.0(transitive)
- Removed@bangle.dev/utils@0.29.0(transitive)