29 lines
1.0 KiB
JavaScript
Raw Normal View History

2024-11-05 22:43:34 +08:00
"use strict";
define(function (require) {
const ctx = require('./common/ctx');
const eventListener = require('./event/MyEventListener')
const utils = require('./common/utils')
console.log("uuid1 -10 : ", utils.Uuid(ctx.usn));
// 初始化第一个输入框
let newParagraph = document.createElement("p");
2024-11-07 00:17:43 +08:00
newParagraph.setAttribute("id", utils.Uuid(ctx.usn, ctx.docType));
newParagraph.setAttribute("data-order", ctx.incrementNumThenReturn());
2024-11-06 14:07:30 +08:00
//前置 span
let preSpan = document.createElement("span");
2024-11-07 00:17:43 +08:00
preSpan.setAttribute("contenteditable", "false")
preSpan.setAttribute("data-flag", "span_pre")
2024-11-05 22:43:34 +08:00
//内置span
let span = document.createElement("span");
span.append(document.createElement("br"));
2024-11-07 00:17:43 +08:00
span.setAttribute("data-flag", "span_content")
newParagraph.append(preSpan, span);
2024-11-05 22:43:34 +08:00
//添加一行
ctx.MyRoot().append(newParagraph);
//收起选区到一个点,光标落在一个可编辑元素上
2024-11-06 14:07:30 +08:00
utils.GetSelection().setPosition(span, 0);
span.focus();
2024-11-05 22:43:34 +08:00
})