简体   繁体   English

如何找到可调整大小的文本区域的自动换行点

[英]How to find the word wrap points of Resizable Textarea

I have a textarea which is resizable. 我有一个可调整大小的textarea。 When users resize the text area...I would like to recreate the text exactly on an image using php intervention. 当用户调整文本区域的大小时...我想使用php干预在图像上完全重新创建文本。 TextArea's do not automatically add new line characters when words are wrapped. 换行时,TextArea不会自动添加换行符。 How do I calculate where the new lines has to be added when the text area is resized? 调整文本区域大小后,如何计算必须在哪里添加新行?

I need to create the image with text wrap and also I need to save the data for later use so that I can display with the same word wrap. 我需要使用自动换行创建图像,还需要保存数据以备后用,以便可以使用相同的自动换行显示。

With a textarea, you can't... maybe if you use a <canvas> , subscribe the resize event of the textarea for resize the canvas with the same dimension, subscribe the textarea change event for insert the same text in the canvas, with same text dimensions, same line height etc etc... you can use that canvas for create the image, without php intervention. 使用textarea,您不能...也许,如果您使用<canvas> ,请订阅textarea的resize事件以调整具有相同尺寸的画布的大小,订阅textarea更改事件以在画布中插入相同的文本,具有相同的文本尺寸,相同的行高等...您可以使用该画布创建图像,而无需php干预。

Don't know if it could work, is untested and it's just the first idea that I had reading your question, if you decide to proceed in this way, let me know if it works! 不知道它是否可以工作,未经测试,这只是我阅读您的问题的第一个主意,如果您决定以这种方式进行操作,请告诉我它是否可以工作!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM