Code Monkey home page Code Monkey logo

replier's Introduction

replier-app

An app to help you corral your email, chat & project management conversations and reply with clarity.

Project setup

npm install

Compiles and hot-reloads for development

npm run serve

Compiles and minifies for production

npm run build

Run your tests

npm run test

Lints and fixes files

npm run lint

Run your unit tests

npm run test:unit

Customize configuration

See Configuration Reference.

replier's People

Contributors

barryph avatar callumflack avatar

Stargazers

 avatar

Watchers

 avatar  avatar

replier's Issues

Direct paste from Gmail web client causes issues with sentences separated by two spaces

Disclaimeer: I'm not really a Javascript developer and I've never used Vue.js or ProseMirror before. I'm pretty much just fiddling with things and seeing what happens.

Issue

When I copy an email with two-space-separated sentences from the Gmail web client and paste it into Replier, the sentences are not split (each paragraph is treated as a single sentence).

When I copy the same email text from a text editor or use the "paste as plain text" option on Windows (there is no such option on my Ubuntu machine) the sentences actually are split correctly. This has me quite confused!

Debugging

I used the following test email:

This is a test email!  This is the second sentence?  This is the third sentence.

Single space, This is a test email! This is the second sentence? This is the third sentence.

I then added some log statements to the selection.js code:

/**
 * Create a decorator for each sentence in the document
 */
function split(doc) {
  const result = [];
  // Text start position relative to current node
  let start = 0;

  function record(from, to, position, node) {
    result.push({
      from: from + position,
      to: to + position,
      text: node.text.substring(from, to)
    });
  }

  // For each node in the document
  doc.descendants((node, position) => {
    // position: Node start position relative to whole document
    start = 0;

    if (node.isText) {
      console.log("Splitting node with text:", node.text);
      let match;
      // Record blocks of text between each match of "EOSPuncRegex"
      // eslint-disable-next-line no-cond-assign
      console.log("End of sentence regex matches sentence:", /([.?!]) /.test(node.text));
      while ((match = EOSPuncRegex.exec(node.text))) {
        const end = match.index + 1;
        record(start, end, position, node);

        start = end;

        // Ignore whitespace, find next character position
        const nextCharacter = node.text
          .substring(end)
          .match(nonWhitespaceRegex);
        if (nextCharacter) {
          start += nextCharacter.index;
        }
      }

      // Record remaining text untill end of node/line
      record(start, node.text.length, position, node);
    }
  });
  return result;
}

The key log statement being console.log("End of sentence regex matches sentence:", /([.?!]) /.test(node.text));

When I paste in plain text, I see the following console output:

  • Splitting node with text: This is a test email! This is the second sentence? This is the third sentence.
  • End of sentence regex matches sentence: true
  • Splitting node with text: Single space, This is a test email! This is the second sentence? This is the third sentence.
  • End of sentence regex matches sentence: true

When I paste copied directly from the Gmail client I see the following console output:

  • Splitting node with text: This is a test email! This is the second sentence? This is the third sentence.
  • End of sentence regex matches sentence: false
  • Splitting node with text: Single space, This is a test email! This is the second sentence? This is the third sentence.
  • End of sentence regex matches sentence: true

From what I can tell with fiddling with things, it seems the global /g flag makes for some unexpected behavior. I'm thinking of trying to re-write the split function to avoid using this and see if that addresses the matter. However, I was wondering if others had suggestions for a better approach.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.