import { getElementId, randomCode, deepCopy } from "../../plugins/utils"; import { getModel as createLines } from "../lines/model"; const COMPOSITION_PROP = { type: "COMPOSITION", sign: "subjective", topicNo: null, topicName: "" }; const MODEL = { type: "COMPOSITION", x: 0, y: 0, w: 0, h: 350, minHeight: 60, sign: "subjective", topicNo: null, isCovered: false, // 是否是最后一个答题区,初始只有一个答题区,默认为true isLast: true, // 是否是扩展的答题区 isExtend: false, // 是否展示作文题题目内容,作文题第1个答题区需要显示作文题题目内容 showTitle: true, // 答题区序号,默认为0 serialNumber: 0, // 每一个作文题都可以包含其他基础元件 // 新建作文题,默认插入5线的多横线 elements: [], // 作文题整体信息,COMPOSITION_PROP parent: {} }; const getModel = () => { return { id: getElementId(), key: randomCode(), ...COMPOSITION_PROP }; }; const getFullModel = compositionProp => { const parent = { ...compositionProp }; let model = { id: getElementId(), key: randomCode(), ...deepCopy(MODEL) }; model.w = parent.w; model.parent = parent; model.topicNo = parent.topicNo; let linesModel = createLines(); linesModel.lineCount = 5; linesModel.h = linesModel.lineCount * (linesModel.lineSpacing + 3); linesModel.w = parent.w; linesModel.container = { id: model.id, type: model.type }; model.h = linesModel.h + 50; model.elements.push(linesModel); return model; }; export { MODEL, getModel, getFullModel };