@shadow-garden/bapbong-ui 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +49 -21
- package/dist/index.js +49 -21
- package/dist/lib/link-panel.d.ts +11 -0
- package/dist/lib/link-panel.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -1103,6 +1103,8 @@ var STYLE6 = `
|
|
|
1103
1103
|
.bb-linkpanel-field svg{flex:none;opacity:.55}
|
|
1104
1104
|
.bb-linkpanel-input{flex:1;min-width:0;height:30px;border:0;background:transparent;color:inherit;font:inherit;font-size:13px;outline:none}
|
|
1105
1105
|
.bb-linkpanel-href{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:13px;color:var(--bb-ui-accent,#d85a30)}
|
|
1106
|
+
.bb-linkpanel-icon{display:inline-flex;flex:none;opacity:.55}
|
|
1107
|
+
.bb-linkpanel-stale{opacity:.6;font-style:italic;color:inherit}
|
|
1106
1108
|
.bb-linkpanel-btn{display:inline-flex;align-items:center;justify-content:center;width:28px;height:28px;padding:0;border:0;border-radius:6px;background:transparent;color:inherit;cursor:pointer;flex:none}
|
|
1107
1109
|
.bb-linkpanel-btn:hover{background:var(--bb-ui-hover,#f1efe8)}
|
|
1108
1110
|
.bb-linkpanel-apply{font:inherit;font-size:13px;font-weight:600;color:var(--bb-ui-accent,#d85a30);background:transparent;border:0;border-radius:6px;padding:6px 8px;cursor:pointer;flex:none}
|
|
@@ -1114,7 +1116,9 @@ var ICONS = {
|
|
|
1114
1116
|
text: '<svg viewBox="0 0 16 16" width="15" height="15" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 4V2.5h10V4M8 2.5v11M6 13.5h4"/></svg>',
|
|
1115
1117
|
copy: '<svg viewBox="0 0 16 16" width="15" height="15" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="5.5" y="5.5" width="8" height="8" rx="1.5"/><path d="M10.5 5.5v-2a1 1 0 0 0-1-1h-6a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2"/></svg>',
|
|
1116
1118
|
edit: '<svg viewBox="0 0 16 16" width="15" height="15" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m9.5 3.5 3 3L6 13l-3.5.5L3 10z"/><path d="m11 2 .9-.9a1.55 1.55 0 0 1 2.2 0l.8.8a1.55 1.55 0 0 1 0 2.2L14 5"/></svg>',
|
|
1117
|
-
unlink: '<svg viewBox="0 0 16 16" width="15" height="15" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M7.5 4.5 9 3a2.47 2.47 0 0 1 3.5 0L13 3.5a2.47 2.47 0 0 1 0 3.5l-1.5 1.5"/><path d="M8.5 11.5 7 13a2.47 2.47 0 0 1-3.5 0L3 12.5a2.47 2.47 0 0 1 0-3.5l1.5-1.5"/><path d="m3 3 10 10"/></svg>'
|
|
1119
|
+
unlink: '<svg viewBox="0 0 16 16" width="15" height="15" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M7.5 4.5 9 3a2.47 2.47 0 0 1 3.5 0L13 3.5a2.47 2.47 0 0 1 0 3.5l-1.5 1.5"/><path d="M8.5 11.5 7 13a2.47 2.47 0 0 1-3.5 0L3 12.5a2.47 2.47 0 0 1 0-3.5l1.5-1.5"/><path d="m3 3 10 10"/></svg>',
|
|
1120
|
+
bookmark: '<svg viewBox="0 0 16 16" width="15" height="15" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M4 2.5h8v11l-4-3-4 3z"/></svg>',
|
|
1121
|
+
goTo: '<svg viewBox="0 0 16 16" width="15" height="15" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 8h9"/><path d="m8.5 4.5 4 3.5-4 3.5"/></svg>'
|
|
1118
1122
|
};
|
|
1119
1123
|
var current2 = null;
|
|
1120
1124
|
var currentKey = null;
|
|
@@ -1190,26 +1194,50 @@ function showLinkPanel(opts) {
|
|
|
1190
1194
|
el.textContent = "";
|
|
1191
1195
|
const row = document.createElement("div");
|
|
1192
1196
|
row.className = "bb-linkpanel-row";
|
|
1193
|
-
const
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1197
|
+
const internal = opts.internal;
|
|
1198
|
+
if (internal) {
|
|
1199
|
+
const icon = document.createElement("span");
|
|
1200
|
+
icon.className = "bb-linkpanel-icon";
|
|
1201
|
+
icon.innerHTML = ICONS.bookmark;
|
|
1202
|
+
row.appendChild(icon);
|
|
1203
|
+
const label = document.createElement("span");
|
|
1204
|
+
label.className = "bb-linkpanel-href";
|
|
1205
|
+
label.textContent = internal.label ?? "V\u1ECB tr\xED kh\xF4ng c\xF2n trong t\xE0i li\u1EC7u";
|
|
1206
|
+
label.title = internal.label ?? existing.href;
|
|
1207
|
+
if (!internal.label) label.classList.add("bb-linkpanel-stale");
|
|
1208
|
+
row.appendChild(label);
|
|
1209
|
+
if (internal.label) {
|
|
1210
|
+
row.appendChild(
|
|
1211
|
+
iconBtn(ICONS.goTo, "\u0110i t\u1EDBi v\u1ECB tr\xED n\xE0y", () => {
|
|
1212
|
+
closeCurrent2();
|
|
1213
|
+
internal.onGo();
|
|
1214
|
+
})
|
|
1215
|
+
);
|
|
1216
|
+
}
|
|
1217
|
+
} else {
|
|
1218
|
+
const href = document.createElement("span");
|
|
1219
|
+
href.className = "bb-linkpanel-href";
|
|
1220
|
+
href.textContent = existing.href;
|
|
1221
|
+
href.title = existing.href;
|
|
1222
|
+
row.appendChild(href);
|
|
1223
|
+
row.appendChild(
|
|
1224
|
+
iconBtn(ICONS.copy, "Copy link", () => {
|
|
1225
|
+
void navigator.clipboard?.writeText(existing.href).catch(() => void 0);
|
|
1226
|
+
closeCurrent2();
|
|
1227
|
+
})
|
|
1228
|
+
);
|
|
1229
|
+
}
|
|
1230
|
+
if (!internal?.generated) {
|
|
1231
|
+
row.appendChild(
|
|
1232
|
+
iconBtn(ICONS.edit, "Edit link", () => renderForm(existing))
|
|
1233
|
+
);
|
|
1234
|
+
row.appendChild(
|
|
1235
|
+
iconBtn(ICONS.unlink, "Remove link", () => {
|
|
1236
|
+
closeCurrent2();
|
|
1237
|
+
opts.onUnlink?.();
|
|
1238
|
+
})
|
|
1239
|
+
);
|
|
1240
|
+
}
|
|
1213
1241
|
el.appendChild(row);
|
|
1214
1242
|
place(el, opts.anchor);
|
|
1215
1243
|
};
|
package/dist/index.js
CHANGED
|
@@ -1060,6 +1060,8 @@ var STYLE6 = `
|
|
|
1060
1060
|
.bb-linkpanel-field svg{flex:none;opacity:.55}
|
|
1061
1061
|
.bb-linkpanel-input{flex:1;min-width:0;height:30px;border:0;background:transparent;color:inherit;font:inherit;font-size:13px;outline:none}
|
|
1062
1062
|
.bb-linkpanel-href{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:13px;color:var(--bb-ui-accent,#d85a30)}
|
|
1063
|
+
.bb-linkpanel-icon{display:inline-flex;flex:none;opacity:.55}
|
|
1064
|
+
.bb-linkpanel-stale{opacity:.6;font-style:italic;color:inherit}
|
|
1063
1065
|
.bb-linkpanel-btn{display:inline-flex;align-items:center;justify-content:center;width:28px;height:28px;padding:0;border:0;border-radius:6px;background:transparent;color:inherit;cursor:pointer;flex:none}
|
|
1064
1066
|
.bb-linkpanel-btn:hover{background:var(--bb-ui-hover,#f1efe8)}
|
|
1065
1067
|
.bb-linkpanel-apply{font:inherit;font-size:13px;font-weight:600;color:var(--bb-ui-accent,#d85a30);background:transparent;border:0;border-radius:6px;padding:6px 8px;cursor:pointer;flex:none}
|
|
@@ -1071,7 +1073,9 @@ var ICONS = {
|
|
|
1071
1073
|
text: '<svg viewBox="0 0 16 16" width="15" height="15" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 4V2.5h10V4M8 2.5v11M6 13.5h4"/></svg>',
|
|
1072
1074
|
copy: '<svg viewBox="0 0 16 16" width="15" height="15" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="5.5" y="5.5" width="8" height="8" rx="1.5"/><path d="M10.5 5.5v-2a1 1 0 0 0-1-1h-6a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2"/></svg>',
|
|
1073
1075
|
edit: '<svg viewBox="0 0 16 16" width="15" height="15" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m9.5 3.5 3 3L6 13l-3.5.5L3 10z"/><path d="m11 2 .9-.9a1.55 1.55 0 0 1 2.2 0l.8.8a1.55 1.55 0 0 1 0 2.2L14 5"/></svg>',
|
|
1074
|
-
unlink: '<svg viewBox="0 0 16 16" width="15" height="15" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M7.5 4.5 9 3a2.47 2.47 0 0 1 3.5 0L13 3.5a2.47 2.47 0 0 1 0 3.5l-1.5 1.5"/><path d="M8.5 11.5 7 13a2.47 2.47 0 0 1-3.5 0L3 12.5a2.47 2.47 0 0 1 0-3.5l1.5-1.5"/><path d="m3 3 10 10"/></svg>'
|
|
1076
|
+
unlink: '<svg viewBox="0 0 16 16" width="15" height="15" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M7.5 4.5 9 3a2.47 2.47 0 0 1 3.5 0L13 3.5a2.47 2.47 0 0 1 0 3.5l-1.5 1.5"/><path d="M8.5 11.5 7 13a2.47 2.47 0 0 1-3.5 0L3 12.5a2.47 2.47 0 0 1 0-3.5l1.5-1.5"/><path d="m3 3 10 10"/></svg>',
|
|
1077
|
+
bookmark: '<svg viewBox="0 0 16 16" width="15" height="15" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M4 2.5h8v11l-4-3-4 3z"/></svg>',
|
|
1078
|
+
goTo: '<svg viewBox="0 0 16 16" width="15" height="15" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 8h9"/><path d="m8.5 4.5 4 3.5-4 3.5"/></svg>'
|
|
1075
1079
|
};
|
|
1076
1080
|
var current2 = null;
|
|
1077
1081
|
var currentKey = null;
|
|
@@ -1147,26 +1151,50 @@ function showLinkPanel(opts) {
|
|
|
1147
1151
|
el.textContent = "";
|
|
1148
1152
|
const row = document.createElement("div");
|
|
1149
1153
|
row.className = "bb-linkpanel-row";
|
|
1150
|
-
const
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1154
|
+
const internal = opts.internal;
|
|
1155
|
+
if (internal) {
|
|
1156
|
+
const icon = document.createElement("span");
|
|
1157
|
+
icon.className = "bb-linkpanel-icon";
|
|
1158
|
+
icon.innerHTML = ICONS.bookmark;
|
|
1159
|
+
row.appendChild(icon);
|
|
1160
|
+
const label = document.createElement("span");
|
|
1161
|
+
label.className = "bb-linkpanel-href";
|
|
1162
|
+
label.textContent = internal.label ?? "V\u1ECB tr\xED kh\xF4ng c\xF2n trong t\xE0i li\u1EC7u";
|
|
1163
|
+
label.title = internal.label ?? existing.href;
|
|
1164
|
+
if (!internal.label) label.classList.add("bb-linkpanel-stale");
|
|
1165
|
+
row.appendChild(label);
|
|
1166
|
+
if (internal.label) {
|
|
1167
|
+
row.appendChild(
|
|
1168
|
+
iconBtn(ICONS.goTo, "\u0110i t\u1EDBi v\u1ECB tr\xED n\xE0y", () => {
|
|
1169
|
+
closeCurrent2();
|
|
1170
|
+
internal.onGo();
|
|
1171
|
+
})
|
|
1172
|
+
);
|
|
1173
|
+
}
|
|
1174
|
+
} else {
|
|
1175
|
+
const href = document.createElement("span");
|
|
1176
|
+
href.className = "bb-linkpanel-href";
|
|
1177
|
+
href.textContent = existing.href;
|
|
1178
|
+
href.title = existing.href;
|
|
1179
|
+
row.appendChild(href);
|
|
1180
|
+
row.appendChild(
|
|
1181
|
+
iconBtn(ICONS.copy, "Copy link", () => {
|
|
1182
|
+
void navigator.clipboard?.writeText(existing.href).catch(() => void 0);
|
|
1183
|
+
closeCurrent2();
|
|
1184
|
+
})
|
|
1185
|
+
);
|
|
1186
|
+
}
|
|
1187
|
+
if (!internal?.generated) {
|
|
1188
|
+
row.appendChild(
|
|
1189
|
+
iconBtn(ICONS.edit, "Edit link", () => renderForm(existing))
|
|
1190
|
+
);
|
|
1191
|
+
row.appendChild(
|
|
1192
|
+
iconBtn(ICONS.unlink, "Remove link", () => {
|
|
1193
|
+
closeCurrent2();
|
|
1194
|
+
opts.onUnlink?.();
|
|
1195
|
+
})
|
|
1196
|
+
);
|
|
1197
|
+
}
|
|
1170
1198
|
el.appendChild(row);
|
|
1171
1199
|
place(el, opts.anchor);
|
|
1172
1200
|
};
|
package/dist/lib/link-panel.d.ts
CHANGED
|
@@ -25,6 +25,17 @@ export interface LinkPanelOptions {
|
|
|
25
25
|
href: string;
|
|
26
26
|
text: string;
|
|
27
27
|
} | null;
|
|
28
|
+
/** The existing link points inside the document (`#bookmark`). Word never
|
|
29
|
+
* shows the raw anchor — it shows where the link GOES — so the panel
|
|
30
|
+
* displays `label` and offers a jump instead of a copyable URL.
|
|
31
|
+
* `generated` marks a link that is field output (a TOC entry): Word won't
|
|
32
|
+
* let you edit or unlink those one by one, and neither do we — updating
|
|
33
|
+
* the field is the way to change them. */
|
|
34
|
+
internal?: {
|
|
35
|
+
label: string | null;
|
|
36
|
+
generated: boolean;
|
|
37
|
+
onGo(): void;
|
|
38
|
+
} | null;
|
|
28
39
|
/** A text range is selected → the Text field is hidden (the selection is
|
|
29
40
|
* the text). */
|
|
30
41
|
hasSelection?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"link-panel.d.ts","sourceRoot":"","sources":["../../src/lib/link-panel.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;GAaG;AAEH,MAAM,WAAW,eAAe;IAC9B,uEAAuE;IACvE,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,eAAe,CAAC;IACxB,6EAA6E;IAC7E,QAAQ,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IACjD;qBACiB;IACjB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;;+DAG2D;IAC3D,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,mEAAmE;IACnE,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3C,QAAQ,CAAC,IAAI,IAAI,CAAC;CACnB;AAED,MAAM,WAAW,eAAe;IAC9B,KAAK,IAAI,IAAI,CAAC;IACd;0EACsE;IACtE,MAAM,IAAI,OAAO,CAAC;CACnB;
|
|
1
|
+
{"version":3,"file":"link-panel.d.ts","sourceRoot":"","sources":["../../src/lib/link-panel.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;GAaG;AAEH,MAAM,WAAW,eAAe;IAC9B,uEAAuE;IACvE,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,eAAe,CAAC;IACxB,6EAA6E;IAC7E,QAAQ,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IACjD;;;;;+CAK2C;IAC3C,QAAQ,CAAC,EAAE;QACT,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;QACrB,SAAS,EAAE,OAAO,CAAC;QACnB,IAAI,IAAI,IAAI,CAAC;KACd,GAAG,IAAI,CAAC;IACT;qBACiB;IACjB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;;+DAG2D;IAC3D,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,mEAAmE;IACnE,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3C,QAAQ,CAAC,IAAI,IAAI,CAAC;CACnB;AAED,MAAM,WAAW,eAAe;IAC9B,KAAK,IAAI,IAAI,CAAC;IACd;0EACsE;IACtE,MAAM,IAAI,OAAO,CAAC;CACnB;AA6ED,wBAAgB,aAAa,CAAC,IAAI,EAAE,gBAAgB,GAAG,eAAe,CA8MrE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shadow-garden/bapbong-ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "bapbong — framework-agnostic editor UI (toolbar/menubar) that mounts into a host element and binds to editor.commands",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -56,6 +56,6 @@
|
|
|
56
56
|
}
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
|
-
"@shadow-garden/bapbong-contracts": "^0.
|
|
59
|
+
"@shadow-garden/bapbong-contracts": "^0.6.0"
|
|
60
60
|
}
|
|
61
61
|
}
|