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