| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- <template>
- <div
- class="base-element-text"
- :style="{
- top: elementInfo.top + 'px',
- left: elementInfo.left + 'px',
- width: elementInfo.width + 'px',
- height: elementInfo.height + 'px',
- }"
- >
- <div
- class="rotate-wrapper"
- :style="{ transform: `rotate(${elementInfo.rotate}deg)` }"
- >
- <div
- class="element-content"
- :style="{
- width: elementInfo.vertical ? 'auto' : elementInfo.width + 'px',
- height: elementInfo.vertical ? elementInfo.height + 'px' : elementInfo.height + 'px',
- backgroundColor: elementInfo.fill,
- opacity: elementInfo.opacity,
- textShadow: shadowStyle,
- lineHeight: elementInfo.lineHeight,
- letterSpacing: (elementInfo.wordSpace || 0) + 'px',
- color: elementInfo.defaultColor,
- fontFamily: elementInfo.defaultFontName,
- writingMode: elementInfo.vertical ? 'vertical-rl' : 'horizontal-tb',
- display: 'flex',
- alignItems: 'center',
- overflow: hidden,
- }"
- >
- <div class="shape-text" :style="elementInfo.style" :class="[elementInfo.align, { 'editable': editable || elementInfo.content }]">
- <ElementOutline
- :width="elementInfo.width"
- :height="elementInfo.height"
- :outline="elementInfo.outline"
- />
- <div
- class="text ProseMirror-static"
- :class="{ 'thumbnail': target === 'thumbnail' }"
- :style="{
- '--paragraphSpace': `${elementInfo.paragraphSpace === undefined ? 5 : elementInfo.paragraphSpace}px`,
- }"
- v-html="elementInfo.content"
- ></div>
- </div>
- </div>
- </div>
- </div>
- </template>
- <script lang="ts" setup>
- import { computed } from 'vue'
- import type { PPTTextElement } from '@/types/slides'
- import ElementOutline from '@/views/components/element/ElementOutline.vue'
- import useElementShadow from '@/views/components/element/hooks/useElementShadow'
- const props = defineProps<{
- elementInfo: PPTTextElement
- target?: string
- }>()
- const shadow = computed(() => props.elementInfo.shadow)
- const { shadowStyle } = useElementShadow(shadow)
- </script>
- <style lang="scss" scoped>
- .base-element-text {
- position: absolute;
- }
- .rotate-wrapper {
- width: 100%;
- height: 100%;
- }
- .element-content {
- position: relative;
- padding: 10px;
- line-height: 1.5;
- word-break: break-word;
- font-family: Kaiti, "Kaiti SC", "Kaiti TC", Roboto, "Noto Sans SC", "Noto Sans TC", "Noto Sans KR", "Noto Sans JP", "Roboto", Roboto, "Noto Sans SC", "Noto Sans TC", "Noto Sans KR", "Noto Sans JP";
- .text {
- position: relative;
- &.thumbnail {
- pointer-events: none;
- }
- }
- }
- .shape-text {
- width:100%;
- height:100%;
- position: absolute;
- top: 0;
- bottom: 0;
- left: 0;
- right: 0;
- display: flex;
- flex-direction: column;
- word-break: break-word;
- pointer-events: none;
- white-space: pre;
- &.editable {
- pointer-events: all;
- }
- &.top {
- justify-content: flex-start;
- }
- &.middle {
- justify-content: center;
- left: 50%;
- top: 50%;
- -webkit-transform: translate(-50%,-50%);
- transform: translate(-50%,-50%);
- }
- &.bottom {
- justify-content: flex-end;
- }
- }
- </style>
|