-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Dialog mode non-modal,
Ctrl-Shift-j
join lines, bug fixes
- Loading branch information
Showing
17 changed files
with
175 additions
and
214 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import {EditorView} from "@codemirror/view" | ||
const doJoinLines = (view: EditorView) => { | ||
const selection = view.state.selection | ||
const trs = [] | ||
const text = view.state.doc.toString() | ||
selection.ranges.forEach((rng, n) => { | ||
const to = rng.empty ? text.length : rng.to | ||
const tin = text.substring(rng.from, to) | ||
const tout = rng.empty | ||
? tin.replace(/\s*\n[\n\s]*/, ' ') | ||
: tin.replace(/\s*\n[\n\s]*/g, ' ') | ||
if (tout !== tin) | ||
trs.push({ | ||
changes: { | ||
from: rng.from, to: to, | ||
insert: tout | ||
} | ||
}) | ||
}) | ||
|
||
if (!trs.length) return false | ||
view.dispatch(...trs) | ||
return true | ||
|
||
} | ||
|
||
// Create extension with current ordinal | ||
function joinLines(options: {} = {}): [] { | ||
return [] | ||
} | ||
|
||
// Keyboard shortcuts | ||
const joinLinesKeymap = [ | ||
{ key: 'Ctrl-Shift-j', run: doJoinLines } | ||
] | ||
|
||
|
||
export {joinLines, joinLinesKeymap} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import {toHtml} from 'hast-util-to-html' | ||
import {list as _list} from 'hast-util-to-mdast/lib/handlers/list' | ||
import type {Content as MdastContent} from 'mdast' | ||
import type {H as HastH} from 'hast-util-to-mdast' | ||
|
||
/** | ||
* Convert inline media (audio/video) hast node to mdast | ||
*/ | ||
function listHastToMdast(h: HastH, node: any): void | MdastContent | MdastContent[] { | ||
return h.inTable | ||
? h(node, 'html', toHtml(node, {allowDangerousHtml: true})) | ||
: _list(h, node) | ||
} | ||
|
||
const tableBlockInlineHtmlHastHandler = { | ||
ul: listHastToMdast, | ||
ol: listHastToMdast | ||
} | ||
|
||
export {tableBlockInlineHtmlHastHandler} |
Oops, something went wrong.