feat(plugins): 同步便利贴 sticky v1.0.6(文本回缩外框自动降高)
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 33s
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 33s
This commit is contained in:
1 parent
53f41c2f9f
commit
18dad1b9af
2 files changed
+26
-8
No files matched your search
+3
-3
@@ -64,9 +64,9 @@
|
||||
},
|
||||
{
|
||||
"id": "sticky",
|
||||
"file": "plugin-sticky.ec6ffaa21fe4.js",
|
||||
"version": "1.0.5",
|
||||
"integrity": "sha256-7G/6oh/kod4qe0Zvt25O/5OFbO1hWJdk36mHcYEH218="
|
||||
"file": "plugin-sticky.11daf5129b91.js",
|
||||
"version": "1.0.6",
|
||||
"integrity": "sha256-Edr1EpuRGNLA4VpHjXgZ7voREYyjTtnmMtwFvTFxOMQ="
|
||||
},
|
||||
{
|
||||
"id": "style-source",
|
||||
|
||||
+23
-5
@@ -299,7 +299,10 @@
|
||||
// 读出来还是旧高度,会自我锁死);
|
||||
// 2. 首次遇到「旧 h 明显大于内容」时把 node.h 校正到内容高度,顺手把外框 minHeight
|
||||
// 覆盖成同一个值——resize 起点 (onResizeStart 读 n0.h) 才和实际视觉一致,拖小立刻生效。
|
||||
// 用户之后手动拖大的 h 不会再次被校正(只针对首次记录的 stale h),所以仍然可以拖大拖小。
|
||||
// 区分两种 h:
|
||||
// - 插件自动跟随内容写出的 h:内容长高就涨、缩回就降(v1.0.6 修的「两行退回一行不缩」);
|
||||
// - 用户拖手柄改出的 h:h 相对上一帧变了 ⇒ 尊重手动尺寸,只在内容超过它时顶一下。
|
||||
// 首次遇到的旧大 h 校正一次(staleH),之后进入自动跟随。
|
||||
function fitOuterBox(st, node) {
|
||||
if (!st || !st.root || !node) return
|
||||
var toolsH = st.tools.offsetHeight || 30
|
||||
@@ -308,9 +311,24 @@
|
||||
var content = Math.round(toolsH + bodyH + 2) // +2 = 宿主节点上下各 1px 边框
|
||||
var h = Number(node.h) || 0
|
||||
if (st.staleH == null) st.staleH = h
|
||||
// 文字变大后内容超过旧 h:同步把 h 顶上去,resize 起点才不会滞后一大截。
|
||||
// 首次遇到的旧大 h 也校正到内容高度;用户之后拖出来的其它更大 h 原样保留。
|
||||
if (h < content - 2 || (h > content + 2 && st.staleH === h)) node.h = content
|
||||
|
||||
if (st.lastBoxH != null && h !== st.lastBoxH) {
|
||||
// 外部(用户拖手柄)改了 h:退出自动跟随,保留手动尺寸
|
||||
st.autoFollow = false
|
||||
} else if (st.autoFollow == null) {
|
||||
// 首帧:旧 h 若明显大于内容,先校正一次,然后进入自动跟随
|
||||
if (h > content + 2 && st.staleH === h) { node.h = content; h = content }
|
||||
st.autoFollow = true
|
||||
}
|
||||
|
||||
if (st.autoFollow) {
|
||||
// 自动跟随:文本/字号增减都双向贴合(这是两行退回一行能缩回去的关键)
|
||||
if (Math.abs(h - content) > 1) { node.h = content; h = content }
|
||||
} else if (h < content - 2) {
|
||||
// 手动尺寸只在内容超出时才顶高,不覆盖用户主动拖大的高度
|
||||
node.h = content; h = content
|
||||
}
|
||||
st.lastBoxH = h
|
||||
var floor = Math.max(content, Number(node.h) || 0)
|
||||
// root → host(.iwb-plugin-node-body) → card(.iwb-node)
|
||||
var card = st.root.parentNode && st.root.parentNode.parentNode
|
||||
@@ -418,7 +436,7 @@
|
||||
global.IWBPluginHost.register({
|
||||
id: 'sticky',
|
||||
name: '便利贴',
|
||||
version: '1.0.5',
|
||||
version: '1.0.6',
|
||||
apiVersion: 1,
|
||||
capabilities: ['panels', 'nodeTypes', 'canvas'],
|
||||
}, function (ctx) {
|
||||
Reference in new issue
Block a user