|
@@ -7,7 +7,7 @@ import { FontColor, FontFamily, FontSize } from "@ckeditor/ckeditor5-font";
|
|
|
import { Link } from "@ckeditor/ckeditor5-link";
|
|
|
import { Paragraph } from "@ckeditor/ckeditor5-paragraph";
|
|
|
import { css } from "@linaria/core";
|
|
|
-import { defineComponent, watch, watchEffect } from "vue";
|
|
|
+import { defineComponent, ref, watch, watchEffect } from "vue";
|
|
|
import { string } from "vue-types";
|
|
|
import { useCompData } from ".";
|
|
|
import { View } from "../View";
|
|
@@ -18,7 +18,7 @@ export const Component = defineComponent({
|
|
|
},
|
|
|
setup(props) {
|
|
|
const comp = useCompData(props.compId);
|
|
|
- const { store, helper, actions } = useEditor();
|
|
|
+ const { store, helper, actions, controls } = useEditor();
|
|
|
const config = {
|
|
|
language: "zh-cn",
|
|
|
plugins: [
|
|
@@ -53,12 +53,22 @@ export const Component = defineComponent({
|
|
|
};
|
|
|
|
|
|
let editorInstance: InlineEditor;
|
|
|
+ let timeOut = ref();
|
|
|
|
|
|
watchEffect(() => {
|
|
|
+ console.log("1111", store.textEditingState);
|
|
|
if (!store.textEditingState) {
|
|
|
editorInstance?.setData(comp.value);
|
|
|
}
|
|
|
});
|
|
|
+ const toolbarClickListener = () => {
|
|
|
+ editorInstance.ui.view.toolbar.element?.addEventListener("click", () => {
|
|
|
+ if (timeOut.value) {
|
|
|
+ clearTimeout(timeOut.value);
|
|
|
+ timeOut.value = null;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ };
|
|
|
|
|
|
return () => (
|
|
|
<View
|
|
@@ -75,13 +85,19 @@ export const Component = defineComponent({
|
|
|
// editorInstance.getData()
|
|
|
// );
|
|
|
// store.setTextEditingState(false);
|
|
|
+
|
|
|
+ // console.log("blur", editorInstance);
|
|
|
+ timeOut.value = setTimeout(() => {
|
|
|
+ store.setTextEditingState(false);
|
|
|
+ controls.historyCtrl.history.submit();
|
|
|
+ }, 500);
|
|
|
}}
|
|
|
onFocus={() => {
|
|
|
store.setTextEditingState(true);
|
|
|
}}
|
|
|
onInput={(e: any) => {
|
|
|
if (editorInstance) {
|
|
|
- actions.updateCompData(
|
|
|
+ actions.setTextarea(
|
|
|
helper.findComp(props.compId) as DesignComp,
|
|
|
"value",
|
|
|
e
|
|
@@ -91,6 +107,7 @@ export const Component = defineComponent({
|
|
|
onReady={(editor: InlineEditor) => {
|
|
|
editorInstance = editor;
|
|
|
editor.setData(comp.value);
|
|
|
+ toolbarClickListener();
|
|
|
if (store.isPreview) {
|
|
|
editor.enableReadOnlyMode("editor");
|
|
|
}
|