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

Allow preventing text drag #4749

Merged
merged 1 commit into from
Jul 5, 2023
Merged

Allow preventing text drag #4749

merged 1 commit into from
Jul 5, 2023

Conversation

fantactuka
Copy link
Contributor

@fantactuka fantactuka commented Jul 5, 2023

This PR adds input event to REMOVE_TEXT_COMMAND to allow preventing text drag by simple plugin:

useEffect(() => {
  const preventInputEvent = (event: unknown, inputType: string) => {
    if (event instanceof InputEvent && event.inputType === inputType) {
      event.preventDefault();
      return true;
    }
    return false;
  };

  return mergeRegister(
    editor.registerCommand(
      CONTROLLED_TEXT_INSERTION_COMMAND,
      event => preventInputEvent(event, 'insertFromDrop'),
      COMMAND_PRIORITY_HIGH,
    ),

    editor.registerCommand(
      REMOVE_TEXT_COMMAND,
      event => preventInputEvent(event, 'deleteByDrag'),
      COMMAND_PRIORITY_HIGH,
    ),
  );
}, [editor]);
Screen.Recording.2023-07-05.at.5.41.35.PM.mov

Fix #4744

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jul 5, 2023
@vercel
Copy link

vercel bot commented Jul 5, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
lexical ✅ Ready (Inspect) Visit Preview Jul 5, 2023 9:42pm
lexical-playground ✅ Ready (Inspect) Visit Preview Jul 5, 2023 9:42pm

@github-actions
Copy link

github-actions bot commented Jul 5, 2023

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
packages/lexical/dist/Lexical.js 27.95 KB (-0.02% 🔽) 559 ms (-0.02% 🔽) 84 ms (+4.88% 🔺) 643 ms
packages/lexical-rich-text/dist/LexicalRichText.js 39 KB (-0.01% 🔽) 781 ms (-0.01% 🔽) 166 ms (+85.35% 🔺) 946 ms
packages/lexical-plain-text/dist/LexicalPlainText.js 38.98 KB (-0.01% 🔽) 780 ms (-0.01% 🔽) 90 ms (-16.29% 🔽) 870 ms

@fantactuka fantactuka merged commit e1d90ca into main Jul 5, 2023
@fantactuka fantactuka deleted the prevent-text-drag branch July 6, 2023 20:08
@zurfyx zurfyx mentioned this pull request Jul 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature: Disable text drag
3 participants