qinyan 1 year ago
parent
commit
9c6eae2856

+ 4 - 1
src/modules/editor/components/CompUI/basicUI/Text/component.tsx

@@ -34,7 +34,7 @@ export const Component = createUIComp({
         Alignment,
       ],
       fontSize: {
-        options: [12, 14, 16, 18, 20, 24, 28, 32, 38,42, 46],
+        options: [12, 14, 16, 18, 20, 24, 28, 32, 38, 42, 46],
       },
       toolbar: {
         items: [
@@ -89,6 +89,9 @@ const textStyle = css`
   p {
     margin: 0;
   }
+  &.ck.ck-editor__editable_inline[dir="ltr"] {
+    text-align: inherit;
+  }
   &.ck.ck-editor__editable_inline {
     > :last-child,
     > :first-child {

+ 86 - 0
src/modules/editor/components/CompUI/customUI/Texts/Text1/component.tsx

@@ -0,0 +1,86 @@
+import { useEditor } from "@/modules/editor";
+import { css, cx } from "@linaria/core";
+import { watch } from "vue";
+import { string } from "vue-types";
+import { useCompData } from ".";
+import { Text } from "../../../basicUI";
+import { createUIComp } from "../../../defines/createUIComp";
+
+export const Component = createUIComp({
+  props: {
+    compId: string().isRequired,
+  },
+  setup(props) {
+    const { helper } = useEditor();
+    const { value } = useCompData(props.compId);
+
+    watch(
+      () => [value.columns],
+      () => {
+        const { columns, list } = value;
+        const offset = columns - list.length;
+        if (offset > 0) {
+          Array.from({ length: offset }, () => {
+            list.push({ label: "标题", content: "内容" });
+          });
+        } else {
+          list.splice(columns, offset * -1);
+        }
+      }
+    );
+
+    return () => (
+      <div class={rootStyles}>
+        {value.list.map((d) => (
+          <div
+            class="flex items-center text-primary px-0.1rem"
+            style={{
+              margin: helper.designToNaturalSize(value.gap),
+            }}
+          >
+            <div
+              class={cx(
+                "py-0.08rem px-0.1rem",
+                value.showBackground ? "label text-white" : "text-secondary"
+              )}
+              style={{
+                width: helper.designToNaturalSize(value.width),
+              }}
+            >
+              <Text.Component
+                v-model={[d.label, "value"]}
+                class="text text-center"
+              />
+            </div>
+            <Text.Component
+              v-model={[d.content, "value"]}
+              class="flex-1 ml-0.3rem"
+            />
+          </div>
+        ))}
+      </div>
+    );
+  },
+});
+
+const rootStyles = css`
+  .label {
+    position: relative;
+    z-index: 1;
+    .text {
+      position: relative;
+      z-index: 1;
+    }
+    &::before {
+      content: "";
+      position: absolute;
+      top: 0;
+      left: 4%;
+      width: 92%;
+      height: 100%;
+      background-color: #333;
+      transform: skewX(347deg);
+      z-index: 0;
+    }
+  }
+`;

+ 65 - 0
src/modules/editor/components/CompUI/customUI/Texts/Text1/index.ts

@@ -0,0 +1,65 @@
+import { InputNumber } from "ant-design-vue";
+import { createAttrsForm } from "../../../defines/createAttrsForm";
+import { createOptions } from "../../../defines/createOptions";
+
+export { Component } from "./component";
+
+export const { options, useCompData } = createOptions({
+  name: "标题",
+  thumbnail: require("./thumbnail.jpg"),
+  layout: { margin: "0.2rem 0.3rem", padding: " 0 0.2rem" },
+  value: {
+    gap: 20,
+    columns: 5,
+    width: 156,
+    showBackground: true,
+    list: [
+      {
+        label: "产品名称",
+        content: "P190(注塑)",
+      },
+      {
+        label: "产品规格",
+        content: "52英寸",
+      },
+      {
+        label: "产品厚度",
+        content: "1.0mm+0.05mm",
+      },
+      {
+        label: "产品底材",
+        content: "产品底材",
+      },
+      {
+        label: "产品用途",
+        content: "凉鞋、跟鞋、高更鞋、时尚休闲鞋等",
+      },
+    ],
+  },
+});
+
+export const Form = createAttrsForm([
+  {
+    label: "列表行数",
+    dataIndex: "value.columns",
+    component: InputNumber,
+  },
+  {
+    label: "行间距",
+    dataIndex: "value.gap",
+    component: InputNumber,
+  },
+  {
+    label: "标题宽度",
+    dataIndex: "value.width",
+    component: InputNumber,
+  },
+  {
+    label: "标题背景色",
+    dataIndex: "value.showBackground",
+    component: "Switch",
+    props: {
+      size: "small",
+    },
+  },
+]);

BIN
src/modules/editor/components/CompUI/customUI/Texts/Text1/thumbnail.jpg


+ 0 - 0
src/modules/editor/components/CompUI/customUI/Titles/Title2/index.tsx → src/modules/editor/components/CompUI/customUI/Titles/Title2/index.ts


+ 3 - 1
src/modules/editor/components/CompUI/customUI/index.ts

@@ -1,11 +1,13 @@
 export * as Card from "./Cards/Card";
-export * as CardList from "./Cards/CardList";
 export * as Card2 from "./Cards/Card2";
 export * as Card3 from "./Cards/Card3";
+export * as CardList from "./Cards/CardList";
 
 export * as Cover from "./Covers/Cover";
 export * as Cover2 from "./Covers/Cover2";
 
+export * as Text1 from "./Texts/Text1";
+
 export * as Title1 from "./Titles/Title1";
 export * as Title2 from "./Titles/Title2";
 export * as Title3 from "./Titles/Title3";