提交 57c81b28 编写于 作者: 辛宝Otto's avatar 辛宝Otto 🥊

feat: rich-text 默认添加 click ,父容器相应 click 事件

上级 2e6f64bf
const PAGE_PATH = '/pages/component/rich-text/rich-text' const PAGE_PATH = '/pages/component/rich-text/rich-text'
describe('rich-text-test', () => { describe('rich-text-test', () => {
// 先屏蔽 android 及 web 平台 // 先屏蔽 android 及 web 平台
...@@ -9,12 +9,12 @@ describe('rich-text-test', () => { ...@@ -9,12 +9,12 @@ describe('rich-text-test', () => {
}) })
return return
} }
let page let page
beforeAll(async () => { beforeAll(async () => {
page = await program.reLaunch(PAGE_PATH) page = await program.reLaunch(PAGE_PATH)
await page.waitFor(1500); await page.waitFor(1500);
}) })
it('richt-text-height', async () => { it('richt-text-height', async () => {
...@@ -54,5 +54,13 @@ describe('rich-text-test', () => { ...@@ -54,5 +54,13 @@ describe('rich-text-test', () => {
autoTest: false autoTest: false
}); });
}); });
}) it('rich-text parent click', async () => {
const element = await page.$('#rich-text-parent')
await element.tap()
await page.waitFor(500)
const element2 = await page.$('#rich-text-str')
expect(await element2.text()).toBe("true")
})
})
...@@ -16,12 +16,16 @@ ...@@ -16,12 +16,16 @@
<text class="uni-subtitle-text">selectable</text> <text class="uni-subtitle-text">selectable</text>
<button type="default" @click="changeText">修改文本内容</button> <button type="default" @click="changeText">修改文本内容</button>
</view> </view>
<view class="text-box"> <view class="text-box" id="rich-text-parent" @click="richTextParentClick">
<rich-text id="richtext" style="border: 1px; border-style: solid; border-color: red;" :selectable="true" <rich-text id="richtext" style="border: 1px; border-style: solid; border-color: red;" :selectable="true"
:nodes="text"></rich-text> :nodes="text"></rich-text>
<view>
<text>rich-text-parent</text>
<text id='rich-text-str'>{{richTextStr}}</text>
</view>
</view> </view>
</view> </view>
</view> </view>
<rich-text v-if="autoTest" id="test-rich-text" :nodes="testNodes" :selectable="true" @itemclick="itemClickForTest" style="position: fixed;width: 100px;height: 100px;"></rich-text> <rich-text v-if="autoTest" id="test-rich-text" :nodes="testNodes" :selectable="true" @itemclick="itemClickForTest" style="position: fixed;width: 100px;height: 100px;"></rich-text>
</template> </template>
...@@ -31,11 +35,12 @@ ...@@ -31,11 +35,12 @@
return { return {
text: "<span>hello uni-app x!</span><br/><span>uni-app x,终极跨平台方案</span>", text: "<span>hello uni-app x!</span><br/><span>uni-app x,终极跨平台方案</span>",
richTextHeight: 0, richTextHeight: 0,
richTextElement: null as UniElement | null, richTextElement: null as UniElement | null,
// 自动化测试 // 自动化测试
autoTest: false, autoTest: false,
testNodes: '<img src="https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/uni@2x.png"></img>', testNodes: '<img src="https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/uni@2x.png"></img>',
isItemClickTrigger: false isItemClickTrigger: false,
richTextStr: false
} }
}, },
onReady() { onReady() {
...@@ -61,16 +66,19 @@ ...@@ -61,16 +66,19 @@
this.richTextHeight = elRect.height this.richTextHeight = elRect.height
console.log('richTextHeight:', this.richTextHeight) console.log('richTextHeight:', this.richTextHeight)
} }
}, },
// 自动化测试 // 自动化测试
itemClickForTest(_ : RichTextItemClickEvent) { itemClickForTest(_ : RichTextItemClickEvent) {
this.isItemClickTrigger = true; this.isItemClickTrigger = true;
}, },
getBoundingClientRectForTest() : DOMRect { getBoundingClientRectForTest() : DOMRect {
return uni.getElementById('test-rich-text')?.getBoundingClientRect()!; return uni.getElementById('test-rich-text')?.getBoundingClientRect()!;
}, },
getWindowInfoForTest() : GetWindowInfoResult { getWindowInfoForTest() : GetWindowInfoResult {
return uni.getWindowInfo(); return uni.getWindowInfo();
},
richTextParentClick() {
this.richTextStr = true;
} }
} }
} }
...@@ -81,4 +89,4 @@ ...@@ -81,4 +89,4 @@
padding: 20px 0; padding: 20px 0;
background-color: white; background-color: white;
} }
</style> </style>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册