really not helpful for now it seems. just stick to content editable for the moment
This commit is contained in:
parent
759169159d
commit
4041236b2d
1 changed files with 29 additions and 7 deletions
|
@ -1,9 +1,9 @@
|
||||||
import { Component, createContext, createEffect, createMemo, createSignal, For, onMount, untrack, useContext } from 'solid-js';
|
import { Accessor, Component, createContext, createEffect, createMemo, createSignal, For, onMount, untrack, useContext } from 'solid-js';
|
||||||
import { debounce } from '@solid-primitives/scheduled';
|
import { debounce } from '@solid-primitives/scheduled';
|
||||||
import { createSelection } from '@solid-primitives/selection';
|
import { createSelection } from '@solid-primitives/selection';
|
||||||
import { createSource } from '~/features/source';
|
import { createSource } from '~/features/source';
|
||||||
import css from './textarea.module.css';
|
|
||||||
import { isServer } from 'solid-js/web';
|
import { isServer } from 'solid-js/web';
|
||||||
|
import css from './textarea.module.css';
|
||||||
|
|
||||||
interface TextareaProps {
|
interface TextareaProps {
|
||||||
class?: string;
|
class?: string;
|
||||||
|
@ -44,11 +44,34 @@ export function Textarea(props: TextareaProps) {
|
||||||
}, 300);
|
}, 300);
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
new MutationObserver(mutate).observe(editorRef()!, {
|
const ref = editorRef()!;
|
||||||
subtree: true,
|
|
||||||
childList: true,
|
console.log(EditContext);
|
||||||
characterData: true,
|
|
||||||
|
const context = new EditContext({
|
||||||
|
text: source.out,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const sub = (event) => context.addEventListener(event, (e: Event) => console.log(event, e));
|
||||||
|
|
||||||
|
sub('textupdate');
|
||||||
|
sub('textformatupdate');
|
||||||
|
sub('characterboundupdate');
|
||||||
|
|
||||||
|
console.log(context);
|
||||||
|
|
||||||
|
ref.editContext = context;
|
||||||
|
|
||||||
|
const resize = () => context.updateControlBounds(ref.getBoundingClientRect());
|
||||||
|
|
||||||
|
window.addEventListener('resize', resize);
|
||||||
|
resize();
|
||||||
|
|
||||||
|
// new MutationObserver(mutate).observe(ref, {
|
||||||
|
// subtree: true,
|
||||||
|
// childList: true,
|
||||||
|
// characterData: true,
|
||||||
|
// });
|
||||||
});
|
});
|
||||||
|
|
||||||
return <>
|
return <>
|
||||||
|
@ -56,7 +79,6 @@ export function Textarea(props: TextareaProps) {
|
||||||
<div
|
<div
|
||||||
ref={setEditorRef}
|
ref={setEditorRef}
|
||||||
class={`${css.textarea} ${props.class}`}
|
class={`${css.textarea} ${props.class}`}
|
||||||
contentEditable
|
|
||||||
dir="auto"
|
dir="auto"
|
||||||
lang={props.lang}
|
lang={props.lang}
|
||||||
innerHTML={source.out}
|
innerHTML={source.out}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue