Repo for the search and displace core module including the interface to select files and search and displace operations to run on them. https://searchanddisplace.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
1020 B

  1. <template>
  2. <div id="text-box" class="text-box">
  3. <div ref="backdrop" class="backdrop">
  4. <div class="matches" v-html="matches"></div>
  5. </div>
  6. <textarea ref="text"
  7. v-model="text"
  8. placeholder="Enter text to check matches"
  9. @scroll="handleScroll">
  10. </textarea>
  11. </div>
  12. </template>
  13. <script lang="ts">
  14. import {Component, Prop, Vue} from "vue-property-decorator";
  15. @Component
  16. export default class TextBox extends Vue {
  17. private text: string = '';
  18. @Prop({default: ''})
  19. public readonly pattern!: string;
  20. @Prop()
  21. public readonly flags!: Array<string>;
  22. getMatches() {
  23. return this.text
  24. .replace(/\n$/g, '\n\n')
  25. .replace(new RegExp(this.pattern, this.flags.join('')), '<mark>$&</mark>');
  26. }
  27. handleScroll() {
  28. // this.$refs.backdrop.scrollTop = this.$refs.text.scrollTop;
  29. }
  30. get matches(): string {
  31. return this.getMatches();
  32. }
  33. };
  34. </script>