텍스트 상자 셰이프

텍스트 상자 셰이프는 빠른 텍스트 편집을 위한 셰이프입니다.

다음 샘플은 셰이프를 텍스트 상자에 설정하는 방법을 보여줍니다. 모든 자동 셰이프를 텍스트 상자에 설정할 수 있습니다.
<template> <div class="sample-tutorial"> <gc-spread-sheets class="sample-spreadsheets" @workbookInitialized="initSpread"> </gc-spread-sheets> <div class="options-container"> <div class="options-title">Options</div> <div class="options-tips">{{ optionsTips }}</div> <input type="checkbox" id="isTextBoxOption" v-model="isTextBox" @change="handleIsTextBoxChange" :disabled="!isShapeSelected"/> <label for="isTextBoxOption">isTextBox</label> <br/> <input type="checkbox" id="resizeToFitTextOption" v-model="resizeToFitText" @change="handleresizeToFitTextChange" :disabled="!isShapeSelected"/> <label for="resizeToFitTextOption">resizeToFitText</label> </div> </div> </template> <script> import Vue from "vue"; import "@mescius/spread-sheets-vue"; import "@mescius/spread-sheets-shapes"; import GC from "@mescius/spread-sheets"; import '@mescius/spread-sheets-resources-ko'; GC.Spread.Common.CultureManager.culture("ko-kr"); const shapeTips = "Text Box With resizeToFitText\nPlease try typing some text here."; const optionsTips = "Please select a shape and try to modify the options."; function setTextBox(shape) { let shapeStyle = shape.style(); shapeStyle.fill.color = 'white'; shapeStyle.textEffect.color = 'black'; shapeStyle.line.color = 'black'; shape.style(shapeStyle); shape.isTextBox(true); } let App = Vue.extend({ name: "app", data: function () { return { isTextBox: false, resizeToFitText: false, isShapeSelected: false, optionsTips: null }; }, methods: { initSpread(spread) { this.spread = spread; this.sheet = this.spread.getActiveSheet(); this.addShape(); this.optionsTips = optionsTips; this.sheet.bind(GC.Spread.Sheets.Events.ShapeSelectionChanged, undefined, (type, data) => { let shape = data.shape; if (shape && shape.isSelected()) { this.isTextBox = shape.isTextBox(); this.resizeToFitText = shape.style().textFrame.resizeToFitText; this.isShapeSelected = true; } else { this.isShapeSelected = false; } }); }, addShape() { const sheet = this.sheet; let textBox = sheet.shapes.add('', GC.Spread.Sheets.Shapes.AutoShapeType.rectangle, 100, 50); setTextBox(textBox); textBox.text("Text Box"); let textBox2 = sheet.shapes.add('', GC.Spread.Sheets.Shapes.AutoShapeType.rectangle, 350, 50, 250); textBox2.text(shapeTips); setTextBox(textBox2); let style = textBox2.style(); style.textFrame.resizeToFitText = true; textBox2.style(style); }, handleIsTextBoxChange() { let shapes = this.sheet.shapes.all(); shapes.filter((shape) => shape.isSelected()).forEach((shape) => { shape.isTextBox(this.isTextBox); }); }, handleresizeToFitTextChange() { let shapes = this.sheet.shapes.all(); shapes.filter((shape) => shape.isSelected()).forEach((shape) => { let shapeStyle = shape.style(); shapeStyle.textFrame.resizeToFitText = this.resizeToFitText; shape.style(shapeStyle); }); } } }); new Vue({render: h => h(App)}).$mount("#app"); </script> <style scoped> body { position: absolute; top: 0; bottom: 0; left: 0; right: 0; } #app { width: 100%; height: 100%; } .sample-tutorial { position: relative; height: 100%; overflow: hidden; } .sample-spreadsheets { width: calc(100% - 250px); height: 100%; /* overflow: hidden; */ } .options-container { position: absolute; top: 0px; right: 0px; width: 250px; height: 100%; padding: 12px; box-sizing: border-box; background: #fbfbfb; overflow: auto; user-select: none; } .options-title { font-size: larger; font-weight: bolder; margin-bottom: 10px; } .options-tips { margin-bottom: 10px; } </style>
<!doctype html> <html style="height:100%;font-size:14px;"> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <link rel="stylesheet" type="text/css" href="$DEMOROOT$/ko/vue/node_modules/@mescius/spread-sheets/styles/gc.spread.sheets.excel2013white.css"> <!-- SystemJS --> <script src="$DEMOROOT$/ko/vue/node_modules/systemjs/dist/system.src.js"></script> <script src="systemjs.config.js"></script> <script> System.import('./src/app.vue'); System.import('$DEMOROOT$/ko/lib/vue/license.js'); </script> </head> <body> <div id="app"></div> </body> </html>
(function (global) { System.config({ transpiler: 'plugin-babel', babelOptions: { es2015: true }, meta: { '*.css': { loader: 'css' }, '*.vue': { loader: 'vue-loader' } }, paths: { // paths serve as alias 'npm:': 'node_modules/' }, // map tells the System loader where to look for things map: { '@mescius/spread-sheets': 'npm:@mescius/spread-sheets/index.js', '@mescius/spread-sheets-vue': 'npm:@mescius/spread-sheets-vue/index.js', '@mescius/spread-sheets-shapes': 'npm:@mescius/spread-sheets-shapes/index.js', '@mescius/spread-sheets-resources-ko': 'npm:@mescius/spread-sheets-resources-ko/index.js', '@grapecity/jsob-test-dependency-package/react-components': 'npm:@grapecity/jsob-test-dependency-package/react-components/index.js', 'jszip': 'npm:jszip/dist/jszip.js', 'css': 'npm:systemjs-plugin-css/css.js', 'vue': 'npm:vue/dist/vue.min.js', 'vue-loader': 'npm:systemjs-vue-browser/index.js', 'tiny-emitter': 'npm:tiny-emitter/index.js', 'plugin-babel': 'npm:systemjs-plugin-babel/plugin-babel.js', 'systemjs-babel-build':'npm:systemjs-plugin-babel/systemjs-babel-browser.js' }, // packages tells the System loader how to load when no filename and/or no extension packages: { src: { defaultExtension: 'js' }, rxjs: { defaultExtension: 'js' }, "node_modules": { defaultExtension: 'js' } } }); })(this);