autumnnote 1.0.9 → 1.1.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/README.md +85 -6
- package/dist/autumnnote.css +169 -0
- package/dist/autumnnote.es.js +805 -22
- package/dist/autumnnote.es.js.map +1 -1
- package/dist/autumnnote.umd.js +805 -22
- package/dist/autumnnote.umd.js.map +1 -1
- package/package.json +3 -2
- package/src/js/Context.js +14 -2
- package/src/js/core/func.js +5 -5
- package/src/js/module/AutoSaveRestore.js +126 -0
- package/src/js/module/BubbleToolbar.js +243 -0
- package/src/js/module/ContextMenu.js +28 -26
- package/src/js/module/MarkdownShortcuts.js +253 -0
- package/src/js/module/Mention.js +337 -0
- package/src/js/settings.js +19 -0
- package/src/styles/autumnnote.scss +191 -0
- package/types/index.d.ts +56 -0
|
@@ -1999,3 +1999,194 @@ $an-video-accent: #8b5cf6; // violet-500
|
|
|
1999
1999
|
display: none !important;
|
|
2000
2000
|
}
|
|
2001
2001
|
}
|
|
2002
|
+
|
|
2003
|
+
// =============================================================================
|
|
2004
|
+
// Auto-save restore banner (#2)
|
|
2005
|
+
// =============================================================================
|
|
2006
|
+
|
|
2007
|
+
.an-asr-banner {
|
|
2008
|
+
display: flex;
|
|
2009
|
+
align-items: center;
|
|
2010
|
+
gap: 8px;
|
|
2011
|
+
padding: 8px 12px;
|
|
2012
|
+
background: #eff6ff;
|
|
2013
|
+
border-bottom: 1px solid #bfdbfe;
|
|
2014
|
+
font-size: 13px;
|
|
2015
|
+
color: #1e40af;
|
|
2016
|
+
flex-wrap: wrap;
|
|
2017
|
+
|
|
2018
|
+
.an-theme-dark & {
|
|
2019
|
+
background: #1e3a5f;
|
|
2020
|
+
border-bottom-color: #1e4d8c;
|
|
2021
|
+
color: #93c5fd;
|
|
2022
|
+
}
|
|
2023
|
+
}
|
|
2024
|
+
|
|
2025
|
+
.an-asr-msg {
|
|
2026
|
+
flex: 1;
|
|
2027
|
+
min-width: 0;
|
|
2028
|
+
}
|
|
2029
|
+
|
|
2030
|
+
.an-asr-btn-restore {
|
|
2031
|
+
padding: 3px 10px;
|
|
2032
|
+
font-size: 12px;
|
|
2033
|
+
font-weight: 600;
|
|
2034
|
+
background: $an-primary;
|
|
2035
|
+
color: #fff;
|
|
2036
|
+
border: none;
|
|
2037
|
+
border-radius: $an-radius-sm;
|
|
2038
|
+
cursor: pointer;
|
|
2039
|
+
line-height: 1.5;
|
|
2040
|
+
|
|
2041
|
+
&:hover {
|
|
2042
|
+
background: $an-primary-hover;
|
|
2043
|
+
}
|
|
2044
|
+
}
|
|
2045
|
+
|
|
2046
|
+
.an-asr-btn-discard {
|
|
2047
|
+
padding: 3px 10px;
|
|
2048
|
+
font-size: 12px;
|
|
2049
|
+
background: transparent;
|
|
2050
|
+
color: $an-muted;
|
|
2051
|
+
border: 1px solid $an-border;
|
|
2052
|
+
border-radius: $an-radius-sm;
|
|
2053
|
+
cursor: pointer;
|
|
2054
|
+
line-height: 1.5;
|
|
2055
|
+
|
|
2056
|
+
&:hover {
|
|
2057
|
+
background: $an-bg-btn-hover;
|
|
2058
|
+
}
|
|
2059
|
+
}
|
|
2060
|
+
|
|
2061
|
+
// =============================================================================
|
|
2062
|
+
// Bubble toolbar (#4)
|
|
2063
|
+
// =============================================================================
|
|
2064
|
+
|
|
2065
|
+
.an-bubble-toolbar {
|
|
2066
|
+
display: none;
|
|
2067
|
+
position: fixed;
|
|
2068
|
+
z-index: 10040;
|
|
2069
|
+
background: $an-bg;
|
|
2070
|
+
border: 1px solid $an-border;
|
|
2071
|
+
border-radius: 8px;
|
|
2072
|
+
padding: 4px 6px;
|
|
2073
|
+
gap: 2px;
|
|
2074
|
+
box-shadow: 0 8px 28px rgba(0, 0, 0, 0.14);
|
|
2075
|
+
align-items: center;
|
|
2076
|
+
animation: an-bubble-in 0.1s ease;
|
|
2077
|
+
pointer-events: auto;
|
|
2078
|
+
user-select: none;
|
|
2079
|
+
|
|
2080
|
+
.an-theme-dark & {
|
|
2081
|
+
background: #24273a;
|
|
2082
|
+
border-color: #3f3f5f;
|
|
2083
|
+
}
|
|
2084
|
+
}
|
|
2085
|
+
|
|
2086
|
+
@keyframes an-bubble-in {
|
|
2087
|
+
from { opacity: 0; transform: translateY(4px); }
|
|
2088
|
+
to { opacity: 1; transform: translateY(0); }
|
|
2089
|
+
}
|
|
2090
|
+
|
|
2091
|
+
.an-bubble-btn {
|
|
2092
|
+
display: flex;
|
|
2093
|
+
align-items: center;
|
|
2094
|
+
justify-content: center;
|
|
2095
|
+
width: 28px;
|
|
2096
|
+
height: 28px;
|
|
2097
|
+
padding: 0;
|
|
2098
|
+
background: transparent;
|
|
2099
|
+
border: none;
|
|
2100
|
+
border-radius: 5px;
|
|
2101
|
+
color: $an-text;
|
|
2102
|
+
cursor: pointer;
|
|
2103
|
+
transition: background $an-transition, color $an-transition;
|
|
2104
|
+
|
|
2105
|
+
svg {
|
|
2106
|
+
pointer-events: none;
|
|
2107
|
+
stroke: currentColor;
|
|
2108
|
+
}
|
|
2109
|
+
|
|
2110
|
+
&:hover {
|
|
2111
|
+
background: $an-bg-btn-hover;
|
|
2112
|
+
color: $an-text;
|
|
2113
|
+
}
|
|
2114
|
+
|
|
2115
|
+
&.an-active {
|
|
2116
|
+
background: $an-bg-btn-active;
|
|
2117
|
+
color: $an-primary;
|
|
2118
|
+
}
|
|
2119
|
+
|
|
2120
|
+
.an-theme-dark & {
|
|
2121
|
+
color: #cdd6f4;
|
|
2122
|
+
|
|
2123
|
+
&:hover {
|
|
2124
|
+
background: #313244;
|
|
2125
|
+
}
|
|
2126
|
+
|
|
2127
|
+
&.an-active {
|
|
2128
|
+
background: #1e3a5f;
|
|
2129
|
+
color: #93c5fd;
|
|
2130
|
+
}
|
|
2131
|
+
}
|
|
2132
|
+
}
|
|
2133
|
+
|
|
2134
|
+
// =============================================================================
|
|
2135
|
+
// @mention dropdown + chip (#5)
|
|
2136
|
+
// =============================================================================
|
|
2137
|
+
|
|
2138
|
+
.an-mention-dropdown {
|
|
2139
|
+
display: none;
|
|
2140
|
+
position: fixed;
|
|
2141
|
+
z-index: 9998;
|
|
2142
|
+
background: $an-bg;
|
|
2143
|
+
border: 1px solid $an-border;
|
|
2144
|
+
border-radius: $an-radius;
|
|
2145
|
+
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
|
|
2146
|
+
min-width: 180px;
|
|
2147
|
+
max-width: 280px;
|
|
2148
|
+
max-height: 240px;
|
|
2149
|
+
overflow-y: auto;
|
|
2150
|
+
padding: 4px 0;
|
|
2151
|
+
}
|
|
2152
|
+
|
|
2153
|
+
.an-mention-item {
|
|
2154
|
+
display: flex;
|
|
2155
|
+
align-items: center;
|
|
2156
|
+
gap: 8px;
|
|
2157
|
+
padding: 6px 12px;
|
|
2158
|
+
cursor: pointer;
|
|
2159
|
+
font-size: 13px;
|
|
2160
|
+
color: $an-text;
|
|
2161
|
+
transition: background $an-transition;
|
|
2162
|
+
|
|
2163
|
+
&:hover,
|
|
2164
|
+
&.an-mention-active {
|
|
2165
|
+
background: $an-bg-btn-hover;
|
|
2166
|
+
}
|
|
2167
|
+
}
|
|
2168
|
+
|
|
2169
|
+
.an-mention-avatar {
|
|
2170
|
+
width: 24px;
|
|
2171
|
+
height: 24px;
|
|
2172
|
+
border-radius: 50%;
|
|
2173
|
+
object-fit: cover;
|
|
2174
|
+
flex-shrink: 0;
|
|
2175
|
+
}
|
|
2176
|
+
|
|
2177
|
+
// Mention chip — inserted inline in the editor content
|
|
2178
|
+
.an-mention {
|
|
2179
|
+
display: inline;
|
|
2180
|
+
background: #eff6ff;
|
|
2181
|
+
color: $an-primary;
|
|
2182
|
+
border-radius: 3px;
|
|
2183
|
+
padding: 0 3px;
|
|
2184
|
+
font-weight: 500;
|
|
2185
|
+
cursor: default;
|
|
2186
|
+
user-select: all;
|
|
2187
|
+
|
|
2188
|
+
.an-theme-dark & {
|
|
2189
|
+
background: #1e3a5f;
|
|
2190
|
+
color: #93c5fd;
|
|
2191
|
+
}
|
|
2192
|
+
}
|
package/types/index.d.ts
CHANGED
|
@@ -110,6 +110,62 @@ export interface AsnOptions {
|
|
|
110
110
|
* Pass a partial locale object to override individual strings.
|
|
111
111
|
*/
|
|
112
112
|
lang?: string | Partial<AsnLocale>;
|
|
113
|
+
|
|
114
|
+
// ---- Auto-save restore (#2) -----------------------------------------------
|
|
115
|
+
|
|
116
|
+
/** Show a restore banner when a previously auto-saved draft exists. Requires autoSave: true. */
|
|
117
|
+
autoSaveRestore?: boolean;
|
|
118
|
+
/** Maximum age in days for a draft to be offered for restore (0 = no expiry). Default: 7. */
|
|
119
|
+
autoSaveRestoreTimeout?: number;
|
|
120
|
+
/** Callback fired after the user chooses to restore a draft. */
|
|
121
|
+
onAutoSaveRestore?: (html: string, context: Context) => void;
|
|
122
|
+
|
|
123
|
+
// ---- Markdown input shortcuts (#3) ----------------------------------------
|
|
124
|
+
|
|
125
|
+
/** Convert Markdown-style syntax typed inline (e.g. "## ", "**bold**") to rich HTML. Default: true. */
|
|
126
|
+
markdownShortcuts?: boolean;
|
|
127
|
+
|
|
128
|
+
// ---- Bubble toolbar (#4) --------------------------------------------------
|
|
129
|
+
|
|
130
|
+
/** Show a mini floating toolbar above the text selection. Default: false. */
|
|
131
|
+
bubbleToolbar?: boolean;
|
|
132
|
+
/** Button names shown in the bubble toolbar. */
|
|
133
|
+
bubbleToolbarItems?: Array<'bold' | 'italic' | 'underline' | 'strikethrough' | 'link' | 'foreColor' | 'removeFormat' | 'inlineCode'>;
|
|
134
|
+
|
|
135
|
+
// ---- @mention (#5) --------------------------------------------------------
|
|
136
|
+
|
|
137
|
+
/** @mention autocomplete configuration. Activated when mention.onSearch is provided. */
|
|
138
|
+
mention?: MentionOptions | null;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// ---------------------------------------------------------------------------
|
|
142
|
+
// Mention types (#5)
|
|
143
|
+
// ---------------------------------------------------------------------------
|
|
144
|
+
|
|
145
|
+
export interface MentionItem {
|
|
146
|
+
id: string | number;
|
|
147
|
+
label: string;
|
|
148
|
+
avatar?: string;
|
|
149
|
+
[key: string]: unknown;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export interface MentionOptions {
|
|
153
|
+
/** Trigger character. Default: '@'. */
|
|
154
|
+
trigger?: string;
|
|
155
|
+
/** Minimum characters to type before searching. Default: 0 (show on trigger character). */
|
|
156
|
+
minChars?: number;
|
|
157
|
+
/** Maximum results shown in the dropdown. Default: 8. */
|
|
158
|
+
maxResults?: number;
|
|
159
|
+
/** Debounce delay in ms before calling onSearch. Default: 200. */
|
|
160
|
+
debounce?: number;
|
|
161
|
+
/** Required. Called with (query, callback) to fetch matching items. */
|
|
162
|
+
onSearch: (query: string, callback: (items: MentionItem[]) => void) => void;
|
|
163
|
+
/** Optional. Return custom HTML string for the inserted chip, or null to use the default. */
|
|
164
|
+
onInsert?: (item: MentionItem) => string | null;
|
|
165
|
+
/** CSS class added to the inserted mention chip. Default: 'an-mention'. */
|
|
166
|
+
mentionClass?: string;
|
|
167
|
+
/** Allow spaces in the query string. Default: false. */
|
|
168
|
+
allowSpaces?: boolean;
|
|
113
169
|
}
|
|
114
170
|
|
|
115
171
|
// ---------------------------------------------------------------------------
|