frappe-ui 1.1.0 → 1.2.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/experimental/Calendar/CalendarEventRow.vue +0 -4
- package/experimental/CommandPalette/CommandPaletteItem.vue +9 -1
- package/experimental/SpriteIcons/IconPicker.vue +2 -1
- package/experimental.ts +0 -21
- package/package.json +1 -3
- package/src/components/Breadcrumbs/Breadcrumbs.vue +2 -1
- package/src/components/DatePicker/DatePicker.md +7 -0
- package/src/components/DatePicker/DatePicker.vue +6 -0
- package/src/components/DatePicker/DateTimePicker.vue +6 -0
- package/src/components/DatePicker/composables.ts +18 -1
- package/src/components/DatePicker/utils.ts +53 -0
- package/src/components/HoverCard/HoverCard.vue +21 -5
- package/src/components/MobileNav/MobileNavItem.vue +3 -22
- package/src/components/SettingsDialog/SettingsDialog.api.md +7 -2
- package/src/components/SettingsDialog/SettingsDialog.md +2 -1
- package/src/components/SettingsDialog/SettingsRow.vue +12 -2
- package/src/components/Sidebar/SidebarItem.vue +3 -33
- package/src/components/SidebarRail/SidebarRailItem.vue +4 -17
- package/src/components/Tooltip/Tooltip.vue +8 -0
- package/src/components/shared/deferredTrigger.ts +174 -0
- package/src/components/shared/navLink.ts +45 -0
- package/src/molecules/editor/extensions/attachment/attachment-engine.ts +1 -1
- package/src/molecules/editor/extensions/content-paste/paste-html-utils.ts +16 -6
- package/src/molecules/editor/extensions/iframe/IframeNodeView.vue +26 -9
- package/src/molecules/editor/extensions/iframe/iframe-allowlist.ts +35 -16
- package/src/molecules/editor/extensions/iframe/iframe-embed-utils.ts +1 -1
- package/src/molecules/editor/extensions/iframe/iframe-extension.ts +30 -30
- package/src/molecules/editor/extensions/link/LinkEditorPopup.vue +1 -1
- package/src/molecules/editor/extensions/link/link-paste-plugin.ts +1 -1
- package/src/molecules/editor/extensions/shared/media-upload-engine.ts +1 -1
- package/src/molecules/list/ListRow.vue +8 -1
- package/src/utils/dialog.ts +20 -2
- package/src/{molecules/editor/extensions/shared → utils}/url-safety.ts +28 -16
- package/tailwind/content.js +0 -1
- package/tailwind/plugin.js +22 -0
- package/vite/doctypeInterfaceGenerator.js +52 -39
- package/vitepress/index.node.ts +0 -2
- package/experimental/TextEditor/TextEditor.api.md +0 -161
- package/experimental/TextEditor/TextEditor.vue +0 -298
- package/experimental/TextEditor/classIcon.ts +0 -21
- package/experimental/TextEditor/commands.js +0 -344
- package/experimental/TextEditor/components/CodeBlockComponent.vue +0 -103
- package/experimental/TextEditor/components/FontColor.vue +0 -153
- package/experimental/TextEditor/components/ImageViewerModal.vue +0 -463
- package/experimental/TextEditor/components/InsertImage.vue +0 -54
- package/experimental/TextEditor/components/InsertLink.vue +0 -13
- package/experimental/TextEditor/components/InsertVideo.vue +0 -14
- package/experimental/TextEditor/components/LinkPopup.vue +0 -99
- package/experimental/TextEditor/components/MediaNodeView.vue +0 -398
- package/experimental/TextEditor/components/MentionList.vue +0 -95
- package/experimental/TextEditor/components/TextEditorBubbleMenu.vue +0 -78
- package/experimental/TextEditor/components/TextEditorFixedMenu.vue +0 -78
- package/experimental/TextEditor/components/TextEditorFloatingMenu.vue +0 -61
- package/experimental/TextEditor/components/TextEditorMenu.vue +0 -218
- package/experimental/TextEditor/components/index.js +0 -0
- package/experimental/TextEditor/extensions/code-block.ts +0 -119
- package/experimental/TextEditor/extensions/color/color-extension.ts +0 -140
- package/experimental/TextEditor/extensions/color/color-styles.css +0 -25
- package/experimental/TextEditor/extensions/color/index.ts +0 -2
- package/experimental/TextEditor/extensions/content-paste-extension.ts +0 -160
- package/experimental/TextEditor/extensions/copy-styles.ts +0 -160
- package/experimental/TextEditor/extensions/emoji/EmojiList.vue +0 -55
- package/experimental/TextEditor/extensions/emoji/emoji-extension.ts +0 -55
- package/experimental/TextEditor/extensions/emoji/emojis.json +0 -7422
- package/experimental/TextEditor/extensions/heading/heading.ts +0 -20
- package/experimental/TextEditor/extensions/highlight/highlight-extension.ts +0 -241
- package/experimental/TextEditor/extensions/highlight/highlight-styles.css +0 -31
- package/experimental/TextEditor/extensions/highlight/index.ts +0 -2
- package/experimental/TextEditor/extensions/iframe/IframeNodeView.vue +0 -308
- package/experimental/TextEditor/extensions/iframe/InsertIframe.vue +0 -209
- package/experimental/TextEditor/extensions/iframe/iframe-extension.ts +0 -404
- package/experimental/TextEditor/extensions/iframe/index.ts +0 -11
- package/experimental/TextEditor/extensions/iframe/utils.ts +0 -283
- package/experimental/TextEditor/extensions/image/image-extension.ts +0 -661
- package/experimental/TextEditor/extensions/image/index.ts +0 -5
- package/experimental/TextEditor/extensions/image-group/ImageGroupNodeView.vue +0 -182
- package/experimental/TextEditor/extensions/image-group/ImageGroupUploadDialog.vue +0 -740
- package/experimental/TextEditor/extensions/image-group/image-group-extension.ts +0 -187
- package/experimental/TextEditor/extensions/image-viewer-extension.ts +0 -162
- package/experimental/TextEditor/extensions/link/index.ts +0 -1
- package/experimental/TextEditor/extensions/link/link-extension.ts +0 -323
- package/experimental/TextEditor/extensions/link/linkPasteHandler.ts +0 -51
- package/experimental/TextEditor/extensions/mention/index.ts +0 -1
- package/experimental/TextEditor/extensions/mention/mention-extension.ts +0 -204
- package/experimental/TextEditor/extensions/mention/style.css +0 -11
- package/experimental/TextEditor/extensions/shared/color-utils.ts +0 -236
- package/experimental/TextEditor/extensions/slash-commands/SlashCommandsList.vue +0 -59
- package/experimental/TextEditor/extensions/slash-commands/slash-commands-extension.ts +0 -184
- package/experimental/TextEditor/extensions/suggestion/SuggestionList.vue +0 -130
- package/experimental/TextEditor/extensions/suggestion/createSuggestionExtension.ts +0 -151
- package/experimental/TextEditor/extensions/suggestion/index.ts +0 -5
- package/experimental/TextEditor/extensions/tag/index.ts +0 -1
- package/experimental/TextEditor/extensions/tag/tag-extension.ts +0 -170
- package/experimental/TextEditor/extensions/toc-node/TocNodeView.vue +0 -439
- package/experimental/TextEditor/extensions/toc-node/index.ts +0 -3
- package/experimental/TextEditor/extensions/toc-node/toc-node-extension.ts +0 -167
- package/experimental/TextEditor/extensions/video-extension.ts +0 -653
- package/experimental/TextEditor/hljs-github.css +0 -197
- package/experimental/TextEditor/index.ts +0 -21
- package/experimental/TextEditor/style.css +0 -190
- package/experimental/TextEditor/types.ts +0 -72
- package/experimental/TextEditor/utils.js +0 -11
- package/src/utils/url-validation.ts +0 -39
|
@@ -1,27 +1,39 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Shared URL-safety primitives for editor
|
|
2
|
+
* Shared URL-safety primitives for components and the editor.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* 1. `safeHref` — keep a link `href` only when its scheme is safe.
|
|
5
|
+
* 2. `isSafeUrl` — does a string parse to an absolute URL with an allowed scheme?
|
|
6
|
+
* 3. `matchesHostname` — exact-or-dot-boundary host allowlist matching.
|
|
7
7
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
8
|
+
* Every check uses the platform `URL` parser rather than a regex, so it sees
|
|
9
|
+
* a URL the way the browser will: `JaVaScRiPt:`, leading control characters
|
|
10
|
+
* and tabs inside the scheme all normalise to `javascript:` and fail.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/** Schemes a link may navigate to. Relative URLs are always allowed. */
|
|
14
|
+
const LINK_SCHEMES: readonly string[] = ['http', 'https', 'mailto', 'tel']
|
|
15
|
+
|
|
16
|
+
// Resolves relative links so only the scheme is checked. Never navigated to.
|
|
17
|
+
const RELATIVE_BASE = 'https://relative.invalid/'
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* `href` when it is a string that is relative or uses a link scheme (http,
|
|
21
|
+
* https, mailto, tel), otherwise `undefined`. Use it wherever an `href` comes
|
|
22
|
+
* from data, so a `javascript:` or `data:` URL never reaches an anchor.
|
|
19
23
|
*/
|
|
24
|
+
export function safeHref(href: unknown): string | undefined {
|
|
25
|
+
if (typeof href !== 'string' || !href) return undefined
|
|
26
|
+
const safe = isSafeUrl(href, {
|
|
27
|
+
allowedSchemes: LINK_SCHEMES,
|
|
28
|
+
base: RELATIVE_BASE,
|
|
29
|
+
})
|
|
30
|
+
return safe ? href : undefined
|
|
31
|
+
}
|
|
20
32
|
|
|
21
33
|
/** Options for {@link isSafeUrl}. */
|
|
22
34
|
export interface SafeUrlOptions {
|
|
23
35
|
/** Schemes allowed (without the trailing colon). Defaults to `['http', 'https']`. */
|
|
24
|
-
allowedSchemes?: string[]
|
|
36
|
+
allowedSchemes?: readonly string[]
|
|
25
37
|
/**
|
|
26
38
|
* Optional base to resolve relative URLs against (e.g. `window.location.origin`).
|
|
27
39
|
* A server-relative `file_url` like `/files/x.png` resolves to an http(s) URL
|
package/tailwind/content.js
CHANGED
|
@@ -54,7 +54,6 @@ export const content = [
|
|
|
54
54
|
glob('experimental/Charts/**/*.{vue,js,ts,jsx,tsx}'),
|
|
55
55
|
glob('experimental/CommandPalette/**/*.{vue,js,ts,jsx,tsx}'),
|
|
56
56
|
glob('experimental/ListView/**/*.{vue,js,ts,jsx,tsx}'),
|
|
57
|
-
glob('experimental/TextEditor/**/*.{vue,js,ts,jsx,tsx}'),
|
|
58
57
|
glob('experimental/ThemeSwitcher/**/*.{vue,js,ts,jsx,tsx}'),
|
|
59
58
|
glob('experimental/SpriteIcons/**/*.{vue,js,ts,jsx,tsx}'),
|
|
60
59
|
glob('vitepress/**/*.{vue,js,ts}'),
|
package/tailwind/plugin.js
CHANGED
|
@@ -198,6 +198,26 @@ let darkCheckboxStyles = {
|
|
|
198
198
|
},
|
|
199
199
|
}
|
|
200
200
|
|
|
201
|
+
// Tailwind's `truncate` sets `overflow: hidden`, which also clips vertically at
|
|
202
|
+
// the line box, so a tight line height cuts off descenders. Here it clips only
|
|
203
|
+
// horizontally. `overflow-x: clip` does not let a flex or grid item shrink below
|
|
204
|
+
// its content as `hidden` did, so the min sizes are set too. Tailwind's
|
|
205
|
+
// `textOverflow` plugin owns all of these classes, so it is disabled below and
|
|
206
|
+
// they are defined here, in the component layer, where utilities on the element
|
|
207
|
+
// win.
|
|
208
|
+
const textOverflowStyles = {
|
|
209
|
+
'.truncate': {
|
|
210
|
+
overflowX: 'clip',
|
|
211
|
+
textOverflow: 'ellipsis',
|
|
212
|
+
whiteSpace: 'nowrap',
|
|
213
|
+
minWidth: '0',
|
|
214
|
+
minHeight: '0',
|
|
215
|
+
},
|
|
216
|
+
'.text-ellipsis': { textOverflow: 'ellipsis' },
|
|
217
|
+
'.overflow-ellipsis': { textOverflow: 'ellipsis' },
|
|
218
|
+
'.text-clip': { textOverflow: 'clip' },
|
|
219
|
+
}
|
|
220
|
+
|
|
201
221
|
export default plugin(
|
|
202
222
|
function ({ addBase, addComponents, matchUtilities, theme }) {
|
|
203
223
|
// tokens.js keys the variables by theme; the selector each theme lands on
|
|
@@ -215,6 +235,7 @@ export default plugin(
|
|
|
215
235
|
addComponents(componentStyles)
|
|
216
236
|
addComponents(buildTextStyleUtilities())
|
|
217
237
|
addComponents(buildFocusRingUtilities())
|
|
238
|
+
addComponents(textOverflowStyles)
|
|
218
239
|
// Authoring sugar for the list-family styling hooks (frappe-ui/list),
|
|
219
240
|
// on the spacing scale with variants and arbitrary values:
|
|
220
241
|
// `max-sm:list-gap-3` instead of `max-sm:[--list-gap:0.75rem]`.
|
|
@@ -227,6 +248,7 @@ export default plugin(
|
|
|
227
248
|
)
|
|
228
249
|
},
|
|
229
250
|
{
|
|
251
|
+
corePlugins: { textOverflow: false },
|
|
230
252
|
theme: {
|
|
231
253
|
colors: colorPalette,
|
|
232
254
|
borderRadius: buildRadiusConfig(),
|
|
@@ -9,7 +9,7 @@ export class DocTypeInterfaceGenerator {
|
|
|
9
9
|
this.processedDoctypes = new Set()
|
|
10
10
|
this.existingInterfaces = {}
|
|
11
11
|
this.updatedInterfaces = 0
|
|
12
|
-
this.
|
|
12
|
+
this.doctypeFiles = new Map()
|
|
13
13
|
this.summary = {
|
|
14
14
|
processed: 0,
|
|
15
15
|
updated: 0,
|
|
@@ -194,45 +194,15 @@ export class DocTypeInterfaceGenerator {
|
|
|
194
194
|
}
|
|
195
195
|
|
|
196
196
|
async findJsonFile(appName, doctypeName) {
|
|
197
|
-
|
|
198
|
-
if (this.
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
'doctype',
|
|
204
|
-
doctypeName,
|
|
205
|
-
`${doctypeName}.json`,
|
|
206
|
-
)
|
|
207
|
-
let foundPath = null
|
|
208
|
-
|
|
209
|
-
const searchDirectory = async (directory) => {
|
|
210
|
-
const files = await fs.readdir(directory)
|
|
211
|
-
for (const file of files) {
|
|
212
|
-
const fullPath = path.join(directory, file)
|
|
213
|
-
try {
|
|
214
|
-
const stat = await fs.stat(fullPath)
|
|
215
|
-
if (stat.isDirectory()) {
|
|
216
|
-
await searchDirectory(fullPath)
|
|
217
|
-
} else if (fullPath.endsWith(targetPattern)) {
|
|
218
|
-
foundPath = fullPath
|
|
219
|
-
return
|
|
220
|
-
}
|
|
221
|
-
} catch (error) {
|
|
222
|
-
// Skip files/directories that can't be accessed (e.g., broken symlinks, permission denied)
|
|
223
|
-
if (error.code === 'ENOENT' || error.code === 'EACCES') {
|
|
224
|
-
continue
|
|
225
|
-
}
|
|
226
|
-
// Re-throw other unexpected errors
|
|
227
|
-
throw error
|
|
228
|
-
}
|
|
229
|
-
}
|
|
197
|
+
// Store the promise so parallel lookups share one walk of the app.
|
|
198
|
+
if (!this.doctypeFiles.has(appName)) {
|
|
199
|
+
this.doctypeFiles.set(
|
|
200
|
+
appName,
|
|
201
|
+
findDoctypeFiles(path.join(this.appsPath, appName)),
|
|
202
|
+
)
|
|
230
203
|
}
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
this.jsonFileCache.set(cacheKey, foundPath)
|
|
235
|
-
return foundPath
|
|
204
|
+
const files = await this.doctypeFiles.get(appName)
|
|
205
|
+
return files.get(doctypeName) ?? null
|
|
236
206
|
}
|
|
237
207
|
|
|
238
208
|
generateBaseInterfaces() {
|
|
@@ -253,3 +223,46 @@ export class DocTypeInterfaceGenerator {
|
|
|
253
223
|
`
|
|
254
224
|
}
|
|
255
225
|
}
|
|
226
|
+
|
|
227
|
+
// node_modules and dot folders hold no doctypes but can be most of an app's
|
|
228
|
+
// tree, so the walk skips them.
|
|
229
|
+
const SKIPPED_FOLDERS = /^(node_modules$|\.)/
|
|
230
|
+
|
|
231
|
+
// Maps each doctype name to its `doctype/<name>/<name>.json` file in the app.
|
|
232
|
+
async function findDoctypeFiles(appPath) {
|
|
233
|
+
const files = new Map()
|
|
234
|
+
|
|
235
|
+
const walk = async (directory) => {
|
|
236
|
+
let entries
|
|
237
|
+
try {
|
|
238
|
+
entries = await fs.readdir(directory, { withFileTypes: true })
|
|
239
|
+
} catch (error) {
|
|
240
|
+
if (error.code === 'ENOENT' || error.code === 'EACCES') {
|
|
241
|
+
return
|
|
242
|
+
}
|
|
243
|
+
throw error
|
|
244
|
+
}
|
|
245
|
+
for (const entry of entries) {
|
|
246
|
+
const fullPath = path.join(directory, entry.name)
|
|
247
|
+
if (entry.isDirectory() && !SKIPPED_FOLDERS.test(entry.name)) {
|
|
248
|
+
await walk(fullPath)
|
|
249
|
+
} else if (
|
|
250
|
+
isDoctypeFile(fullPath) &&
|
|
251
|
+
!files.has(path.basename(directory))
|
|
252
|
+
) {
|
|
253
|
+
files.set(path.basename(directory), fullPath)
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
await walk(appPath)
|
|
259
|
+
return files
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
function isDoctypeFile(filePath) {
|
|
263
|
+
const doctypeFolder = path.dirname(filePath)
|
|
264
|
+
return (
|
|
265
|
+
path.basename(filePath) === `${path.basename(doctypeFolder)}.json` &&
|
|
266
|
+
path.basename(path.dirname(doctypeFolder)) === 'doctype'
|
|
267
|
+
)
|
|
268
|
+
}
|
package/vitepress/index.node.ts
CHANGED
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
<!-- Auto Generated by scripts/propsgen.ts -->
|
|
2
|
-
<script setup>
|
|
3
|
-
import PropsTable from '@/components/Docs/PropsTable.vue'
|
|
4
|
-
import SlotsTable from '@/components/Docs/SlotsTable.vue'
|
|
5
|
-
import EmitsTable from '@/components/Docs/EmitsTable.vue'
|
|
6
|
-
|
|
7
|
-
const propsData = [
|
|
8
|
-
{
|
|
9
|
-
name: 'content',
|
|
10
|
-
description: 'Initial editor content (HTML/string). `null` renders an empty editor',
|
|
11
|
-
required: false,
|
|
12
|
-
type: 'string | null',
|
|
13
|
-
default: 'null'
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
name: 'placeholder',
|
|
17
|
-
description: 'Placeholder text or dynamic placeholder resolver',
|
|
18
|
-
required: false,
|
|
19
|
-
type: 'string | (() => string)',
|
|
20
|
-
default: '""'
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
name: 'editorClass',
|
|
24
|
-
description: 'Custom classes applied to the editor root',
|
|
25
|
-
required: false,
|
|
26
|
-
type: 'string | string[] | object',
|
|
27
|
-
default: '"prose-sm"'
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
name: 'editable',
|
|
31
|
-
description: 'Toggles editability of the editor',
|
|
32
|
-
required: false,
|
|
33
|
-
type: 'boolean',
|
|
34
|
-
default: 'true'
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
name: 'autofocus',
|
|
38
|
-
description: 'Autofocus the editor on mount',
|
|
39
|
-
required: false,
|
|
40
|
-
type: 'boolean',
|
|
41
|
-
default: 'false'
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
name: 'bubbleMenu',
|
|
45
|
-
description: 'Enables bubble menu or provides custom bubble menu items',
|
|
46
|
-
required: false,
|
|
47
|
-
type: 'boolean | any[]',
|
|
48
|
-
default: 'false'
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
name: 'bubbleMenuOptions',
|
|
52
|
-
description: 'Configuration options for the bubble menu',
|
|
53
|
-
required: false,
|
|
54
|
-
type: 'object',
|
|
55
|
-
default: '{}'
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
name: 'fixedMenu',
|
|
59
|
-
description: 'Enables fixed menu or provides custom fixed menu items',
|
|
60
|
-
required: false,
|
|
61
|
-
type: 'boolean | any[]',
|
|
62
|
-
default: 'false'
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
name: 'floatingMenu',
|
|
66
|
-
description: 'Enables floating menu or provides custom floating menu items',
|
|
67
|
-
required: false,
|
|
68
|
-
type: 'boolean | any[]',
|
|
69
|
-
default: 'false'
|
|
70
|
-
},
|
|
71
|
-
{
|
|
72
|
-
name: 'extensions',
|
|
73
|
-
description: 'Custom TipTap extensions',
|
|
74
|
-
required: false,
|
|
75
|
-
type: 'any[]',
|
|
76
|
-
default: '[]'
|
|
77
|
-
},
|
|
78
|
-
{
|
|
79
|
-
name: 'starterkitOptions',
|
|
80
|
-
description: 'Options passed to TipTap StarterKit',
|
|
81
|
-
required: false,
|
|
82
|
-
type: 'any',
|
|
83
|
-
default: '{}'
|
|
84
|
-
},
|
|
85
|
-
{
|
|
86
|
-
name: 'mentions',
|
|
87
|
-
description: 'Mention extension configuration',
|
|
88
|
-
required: false,
|
|
89
|
-
type: 'ConfigureMentionOptions',
|
|
90
|
-
default: 'null'
|
|
91
|
-
},
|
|
92
|
-
{
|
|
93
|
-
name: 'tags',
|
|
94
|
-
description: 'Tag / hashtag configuration',
|
|
95
|
-
required: false,
|
|
96
|
-
type: 'any[] | null',
|
|
97
|
-
default: 'null'
|
|
98
|
-
},
|
|
99
|
-
{
|
|
100
|
-
name: 'uploadFunction',
|
|
101
|
-
description: 'Async file upload handler (used for images, files, etc.)',
|
|
102
|
-
required: false,
|
|
103
|
-
type: '((file: File) => Promise<UploadedFile>)'
|
|
104
|
-
},
|
|
105
|
-
{
|
|
106
|
-
name: 'uploadArgs',
|
|
107
|
-
description: 'Extra arguments passed to the upload function',
|
|
108
|
-
required: false,
|
|
109
|
-
type: 'object'
|
|
110
|
-
}
|
|
111
|
-
]
|
|
112
|
-
|
|
113
|
-
const slotsData = [
|
|
114
|
-
{
|
|
115
|
-
name: 'top',
|
|
116
|
-
description: '',
|
|
117
|
-
type: '{ editor: { contentComponent: { uid: number; type: FunctionalComponent<{}, {}, any, {}> | { [x: stri'
|
|
118
|
-
},
|
|
119
|
-
{
|
|
120
|
-
name: 'editor',
|
|
121
|
-
description: '',
|
|
122
|
-
type: '{ editor: { contentComponent: { uid: number; type: FunctionalComponent<{}, {}, any, {}> | { [x: stri'
|
|
123
|
-
},
|
|
124
|
-
{
|
|
125
|
-
name: 'bottom',
|
|
126
|
-
description: '',
|
|
127
|
-
type: '{ editor: { contentComponent: { uid: number; type: FunctionalComponent<{}, {}, any, {}> | { [x: stri'
|
|
128
|
-
}
|
|
129
|
-
]
|
|
130
|
-
|
|
131
|
-
const emitsData = [
|
|
132
|
-
{
|
|
133
|
-
name: 'change',
|
|
134
|
-
description: 'Fired after the value is committed.',
|
|
135
|
-
type: '[content: string]'
|
|
136
|
-
},
|
|
137
|
-
{
|
|
138
|
-
name: 'focus',
|
|
139
|
-
description: '',
|
|
140
|
-
type: '[event: FocusEvent]'
|
|
141
|
-
},
|
|
142
|
-
{
|
|
143
|
-
name: 'blur',
|
|
144
|
-
description: '',
|
|
145
|
-
type: '[event: FocusEvent]'
|
|
146
|
-
},
|
|
147
|
-
{
|
|
148
|
-
name: 'transaction',
|
|
149
|
-
description: '',
|
|
150
|
-
type: '[editor: object]'
|
|
151
|
-
}
|
|
152
|
-
]
|
|
153
|
-
</script>
|
|
154
|
-
|
|
155
|
-
## API Reference
|
|
156
|
-
|
|
157
|
-
<PropsTable name="TextEditor" :data="propsData"/>
|
|
158
|
-
|
|
159
|
-
<SlotsTable :data="slotsData"/>
|
|
160
|
-
|
|
161
|
-
<EmitsTable :data="emitsData"/>
|
|
@@ -1,298 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div
|
|
3
|
-
v-if="editor"
|
|
4
|
-
class="relative w-full"
|
|
5
|
-
:class="attrsClass"
|
|
6
|
-
:style="attrsStyle"
|
|
7
|
-
v-bind="attrsWithoutClassStyle"
|
|
8
|
-
ref="rootRef"
|
|
9
|
-
>
|
|
10
|
-
<TextEditorBubbleMenu :buttons="bubbleMenu" :options="bubbleMenuOptions" />
|
|
11
|
-
<TextEditorFixedMenu
|
|
12
|
-
class="w-full overflow-x-auto rounded-t-6 border border-outline-elevation-2"
|
|
13
|
-
:buttons="fixedMenu"
|
|
14
|
-
/>
|
|
15
|
-
<TextEditorFloatingMenu :buttons="floatingMenu" />
|
|
16
|
-
<slot name="top" :editor />
|
|
17
|
-
<slot name="editor" :editor="editor">
|
|
18
|
-
<EditorContent :editor="editor" />
|
|
19
|
-
</slot>
|
|
20
|
-
<slot name="bottom" :editor />
|
|
21
|
-
</div>
|
|
22
|
-
</template>
|
|
23
|
-
|
|
24
|
-
<script lang="ts">
|
|
25
|
-
// @ts-nocheck -- frozen v0 code, kept out of type-check (see tsconfig.app.json)
|
|
26
|
-
// Module-scoped so the deprecation notice fires once per process, not per instance.
|
|
27
|
-
let deprecationWarned = false
|
|
28
|
-
</script>
|
|
29
|
-
|
|
30
|
-
<script setup lang="ts">
|
|
31
|
-
// @ts-nocheck -- frozen v0 code, kept out of type-check (see tsconfig.app.json)
|
|
32
|
-
import {
|
|
33
|
-
normalizeClass,
|
|
34
|
-
normalizeStyle,
|
|
35
|
-
computed,
|
|
36
|
-
watch,
|
|
37
|
-
onMounted,
|
|
38
|
-
onBeforeUnmount,
|
|
39
|
-
provide,
|
|
40
|
-
ref,
|
|
41
|
-
useAttrs,
|
|
42
|
-
useTemplateRef,
|
|
43
|
-
} from 'vue'
|
|
44
|
-
|
|
45
|
-
import { Editor, EditorContent } from '@tiptap/vue-3'
|
|
46
|
-
import type { EditorView } from '@tiptap/pm/view'
|
|
47
|
-
import StarterKit from '@tiptap/starter-kit'
|
|
48
|
-
import { Placeholder } from '@tiptap/extensions'
|
|
49
|
-
import Typography from '@tiptap/extension-typography'
|
|
50
|
-
import { TextStyleKit } from '@tiptap/extension-text-style'
|
|
51
|
-
import { TaskList, TaskItem } from '@tiptap/extension-list'
|
|
52
|
-
import TextAlign from '@tiptap/extension-text-align'
|
|
53
|
-
import {
|
|
54
|
-
Table,
|
|
55
|
-
TableRow,
|
|
56
|
-
TableCell,
|
|
57
|
-
TableHeader,
|
|
58
|
-
} from '@tiptap/extension-table'
|
|
59
|
-
|
|
60
|
-
import { ImageExtension } from './extensions/image'
|
|
61
|
-
import { VideoExtension } from './extensions/video-extension'
|
|
62
|
-
import ImageViewerExtension from './extensions/image-viewer-extension'
|
|
63
|
-
import { IframeExtension } from './extensions/iframe'
|
|
64
|
-
import { TocNodeExtension } from './extensions/toc-node'
|
|
65
|
-
import { LinkExtension } from './extensions/link/'
|
|
66
|
-
import NamedColorExtension from './extensions/color'
|
|
67
|
-
import NamedHighlightExtension from './extensions/highlight'
|
|
68
|
-
import StyleClipboardExtension from './extensions/copy-styles'
|
|
69
|
-
import { MentionExtension } from './extensions/mention'
|
|
70
|
-
import EmojiExtension from './extensions/emoji/emoji-extension'
|
|
71
|
-
import SlashCommands from './extensions/slash-commands/slash-commands-extension'
|
|
72
|
-
import { ContentPasteExtension } from './extensions/content-paste-extension'
|
|
73
|
-
import { Heading } from './extensions/heading/heading'
|
|
74
|
-
import { ImageGroup } from './extensions/image-group/image-group-extension'
|
|
75
|
-
import { ExtendedCode, ExtendedCodeBlock } from './extensions/code-block'
|
|
76
|
-
|
|
77
|
-
import TextEditorFixedMenu from './components/TextEditorFixedMenu.vue'
|
|
78
|
-
import TextEditorBubbleMenu from './components/TextEditorBubbleMenu.vue'
|
|
79
|
-
import TextEditorFloatingMenu from './components/TextEditorFloatingMenu.vue'
|
|
80
|
-
|
|
81
|
-
import { useFileUpload } from '#utils/useFileUpload'
|
|
82
|
-
import { TextEditorEmits, TextEditorProps } from './types'
|
|
83
|
-
import { getTagExtensions } from './extensions/tag'
|
|
84
|
-
|
|
85
|
-
defineOptions({ inheritAttrs: false })
|
|
86
|
-
|
|
87
|
-
function defaultUploadFunction(file: File) {
|
|
88
|
-
// useFileUpload is frappe specific
|
|
89
|
-
let fileUpload = useFileUpload()
|
|
90
|
-
// Default uploads to private so editor images/attachments are not served from
|
|
91
|
-
// the unauthenticated /files/ path (frappe/security#206). Callers can still
|
|
92
|
-
// override via uploadArgs (e.g. `private: false` for intentionally public files).
|
|
93
|
-
return fileUpload.upload(file, { private: true, ...(props.uploadArgs || {}) })
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
const props = withDefaults(defineProps<TextEditorProps>(), {
|
|
97
|
-
content: null,
|
|
98
|
-
placeholder: '',
|
|
99
|
-
editorClass: 'prose-sm',
|
|
100
|
-
editable: true,
|
|
101
|
-
autofocus: false,
|
|
102
|
-
bubbleMenu: false,
|
|
103
|
-
bubbleMenuOptions: () => ({}),
|
|
104
|
-
fixedMenu: false,
|
|
105
|
-
floatingMenu: false,
|
|
106
|
-
extensions: () => [],
|
|
107
|
-
starterkitOptions: () => ({}),
|
|
108
|
-
mentions: null,
|
|
109
|
-
tags: null,
|
|
110
|
-
})
|
|
111
|
-
|
|
112
|
-
const emit = defineEmits<TextEditorEmits>()
|
|
113
|
-
|
|
114
|
-
const editor = ref<Editor | null>(null)
|
|
115
|
-
|
|
116
|
-
const attrs = useAttrs()
|
|
117
|
-
const attrsClass = computed(() => normalizeClass(attrs.class))
|
|
118
|
-
const attrsStyle = computed(() => normalizeStyle(attrs.style))
|
|
119
|
-
const attrsWithoutClassStyle = computed(() => {
|
|
120
|
-
return Object.fromEntries(
|
|
121
|
-
Object.entries(attrs).filter(([key]) => key !== 'class' && key !== 'style'),
|
|
122
|
-
)
|
|
123
|
-
})
|
|
124
|
-
|
|
125
|
-
const editorProps = computed(() => {
|
|
126
|
-
return {
|
|
127
|
-
attributes: {
|
|
128
|
-
class: normalizeClass(['prose', props.editorClass]),
|
|
129
|
-
},
|
|
130
|
-
handleDOMEvents: {
|
|
131
|
-
// ProseMirror's dragstart runs even when read-only and overwrites the drag
|
|
132
|
-
// data; claiming the event (without preventDefault) keeps the browser's
|
|
133
|
-
// native payload, such as a link URL.
|
|
134
|
-
dragstart: (view: EditorView) => !view.editable,
|
|
135
|
-
},
|
|
136
|
-
}
|
|
137
|
-
})
|
|
138
|
-
|
|
139
|
-
watch(
|
|
140
|
-
() => props.content,
|
|
141
|
-
(val) => {
|
|
142
|
-
if (editor.value) {
|
|
143
|
-
let currentHTML = editor.value.getHTML()
|
|
144
|
-
if (currentHTML !== val) {
|
|
145
|
-
editor.value.commands.setContent(val)
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
},
|
|
149
|
-
)
|
|
150
|
-
|
|
151
|
-
watch(
|
|
152
|
-
() => props.editable,
|
|
153
|
-
(value) => {
|
|
154
|
-
if (editor.value) {
|
|
155
|
-
editor.value.setEditable(value)
|
|
156
|
-
}
|
|
157
|
-
},
|
|
158
|
-
)
|
|
159
|
-
|
|
160
|
-
watch(
|
|
161
|
-
editorProps,
|
|
162
|
-
(value) => {
|
|
163
|
-
if (editor.value) {
|
|
164
|
-
editor.value.setOptions({
|
|
165
|
-
editorProps: value,
|
|
166
|
-
})
|
|
167
|
-
}
|
|
168
|
-
},
|
|
169
|
-
{ deep: true },
|
|
170
|
-
)
|
|
171
|
-
|
|
172
|
-
onMounted(() => {
|
|
173
|
-
if (import.meta.env.DEV && !deprecationWarned) {
|
|
174
|
-
deprecationWarned = true
|
|
175
|
-
console.warn(
|
|
176
|
-
"<TextEditor> is deprecated. Use <Editor> with RichTextKit from 'frappe-ui/editor' for standard rich text, or compose your own kits/extensions for custom editors.",
|
|
177
|
-
)
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
editor.value = new Editor({
|
|
181
|
-
content: props.content || null,
|
|
182
|
-
editorProps: editorProps.value,
|
|
183
|
-
editable: props.editable,
|
|
184
|
-
autofocus: props.autofocus,
|
|
185
|
-
extensions: [
|
|
186
|
-
StarterKit.configure({
|
|
187
|
-
...props.starterkitOptions,
|
|
188
|
-
code: false,
|
|
189
|
-
codeBlock: false,
|
|
190
|
-
heading: false,
|
|
191
|
-
link: false,
|
|
192
|
-
}),
|
|
193
|
-
Heading.configure({
|
|
194
|
-
...(typeof props.starterkitOptions?.heading === 'object' &&
|
|
195
|
-
props.starterkitOptions.heading !== null
|
|
196
|
-
? props.starterkitOptions.heading
|
|
197
|
-
: {}),
|
|
198
|
-
}),
|
|
199
|
-
Table.configure({
|
|
200
|
-
resizable: true,
|
|
201
|
-
renderWrapper: true,
|
|
202
|
-
}),
|
|
203
|
-
TableRow,
|
|
204
|
-
TableHeader,
|
|
205
|
-
TableCell,
|
|
206
|
-
TaskList,
|
|
207
|
-
TaskItem.configure({
|
|
208
|
-
nested: true,
|
|
209
|
-
}),
|
|
210
|
-
Typography,
|
|
211
|
-
TextAlign.configure({
|
|
212
|
-
types: ['heading', 'paragraph'],
|
|
213
|
-
}),
|
|
214
|
-
TextStyleKit.configure({
|
|
215
|
-
backgroundColor: false,
|
|
216
|
-
color: false,
|
|
217
|
-
}),
|
|
218
|
-
NamedColorExtension,
|
|
219
|
-
NamedHighlightExtension,
|
|
220
|
-
ExtendedCode,
|
|
221
|
-
ExtendedCodeBlock,
|
|
222
|
-
ImageExtension.configure({
|
|
223
|
-
uploadFunction: props.uploadFunction || defaultUploadFunction,
|
|
224
|
-
}),
|
|
225
|
-
ImageGroup.configure({
|
|
226
|
-
uploadFunction: props.uploadFunction || defaultUploadFunction,
|
|
227
|
-
}),
|
|
228
|
-
ImageViewerExtension,
|
|
229
|
-
VideoExtension.configure({
|
|
230
|
-
uploadFunction: props.uploadFunction || defaultUploadFunction,
|
|
231
|
-
}),
|
|
232
|
-
IframeExtension,
|
|
233
|
-
TocNodeExtension,
|
|
234
|
-
LinkExtension.configure({
|
|
235
|
-
openOnClick: false,
|
|
236
|
-
}),
|
|
237
|
-
Placeholder.configure({
|
|
238
|
-
placeholder:
|
|
239
|
-
typeof props.placeholder === 'function'
|
|
240
|
-
? props.placeholder
|
|
241
|
-
: () => props.placeholder as string,
|
|
242
|
-
}),
|
|
243
|
-
props.mentions &&
|
|
244
|
-
MentionExtension.configure(
|
|
245
|
-
Array.isArray(props.mentions)
|
|
246
|
-
? { mentions: props.mentions }
|
|
247
|
-
: {
|
|
248
|
-
mentions: props.mentions.mentions,
|
|
249
|
-
component: props.mentions.component,
|
|
250
|
-
},
|
|
251
|
-
),
|
|
252
|
-
EmojiExtension,
|
|
253
|
-
SlashCommands,
|
|
254
|
-
...getTagExtensions(() => props.tags),
|
|
255
|
-
ContentPasteExtension.configure({
|
|
256
|
-
enabled: true,
|
|
257
|
-
uploadFunction: props.uploadFunction || defaultUploadFunction,
|
|
258
|
-
}),
|
|
259
|
-
StyleClipboardExtension,
|
|
260
|
-
...(props.extensions || []),
|
|
261
|
-
],
|
|
262
|
-
onUpdate: ({ editor }) => {
|
|
263
|
-
emit('change', editor.getHTML())
|
|
264
|
-
},
|
|
265
|
-
onTransaction: ({ editor }) => {
|
|
266
|
-
emit('transaction', editor)
|
|
267
|
-
},
|
|
268
|
-
onFocus: ({ editor, event }) => {
|
|
269
|
-
emit('focus', event)
|
|
270
|
-
},
|
|
271
|
-
onBlur: ({ editor, event }) => {
|
|
272
|
-
emit('blur', event)
|
|
273
|
-
},
|
|
274
|
-
})
|
|
275
|
-
})
|
|
276
|
-
|
|
277
|
-
onBeforeUnmount(() => {
|
|
278
|
-
if (editor.value) {
|
|
279
|
-
editor.value.destroy()
|
|
280
|
-
editor.value = null
|
|
281
|
-
}
|
|
282
|
-
})
|
|
283
|
-
|
|
284
|
-
provide(
|
|
285
|
-
'editor',
|
|
286
|
-
computed(() => editor.value),
|
|
287
|
-
)
|
|
288
|
-
|
|
289
|
-
const rootRef = useTemplateRef('rootRef')
|
|
290
|
-
defineExpose({
|
|
291
|
-
editor,
|
|
292
|
-
rootRef,
|
|
293
|
-
})
|
|
294
|
-
</script>
|
|
295
|
-
|
|
296
|
-
<style>
|
|
297
|
-
@import './style.css';
|
|
298
|
-
</style>
|