How to store custom emojis inside text in mongodb - mongodb

In a web application, a first idea of storing a text message that contains a custom emoji is to save the link of the emoji within the text.
For example if the Messages collection has a content field, that field would contain the following when an emoji is saved within the text:
I am an example content with an emoji icon <img src='assets/emojis/custom-emoji.png'/>
I am not sure if this is the best way, and I would like to know what are the recommendations for this kind of situation.

I would recommend storing them in some symbolic way e.g. {emoji:smileyface}. This will allow you to update image paths without doing any data migration in the future. It will also allow you to do things like theming.
You can do the mapping in a variable on the client or server and at the point of retrieving data map symbol -> path.

Related

How TO Save State in Flutter Locally

how to save state in flutter am trying to make a quantity number which is displayed in text widge there is plus and minus button once I go back from the page the quantity becomes zero even though i have made it any other number
Since your use case is simple , it only requires storing the requisite data to JSON or UTF-8 and writing this data to an editable File.
1.Saving data as JSON
The dart:convert library has converters for JSON and UTF-8, as well as support for creating additional converters. JSON is a simple text format for representing structured objects and collections. UTF-8 is a common variable-width encoding that can represent every character in the Unicode character set.
2.Creating and saving to an editable File
The I/O library enables command-line apps to read and write files and browse directories.
You can used the provider package in Flutter to manage your application state.
Here is the link to the provider package and it's documentation.
Provider Package
Provider Documentation
When asking questions on StackOverflow, it's generally preferred to share some code that you have tried.
In your case, it's likely that you need to use setState in your widget somewhere to modify the value of a variable in your widget class. But without seeing your code, it will be difficult to answer completely.

Is it possible to embed form inputs into a rich text editor document model?

I am building a project with Django 2.2.4 and PostgreSQL 11.4. I am using JSON database fields to store data in JSON arrays.
In my app users create documents using "rich text editor" that provides standard text/image features already.
I also want to enable users create the document to drag and drop form inputs into the body of the document so that once the document is "published" other users can view the document an add input values to these fields before submitting and saving the document again.
Now, I'm trying to figure out conceptually the most efficient way to approach this.
I thought the first step would be to use an abstracted rich text editor which separates the document structure from the HTML, e.g. CKEditor or Quill; if I was to serialise the document with form inputs included I could in theory store templates in one JSONField and inputs in another.
This list is a really useful overview of various editors, but despite having read a lot of documentation it's not clear if this approach would be either correct or actually possible.
Does anyone have any similar experiences?
Pretty sure this isn't possible unfortunately.
Could you elaborate on what you're trying to do with this?

Input field data is visible to the user but apparently invisible to Chrome Dev Tools? How can I get at it?

Since I know Cypress, I offered to help a friend screen scrape data out of a legacy system for which he no longer has database access, but I seem to be at a dead-end.
The PHP code fills the form fields somehow, and I can cut'n paste from them into an editor but, when I try to automate that, the input field's innerText is always empty strings. I can use Dev Tools to search the DOM and find the text of the field labels, but searching for the input field text turns up nothing.
Is there really no way to get at that data?
How can Chrome be unable to find data that it is actually displaying?
Is this some kind of security barrier?

Space length limitation

I have a word document file which is a form.
I try to complete it. Here is a screenshot of how it is looks like
When I type in the grey box there is a limitation in length and when I reach it, it won't let me type more.
I am not sure of what it is, however I want to insert an image or a table but I can't.
How can I make it?
The field you are trying to enter information into is a Legacy Text Form Field in Word 2010. In order to have a data entry area within the form that will accept text, tables, and images, delete this field and replace it with a Rich Text Content Control. This control is found on Word's Developer Tab:
Instructions for Displaying Word Developer Tab (if needed)
Like the legacy form fields, content controls allow manual or programmatic entry of data as well the ability to restrict editing of the data within the content control. Gregory K. Maxey has posted an incredibly detailed tutorial on creating forms with content controls, programming the content entry via VBA (Visual Basic for Applications) and restricting editing of the control's contents (all of which is available using the Rich Text Content Control):
Create Forms with Content Controls by Gregory K. Maxey
The same author also has an additional posting on content controls where he provides links to and offers explanations of more advanced content control abilities such as data mapping:
Content Controls (Additional Information) by Gregory K. Maxey
Lastly, Microsoft also provides some guidance on programming content controls via .NET (which I think may be beyond the scope of your question, but which I include for future readers):
MSDN: How to Add Content Controls to Word Documents

Converting large amounts of text and dynamic data into PDF

I have a three page Word document that needs to be converted into PDF. This Word document was given to me as a template to show me what the PDF output should look like. I tried converting this document into PDF, created a PDF form and used iTextSharp to open the form, populate it with data and return it back to the client. This is all great but due to large amounts of data stored, the placeholders were insufficient and the text would be truncated or hidden.
My second attempt was to create an MVC 2 View without master page, pass the model to the view, take the HTML representation of the View, pass it over to iTextSharp and render the PDF. The problem here was that iTextSharp failed on some tags (one of them was <hr> tag). I managed to get rid of the problematic tag, but then tables were not rendered properly. Namely, the border attribute was ignored so I ended up with borderless tables. That attempt failed.
I need a suggestion or advice on the most efficient way to create a PDF document in MVC 2 which would be maintainable in the long run. I really don't want my actions to be 200+ lines long. Working directly with the Word document is not the best solution as I have never worked with VSTO so I don't quite know what it would look like to open Word and manipulate text inside of it and add dynamic data and then convert that dynamically into PDF.
Any suggestion is highly welcome.
Best regards!
One thing that I've done in the past is to save the Word file as a DOCX and unzip it since DOCX is just a renamed zip file. Within the archive open up /word/document.xml and you'll see your document. There's a lot of weird XML tags in there but overall you should get a pretty good idea of where your content is. Then just add placeholder text like {FIRST_NAME}, save the file and re-zip.
Then from code you can just perform the same steps, unzipping with something like SharpZipLib or DotNetZip, swapping placeholder copy, re-zipping and then using very simple Word automation to Save-As a PDF.
The other route is to fully utilize iTextSharp and actually write Paragraphs and PdfPTable and everything else. It takes a lot longer to setup but would give you the most control.
Q: you say "... but due to large amounts of data stored, the placeholders were insufficient and the text would be truncated or hidden"
How do you end up having to much data ? If the word template can "hold" the data in 3 pages, they should fit in 3 PDF pages.
I used to use iTextSharp to create my PDF's, but I also almost always ended up building the PDF document from scratch myself.(not really a <200 line solution) Have you considerate another library, I recently switched to MigraDoc's PDFSharp.Way simpler to use then iText, lotsa examples / docus
Just my two cents
Word documents object model is quite easy to understand. It will either contain series of Paragraphs or Tables. Using the Open XML SDK, you can iterate through each paragraph/table in the word document and retrieve it's content and styles. Then you can generate PDF document on the fly using those retrieved information. This will work under MVC too.
But if your word document contains complex elements, then it will take some more time for you to implement based on this approach. Also, this approach would only work with (Word 2007 and 2010) files.
Also, HTML to PDF options currently available in the ITextSharp library would work with only known set of tags, as far as I know.
Another suggestion is to make use of commercially available .NET components. There are lot of good solution available. For ex: Syncfusion