|
@@ -4,6 +4,7 @@ import { Bold, Italic } from "@ckeditor/ckeditor5-basic-styles";
|
|
|
import { InlineEditor } from "@ckeditor/ckeditor5-editor-inline";
|
|
|
import { Essentials } from "@ckeditor/ckeditor5-essentials";
|
|
|
import { FontColor, FontFamily, FontSize } from "@ckeditor/ckeditor5-font";
|
|
|
+import LineHeight from "ckeditor5-line-height-latest/src/lineheight";
|
|
|
import { Link } from "@ckeditor/ckeditor5-link";
|
|
|
import { Paragraph } from "@ckeditor/ckeditor5-paragraph";
|
|
|
import { css } from "@linaria/core";
|
|
@@ -29,6 +30,7 @@ function GetConfig() {
|
|
|
fontSizeOptions.push({ title: s + "", model: s + "px" });
|
|
|
}
|
|
|
const fontFamilyOptions = [
|
|
|
+ { title: "默认字体", model: "" },
|
|
|
{ title: "宋体", model: "宋体,Songti,STSong,serif" },
|
|
|
{ title: "黑体", model: "黑体,Heiti,STHeiti,sans-serif" },
|
|
|
{ title: "仿宋", model: "仿宋,FangSong,STFangsong,serif" },
|
|
@@ -47,6 +49,7 @@ function GetConfig() {
|
|
|
FontSize,
|
|
|
FontFamily,
|
|
|
Alignment,
|
|
|
+ LineHeight,
|
|
|
],
|
|
|
fontSize: {
|
|
|
options: fontSizeOptions,
|
|
@@ -56,6 +59,9 @@ function GetConfig() {
|
|
|
options: fontFamilyOptions,
|
|
|
supportAllValues: true,
|
|
|
},
|
|
|
+ lineHeight: {
|
|
|
+ options: [1, 1.5, 2, 2.5, 3],
|
|
|
+ },
|
|
|
toolbar: {
|
|
|
items: [
|
|
|
// "undo",
|
|
@@ -63,7 +69,8 @@ function GetConfig() {
|
|
|
// "|",
|
|
|
"fontColor",
|
|
|
"fontFamily",
|
|
|
- "fontsize",
|
|
|
+ "fontSize",
|
|
|
+ "lineHeight",
|
|
|
"bold",
|
|
|
"italic",
|
|
|
"|",
|
|
@@ -109,12 +116,17 @@ export const Component = defineComponent({
|
|
|
}
|
|
|
}}
|
|
|
>
|
|
|
- {
|
|
|
- state.editableId ? <EditorComp compId={props.compId} key={state.editableId} onLost={()=>{
|
|
|
- state.editableId = "";
|
|
|
- }} />
|
|
|
- : <div innerHTML={comp.value} class={readOnlyText} />
|
|
|
- }
|
|
|
+ {state.editableId ? (
|
|
|
+ <EditorComp
|
|
|
+ compId={props.compId}
|
|
|
+ key={state.editableId}
|
|
|
+ onLost={() => {
|
|
|
+ state.editableId = "";
|
|
|
+ }}
|
|
|
+ />
|
|
|
+ ) : (
|
|
|
+ <div innerHTML={comp.value} class={readOnlyText} />
|
|
|
+ )}
|
|
|
</View>
|
|
|
);
|
|
|
},
|
|
@@ -164,49 +176,54 @@ const EditorComp = defineComponent({
|
|
|
|
|
|
const preHeight = ref<number>(0);
|
|
|
|
|
|
- return ()=><ckeditor
|
|
|
- class={textStyle}
|
|
|
- ref={inputRef}
|
|
|
- editor={InlineEditor}
|
|
|
- onInput={(value: any) => {
|
|
|
- if (editorInstance.value && comp.value !== value) {
|
|
|
- actions.updateCompData(comp, "value", value);
|
|
|
- nextTick(()=>{
|
|
|
-
|
|
|
- const h = helper.pxToDesignSize(inputRef.value?.$el.clientHeight);
|
|
|
- const isChange = Math.abs(preHeight.value - h) > 1;
|
|
|
- preHeight.value = h;
|
|
|
- actions.updateCompDatas(comp, ["value", "layout.size.1"], [value, preHeight.value])
|
|
|
- helper.extendStreamCard(store.currStreamCardId);
|
|
|
- if (isChange) {
|
|
|
- console.log("changing=>", isChange);
|
|
|
- actions.selectObjs([]);
|
|
|
- setTimeout(() => {
|
|
|
- actions.selectObjs([props.compId]);
|
|
|
- }, 0);
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
- }}
|
|
|
- onReady={(editor: InlineEditor) => {
|
|
|
- editorInstance.value = editor;
|
|
|
- console.log("editor")
|
|
|
- editor.setData(comp.value);
|
|
|
- editor.focus();
|
|
|
- const range = document.createRange();
|
|
|
- range.selectNodeContents(inputRef.value.$el);
|
|
|
- const selection = window.getSelection();
|
|
|
- selection?.removeAllRanges();
|
|
|
- selection?.addRange(range);
|
|
|
- }}
|
|
|
- config={GetConfig()}
|
|
|
- />
|
|
|
+ return () => (
|
|
|
+ <ckeditor
|
|
|
+ class={textStyle}
|
|
|
+ ref={inputRef}
|
|
|
+ editor={InlineEditor}
|
|
|
+ onInput={(value: any) => {
|
|
|
+ if (editorInstance.value && comp.value !== value) {
|
|
|
+ actions.updateCompData(comp, "value", value);
|
|
|
+ nextTick(() => {
|
|
|
+ const h = helper.pxToDesignSize(inputRef.value?.$el.clientHeight);
|
|
|
+ const isChange = Math.abs(preHeight.value - h) > 1;
|
|
|
+ preHeight.value = h;
|
|
|
+ actions.updateCompDatas(
|
|
|
+ comp,
|
|
|
+ ["value", "layout.size.1"],
|
|
|
+ [value, preHeight.value]
|
|
|
+ );
|
|
|
+ helper.extendStreamCard(store.currStreamCardId);
|
|
|
+ if (isChange) {
|
|
|
+ console.log("changing=>", isChange);
|
|
|
+ actions.selectObjs([]);
|
|
|
+ setTimeout(() => {
|
|
|
+ actions.selectObjs([props.compId]);
|
|
|
+ }, 0);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }}
|
|
|
+ onReady={(editor: InlineEditor) => {
|
|
|
+ editorInstance.value = editor;
|
|
|
+ console.log("editor");
|
|
|
+ editor.setData(comp.value);
|
|
|
+ editor.focus();
|
|
|
+ const range = document.createRange();
|
|
|
+ range.selectNodeContents(inputRef.value.$el);
|
|
|
+ const selection = window.getSelection();
|
|
|
+ selection?.removeAllRanges();
|
|
|
+ selection?.addRange(range);
|
|
|
+ }}
|
|
|
+ config={GetConfig()}
|
|
|
+ />
|
|
|
+ );
|
|
|
},
|
|
|
-})
|
|
|
+});
|
|
|
|
|
|
const readOnlyText = css`
|
|
|
pointer-events: none;
|
|
|
-`
|
|
|
+`;
|
|
|
|
|
|
const textStyle = css`
|
|
|
font-size: 12px;
|