PR comments.
This commit is contained in:
parent
b3ccca051e
commit
dd96f4ef8e
|
@ -60,8 +60,8 @@
|
||||||
|
|
||||||
const dispatch = createEventDispatcher()
|
const dispatch = createEventDispatcher()
|
||||||
|
|
||||||
let textarea: HTMLDivElement | undefined
|
let textarea: HTMLDivElement
|
||||||
let editor: EditorView | undefined
|
let editor: EditorView
|
||||||
let mounted = false
|
let mounted = false
|
||||||
let isEditorInitialised = false
|
let isEditorInitialised = false
|
||||||
let queuedRefresh = false
|
let queuedRefresh = false
|
||||||
|
@ -73,7 +73,7 @@
|
||||||
|
|
||||||
$: {
|
$: {
|
||||||
if (autofocus && isEditorInitialised) {
|
if (autofocus && isEditorInitialised) {
|
||||||
editor?.focus()
|
editor.focus()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@
|
||||||
isDark = !currentTheme.includes("light")
|
isDark = !currentTheme.includes("light")
|
||||||
|
|
||||||
// Issue theme compartment update
|
// Issue theme compartment update
|
||||||
editor?.dispatch({
|
editor.dispatch({
|
||||||
effects: themeConfig.reconfigure([...(isDark ? [oneDark] : [])]),
|
effects: themeConfig.reconfigure([...(isDark ? [oneDark] : [])]),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -119,7 +119,7 @@
|
||||||
(editor.state.doc.toString() !== value || queuedRefresh)
|
(editor.state.doc.toString() !== value || queuedRefresh)
|
||||||
) {
|
) {
|
||||||
editor.dispatch({
|
editor.dispatch({
|
||||||
changes: { from: 0, to: editor.state.doc.length, insert: value! },
|
changes: { from: 0, to: editor.state.doc.length, insert: value },
|
||||||
})
|
})
|
||||||
queuedRefresh = false
|
queuedRefresh = false
|
||||||
}
|
}
|
||||||
|
@ -127,7 +127,7 @@
|
||||||
|
|
||||||
// Export a function to expose caret position
|
// Export a function to expose caret position
|
||||||
export const getCaretPosition = () => {
|
export const getCaretPosition = () => {
|
||||||
const selection_range = editor?.state.selection.ranges[0]
|
const selection_range = editor.state.selection.ranges[0]
|
||||||
return {
|
return {
|
||||||
start: selection_range?.from,
|
start: selection_range?.from,
|
||||||
end: selection_range?.to,
|
end: selection_range?.to,
|
||||||
|
@ -142,7 +142,7 @@
|
||||||
}) => {
|
}) => {
|
||||||
// Updating the value inside.
|
// Updating the value inside.
|
||||||
// Retain focus
|
// Retain focus
|
||||||
editor?.dispatch({
|
editor.dispatch({
|
||||||
changes: {
|
changes: {
|
||||||
from: opts.start || editor.state.doc.length,
|
from: opts.start || editor.state.doc.length,
|
||||||
to: opts.end || editor.state.doc.length,
|
to: opts.end || editor.state.doc.length,
|
||||||
|
@ -323,7 +323,7 @@
|
||||||
keymap.of(buildKeymap()),
|
keymap.of(buildKeymap()),
|
||||||
EditorView.domEventHandlers({
|
EditorView.domEventHandlers({
|
||||||
blur: () => {
|
blur: () => {
|
||||||
dispatch("blur", editor?.state.doc.toString())
|
dispatch("blur", editor.state.doc.toString())
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
EditorView.updateListener.of(v => {
|
EditorView.updateListener.of(v => {
|
||||||
|
|
|
@ -18,7 +18,7 @@ const defaultColors: ColorsOptions = {
|
||||||
nullColor: "cornflowerblue",
|
nullColor: "cornflowerblue",
|
||||||
}
|
}
|
||||||
|
|
||||||
const entityMap: Record<string, string> = {
|
const entityMap = {
|
||||||
"&": "&",
|
"&": "&",
|
||||||
"<": "<",
|
"<": "<",
|
||||||
">": ">",
|
">": ">",
|
||||||
|
|
Loading…
Reference in New Issue