Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Handle section breaks when pasting text from other sources" #213

Merged
merged 1 commit into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 0 additions & 37 deletions blocks/edit/prose/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
/* eslint-disable max-classes-per-file */
import {
DOMParser,
EditorState,
EditorView,
Schema,
TextSelection,
baseSchema,
history,
buildKeymap,
Expand All @@ -19,8 +17,6 @@ import {
liftListItem,
sinkListItem,
gapCursor,
InputRule,
inputRules,
Y,
WebsocketProvider,
ySyncPlugin,
Expand All @@ -35,7 +31,6 @@ import prose2aem from '../../shared/prose2aem.js';
import menu from './plugins/menu.js';
import imageDrop from './plugins/imageDrop.js';
import linkConverter from './plugins/linkConverter.js';
import sectionPasteHandler from './plugins/sectionPasteHandler.js';
import { COLLAB_ORIGIN, getDaAdmin } from '../../shared/constants.js';
import { addLocNodes, getLocClass } from './loc-utils.js';

Expand Down Expand Up @@ -206,36 +201,6 @@ function generateColor(name, hRange = [0, 360], sRange = [60, 80], lRange = [40,
return `#${f(0)}${f(8)}${f(4)}`;
}

function getDashesInputRule() {
return new InputRule(
/^---[\n]$/,
(state, match, start, end) => {
const div = document.createElement('div');
div.append(document.createElement('hr'));
const newNodes = DOMParser.fromSchema(state.schema).parse(div);

const selection = TextSelection.create(state.doc, start, end);
dispatchTransaction(state.tr.setSelection(selection).replaceSelectionWith(newNodes));
},
);
}

// This function returns a modified inputrule plugin that triggers when the regex in the
// rule matches and the Enter key is pressed
function getInputRulesPlugin() {
const irsplugin = inputRules({ rules: [getDashesInputRule()] });

const hkd = (view, event) => {
if (event.key !== 'Enter') return false;
const { $cursor } = view.state.selection;
if ($cursor) return irsplugin.props.handleTextInput(view, $cursor.pos, $cursor.pos, '\n');
return false;
};
irsplugin.props.handleKeyDown = hkd; // Add the handleKeyDown function

return irsplugin;
}

export default function initProse({ editor, path }) {
// Destroy ProseMirror if it already exists - GH-212
if (window.view) delete window.view;
Expand Down Expand Up @@ -296,10 +261,8 @@ export default function initProse({ editor, path }) {
menu,
imageDrop(schema),
linkConverter(schema),
sectionPasteHandler(schema),
columnResizing(),
tableEditing(),
getInputRulesPlugin(),
keymap(buildKeymap(schema)),
keymap(baseKeymap),
keymap({
Expand Down
153 changes: 0 additions & 153 deletions blocks/edit/prose/plugins/sectionPasteHandler.js

This file was deleted.

Loading
Loading