claude-dev-env 1.82.0 → 1.84.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/CLAUDE.md +16 -13
- package/_shared/pr-loop/audit-contract.md +24 -12
- package/_shared/pr-loop/scripts/CLAUDE.md +1 -0
- package/_shared/pr-loop/scripts/README.md +1 -0
- package/_shared/pr-loop/scripts/_claude_permissions_common.py +16 -5
- package/_shared/pr-loop/scripts/code_rules_gate.py +2 -3
- package/_shared/pr-loop/scripts/pr_loop_shared_constants/CLAUDE.md +1 -0
- package/_shared/pr-loop/scripts/pr_loop_shared_constants/reviewer_availability_constants.py +12 -0
- package/_shared/pr-loop/scripts/pr_loop_shared_constants/terminology_sweep_constants.py +0 -2
- package/_shared/pr-loop/scripts/reviewer_availability.py +182 -0
- package/_shared/pr-loop/scripts/reviews_disabled.py +2 -0
- package/_shared/pr-loop/scripts/terminology_sweep.py +9 -33
- package/_shared/pr-loop/scripts/tests/CLAUDE.md +2 -0
- package/_shared/pr-loop/scripts/tests/test__claude_permissions_common.py +212 -0
- package/_shared/pr-loop/scripts/tests/test_agent_config_carveout.py +18 -0
- package/_shared/pr-loop/scripts/tests/test_claude_permissions_common.py +18 -0
- package/_shared/pr-loop/scripts/tests/test_code_rules_gate.py +37 -0
- package/_shared/pr-loop/scripts/tests/test_reviewer_availability.py +159 -0
- package/_shared/pr-loop/scripts/tests/test_reviewer_availability_constants.py +36 -0
- package/_shared/pr-loop/scripts/tests/test_reviews_disabled.py +14 -0
- package/_shared/pr-loop/scripts/tests/test_terminology_sweep.py +14 -4
- package/agents/clean-coder.md +3 -0
- package/audit-rubrics/category_rubrics/category-o-docstring-vs-impl-drift.md +1 -1
- package/bin/install.mjs +16 -8
- package/bin/install.test.mjs +17 -6
- package/commands/CLAUDE.md +0 -1
- package/docs/CODE_RULES.md +1 -1
- package/hooks/blocking/CLAUDE.md +2 -4
- package/hooks/blocking/code_rules_constants_config.py +164 -1
- package/hooks/blocking/code_rules_docstrings.py +428 -15
- package/hooks/blocking/code_rules_enforcer.py +33 -0
- package/hooks/blocking/code_rules_imports_logging.py +867 -1
- package/hooks/blocking/code_rules_magic_values.py +5 -0
- package/hooks/blocking/code_rules_naming_collection.py +152 -6
- package/hooks/blocking/code_rules_shared.py +34 -0
- package/hooks/blocking/code_rules_string_magic.py +68 -0
- package/hooks/blocking/duplicate_rmtree_helper_blocker.py +4 -4
- package/hooks/blocking/pre_tool_use_dispatcher.py +3 -3
- package/hooks/blocking/reviewer_spawn_gate.py +182 -0
- package/hooks/blocking/stale_comment_reference_blocker.py +267 -0
- package/hooks/blocking/state_description_blocker.py +96 -5
- package/hooks/blocking/test_code_rules_config_duplicate_path_anchor.py +132 -0
- package/hooks/blocking/test_code_rules_enforcer_cap_meta.py +2 -0
- package/hooks/blocking/test_code_rules_enforcer_docstring_delegation_summary.py +385 -0
- package/hooks/blocking/test_code_rules_enforcer_docstring_prose_wall_illustration.py +197 -0
- package/hooks/blocking/test_code_rules_enforcer_docstring_runon_sentence.py +27 -0
- package/hooks/blocking/test_code_rules_enforcer_join_separator_magic.py +67 -0
- package/hooks/blocking/test_code_rules_enforcer_module_docstring_roster.py +40 -0
- package/hooks/blocking/test_code_rules_enforcer_naive_datetime.py +213 -0
- package/hooks/blocking/test_code_rules_enforcer_referenced_underscore_loop.py +169 -0
- package/hooks/blocking/test_code_rules_enforcer_split_constants_config.py +33 -0
- package/hooks/blocking/test_code_rules_enforcer_split_shared.py +23 -0
- package/hooks/blocking/test_code_rules_js_bare_flag_return_directive.py +266 -0
- package/hooks/blocking/test_code_rules_js_sibling_return_object_key_drift.py +490 -0
- package/hooks/blocking/test_code_rules_logging_adjacent_literals.py +171 -0
- package/hooks/blocking/test_code_rules_magic_values.py +54 -0
- package/hooks/blocking/test_duplicate_rmtree_helper_blocker.py +0 -6
- package/hooks/blocking/test_pr_converge_bugteam_enforcer_state_tolerance.py +184 -0
- package/hooks/blocking/test_pre_tool_use_dispatcher.py +9 -3
- package/hooks/blocking/test_reviewer_spawn_gate.py +230 -0
- package/hooks/blocking/test_shared_stdin_adoption.py +5 -30
- package/hooks/blocking/test_stale_comment_reference_blocker.py +236 -0
- package/hooks/blocking/test_state_description_blocker.py +135 -0
- package/hooks/hooks.json +5 -0
- package/hooks/hooks_constants/CLAUDE.md +3 -4
- package/hooks/hooks_constants/blocking_check_limits.py +46 -0
- package/hooks/hooks_constants/code_rules_enforcer_constants.py +41 -0
- package/hooks/hooks_constants/code_rules_path_utils_constants.py +1 -1
- package/hooks/hooks_constants/duplicate_rmtree_helper_blocker_constants.py +0 -1
- package/hooks/hooks_constants/post_tool_use_dispatcher_constants.py +0 -5
- package/hooks/hooks_constants/pre_tool_use_dispatcher_constants.py +4 -0
- package/hooks/hooks_constants/reviewer_spawn_gate_constants.py +41 -0
- package/hooks/hooks_constants/stale_comment_reference_blocker_constants.py +76 -0
- package/hooks/hooks_constants/state_description_blocker_constants.py +8 -0
- package/hooks/validation/post_tool_use_dispatcher.py +1 -1
- package/hooks/validation/test_post_tool_use_dispatcher.py +51 -35
- package/hooks/workflow/CLAUDE.md +2 -8
- package/package.json +1 -1
- package/rules/CLAUDE.md +5 -2
- package/rules/claude-md-orphan-file.md +5 -0
- package/rules/docstring-prose-matches-implementation.md +10 -1
- package/rules/env-var-table-code-drift.md +5 -0
- package/rules/es-exe-file-search.md +17 -0
- package/rules/no-historical-clutter.md +12 -1
- package/rules/orphan-css-class.md +5 -0
- package/rules/package-inventory-stale-entry.md +10 -0
- package/rules/paired-test-coverage.md +5 -0
- package/rules/plain-illustrative-docstrings.md +40 -1
- package/rules/verify-before-asking.md +7 -0
- package/rules/verify-runtime-state.md +40 -0
- package/rules/windows-filesystem-safe.md +8 -0
- package/rules/workers-done-before-complete.md +33 -0
- package/rules/workflow-substitution-slots.md +5 -0
- package/skills/CLAUDE.md +7 -2
- package/skills/autoconverge/SKILL.md +48 -61
- package/skills/autoconverge/reference/closing-report.md +6 -6
- package/skills/autoconverge/reference/convergence.md +17 -15
- package/skills/autoconverge/reference/gotchas.md +6 -3
- package/skills/autoconverge/workflow/autoconverge_report_constants/render_report_constants.py +2 -9
- package/skills/autoconverge/workflow/converge.contract.test.mjs +153 -10
- package/skills/autoconverge/workflow/converge.copilot-gate.test.mjs +55 -19
- package/skills/autoconverge/workflow/converge.merge-conflict.test.mjs +16 -9
- package/skills/autoconverge/workflow/converge.mjs +167 -106
- package/skills/autoconverge/workflow/render_report.py +7 -11
- package/skills/bugteam/CLAUDE.md +1 -1
- package/skills/bugteam/PROMPTS.md +7 -6
- package/skills/bugteam/SKILL.md +25 -72
- package/skills/bugteam/reference/CLAUDE.md +1 -3
- package/skills/bugteam/reference/README.md +1 -1
- package/skills/bugteam/reference/audit-and-teammates.md +1 -1
- package/skills/bugteam/reference/obstacles/fix-publish-summary.md +1 -1
- package/skills/bugteam/reference/team-setup.md +8 -7
- package/skills/bugteam/scripts/CLAUDE.md +0 -6
- package/skills/bugteam/scripts/README.md +0 -4
- package/skills/bugteam/scripts/bugteam_scripts_constants/CLAUDE.md +0 -1
- package/skills/code/SKILL.md +2 -0
- package/skills/copilot-review/CLAUDE.md +1 -1
- package/skills/copilot-review/SKILL.md +25 -23
- package/skills/everything-search/SKILL.md +5 -0
- package/skills/findbugs/CLAUDE.md +2 -2
- package/skills/findbugs/SKILL.md +22 -83
- package/skills/fixbugs/SKILL.md +2 -4
- package/skills/log-audit/CLAUDE.md +20 -0
- package/skills/log-audit/SKILL.md +68 -0
- package/skills/log-audit/reference/CLAUDE.md +9 -0
- package/skills/log-audit/reference/charter.md +52 -0
- package/skills/log-audit/scripts/CLAUDE.md +27 -0
- package/skills/log-audit/scripts/cluster_recurrences.py +261 -0
- package/skills/log-audit/scripts/collect_log_window.py +199 -0
- package/skills/log-audit/scripts/log_audit_constants/CLAUDE.md +12 -0
- package/skills/log-audit/scripts/log_audit_constants/cluster_recurrences_constants.py +23 -0
- package/skills/log-audit/scripts/log_audit_constants/collect_log_window_constants.py +24 -0
- package/skills/log-audit/scripts/log_audit_constants/mine_copilot_findings_constants.py +49 -0
- package/skills/log-audit/scripts/mine_copilot_findings.py +302 -0
- package/skills/log-audit/scripts/test_cluster_recurrences.py +160 -0
- package/skills/log-audit/scripts/test_collect_log_window.py +111 -0
- package/skills/log-audit/scripts/test_mine_copilot_findings.py +126 -0
- package/skills/monitor-open-prs/SKILL.md +2 -2
- package/skills/post-audit-findings/SKILL.md +84 -0
- package/skills/pr-converge/CLAUDE.md +2 -0
- package/skills/pr-converge/SKILL.md +72 -59
- package/skills/pr-converge/reference/CLAUDE.md +1 -1
- package/skills/pr-converge/reference/convergence-gates.md +16 -19
- package/skills/pr-converge/reference/examples.md +5 -5
- package/skills/pr-converge/reference/fix-protocol.md +16 -43
- package/skills/pr-converge/reference/obstacles/fix-publish-summary.md +1 -1
- package/skills/pr-converge/reference/per-tick.md +24 -45
- package/skills/pr-converge/reference/state-schema.md +15 -0
- package/skills/pr-converge/scripts/README.md +3 -5
- package/skills/pr-fix-protocol/SKILL.md +70 -0
- package/skills/pr-loop-lifecycle/SKILL.md +73 -0
- package/skills/{bugteam → pr-loop-lifecycle}/reference/teardown-publish-permissions.md +22 -24
- package/skills/pr-scope-resolve/SKILL.md +48 -0
- package/skills/qbug/CLAUDE.md +4 -4
- package/skills/qbug/SKILL.md +46 -144
- package/skills/qbug/test_qbug_skill_audit_schema.py +2 -2
- package/skills/qbug/test_qbug_skill_post_fix_audit.py +1 -1
- package/skills/reviewer-gates/SKILL.md +96 -0
- package/skills/session-log/CLAUDE.md +7 -7
- package/skills/session-log/SKILL.md +27 -44
- package/skills/test_markdown_link_integrity.py +103 -0
- package/commands/doc-gist.md +0 -16
- package/hooks/blocking/_md_to_html_blocker_test_support.py +0 -65
- package/hooks/blocking/conftest.py +0 -30
- package/hooks/blocking/md_path_exemptions.py +0 -224
- package/hooks/blocking/md_to_html_blocker.py +0 -155
- package/hooks/blocking/test_md_to_html_blocker_exemptions.py +0 -434
- package/hooks/blocking/test_md_to_html_blocker_extensions.py +0 -157
- package/hooks/blocking/test_md_to_html_blocker_path_resolution.py +0 -336
- package/hooks/hooks_constants/doc_gist_auto_publish_constants.py +0 -18
- package/hooks/hooks_constants/html_companion_constants.py +0 -20
- package/hooks/hooks_constants/md_to_html_blocker_constants.py +0 -76
- package/hooks/hooks_constants/test_md_to_html_blocker_constants.py +0 -125
- package/hooks/workflow/doc_gist_auto_publish.py +0 -144
- package/hooks/workflow/md_to_html_companion.py +0 -358
- package/hooks/workflow/test_doc_gist_auto_publish.py +0 -117
- package/hooks/workflow/test_md_to_html_companion.py +0 -613
- package/skills/bugteam/reference/audit-contract.md +0 -163
- package/skills/bugteam/scripts/_bugteam_permissions_common.py +0 -455
- package/skills/bugteam/scripts/bugteam_scripts_constants/claude_permissions_common_constants.py +0 -69
- package/skills/bugteam/scripts/grant_project_claude_permissions.py +0 -280
- package/skills/bugteam/scripts/revoke_project_claude_permissions.py +0 -266
- package/skills/bugteam/scripts/test__bugteam_permissions_common.py +0 -160
- package/skills/bugteam/scripts/test_agent_config_carveout.py +0 -356
- package/skills/bugteam/scripts/test_bugteam_permissions_common.py +0 -140
- package/skills/doc-gist/CLAUDE.md +0 -25
- package/skills/doc-gist/SKILL.md +0 -97
- package/skills/doc-gist/references/CLAUDE.md +0 -9
- package/skills/doc-gist/references/examples/01-exploration-code-approaches.html +0 -453
- package/skills/doc-gist/references/examples/02-exploration-visual-designs.html +0 -515
- package/skills/doc-gist/references/examples/03-code-review-pr.html +0 -638
- package/skills/doc-gist/references/examples/04-code-understanding.html +0 -491
- package/skills/doc-gist/references/examples/05-design-system.html +0 -629
- package/skills/doc-gist/references/examples/06-component-variants.html +0 -605
- package/skills/doc-gist/references/examples/07-prototype-animation.html +0 -455
- package/skills/doc-gist/references/examples/08-prototype-interaction.html +0 -396
- package/skills/doc-gist/references/examples/09-slide-deck.html +0 -592
- package/skills/doc-gist/references/examples/10-svg-illustrations.html +0 -492
- package/skills/doc-gist/references/examples/11-status-report.html +0 -528
- package/skills/doc-gist/references/examples/12-incident-report.html +0 -596
- package/skills/doc-gist/references/examples/13-flowchart-diagram.html +0 -395
- package/skills/doc-gist/references/examples/14-research-feature-explainer.html +0 -381
- package/skills/doc-gist/references/examples/15-research-concept-explainer.html +0 -368
- package/skills/doc-gist/references/examples/16-implementation-plan.html +0 -702
- package/skills/doc-gist/references/examples/17-pr-writeup.html +0 -595
- package/skills/doc-gist/references/examples/18-editor-triage-board.html +0 -573
- package/skills/doc-gist/references/examples/19-editor-feature-flags.html +0 -663
- package/skills/doc-gist/references/examples/20-editor-prompt-tuner.html +0 -722
- package/skills/doc-gist/references/examples/21-decision-signoff.html +0 -546
- package/skills/doc-gist/references/examples/CLAUDE.md +0 -25
- package/skills/doc-gist/references/examples/README.md +0 -5
- package/skills/doc-gist/scripts/CLAUDE.md +0 -27
- package/skills/doc-gist/scripts/doc_gist_scripts_constants/CLAUDE.md +0 -10
- package/skills/doc-gist/scripts/doc_gist_scripts_constants/gist_upload_constants.py +0 -16
- package/skills/doc-gist/scripts/gist_upload.py +0 -177
- package/skills/doc-gist/scripts/test_gist_upload.py +0 -51
- /package/skills/{doc-gist/scripts/doc_gist_scripts_constants → log-audit/scripts/log_audit_constants}/__init__.py +0 -0
|
@@ -1,722 +0,0 @@
|
|
|
1
|
-
<!doctype html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="utf-8" />
|
|
5
|
-
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
6
|
-
<title>Birchline — Support reply prompt tuner</title>
|
|
7
|
-
<style>
|
|
8
|
-
:root {
|
|
9
|
-
--ivory: #FAF9F5;
|
|
10
|
-
--slate: #141413;
|
|
11
|
-
--clay: #D97757;
|
|
12
|
-
--clay-d: #B85C3E;
|
|
13
|
-
--oat: #E3DACC;
|
|
14
|
-
--olive: #788C5D;
|
|
15
|
-
--gray-50: #F0EEE6;
|
|
16
|
-
--gray-200: #D1CFC5;
|
|
17
|
-
--gray-500: #87867F;
|
|
18
|
-
--gray-800: #3D3D3A;
|
|
19
|
-
--white: #ffffff;
|
|
20
|
-
--serif: ui-serif, Georgia, "Times New Roman", serif;
|
|
21
|
-
--sans: system-ui, -apple-system, "Segoe UI", sans-serif;
|
|
22
|
-
--mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
|
|
23
|
-
}
|
|
24
|
-
* { box-sizing: border-box; }
|
|
25
|
-
html, body {
|
|
26
|
-
margin: 0;
|
|
27
|
-
background: var(--ivory);
|
|
28
|
-
color: var(--slate);
|
|
29
|
-
font-family: var(--sans);
|
|
30
|
-
font-size: 14px;
|
|
31
|
-
line-height: 1.5;
|
|
32
|
-
}
|
|
33
|
-
.wrap {
|
|
34
|
-
max-width: 1180px;
|
|
35
|
-
margin: 0 auto;
|
|
36
|
-
padding: 48px 32px 64px;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/* ---------- header ---------- */
|
|
40
|
-
header { margin-bottom: 22px; }
|
|
41
|
-
.eyebrow {
|
|
42
|
-
font-family: var(--mono);
|
|
43
|
-
font-size: 11px;
|
|
44
|
-
letter-spacing: 0.08em;
|
|
45
|
-
text-transform: uppercase;
|
|
46
|
-
color: var(--gray-500);
|
|
47
|
-
}
|
|
48
|
-
h1 {
|
|
49
|
-
font-family: var(--serif);
|
|
50
|
-
font-weight: 500;
|
|
51
|
-
font-size: 30px;
|
|
52
|
-
letter-spacing: -0.01em;
|
|
53
|
-
margin: 6px 0 4px;
|
|
54
|
-
}
|
|
55
|
-
.sub {
|
|
56
|
-
color: var(--gray-500);
|
|
57
|
-
max-width: 640px;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/* ---------- toolbar ---------- */
|
|
61
|
-
.toolbar {
|
|
62
|
-
position: sticky;
|
|
63
|
-
top: 0;
|
|
64
|
-
z-index: 10;
|
|
65
|
-
display: flex;
|
|
66
|
-
align-items: center;
|
|
67
|
-
gap: 10px;
|
|
68
|
-
background: var(--ivory);
|
|
69
|
-
padding: 10px 0 14px;
|
|
70
|
-
margin-bottom: 6px;
|
|
71
|
-
border-bottom: 1px solid var(--gray-200);
|
|
72
|
-
}
|
|
73
|
-
.toolbar .spacer { flex: 1; }
|
|
74
|
-
.toolbar .hint {
|
|
75
|
-
font-family: var(--mono);
|
|
76
|
-
font-size: 11px;
|
|
77
|
-
color: var(--gray-500);
|
|
78
|
-
letter-spacing: 0.02em;
|
|
79
|
-
}
|
|
80
|
-
button {
|
|
81
|
-
font-family: var(--mono);
|
|
82
|
-
font-size: 12px;
|
|
83
|
-
cursor: pointer;
|
|
84
|
-
-webkit-appearance: none;
|
|
85
|
-
appearance: none;
|
|
86
|
-
}
|
|
87
|
-
.btn-primary {
|
|
88
|
-
background: var(--slate);
|
|
89
|
-
color: var(--ivory);
|
|
90
|
-
border: 1.5px solid var(--slate);
|
|
91
|
-
border-radius: 999px;
|
|
92
|
-
padding: 9px 16px;
|
|
93
|
-
transition: background 140ms ease, transform 80ms ease;
|
|
94
|
-
}
|
|
95
|
-
.btn-primary:hover { background: var(--gray-800); }
|
|
96
|
-
.btn-primary:active { transform: translateY(1px); }
|
|
97
|
-
.btn-primary.copied { background: var(--olive); border-color: var(--olive); }
|
|
98
|
-
.btn-ghost {
|
|
99
|
-
background: transparent;
|
|
100
|
-
color: var(--gray-800);
|
|
101
|
-
border: 1.5px solid var(--gray-200);
|
|
102
|
-
border-radius: 999px;
|
|
103
|
-
padding: 8px 15px;
|
|
104
|
-
transition: border-color 140ms ease, color 140ms ease;
|
|
105
|
-
}
|
|
106
|
-
.btn-ghost:hover { border-color: var(--gray-500); color: var(--slate); }
|
|
107
|
-
|
|
108
|
-
/* ---------- two-column layout ---------- */
|
|
109
|
-
.cols {
|
|
110
|
-
display: grid;
|
|
111
|
-
grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
|
|
112
|
-
gap: 24px;
|
|
113
|
-
align-items: start;
|
|
114
|
-
margin-top: 18px;
|
|
115
|
-
}
|
|
116
|
-
@media (max-width: 880px) {
|
|
117
|
-
.cols { grid-template-columns: 1fr; }
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
.panel {
|
|
121
|
-
background: var(--white);
|
|
122
|
-
border: 1.5px solid var(--gray-200);
|
|
123
|
-
border-radius: 12px;
|
|
124
|
-
overflow: hidden;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
/* ---------- left: editor ---------- */
|
|
128
|
-
.ed-toolbar {
|
|
129
|
-
display: flex;
|
|
130
|
-
align-items: center;
|
|
131
|
-
gap: 10px;
|
|
132
|
-
padding: 11px 16px;
|
|
133
|
-
border-bottom: 1.5px solid var(--gray-200);
|
|
134
|
-
background: var(--gray-50);
|
|
135
|
-
}
|
|
136
|
-
.ed-label {
|
|
137
|
-
font-family: var(--mono);
|
|
138
|
-
font-size: 11px;
|
|
139
|
-
letter-spacing: 0.1em;
|
|
140
|
-
color: var(--gray-500);
|
|
141
|
-
text-transform: uppercase;
|
|
142
|
-
}
|
|
143
|
-
.ed-toolbar .spacer { flex: 1; }
|
|
144
|
-
.counter {
|
|
145
|
-
font-family: var(--mono);
|
|
146
|
-
font-size: 11px;
|
|
147
|
-
color: var(--gray-800);
|
|
148
|
-
background: var(--white);
|
|
149
|
-
border: 1.5px solid var(--gray-200);
|
|
150
|
-
border-radius: 999px;
|
|
151
|
-
padding: 3px 10px;
|
|
152
|
-
white-space: nowrap;
|
|
153
|
-
font-variant-numeric: tabular-nums;
|
|
154
|
-
}
|
|
155
|
-
.editor {
|
|
156
|
-
font-family: var(--mono);
|
|
157
|
-
font-size: 13px;
|
|
158
|
-
line-height: 1.7;
|
|
159
|
-
padding: 18px;
|
|
160
|
-
min-height: 360px;
|
|
161
|
-
white-space: pre-wrap;
|
|
162
|
-
word-break: break-word;
|
|
163
|
-
background: var(--white);
|
|
164
|
-
color: var(--slate);
|
|
165
|
-
outline: none;
|
|
166
|
-
caret-color: var(--clay);
|
|
167
|
-
tab-size: 2;
|
|
168
|
-
}
|
|
169
|
-
.editor:focus-visible { outline: none; }
|
|
170
|
-
.slot {
|
|
171
|
-
background: var(--oat);
|
|
172
|
-
color: var(--clay-d);
|
|
173
|
-
border-radius: 4px;
|
|
174
|
-
padding: 0 3px;
|
|
175
|
-
font-weight: 600;
|
|
176
|
-
}
|
|
177
|
-
.slot.warn {
|
|
178
|
-
background: rgba(217, 119, 87, 0.14);
|
|
179
|
-
color: var(--clay-d);
|
|
180
|
-
text-decoration: underline dashed var(--clay) 1.5px;
|
|
181
|
-
text-underline-offset: 3px;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
.legend {
|
|
185
|
-
border-top: 1.5px solid var(--gray-200);
|
|
186
|
-
padding: 12px 16px 14px;
|
|
187
|
-
background: var(--gray-50);
|
|
188
|
-
}
|
|
189
|
-
.legend-label {
|
|
190
|
-
font-family: var(--mono);
|
|
191
|
-
font-size: 10px;
|
|
192
|
-
letter-spacing: 0.1em;
|
|
193
|
-
text-transform: uppercase;
|
|
194
|
-
color: var(--gray-500);
|
|
195
|
-
margin-bottom: 8px;
|
|
196
|
-
}
|
|
197
|
-
.legend-chips { display: flex; flex-wrap: wrap; gap: 6px; }
|
|
198
|
-
.chip {
|
|
199
|
-
font-family: var(--mono);
|
|
200
|
-
font-size: 11px;
|
|
201
|
-
background: var(--oat);
|
|
202
|
-
color: var(--clay-d);
|
|
203
|
-
border-radius: 4px;
|
|
204
|
-
padding: 2px 7px;
|
|
205
|
-
font-weight: 600;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
/* ---------- right: preview ---------- */
|
|
209
|
-
.preview-panel { padding: 16px; display: flex; flex-direction: column; gap: 14px; }
|
|
210
|
-
.preview-head {
|
|
211
|
-
font-family: var(--mono);
|
|
212
|
-
font-size: 11px;
|
|
213
|
-
letter-spacing: 0.1em;
|
|
214
|
-
text-transform: uppercase;
|
|
215
|
-
color: var(--gray-500);
|
|
216
|
-
padding: 0 2px 2px;
|
|
217
|
-
}
|
|
218
|
-
.sample {
|
|
219
|
-
border: 1.5px solid var(--gray-200);
|
|
220
|
-
border-radius: 10px;
|
|
221
|
-
overflow: hidden;
|
|
222
|
-
}
|
|
223
|
-
.sample-head {
|
|
224
|
-
display: flex;
|
|
225
|
-
align-items: center;
|
|
226
|
-
gap: 9px;
|
|
227
|
-
padding: 9px 13px;
|
|
228
|
-
border-bottom: 1.5px solid var(--gray-200);
|
|
229
|
-
background: var(--gray-50);
|
|
230
|
-
}
|
|
231
|
-
.badge {
|
|
232
|
-
font-family: var(--mono);
|
|
233
|
-
font-size: 10px;
|
|
234
|
-
letter-spacing: 0.08em;
|
|
235
|
-
color: var(--gray-500);
|
|
236
|
-
}
|
|
237
|
-
.cust {
|
|
238
|
-
font-family: var(--serif);
|
|
239
|
-
font-size: 14px;
|
|
240
|
-
font-weight: 500;
|
|
241
|
-
letter-spacing: -0.005em;
|
|
242
|
-
}
|
|
243
|
-
.sample-head .spacer { flex: 1; }
|
|
244
|
-
.plan {
|
|
245
|
-
font-family: var(--mono);
|
|
246
|
-
font-size: 10px;
|
|
247
|
-
letter-spacing: 0.05em;
|
|
248
|
-
text-transform: uppercase;
|
|
249
|
-
border-radius: 999px;
|
|
250
|
-
padding: 2px 8px;
|
|
251
|
-
border: 1.5px solid var(--gray-200);
|
|
252
|
-
color: var(--gray-800);
|
|
253
|
-
background: var(--white);
|
|
254
|
-
}
|
|
255
|
-
.plan.team { background: var(--oat); border-color: var(--oat); color: var(--clay-d); }
|
|
256
|
-
.plan.studio { background: var(--olive); border-color: var(--olive); color: var(--ivory); }
|
|
257
|
-
.rendered {
|
|
258
|
-
font-family: var(--mono);
|
|
259
|
-
font-size: 12.5px;
|
|
260
|
-
line-height: 1.6;
|
|
261
|
-
color: var(--gray-800);
|
|
262
|
-
white-space: pre-wrap;
|
|
263
|
-
word-break: break-word;
|
|
264
|
-
padding: 12px 13px 14px;
|
|
265
|
-
}
|
|
266
|
-
.filled {
|
|
267
|
-
background: var(--gray-50);
|
|
268
|
-
border-radius: 3px;
|
|
269
|
-
padding: 0 2px;
|
|
270
|
-
box-shadow: inset 0 0 0 1px var(--gray-200);
|
|
271
|
-
}
|
|
272
|
-
.missing {
|
|
273
|
-
background: rgba(217, 119, 87, 0.12);
|
|
274
|
-
color: var(--clay-d);
|
|
275
|
-
border-radius: 3px;
|
|
276
|
-
padding: 0 2px;
|
|
277
|
-
font-weight: 600;
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
footer {
|
|
281
|
-
margin-top: 36px;
|
|
282
|
-
font-family: var(--mono);
|
|
283
|
-
font-size: 11px;
|
|
284
|
-
color: var(--gray-500);
|
|
285
|
-
letter-spacing: 0.02em;
|
|
286
|
-
}
|
|
287
|
-
</style>
|
|
288
|
-
</head>
|
|
289
|
-
<body>
|
|
290
|
-
<div class="wrap">
|
|
291
|
-
|
|
292
|
-
<header>
|
|
293
|
-
<div class="eyebrow">Birchline / editor / prompt-tuner</div>
|
|
294
|
-
<h1>Support reply draft prompt</h1>
|
|
295
|
-
<p class="sub">Edit the system prompt on the left and watch three real sample tickets re-render the filled template on the right, live as you type. When it reads well across all three moods, copy the template out.</p>
|
|
296
|
-
</header>
|
|
297
|
-
|
|
298
|
-
<div class="toolbar">
|
|
299
|
-
<button id="copyBtn" class="btn-primary">Copy prompt</button>
|
|
300
|
-
<button id="resetBtn" class="btn-ghost">Reset</button>
|
|
301
|
-
<div class="spacer"></div>
|
|
302
|
-
<div class="hint">slots use <strong>{{double_brace}}</strong> syntax</div>
|
|
303
|
-
</div>
|
|
304
|
-
|
|
305
|
-
<div class="cols">
|
|
306
|
-
|
|
307
|
-
<!-- left -->
|
|
308
|
-
<section class="panel">
|
|
309
|
-
<div class="ed-toolbar">
|
|
310
|
-
<span class="ed-label">Template</span>
|
|
311
|
-
<div class="spacer"></div>
|
|
312
|
-
<span id="counter" class="counter">0 chars · ~0 tokens</span>
|
|
313
|
-
</div>
|
|
314
|
-
<div id="editor" class="editor" contenteditable="true" spellcheck="false" autocapitalize="off" autocorrect="off"></div>
|
|
315
|
-
<div class="legend">
|
|
316
|
-
<div class="legend-label">Available slots</div>
|
|
317
|
-
<div id="legendChips" class="legend-chips"></div>
|
|
318
|
-
</div>
|
|
319
|
-
</section>
|
|
320
|
-
|
|
321
|
-
<!-- right -->
|
|
322
|
-
<section class="panel preview-panel">
|
|
323
|
-
<div class="preview-head">Live preview · 3 sample tickets</div>
|
|
324
|
-
<div id="samples"></div>
|
|
325
|
-
</section>
|
|
326
|
-
|
|
327
|
-
</div>
|
|
328
|
-
|
|
329
|
-
<footer>Highlighted slots fill from each sample's ticket fields. Anything underlined in dashed clay isn't a known field and will pass through unfilled.</footer>
|
|
330
|
-
|
|
331
|
-
</div>
|
|
332
|
-
|
|
333
|
-
<script>
|
|
334
|
-
(function () {
|
|
335
|
-
"use strict";
|
|
336
|
-
|
|
337
|
-
// ---------------------------------------------------------------------------
|
|
338
|
-
// Data
|
|
339
|
-
// ---------------------------------------------------------------------------
|
|
340
|
-
|
|
341
|
-
var DEFAULT_TEMPLATE =
|
|
342
|
-
'You are a support agent for Birchline, a project workspace for small teams.\n' +
|
|
343
|
-
'\n' +
|
|
344
|
-
'A customer named {{customer_name}} on the {{plan_tier}} plan wrote in about:\n' +
|
|
345
|
-
'"{{ticket_subject}}"\n' +
|
|
346
|
-
'\n' +
|
|
347
|
-
'Their message:\n' +
|
|
348
|
-
'{{ticket_body}}\n' +
|
|
349
|
-
'\n' +
|
|
350
|
-
'Write a reply that is {{tone}}, no more than 120 words, and ends with a single concrete next step.\n' +
|
|
351
|
-
'Never promise a refund without escalating. Sign off as "The Birchline team."';
|
|
352
|
-
|
|
353
|
-
var SAMPLES = [
|
|
354
|
-
{
|
|
355
|
-
label: 'SAMPLE 1',
|
|
356
|
-
planClass: 'free',
|
|
357
|
-
data: {
|
|
358
|
-
customer_name: 'Priya N.',
|
|
359
|
-
plan_tier: 'Free',
|
|
360
|
-
ticket_subject: 'Where did my board go?',
|
|
361
|
-
ticket_body: 'Hi — I made a board yesterday called "Spring launch" with my coworker and today I can’t find it anywhere. I’m new to Birchline and I’m not sure if I deleted it by accident or if I’m just looking in the wrong place. Can you help?',
|
|
362
|
-
tone: 'warm and patient'
|
|
363
|
-
}
|
|
364
|
-
},
|
|
365
|
-
{
|
|
366
|
-
label: 'SAMPLE 2',
|
|
367
|
-
planClass: 'team',
|
|
368
|
-
data: {
|
|
369
|
-
customer_name: 'Marcus D.',
|
|
370
|
-
plan_tier: 'Team',
|
|
371
|
-
ticket_subject: 'Sync keeps dropping comments',
|
|
372
|
-
ticket_body: 'This is the third time this week. I leave comments on cards from my laptop, switch to my phone on the train, and they’re gone. My team thinks I’m ignoring them. We pay for 14 seats and this is genuinely making us look bad to a client.',
|
|
373
|
-
tone: 'direct and apologetic'
|
|
374
|
-
}
|
|
375
|
-
},
|
|
376
|
-
{
|
|
377
|
-
label: 'SAMPLE 3',
|
|
378
|
-
planClass: 'studio',
|
|
379
|
-
data: {
|
|
380
|
-
customer_name: 'Lena K.',
|
|
381
|
-
plan_tier: 'Studio',
|
|
382
|
-
ticket_subject: 'Update billing entity on next invoice',
|
|
383
|
-
ticket_body: 'Hey folks! We just spun up a new holding company (Korhonen Studio Oy) and finance would love the May invoice to use that name + our new VAT ID, FI28361049. No rush at all, just want it sorted before the cycle runs. Thanks a million.',
|
|
384
|
-
tone: 'brisk and friendly'
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
];
|
|
388
|
-
|
|
389
|
-
var KNOWN_SLOTS = ['customer_name', 'plan_tier', 'ticket_subject', 'ticket_body', 'tone'];
|
|
390
|
-
var SLOT_RE = /\{\{\s*([a-zA-Z0-9_]+)\s*\}\}/g;
|
|
391
|
-
|
|
392
|
-
// ---------------------------------------------------------------------------
|
|
393
|
-
// DOM refs
|
|
394
|
-
// ---------------------------------------------------------------------------
|
|
395
|
-
|
|
396
|
-
var editor = document.getElementById('editor');
|
|
397
|
-
var counterEl = document.getElementById('counter');
|
|
398
|
-
var samplesEl = document.getElementById('samples');
|
|
399
|
-
var legendEl = document.getElementById('legendChips');
|
|
400
|
-
var copyBtn = document.getElementById('copyBtn');
|
|
401
|
-
var resetBtn = document.getElementById('resetBtn');
|
|
402
|
-
|
|
403
|
-
// ---------------------------------------------------------------------------
|
|
404
|
-
// Helpers
|
|
405
|
-
// ---------------------------------------------------------------------------
|
|
406
|
-
|
|
407
|
-
function escapeHtml(s) {
|
|
408
|
-
return s
|
|
409
|
-
.replace(/&/g, '&')
|
|
410
|
-
.replace(/</g, '<')
|
|
411
|
-
.replace(/>/g, '>')
|
|
412
|
-
.replace(/"/g, '"');
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
// Read plain text out of the contenteditable. We rely on white-space:pre-wrap
|
|
416
|
-
// and only ever insert text + inline <span>s, so textContent is faithful as
|
|
417
|
-
// long as the browser hasn't injected block elements or <br>s. Normalize both.
|
|
418
|
-
function getPlainText() {
|
|
419
|
-
var out = '';
|
|
420
|
-
var walker = document.createTreeWalker(editor, NodeFilter.SHOW_TEXT | NodeFilter.SHOW_ELEMENT, null);
|
|
421
|
-
var node;
|
|
422
|
-
while ((node = walker.nextNode())) {
|
|
423
|
-
if (node.nodeType === Node.TEXT_NODE) {
|
|
424
|
-
out += node.nodeValue;
|
|
425
|
-
} else if (node.nodeType === Node.ELEMENT_NODE) {
|
|
426
|
-
var tag = node.tagName;
|
|
427
|
-
if (tag === 'BR') out += '\n';
|
|
428
|
-
// Some browsers wrap new lines in <div>; emit a newline before a div
|
|
429
|
-
// that isn't the first child and doesn't already start after one.
|
|
430
|
-
if (tag === 'DIV' && node !== editor.firstChild && out.length && out[out.length - 1] !== '\n') {
|
|
431
|
-
out += '\n';
|
|
432
|
-
}
|
|
433
|
-
}
|
|
434
|
-
}
|
|
435
|
-
return out;
|
|
436
|
-
}
|
|
437
|
-
|
|
438
|
-
// ---- Caret save/restore by character offset ----
|
|
439
|
-
|
|
440
|
-
function getCaretOffset() {
|
|
441
|
-
var sel = window.getSelection();
|
|
442
|
-
if (!sel || sel.rangeCount === 0) return null;
|
|
443
|
-
var range = sel.getRangeAt(0);
|
|
444
|
-
if (!editor.contains(range.startContainer)) return null;
|
|
445
|
-
|
|
446
|
-
var pre = range.cloneRange();
|
|
447
|
-
pre.selectNodeContents(editor);
|
|
448
|
-
pre.setEnd(range.startContainer, range.startOffset);
|
|
449
|
-
|
|
450
|
-
// Count characters by walking text nodes within the pre-range. We mirror
|
|
451
|
-
// getPlainText's newline handling so offsets line up.
|
|
452
|
-
var frag = pre.cloneContents();
|
|
453
|
-
var off = 0;
|
|
454
|
-
var walker = document.createTreeWalker(frag, NodeFilter.SHOW_TEXT | NodeFilter.SHOW_ELEMENT, null);
|
|
455
|
-
var node, lastChar = '';
|
|
456
|
-
var first = true;
|
|
457
|
-
while ((node = walker.nextNode())) {
|
|
458
|
-
if (node.nodeType === Node.TEXT_NODE) {
|
|
459
|
-
off += node.nodeValue.length;
|
|
460
|
-
if (node.nodeValue.length) lastChar = node.nodeValue[node.nodeValue.length - 1];
|
|
461
|
-
} else {
|
|
462
|
-
if (node.tagName === 'BR') { off += 1; lastChar = '\n'; }
|
|
463
|
-
if (node.tagName === 'DIV' && !first && lastChar !== '\n') { off += 1; lastChar = '\n'; }
|
|
464
|
-
}
|
|
465
|
-
first = false;
|
|
466
|
-
}
|
|
467
|
-
return off;
|
|
468
|
-
}
|
|
469
|
-
|
|
470
|
-
function setCaretOffset(offset) {
|
|
471
|
-
if (offset == null) return;
|
|
472
|
-
var sel = window.getSelection();
|
|
473
|
-
if (!sel) return;
|
|
474
|
-
|
|
475
|
-
var walker = document.createTreeWalker(editor, NodeFilter.SHOW_TEXT, null);
|
|
476
|
-
var node;
|
|
477
|
-
var remaining = offset;
|
|
478
|
-
var lastNode = null;
|
|
479
|
-
|
|
480
|
-
while ((node = walker.nextNode())) {
|
|
481
|
-
lastNode = node;
|
|
482
|
-
var len = node.nodeValue.length;
|
|
483
|
-
if (remaining <= len) {
|
|
484
|
-
var range = document.createRange();
|
|
485
|
-
range.setStart(node, remaining);
|
|
486
|
-
range.collapse(true);
|
|
487
|
-
sel.removeAllRanges();
|
|
488
|
-
sel.addRange(range);
|
|
489
|
-
return;
|
|
490
|
-
}
|
|
491
|
-
remaining -= len;
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
// Past the end — place at end of last text node, or at end of editor.
|
|
495
|
-
var range2 = document.createRange();
|
|
496
|
-
if (lastNode) {
|
|
497
|
-
range2.setStart(lastNode, lastNode.nodeValue.length);
|
|
498
|
-
} else {
|
|
499
|
-
range2.selectNodeContents(editor);
|
|
500
|
-
range2.collapse(false);
|
|
501
|
-
}
|
|
502
|
-
range2.collapse(true);
|
|
503
|
-
sel.removeAllRanges();
|
|
504
|
-
sel.addRange(range2);
|
|
505
|
-
}
|
|
506
|
-
|
|
507
|
-
// ---- Highlighting ----
|
|
508
|
-
|
|
509
|
-
function highlightHtml(text) {
|
|
510
|
-
var html = '';
|
|
511
|
-
var last = 0;
|
|
512
|
-
SLOT_RE.lastIndex = 0;
|
|
513
|
-
var m;
|
|
514
|
-
while ((m = SLOT_RE.exec(text)) !== null) {
|
|
515
|
-
html += escapeHtml(text.slice(last, m.index));
|
|
516
|
-
var name = m[1];
|
|
517
|
-
var cls = KNOWN_SLOTS.indexOf(name) !== -1 ? 'slot' : 'slot warn';
|
|
518
|
-
html += '<span class="' + cls + '">' + escapeHtml(m[0]) + '</span>';
|
|
519
|
-
last = m.index + m[0].length;
|
|
520
|
-
}
|
|
521
|
-
html += escapeHtml(text.slice(last));
|
|
522
|
-
return html;
|
|
523
|
-
}
|
|
524
|
-
|
|
525
|
-
function renderEditor(text, caret) {
|
|
526
|
-
editor.innerHTML = highlightHtml(text);
|
|
527
|
-
if (caret != null && document.activeElement === editor) {
|
|
528
|
-
setCaretOffset(caret);
|
|
529
|
-
}
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
// ---- Preview ----
|
|
533
|
-
|
|
534
|
-
function fillHtml(text, data) {
|
|
535
|
-
var html = '';
|
|
536
|
-
var last = 0;
|
|
537
|
-
SLOT_RE.lastIndex = 0;
|
|
538
|
-
var m;
|
|
539
|
-
while ((m = SLOT_RE.exec(text)) !== null) {
|
|
540
|
-
html += escapeHtml(text.slice(last, m.index));
|
|
541
|
-
var name = m[1];
|
|
542
|
-
if (Object.prototype.hasOwnProperty.call(data, name)) {
|
|
543
|
-
html += '<span class="filled">' + escapeHtml(String(data[name])) + '</span>';
|
|
544
|
-
} else {
|
|
545
|
-
html += '<span class="missing">' + escapeHtml(m[0]) + '</span>';
|
|
546
|
-
}
|
|
547
|
-
last = m.index + m[0].length;
|
|
548
|
-
}
|
|
549
|
-
html += escapeHtml(text.slice(last));
|
|
550
|
-
return html;
|
|
551
|
-
}
|
|
552
|
-
|
|
553
|
-
var sampleNodes = [];
|
|
554
|
-
|
|
555
|
-
function buildSamples() {
|
|
556
|
-
samplesEl.innerHTML = '';
|
|
557
|
-
sampleNodes = [];
|
|
558
|
-
SAMPLES.forEach(function (s) {
|
|
559
|
-
var card = document.createElement('div');
|
|
560
|
-
card.className = 'sample';
|
|
561
|
-
|
|
562
|
-
var head = document.createElement('div');
|
|
563
|
-
head.className = 'sample-head';
|
|
564
|
-
|
|
565
|
-
var badge = document.createElement('span');
|
|
566
|
-
badge.className = 'badge';
|
|
567
|
-
badge.textContent = s.label;
|
|
568
|
-
|
|
569
|
-
var cust = document.createElement('span');
|
|
570
|
-
cust.className = 'cust';
|
|
571
|
-
cust.textContent = s.data.customer_name;
|
|
572
|
-
|
|
573
|
-
var spacer = document.createElement('span');
|
|
574
|
-
spacer.className = 'spacer';
|
|
575
|
-
|
|
576
|
-
var plan = document.createElement('span');
|
|
577
|
-
plan.className = 'plan ' + s.planClass;
|
|
578
|
-
plan.textContent = s.data.plan_tier;
|
|
579
|
-
|
|
580
|
-
head.appendChild(badge);
|
|
581
|
-
head.appendChild(cust);
|
|
582
|
-
head.appendChild(spacer);
|
|
583
|
-
head.appendChild(plan);
|
|
584
|
-
|
|
585
|
-
var body = document.createElement('div');
|
|
586
|
-
body.className = 'rendered';
|
|
587
|
-
|
|
588
|
-
card.appendChild(head);
|
|
589
|
-
card.appendChild(body);
|
|
590
|
-
samplesEl.appendChild(card);
|
|
591
|
-
sampleNodes.push({ body: body, data: s.data });
|
|
592
|
-
});
|
|
593
|
-
samplesEl.style.display = 'flex';
|
|
594
|
-
samplesEl.style.flexDirection = 'column';
|
|
595
|
-
samplesEl.style.gap = '14px';
|
|
596
|
-
}
|
|
597
|
-
|
|
598
|
-
function buildLegend() {
|
|
599
|
-
legendEl.innerHTML = '';
|
|
600
|
-
KNOWN_SLOTS.forEach(function (name) {
|
|
601
|
-
var c = document.createElement('span');
|
|
602
|
-
c.className = 'chip';
|
|
603
|
-
c.textContent = '{{' + name + '}}';
|
|
604
|
-
legendEl.appendChild(c);
|
|
605
|
-
});
|
|
606
|
-
}
|
|
607
|
-
|
|
608
|
-
// ---- Counter ----
|
|
609
|
-
|
|
610
|
-
function updateCounter(text) {
|
|
611
|
-
var chars = text.length;
|
|
612
|
-
var tokens = Math.round(chars / 4.2);
|
|
613
|
-
counterEl.textContent = chars + ' chars · ~' + tokens + ' tokens';
|
|
614
|
-
}
|
|
615
|
-
|
|
616
|
-
// ---- Master refresh ----
|
|
617
|
-
|
|
618
|
-
function refresh(opts) {
|
|
619
|
-
opts = opts || {};
|
|
620
|
-
var text = opts.text != null ? opts.text : getPlainText();
|
|
621
|
-
var caret = opts.preserveCaret ? getCaretOffset() : null;
|
|
622
|
-
|
|
623
|
-
renderEditor(text, caret);
|
|
624
|
-
updateCounter(text);
|
|
625
|
-
sampleNodes.forEach(function (sn) {
|
|
626
|
-
sn.body.innerHTML = fillHtml(text, sn.data);
|
|
627
|
-
});
|
|
628
|
-
}
|
|
629
|
-
|
|
630
|
-
// ---------------------------------------------------------------------------
|
|
631
|
-
// Events
|
|
632
|
-
// ---------------------------------------------------------------------------
|
|
633
|
-
|
|
634
|
-
var raf = null;
|
|
635
|
-
editor.addEventListener('input', function () {
|
|
636
|
-
if (raf) cancelAnimationFrame(raf);
|
|
637
|
-
raf = requestAnimationFrame(function () {
|
|
638
|
-
raf = null;
|
|
639
|
-
refresh({ preserveCaret: true });
|
|
640
|
-
});
|
|
641
|
-
});
|
|
642
|
-
|
|
643
|
-
// Force plain-text paste so we never inherit foreign HTML.
|
|
644
|
-
editor.addEventListener('paste', function (e) {
|
|
645
|
-
e.preventDefault();
|
|
646
|
-
var txt = (e.clipboardData || window.clipboardData).getData('text/plain');
|
|
647
|
-
var sel = window.getSelection();
|
|
648
|
-
if (!sel || !sel.rangeCount) return;
|
|
649
|
-
var range = sel.getRangeAt(0);
|
|
650
|
-
range.deleteContents();
|
|
651
|
-
range.insertNode(document.createTextNode(txt));
|
|
652
|
-
range.collapse(false);
|
|
653
|
-
sel.removeAllRanges();
|
|
654
|
-
sel.addRange(range);
|
|
655
|
-
refresh({ preserveCaret: true });
|
|
656
|
-
});
|
|
657
|
-
|
|
658
|
-
// Insert literal newline on Enter so we don't get nested <div>s.
|
|
659
|
-
editor.addEventListener('keydown', function (e) {
|
|
660
|
-
if (e.key === 'Enter') {
|
|
661
|
-
e.preventDefault();
|
|
662
|
-
var sel = window.getSelection();
|
|
663
|
-
if (!sel || !sel.rangeCount) return;
|
|
664
|
-
var range = sel.getRangeAt(0);
|
|
665
|
-
range.deleteContents();
|
|
666
|
-
var nl = document.createTextNode('\n');
|
|
667
|
-
range.insertNode(nl);
|
|
668
|
-
range.setStartAfter(nl);
|
|
669
|
-
range.collapse(true);
|
|
670
|
-
sel.removeAllRanges();
|
|
671
|
-
sel.addRange(range);
|
|
672
|
-
refresh({ preserveCaret: true });
|
|
673
|
-
}
|
|
674
|
-
});
|
|
675
|
-
|
|
676
|
-
var copyTimer = null;
|
|
677
|
-
copyBtn.addEventListener('click', function () {
|
|
678
|
-
var text = getPlainText();
|
|
679
|
-
var done = function () {
|
|
680
|
-
copyBtn.textContent = 'Copied ✓';
|
|
681
|
-
copyBtn.classList.add('copied');
|
|
682
|
-
if (copyTimer) clearTimeout(copyTimer);
|
|
683
|
-
copyTimer = setTimeout(function () {
|
|
684
|
-
copyBtn.textContent = 'Copy prompt';
|
|
685
|
-
copyBtn.classList.remove('copied');
|
|
686
|
-
}, 1200);
|
|
687
|
-
};
|
|
688
|
-
if (navigator.clipboard && navigator.clipboard.writeText) {
|
|
689
|
-
navigator.clipboard.writeText(text).then(done, function () {
|
|
690
|
-
fallbackCopy(text); done();
|
|
691
|
-
});
|
|
692
|
-
} else {
|
|
693
|
-
fallbackCopy(text); done();
|
|
694
|
-
}
|
|
695
|
-
});
|
|
696
|
-
|
|
697
|
-
function fallbackCopy(text) {
|
|
698
|
-
var ta = document.createElement('textarea');
|
|
699
|
-
ta.value = text;
|
|
700
|
-
ta.style.position = 'fixed';
|
|
701
|
-
ta.style.left = '-9999px';
|
|
702
|
-
document.body.appendChild(ta);
|
|
703
|
-
ta.select();
|
|
704
|
-
try { document.execCommand('copy'); } catch (e) { /* ignore */ }
|
|
705
|
-
document.body.removeChild(ta);
|
|
706
|
-
}
|
|
707
|
-
|
|
708
|
-
resetBtn.addEventListener('click', function () {
|
|
709
|
-
refresh({ text: DEFAULT_TEMPLATE });
|
|
710
|
-
});
|
|
711
|
-
|
|
712
|
-
// ---------------------------------------------------------------------------
|
|
713
|
-
// Boot
|
|
714
|
-
// ---------------------------------------------------------------------------
|
|
715
|
-
|
|
716
|
-
buildLegend();
|
|
717
|
-
buildSamples();
|
|
718
|
-
refresh({ text: DEFAULT_TEMPLATE });
|
|
719
|
-
})();
|
|
720
|
-
</script>
|
|
721
|
-
</body>
|
|
722
|
-
</html>
|