|
@@ -1,19 +1,21 @@
|
|
|
import { useEditor } from "@/modules/editor";
|
|
|
+import { Alignment } from "@ckeditor/ckeditor5-alignment";
|
|
|
import { Bold, Italic } from "@ckeditor/ckeditor5-basic-styles";
|
|
|
import { InlineEditor } from "@ckeditor/ckeditor5-editor-inline";
|
|
|
import { Essentials } from "@ckeditor/ckeditor5-essentials";
|
|
|
-import { Alignment } from "@ckeditor/ckeditor5-alignment";
|
|
|
import { FontFamily, FontSize } from "@ckeditor/ckeditor5-font";
|
|
|
import { Link } from "@ckeditor/ckeditor5-link";
|
|
|
import { Paragraph } from "@ckeditor/ckeditor5-paragraph";
|
|
|
import { defineComponent } from "vue";
|
|
|
import { string } from "vue-types";
|
|
|
+import { View } from "../View";
|
|
|
+import { css } from "@linaria/core";
|
|
|
|
|
|
-export const CkEditor = defineComponent({
|
|
|
+export const Text = defineComponent({
|
|
|
props: {
|
|
|
- value: string().def("请输入文本"),
|
|
|
+ value: string().def(""),
|
|
|
},
|
|
|
- emits: ["change"],
|
|
|
+ emits: ["update:value"],
|
|
|
setup(props, { emit }) {
|
|
|
const { store } = useEditor();
|
|
|
const config = {
|
|
@@ -47,19 +49,35 @@ export const CkEditor = defineComponent({
|
|
|
},
|
|
|
};
|
|
|
return () => (
|
|
|
- <ckeditor
|
|
|
- editor={InlineEditor}
|
|
|
- onBlur={(e: any, editor: InlineEditor) =>
|
|
|
- emit("change", editor.getData())
|
|
|
- }
|
|
|
- onReady={(editor: InlineEditor) => {
|
|
|
- editor.setData(props.value);
|
|
|
- if (!store.isEditMode) {
|
|
|
- editor.enableReadOnlyMode("editor");
|
|
|
+ <View>
|
|
|
+ <ckeditor
|
|
|
+ class={textStyle}
|
|
|
+ editor={InlineEditor}
|
|
|
+ onBlur={(e: any, editor: InlineEditor) =>
|
|
|
+ emit("update:value", editor.getData())
|
|
|
}
|
|
|
- }}
|
|
|
- config={config}
|
|
|
- />
|
|
|
+ onReady={(editor: InlineEditor) => {
|
|
|
+ editor.setData(props.value);
|
|
|
+ if (!store.isEditMode) {
|
|
|
+ editor.enableReadOnlyMode("editor");
|
|
|
+ }
|
|
|
+ }}
|
|
|
+ config={config}
|
|
|
+ />
|
|
|
+ </View>
|
|
|
);
|
|
|
},
|
|
|
});
|
|
|
+
|
|
|
+const textStyle = css`
|
|
|
+ p {
|
|
|
+ margin: 0;
|
|
|
+ }
|
|
|
+ &.ck.ck-editor__editable_inline {
|
|
|
+ > :last-child,
|
|
|
+ > :first-child {
|
|
|
+ margin-top: 0;
|
|
|
+ margin-bottom: 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+`;
|