[cm6] Move figure paste handler to core LaTeX extensions (#14957)

GitOrigin-RevId: 2dd6b036c5e9122a7e7564d4246f10444ba593e3
This commit is contained in:
Alf Eaton 2023-09-27 11:49:17 +01:00 committed by Copybot
parent e54f67008d
commit cb1b5b7d54
4 changed files with 39 additions and 3 deletions

View file

@ -202,6 +202,9 @@ export const figureModalPasteHandler = (): Extension => {
if (!evt.clipboardData || evt.clipboardData.files.length === 0) {
return
}
if (evt.clipboardData.types.includes('text/plain')) {
return // allow pasted text to be handled even if there's also a file on the clipboard
}
const file = evt.clipboardData.files[0]
if (!ALLOWED_MIME_TYPES.has(file.type)) {
return

View file

@ -19,7 +19,6 @@ import { restoreScrollPosition } from '../scroll-position'
import { CurrentDoc } from '../../../../../../types/current-doc'
import isValidTeXFile from '../../../../main/is-valid-tex-file'
import { listItemMarker } from './list-item-marker'
import { figureModalPasteHandler } from '../figure-modal'
import { isSplitTestEnabled } from '../../../../utils/splitTestUtils'
import { toolbarPanel } from '../toolbar/toolbar-panel'
import { selectDecoratedArgument } from './select-decorated-argument'
@ -204,7 +203,6 @@ const extension = (options: Options) => [
isSplitTestEnabled('source-editor-toolbar') ? [] : toolbarPanel(),
selectDecoratedArgument,
showContentWhenParsed,
figureModalPasteHandler(),
isSplitTestEnabled('paste-html') ? pasteHtml : [],
isSplitTestEnabled('table-generator') ? tableGeneratorTheme : [],
]

View file

@ -16,7 +16,10 @@ import importOverleafModules from '../../../../../macros/import-overleaf-module.
import { documentOutline } from './document-outline'
import { LaTeXLanguage } from './latex-language'
import { documentEnvironmentNames } from './document-environment-names'
import { figureModal } from '../../extensions/figure-modal'
import {
figureModal,
figureModalPasteHandler,
} from '../../extensions/figure-modal'
const completionSources: CompletionSource[] = [
...argumentCompletionSources,
@ -44,5 +47,6 @@ export const latex = () => {
})
),
figureModal(),
figureModalPasteHandler(),
])
}

View file

@ -35,12 +35,43 @@ export const Latex = (args: any, { globals: { theme } }: any) => {
sharejs_doc: mockDoc(content.tex, changes.tex),
open_doc_name: 'example.tex',
},
rootFolder: {
name: 'rootFolder',
id: 'root-folder-id',
type: 'folder',
children: [
{
name: 'example.tex.tex',
id: 'example-doc-id',
type: 'doc',
selected: false,
$$hashKey: 'object:89',
},
{
name: 'frog.jpg',
id: 'frog-image-id',
type: 'file',
linkedFileData: null,
created: '2023-05-04T16:11:04.352Z',
$$hashKey: 'object:108',
},
],
selected: false,
},
settings: {
...settings,
overallTheme: theme === 'default-' ? '' : theme,
},
})
useMeta({
'ol-showSymbolPalette': true,
'ol-splitTestVariants': {
'figure-modal': 'enabled',
'table-generator': 'enabled',
},
})
return <SourceEditor />
}