|
|
|
@ -7,7 +7,7 @@ import { GetEntity } from '../../Common/Utils';
|
|
|
|
|
import { DownPanelStore } from '../../UI/Store/DownPanelStore';
|
|
|
|
|
import { RoomRegion } from '../Room/Entity/Region/RoomRegion';
|
|
|
|
|
import { FontLoader } from './FontLoader';
|
|
|
|
|
import { Text } from './Text';
|
|
|
|
|
import { TEXT_HEIGHT_SCALE, Text } from './Text';
|
|
|
|
|
|
|
|
|
|
//这是一个单例类.
|
|
|
|
|
export class TextArea extends Singleton
|
|
|
|
@ -84,12 +84,13 @@ export class TextArea extends Singleton
|
|
|
|
|
}
|
|
|
|
|
CreateEditorArea(position?: Vector3)
|
|
|
|
|
{
|
|
|
|
|
let height = this.TextareaHeight;
|
|
|
|
|
let height = this.TextareaHeight * TEXT_HEIGHT_SCALE;
|
|
|
|
|
let pos = this.ScreenPostion;
|
|
|
|
|
|
|
|
|
|
// 因为textarea自适应宽高比较麻烦,所以用可编辑的div
|
|
|
|
|
let textarea = document.createElement('div');
|
|
|
|
|
let strs = this._CurrentValue.split("\n");
|
|
|
|
|
let row = strs.length;
|
|
|
|
|
let innnerHtml = strs.shift();
|
|
|
|
|
for (let s of strs)
|
|
|
|
|
innnerHtml += `<div>${s}</div>`;
|
|
|
|
@ -102,12 +103,12 @@ export class TextArea extends Singleton
|
|
|
|
|
let rect = canvasEl.getBoundingClientRect();
|
|
|
|
|
|
|
|
|
|
textarea.style.cssText = `
|
|
|
|
|
line-height:1;
|
|
|
|
|
line-height:${TEXT_HEIGHT_SCALE};
|
|
|
|
|
min-width:100px;
|
|
|
|
|
font-size:${height}px;
|
|
|
|
|
min-height:${height}px;
|
|
|
|
|
left:${position?.x ?? pos.x + rect.left}px;
|
|
|
|
|
top:${position?.y ?? pos.y - height + rect.top}px;
|
|
|
|
|
top:${position?.y ?? pos.y - height * TEXT_HEIGHT_SCALE * row + rect.top}px;
|
|
|
|
|
`;
|
|
|
|
|
this._AreaContiner.appendChild(textarea);
|
|
|
|
|
textarea.focus();
|
|
|
|
|